[要望] onBeforeDocFormUndeleteとonDocFormUndelete

MODx 0.9.6.1に対して、ドキュメントの削除を取り消す際のシステムイベントが存在しないとの報告があがっている。

報告はバグとしてあげられているが、実際には要望に近いだろう。

削除済みのドキュメントを取り消す直前のonBeforeDocFormUndeleteイベントと、取り消す際のonDocFormUndeleteイベントが必要だったらしく、データベースへのレコードの追加とコアファイルの修正で対応したとのこと。

レコード追加用のSQL
INSERT INTO `modx_system_eventnames` (
    `id` ,
    `name` ,
    `service` ,
    `groupname`
)
VALUES ( NULL , 'OnDocFormUndelete', '1', 'Documents' ),
       ( NULL , 'OnBeforeDocFormUndelete', '1', 'Documents' );
追加: /manager/processors/undelete_document.processor.php(63行目付近)
getChildren($id);

// invoke OnBeforeDocFormUndelete event
$modx->invokeEvent("OnBeforeDocFormUndelete",
    array(
        "id" => $id,
        "children" => $children
    ));
追加: /manager/processors/undelete_document.processor.php(74行目付近)
//'undelete' the document.
$sql = "UPDATE $dbase.`".$table_prefix."site_content` SET deleted=0, deletedby=0, deletedon=0 WHERE id=$id;";
$rs = mysql_query($sql);
if(!$rs) {
    echo "Something went wrong while trying to set the document to undeleted status...";
    exit;
} else {
    // invoke OnDocFormUndelete event
    $modx->invokeEvent("OnDocFormUndelete",
    array(
        "id" => $id,
        "children" => $children
    ));

    // empty cache
    include_once "cache_sync.class.processor.php";
    $sync = new synccache();
    $sync->setCachepath("../assets/cache/");
    $sync->setReport(false);
    $sync->emptyCache(); // first empty the cache		
    // finished emptying cache - redirect
    $header="Location: index.php?r=1&a=7";
    header($header);
}

同様の方法で独自のシステムイベントを追加することが可能だろう。

M子