示例#1
0
文件: forums.php 项目: netovs/Core
/**
 * Delete a forum or folder.
 *
 * When a folder is deleted, then the contained folders and forums are
 * linked to the parent of the folder.
 *
 * @param integer $forum_id
 *   The forum_id to delete.
 *
 * @return mixed
 *   An array containing the data for the deleted forum or folder.
 *   NULL in case no forum or folder exists for the provided forum id. 
 */
function phorum_api_forums_delete($forum_id)
{
    global $PHORUM;
    $forum = phorum_api_forums_get($forum_id);
    // Check if the forum or folder was found. If not, then return NULL.
    // We do not trigger an error here, since the forum/folder not existing
    // is the desired situation anyway.
    if ($forum === NULL) {
        return NULL;
    }
    // Handle deleting a folder.
    if ($forum['folder_flag']) {
        /*
         * [hook]
         *     admin_folder_delete
         *
         * [availability]
         *     Phorum 5 >= 5.3
         *
         * [description]
         *     This hook is called whenever a folder is deleted.
         *
         * [category]
         *     Admin interface
         *
         * [when]
         *     Right before the folder will be deleted from the database.
         *
         * [input]
         *     The ID of the folder.
         *
         * [output]
         *     Same as input.
         *
         * [example]
         *     <hookcode>
         *     function phorum_mod_foo_admin_folder_delete ($id) 
         *     {
         *         // E.g. Notify an external system that the folder has
         *         // been deleted.
         *
         *         // Return the folder ID for other hooks.
         *         return $id;
         *
         *     }
         *     </hookcode>
         */
        phorum_api_hook("admin_folder_delete", $forum_id);
        // When the folder is a vroot folder currently, then disable
        // the vroot setting for it by linking it to the vroot of
        // the parent folder. This will take care of recursive updates
        // down the hierarchy as well.
        if ($forum['vroot'] == $forum['forum_id']) {
            $parent_vroot = 0;
            if ($forum['parent_id']) {
                $parent_folder = phorum_api_forums_get($forum['parent_id']);
                if ($parent_folder) {
                    // This check should not be necessary.
                    $parent_vroot = $parent_folder['vroot'];
                }
            }
            phorum_api_forums_save(array('forum_id' => $forum['forum_id'], 'vroot' => $parent_vroot));
        }
        // This call deletes the folder from the database.
        // It will link child folders and forums to the deleted folder's parent.
        $PHORUM['DB']->drop_folder($forum_id);
    } else {
        /*
         * [hook]
         *     admin_forum_delete
         *
         * [description]
         *     This hook is called whenever a forum is deleted.
         *
         * [category]
         *     Admin interface
         *
         * [when]
         *     Right before the forum will be deleted from the database.
         *
         * [input]
         *     The ID of the forum.
         *
         * [output]
         *     Same as input.
         *
         * [example]
         *     <hookcode>
         *     function phorum_mod_foo_admin_forum_delete ($id) 
         *     {
         *         // E.g. Notify an external system that the forum has
         *         // been deleted.
         *
         *         // Return the forum ID for other hooks.
         *         return $id;
         *
         *     }
         *     </hookcode>
         */
        phorum_api_hook("admin_forum_delete", $forum_id);
        $PHORUM['DB']->drop_forum($forum_id);
    }
    return $forum;
}
示例#2
0
文件: newforum.php 项目: netovs/Core
        phorum_api_redirect($url);
    }
    extract($forum);
} elseif (defined("PHORUM_EDIT_FORUM")) {
    $forum_id = isset($_POST['forum_id']) ? $_POST['forum_id'] : $_GET['forum_id'];
    $forum = phorum_api_forums_by_forum_id($forum_id, PHORUM_FLAG_INCLUDE_INACTIVE);
    extract($forum);
} elseif (defined("PHORUM_DEFAULT_OPTIONS")) {
    extract($PHORUM["default_forum_options"]);
} else {
    $parent_id = $PHORUM['vroot'];
    if (!empty($_GET['parent_id'])) {
        $parent_id = (int) $_GET['parent_id'];
    }
    // Prepare a forum data array for initializing the form.
    $forum = phorum_api_forums_save(array('forum_id' => NULL, 'folder_flag' => 0, 'inherit_id' => 0, 'parent_id' => $parent_id, 'name' => ''), PHORUM_FLAG_PREPARE);
    extract($forum);
}
// ----------------------------------------------------------------------
// Handle displaying the forum settings form
// ----------------------------------------------------------------------
if ($errors) {
    phorum_admin_error(join("<br/>", $errors));
}
if (isset($_GET['okmsg'])) {
    phorum_admin_okmsg(htmlspecialchars($_GET['okmsg']));
}
require_once './include/admin/PhorumInputForm.php';
$frm = new PhorumInputForm("", "post");
if (defined("PHORUM_DEFAULT_OPTIONS")) {
    $frm->hidden("module", "forum_defaults");
示例#3
0
                                 break;
                             case "attach":
                                 $new_forum[$field] = $new_forum[$field] | PHORUM_USER_ALLOW_ATTACH;
                                 break;
                             case "mod":
                                 $new_forum[$field] = $new_forum[$field] | PHORUM_USER_ALLOW_MODERATE_MESSAGES;
                                 break;
                         }
                     }
                 }
             }
         } else {
             $new_forum["pub_perms"] = PHORUM_USER_ALLOW_READ;
             $new_forum["reg_perms"] = PHORUM_USER_ALLOW_READ | PHORUM_USER_ALLOW_REPLY | PHORUM_USER_ALLOW_EDIT | PHORUM_USER_ALLOW_NEW_TOPIC;
         }
         $new_forum = phorum_api_forums_save($new_forum);
         $map["forums"][$forum["id"]] = $new_forum["forum_id"];
         $done++;
         progress($done, count($data->forum));
     }
     echo "\n\n";
     break;
 case "topics":
     echo "Importing Topics...\n";
     $done = 0;
     foreach ($data->topic as $topic) {
         $topic = makeArray($topic);
         $forum_id = $map["forums"][$topic["forum_id"]];
         $thread = 0;
         $parent = 0;
         // good ol simplexml and its one element sh-t