コード例 #1
0
function wfDeleteFamilyTreeId($args)
{
    global $wgAjaxCachePolicy, $wgUser, $wrBotUserID;
    // set cache policy
    $wgAjaxCachePolicy->setPolicy(0);
    // validate input arguments
    $status = FTE_SUCCESS;
    $args = AjaxUtil::getArgs($args);
    if (!@$args['tree_id'] || !@$args['user']) {
        $status = FTE_INVALID_ARG;
    } else {
        if (!$wgUser->isLoggedIn()) {
            $status = FTE_NOT_LOGGED_IN;
        } else {
            if ($wgUser->getID() != $wrBotUserID || $wgUser->isBlocked() || wfReadOnly()) {
                $status = FTE_NOT_AUTHORIZED;
            } else {
                $db =& wfGetDB(DB_MASTER);
                $db->begin();
                // set up delete job (the delete job should also remove familytree_page/data/gedcom eventually)
                $treeId = $args['tree_id'];
                $job = new DeleteFamilyTreeJob(array('tree_id' => $treeId, 'user' => $args['user'], 'delete_pages' => '1'));
                $job->insert();
                // remove familytree if exists
                $db->delete('familytree', array('ft_tree_id' => $treeId));
                FamilyTreeUtil::deleteFamilyTreesCache($args['user']);
                $db->commit();
            }
        }
    }
    // return status
    return "<delete status=\"{$status}\"></delete>";
}
コード例 #2
0
ファイル: FamilyTreeUtil.php プロジェクト: k-hasan-19/wiki
 public static function deleteFamilyTree($db, $userName, $treeName, $delPages)
 {
     global $wgUser;
     if ($wgUser->isBlocked() || wfReadOnly()) {
         return FTE_NOT_AUTHORIZED;
     }
     $status = FTE_SUCCESS;
     $treeId = $db->selectField('familytree', 'ft_tree_id', array('ft_user' => $userName, 'ft_name' => $treeName));
     $errno = $db->lastErrno();
     if ($errno > 0) {
         $status = FTE_DB_ERROR;
     } else {
         if ($treeId === false) {
             $status = FTE_NOT_FOUND;
         } else {
             // set up delete job (the delete job should also remove familytree_page/data/gedcom eventually)
             $job = new DeleteFamilyTreeJob(array('tree_id' => $treeId, 'user' => $userName, 'delete_pages' => $delPages ? '1' : '0'));
             $job->insert();
             $errno = $db->lastErrno();
             if ($errno > 0) {
                 $status = FTE_DB_ERROR;
             }
         }
     }
     if ($status == FTE_SUCCESS) {
         // remove familytree
         $db->delete('familytree', array('ft_tree_id' => $treeId));
         FamilyTreeUtil::deleteFamilyTreesCache($userName);
         $errno = $db->lastErrno();
         if ($errno > 0) {
             $status = FTE_DB_ERROR;
         }
     }
     // purge user page
     StructuredData::purgeTitle(Title::makeTitle(NS_USER, $userName));
     return $status;
 }