Ejemplo n.º 1
0
     if ($oldfolder['name'] != $_POST['name'] || $oldfolder['parent_id'] != $_POST['parent_id'] || $setvroot) {
         $setforumpath = true;
     }
     // add the folder
 }
 // other db-operations done, now doing the work for vroots
 if ($res) {
     $cur_folder_tmp = phorum_db_get_forums($cur_folder_id);
     $cur_folder = array_shift($cur_folder_tmp);
     if ($setforumpath) {
         $setforum_children = phorum_admin_get_descending($cur_folder_id);
         $built_paths = phorum_admin_build_path_array();
         phorum_db_update_forum(array('forum_id' => $cur_folder_id, 'forum_path' => $built_paths[$cur_folder_id]));
         if (is_array($setforum_children) && count($setforum_children)) {
             foreach ($setforum_children as $child_forum_id => $child) {
                 phorum_db_update_forum(array('forum_id' => $child['forum_id'], 'forum_path' => $built_paths[$child_forum_id]));
             }
         }
     }
     if (!$setvroot && ($oldfolder['vroot'] && $oldfolder['vroot'] == $cur_folder_id || $oldfolder['parent_id'] != $cur_folder['parent_id'])) {
         // get the parent_id and set its vroot (if its a folder)
         // to the desc folders/forums
         if ($cur_folder['parent_id'] > 0) {
             // is it a real folder?
             $parent_folder = phorum_db_get_forums($cur_folder['parent_id']);
             // then set the vroot to the vroot of the parent-folder (be it 0 or a real vroot)
             phorum_admin_set_vroot($cur_folder_id, $parent_folder[$cur_folder['parent_id']]['vroot'], $cur_folder_id);
         } else {
             // just default root ...
             phorum_admin_set_vroot($cur_folder_id, 0, $cur_folder_id);
         }
Ejemplo n.º 2
0
/**
 * Change the displaying order for forums and folders in a certain folder.
 *
 * @param integer $folder_id
 *     The forum_id of the folder in which to change the display order.
 *
 * @param integer $forum_id
 *     The id of the forum or folder to move.
 *
 * @param string $movement
 *     This field determines the type of movement to apply to the forum
 *     or folder. This can be one of:
 *     - "up": Move the forum or folder $value positions up
 *     - "down": Move the forum or folder $value permissions down
 *     - "pos": Move the forum or folder to position $value
 *     - "start": Move the forum or folder to the start of the list
 *     - "end": Move the forum or folder to the end of the list
 *
 * @param mixed $value
 *     This field specifies a value for the requested type of movement.
 *     An integer value is only needed for movements "up", "down" and "pos".
 *     For other movements, this parameter can be omitted.
 */
function phorum_api_forums_change_order($folder_id, $forum_id, $movement, $value = NULL)
{
    settype($folder_id, 'int');
    settype($forum_id, 'int');
    if ($value !== NULL) {
        settype($value, 'int');
    }
    // Get the forums for the specified folder.
    $forums = phorum_api_forums_by_folder($folder_id);
    // Prepare the forum list for easy ordering.
    $current_pos = NULL;
    $pos = 0;
    $forum_ids = array();
    foreach ($forums as $forum) {
        if ($forum['forum_id'] == $forum_id) {
            $current_pos = $pos;
        }
        $forum_ids[$pos++] = $forum['forum_id'];
    }
    $pos--;
    // to make this the last index position in the array.
    // If the forum_id is not in the folder, then return right away.
    if ($current_pos === NULL) {
        return;
    }
    switch ($movement) {
        case "up":
            $new_pos = $current_pos - $value;
            break;
        case "down":
            $new_pos = $current_pos + $value;
            break;
        case "pos":
            $new_pos = $value;
            break;
        case "start":
            $new_pos = 0;
            break;
        case "end":
            $new_pos = $pos;
            break;
        default:
            trigger_error("phorum_api_forums_change_order(): " . "Illegal \$movement parameter \"{$movement}\" used", E_USER_ERROR);
    }
    // Keep the new position within boundaries.
    if ($new_pos < 0) {
        $new_pos = 0;
    }
    if ($new_pos > $pos) {
        $new_pos = $pos;
    }
    // No order change, then return.
    if ($new_pos == $current_pos) {
        return;
    }
    // Reorder the forum_ids array to represent the order change.
    $new_order = array();
    for ($i = 0; $i <= $pos; $i++) {
        if ($i == $current_pos) {
            continue;
        }
        if ($i == $new_pos) {
            if ($i < $current_pos) {
                $new_order[] = $forum_id;
                $new_order[] = $forum_ids[$i];
            } else {
                $new_order[] = $forum_ids[$i];
                $new_order[] = $forum_id;
            }
        } else {
            $new_order[] = $forum_ids[$i];
        }
    }
    // Loop through all the forums and update the ones that changed.
    // We have to look at them all, because the default value for
    // display order is 0 for all forums. So, in an unsorted folder,
    // all the display order values are set to 0 until you move one.
    foreach ($new_order as $display_order => $forum_id) {
        if ($forums[$forum_id]['display_order'] != $display_order) {
            phorum_db_update_forum(array('forum_id' => $forum_id, 'display_order' => $display_order));
        }
    }
}
Ejemplo n.º 3
0
        }

        if(empty($error)){
            unset($_POST["module"]);
            unset($_POST["vroot"]); // we set it separately below

            if(defined("PHORUM_EDIT_FOLDER")){
                $cur_folder_id=$_POST['forum_id'];
                
                // we need the old folder for vroots ... see below
                $oldfolder_tmp=phorum_db_get_forums($cur_folder_id);
                $oldfolder=array_shift($oldfolder_tmp);
                
                
                // update the folder
                $res=phorum_db_update_forum($_POST);
                
            } else {
                $oldfolder=array('vroot'=>0,'parent_id'=>0);
                // add the folder
                $res=phorum_db_add_forum($_POST);
                $cur_folder_id=$res;
            }

            if($res){ // other db-operations done, now doing the work for vroots
            
                $cur_folder_tmp=phorum_db_get_forums($cur_folder_id);
                $cur_folder=array_shift($cur_folder_tmp);
                               
                
                if(!$setvroot && (
Ejemplo n.º 4
0
    function phorum_admin_set_vroot($folder,$vroot=-1,$old_vroot=0) {
        // which vroot
        if($vroot == -1) {
            $vroot=$folder;
        }

        // get the desc forums/folders
        $descending=phorum_admin_get_descending($folder);
        $valid=array();

        // collecting vroots
        $vroots=array();
        foreach($descending as $id => $data) {
            if($data['folder_flag'] == 1 && $data['vroot'] != 0 && $data['forum_id'] == $data['vroot']) {
                $vroots[$data['vroot']]=true;
            }
        }

        // getting forums which are not in a vroot or not in *this* vroot
        foreach($descending as $id => $data) {
            if($data['vroot'] == $old_vroot || !isset($vroots[$data['vroot']])) {
                $valid[$id]=$data;
            }
        }

        // $valid = forums/folders which are not in another vroot
        $set_ids=array_keys($valid);
        $set_ids[]=$folder;

        $new_forum_data=array('forum_id'=>$set_ids,'vroot'=>$vroot);
        $returnval=phorum_db_update_forum($new_forum_data);

        return $returnval;
    }
Ejemplo n.º 5
0
    }
    if (isset($_POST['rebuild_userposts']) && !empty($_POST['rebuild_userposts'])) {
        $ret = phorum_db_rebuild_user_posts();
        $okmsg .= "Postcounts for users updated.<br />";
    }
    if (isset($_POST['rebuild_display_names']) && !empty($_POST['rebuild_display_names'])) {
        $redir_url = phorum_admin_build_url(array('module=update_display_names', 'request=integrity'), TRUE);
        phorum_redirect_by_url($redir_url);
        exit;
    }
    if (isset($_POST['rebuild_forumpaths']) && !empty($_POST['rebuild_forumpaths'])) {
        $forums = phorum_admin_build_path_array();
        unset($forums[0]);
        foreach ($forums as $fid => $forumpath) {
            $update_forum = array('forum_id' => $fid, 'forum_path' => $forumpath);
            phorum_db_update_forum($update_forum);
        }
        $okmsg .= "Forum paths successfully rebuilt.<br />";
    }
}
if ($error) {
    phorum_admin_error($error);
} elseif ($okmsg) {
    phorum_admin_okmsg($okmsg);
}
include_once "./include/admin/PhorumInputForm.php";
$frm =& new PhorumInputForm("", "post");
$frm->hidden("module", "rebuild");
$frm->addbreak("Rebuild parameters");
$row = $frm->addrow("Rebuild forum statistics", $frm->checkbox('rebuild_forumstats', 1, "Yes"));
$frm->addhelp($row, "Rebuild forum statistics", "Phorum keeps the count of messages and threads in a forum and also the date of the last post in some variables in the forums-table. If you manually delete messages from or manually add messages to the forum, this data will usually be out of sync. This leads to wrong paging on the list of messages and wrong counts on the index-page. Therefore run this part to update the forumstatistics this way.");
Ejemplo n.º 6
0
 *                 $PHORUM["DATA"]["LANG"]["mod_foo"]["MessageEditedSubject"],
 *                 $pm_message,
 *                 $dbmessage["user_id"]
 *                 );
 *         }
 *     }
 *     </hookcode>
 */
