/** * Delete an existing family tree * * @param unknown_type $args user, name * @return FTE_SUCCESS, FTE_INVALID_ARG, FTE_NOT_LOGGED_IN, FTE_NOT_AUTHORIZED, FTE_NOT_FOUND, FTE_DUP_KEY, FTE_DB_ERROR */ function wfDeleteFamilyTree($args) { global $wgAjaxCachePolicy, $wgUser; // set cache policy $wgAjaxCachePolicy->setPolicy(0); // validate input arguments $status = FTE_SUCCESS; $delPages = false; $args = AjaxUtil::getArgs($args); if (!@$args['user'] || !@$args['name']) { $status = FTE_INVALID_ARG; } else { if (!$wgUser->isLoggedIn()) { $status = FTE_NOT_LOGGED_IN; } else { if ($wgUser->isBlocked() || wfReadOnly() || $args['user'] != $wgUser->getName()) { $status = FTE_NOT_AUTHORIZED; } else { $delPages = @$args['delete_pages'] == 1; $db =& wfGetDB(DB_MASTER); $db->begin(); $db->ignoreErrors(true); $status = FamilyTreeUtil::deleteFamilyTree($db, $args['user'], $args['name'], $delPages); if ($status == FTE_SUCCESS) { $db->commit(); } else { $db->rollback(); } } } } // return status return "<delete status=\"{$status}\"></delete>"; }
private function deleteTree() { global $wgUser, $wrAdminUserName; if ($this->user && $wgUser->getName() == $wrAdminUserName) { $userName = $this->user; } else { $userName = $wgUser->getName(); } if ($this->name && $userName && ($userName != $wgUser->getName() || $this->confirmed)) { $db =& wfGetDB(DB_MASTER); $db->ignoreErrors(true); $status = FamilyTreeUtil::deleteFamilyTree($db, $userName, $this->name, true); $db->ignoreErrors(false); if ($status != FTE_SUCCESS) { $msg = 'Error deleting ' . $this->name; } else { $msg = $this->name . ' is being deleted'; } $this->show($msg); } else { if ($this->name && $this->canceled) { $this->show(); } else { $name = htmlspecialchars($this->name); $label = 'Are you sure you want to delete your <b>' . $name . '</b> family tree'; $field = $label . '? <input type="submit" name="confirmed" value="Yes"/>'; $this->showInputForm('Are you sure?', $field, 'canceled', 'No'); } } }