if (isset($PHORUM["hooks"]["after_edit"])) {
    phorum_hook("after_edit", $dbmessage);
}
// remove the message from the cache if caching is enabled
// no need to clear the thread-index as the message has only been changed
if ($PHORUM['cache_messages']) {
    phorum_cache_remove('message', $message["message_id"]);
    phorum_db_update_forum(array('forum_id' => $PHORUM['forum_id'], 'cache_version' => $PHORUM['cache_version'] + 1));
}
// Update children to the same sort setting.
if (!$message["parent_id"] && $origmessage["sort"] != $dbmessage["sort"]) {
    $messages = phorum_db_get_messages($message["thread"], 0);
    unset($messages["users"]);
    foreach ($messages as $message_id => $msg) {
        if ($msg["sort"] != $dbmessage["sort"] || $msg["forum_id"] != $dbmessage["forum_id"]) {
            $msg["sort"] = $dbmessage["sort"];
            phorum_db_update_message($message_id, $msg);
            if ($PHORUM['cache_messages']) {
                phorum_cache_remove('message', $message_id);
            }
        }
    }
}
Ejemplo n.º 7
0
             unset($forum_settings["message_count"]);
             unset($forum_settings["sticky_count"]);
             unset($forum_settings["thread_count"]);
             unset($forum_settings["last_post_time"]);
             unset($forum_settings["vroot"]);
             $res_inherit = phorum_db_update_forum($forum_settings);
         }
     } else {
         if (isset($_POST['forum_id'])) {
             unset($_POST['forum_id']);
         }
         $res = phorum_db_add_forum($_POST);
         // set/build the forum_path
         $cur_forum_id = $res;
         $built_paths = phorum_admin_build_path_array($cur_forum_id);
         phorum_db_update_forum(array('forum_id' => $cur_forum_id, 'forum_path' => $built_paths[$cur_forum_id]));
     }
     if ($res) {
         if ($reload) {
             $url = phorum_admin_build_url(array('module=editforum', 'forum_id=' . $_POST['forum_id']));
         } else {
             $url = phorum_admin_build_url(array('module=default', 'parent_id=' . $_POST['parent_id']));
         }
         phorum_redirect_by_url($url);
         exit;
     } else {
         $error = "Database error while adding/updating forum.";
     }
 }
 foreach ($_POST as $key => $value) {
     ${$key} = $value;
Ejemplo n.º 8
0
            // setting the current settings to all forums/folders inheriting from this forum/default settings
            $forum_inherit_settings =phorum_db_get_forums(false,false,false,intval($_POST["forum_id"]));
            foreach($forum_inherit_settings as $inherit_setting) {
                $forum_settings["forum_id"] =$inherit_setting["forum_id"];
                // We don't need to inherit this settings
                unset($forum_settings["name"]);
                unset($forum_settings["description"]);
                unset($forum_settings["active"]);
                unset($forum_settings["parent_id"]);
                unset($forum_settings["inherit_id"]);
                unset($forum_settings["message_count"]);
                unset($forum_settings["thread_count"]);
                unset($forum_settings["last_post_time"]);

                $res_inherit =phorum_db_update_forum($forum_settings);
            }

        } else {

            $res=phorum_db_add_forum($_POST);
        }

        if($res){
            if($reload){
                $url = $_SERVER['PHP_SELF']."?module=editforum&forum_id=$_POST[forum_id]";
            } else {
                $url = $_SERVER['PHP_SELF']."?module=default&parent_id=$_POST[parent_id]";
            }

            phorum_redirect_by_url($url);
Ejemplo n.º 9
0
    // if we have a newkey, make the move
    if(isset($newkey)){
        $tmp=$forum_order[$key];
        $forum_order[$key]=$forum_order[$newkey];
        $forum_order[$newkey]=$tmp;
        

        // loop through all the forums and updated the ones that changed.
        // We have to look at them all because the default value for
        // display order is 0 for all forums.  So, in an unsorted forlder
        // all the values are set to 0 until you move one.
        foreach($forum_order as $new_display_order=>$forum_id){
            if($forums[$forum_id]["display_order"]!=$new_display_order){
                $forums[$forum_id]["display_order"]=$new_display_order;
                phorum_db_update_forum($forums[$forum_id]);
            }
        }

        // get a fresh forum list with updated order.
        $forums=phorum_db_get_forums(0, $parent_id);
    }

}

foreach($forums as $forum_id => $forum){



    if($forum["folder_flag"]){
        $type="Folder";
Ejemplo n.º 10
0
         *     Same as input.
         */
        phorum_hook('after_split', $_POST['message']);
        break;
    default:
        if (!isset($PHORUM['DATA']['OKMSG'])) {
            $PHORUM['DATA']['OKMSG'] = "";
        }
        $PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"];
}
// remove the affected messages from the cache if caching is enabled.
if ($PHORUM['cache_messages']) {
    $invalidate_forums = array();
    foreach ($invalidate_message_cache as $message) {
        phorum_cache_remove('message', $message["message_id"]);
        $invalidate_forums[$message['forum_id']] = $message['forum_id'];
    }
    if (is_array($invalidate_forums) && count($invalidate_forums)) {
        require_once './include/api/forums.php';
        // retrieve the data for all involved forums to get the correct cache version
        $forums_data = phorum_api_forums_get($invalidate_forums);
        // increment the cache version for all involved forums once
        foreach ($invalidate_forums as $forum_id) {
            phorum_db_update_forum(array('forum_id' => $forum_id, 'cache_version' => $forums_data[$forum_id]['cache_version'] + 1));
        }
    }
}
if (!isset($PHORUM['DATA']['BACKMSG'])) {
    $PHORUM['DATA']["BACKMSG"] = $PHORUM['DATA']["LANG"]["BackToList"];
}
phorum_output($template);