From: Eloi G. <ada...@us...> - 2004-09-19 06:37:10
|
Update of /cvsroot/phpwsbb/phpwsbb/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20060/class Modified Files: Forum.php Manager.php Message.php Thread.php Log Message: Finished forum-specific moderator feature. Index: Thread.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Thread.php,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** Thread.php 19 Sep 2004 05:14:22 -0000 1.59 --- Thread.php 19 Sep 2004 06:37:01 -0000 1.60 *************** *** 144,148 **** $sql = 'SELECT id FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_messages WHERE tid=' . $this->getId(); ! if (!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'hide_threads') && $this->isModerator) $sql .= ' AND hidden=0'; $sql .= ' ORDER BY created'; --- 144,148 ---- $sql = 'SELECT id FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_messages WHERE tid=' . $this->getId(); ! if (!($_SESSION['OBJ_user']->allow_access('phpwsbb', 'hide_threads') && $this->isModerator)) $sql .= ' AND hidden=0'; $sql .= ' ORDER BY created'; *************** *** 166,170 **** function _view($ro = FALSE) { ! if ($this->isHidden() && !$_SESSION['OBJ_user']->allow_access('phpwsbb', 'hide_threads') && $this->isModerator) { $content = '<div class="errortext">' . $_SESSION['translate']->it('There is nothing here to see.') . '</div>'; return $content; --- 166,170 ---- function _view($ro = FALSE) { ! if ($this->isHidden() && !($_SESSION['OBJ_user']->allow_access('phpwsbb', 'hide_threads') && $this->isModerator)) { $content = '<div class="errortext">' . $_SESSION['translate']->it('There is nothing here to see.') . '</div>'; return $content; *************** *** 358,362 **** function _delete() { ! if (!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'delete_threads') && $this->isModerator) { $message = $_SESSION['translate']->it('Access to delete this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_delete()', $message, 'exit', 1); --- 358,362 ---- function _delete() { ! if (!($_SESSION['OBJ_user']->allow_access('phpwsbb', 'delete_threads') && $this->isModerator)) { $message = $_SESSION['translate']->it('Access to delete this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_delete()', $message, 'exit', 1); *************** *** 410,414 **** function _lock($unlock = FALSE) { ! if (!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'lock_threads') && $this->isModerator) { $message = $_SESSION['translate']->it('Access to lock this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_lock()', $message, 'exit', 1); --- 410,414 ---- function _lock($unlock = FALSE) { ! if (!($_SESSION['OBJ_user']->allow_access('phpwsbb', 'lock_threads') && $this->isModerator)) { $message = $_SESSION['translate']->it('Access to lock this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_lock()', $message, 'exit', 1); *************** *** 452,456 **** function _stick($unstick = FALSE) { ! if (!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'sticky_threads') && $this->isModerator) { $message = $_SESSION['translate']->it('Access to stick this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_stock()', $message, 'exit', 1); --- 452,456 ---- function _stick($unstick = FALSE) { ! if (!($_SESSION['OBJ_user']->allow_access('phpwsbb', 'sticky_threads') && $this->isModerator)) { $message = $_SESSION['translate']->it('Access to stick this topic was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Thread::_stock()', $message, 'exit', 1); Index: Message.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Message.php,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** Message.php 19 Sep 2004 03:51:01 -0000 1.65 --- Message.php 19 Sep 2004 06:37:01 -0000 1.66 *************** *** 236,240 **** */ function _edit() { ! if (!empty($this->_id) && !($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_messages') && $this->isModerator) && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to edit message [var1] was denied due to lack of proper permissions.', $this->_id); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Message::_edit()', $message, 'exit', 1); --- 236,240 ---- */ function _edit() { ! if (!empty($this->_id) && !$_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_messages') && !$this->isModerator && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to edit message [var1] was denied due to lack of proper permissions.', $this->_id); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Message::_edit()', $message, 'exit', 1); *************** *** 359,363 **** */ function _save() { ! if (!empty($this->_id) && !($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_messages') && $this->isModerator) && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to save message [var1] was denied due to lack of proper permissions.', $this->_id); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Manager::_accessDenied()', $message, 'exit', 1); --- 359,363 ---- */ function _save() { ! if (!empty($this->_id) && !$_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_messages') && !$this->isModerator && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to save message [var1] was denied due to lack of proper permissions.', $this->_id); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Manager::_accessDenied()', $message, 'exit', 1); *************** *** 536,540 **** */ function _delete() { ! if (!($_SESSION['OBJ_user']->allow_access('phpwsbb', 'delete_messages') && $this->isModerator) && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to delete this message was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Message::_delete()', $message, 'exit', 1); --- 536,540 ---- */ function _delete() { ! if (!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'delete_messages') && !$this->isModerator && ($_SESSION['OBJ_user']->username != $this->getOwner())) { $message = $_SESSION['translate']->it('Access to delete this message was denied due to lack of proper permissions.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Message::_delete()', $message, 'exit', 1); Index: Forum.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Forum.php,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Forum.php 17 Sep 2004 15:59:59 -0000 1.29 --- Forum.php 19 Sep 2004 06:37:00 -0000 1.30 *************** *** 137,142 **** } - // $tmp = $GLOBALS['core']->getCol('SELECT username FROM mod_users WHERE user_id IN ('.$this->_moderators.')', TRUE); - // $this->moderator_names = implode(',', $moderator_names); /* To perform a moderation action, user must either be a moderator of this forum or be able to edit forums (supermoderator) */ $this->isModerator = $_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_forums') --- 137,140 ---- *************** *** 176,179 **** --- 174,184 ---- if($_SESSION['OBJ_user']->user_id) $tags['MYPROFILE'] = '<a href="./index.php?module=phpwsbb&PHPWSBB_MAN_OP=usersettings">' . $_SESSION['translate']->it('My Forum Settings') . '</a>'; + if(!empty($this->_moderators)) { + if($tmp = $GLOBALS['core']->getCol('SELECT username FROM mod_users WHERE user_id IN ('.$this->_moderators.')', TRUE)) + $tags['MODERATORS'] = implode(', ', $tmp); + else + $tags['MODERATORS'] = $_SESSION['translate']->it('None'); + $tags['MODERATORS_LABEL'] = $_SESSION['translate']->it('Forum Moderators'); + } if(!$ro) { *************** *** 224,228 **** $form->add('Forum_description', 'textarea', $this->_description); $form->setRows('Forum_description',10); ! $form->setCols('Forum_description',70); $form->setTab('Forum_description', $tabs); $tabs++; --- 229,233 ---- $form->add('Forum_description', 'textarea', $this->_description); $form->setRows('Forum_description',10); ! $form->setWidth('Forum_description',95); $form->setTab('Forum_description', $tabs); $tabs++; *************** *** 257,260 **** --- 262,287 ---- $tags['SORTORDER_HELP'] = CLS_help::show_link('phpwsbb', 'sortorder'); + /* Moderator List */ + // Display list of automatic moderators (those that can edit forums) + $super_mods = $GLOBALS['core']->getCol('SELECT u.username FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_user_uservar AS v ON ( v.user_id = u.user_id) WHERE u.deity OR (u.admin_switch AND v.varName="MOD_phpwsbb" AND v.varValue LIKE "%edit_forums%") ORDER BY u.username ASC'); + if($super_mods) { + $tags['S_MODERATORS_LABEL'] = $_SESSION['translate']->it('These users have moderation capabilities even if they\'re not selected'); + $tags['S_MODERATORS'] = implode(', ', $super_mods); + } + // Create list of eligible moderators (those that can edit messages) + $eligible_mods = $GLOBALS['core']->query('SELECT u.username,u.user_id FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_user_uservar AS v ON ( v.user_id = u.user_id) WHERE u.deity OR (u.admin_switch AND v.varName="MOD_phpwsbb" AND (v.varValue LIKE "%edit_forums%" OR v.varValue LIKE "%edit_messages%")) ORDER BY u.username ASC'); + if($eligible_mods) { + $tags['MODERATORS_LABEL'] = $_SESSION['translate']->it('Choose moderators for this forum'); + $tags['MODERATORS'] = ''; + // Create a checkbox for every user on the list + $mod_arr = explode(',', $this->_moderators); + while ($row = $eligible_mods->fetchrow(DB_FETCHMODE_ASSOC)) { + if(in_array($row['user_id'], $mod_arr)) + $checked = 'checked="checked" '; + else + $checked = ''; + $tags['MODERATORS'] .= '<label><input name="phpwsBB_moderator[]" value="'.$row['user_id'].'" '.$checked.'type="checkbox"> '.$row['username'].'</label><br />'; + } + } if($_SESSION['OBJ_user']->js_on) *************** *** 293,296 **** --- 320,328 ---- } + if(isset($_POST['phpwsBB_moderator']) && is_array($_POST['phpwsBB_moderator'])) { + $this->_moderators = implode(',', $_POST['phpwsBB_moderator']); + } + + /* Hacks to get around some of Eloi's DDL */ if (empty($this->_posts)) *************** *** 321,325 **** $_SESSION['OBJ_fatcat']->saveSelect($this->getLabel(), 'index.php?module=phpwsbb&PHPWSBB_MAN_OP=viewforum&PHPWS_MAN_ITEMS=' . $this->getId(), $this->getId()); ! $GLOBALS['CNT_phpwsbb']['content'] .= $_SESSION['PHPWSBB_Manager']->_menu($this) . $_SESSION['translate']->it('Your forum was successfully saved.') . '<br />\n'; $GLOBALS['CNT_phpwsbb']['content'] .= '<a href="./index.php?module=phpwsbb&PHPWSBB_MAN_OP=list">' . $_SESSION['translate']->it('Back to Forums') . '</a>'; --- 353,357 ---- $_SESSION['OBJ_fatcat']->saveSelect($this->getLabel(), 'index.php?module=phpwsbb&PHPWSBB_MAN_OP=viewforum&PHPWS_MAN_ITEMS=' . $this->getId(), $this->getId()); ! $GLOBALS['CNT_phpwsbb']['content'] .= $_SESSION['PHPWSBB_Manager']->_menu($this) . $_SESSION['translate']->it('Your forum was successfully saved.') . "<br />\n"; $GLOBALS['CNT_phpwsbb']['content'] .= '<a href="./index.php?module=phpwsbb&PHPWSBB_MAN_OP=list">' . $_SESSION['translate']->it('Back to Forums') . '</a>'; Index: Manager.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Manager.php,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Manager.php 17 Sep 2004 15:53:33 -0000 1.47 --- Manager.php 19 Sep 2004 06:37:00 -0000 1.48 *************** *** 591,595 **** */ function _getUserSettings($id=null) { ! if(!$_SESSION['OBJ_user']->username || !($id && $_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_users'))) { $message = $_SESSION['translate']->it('Access to edit settings was denied.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Manager::_getSettings()', $message, 'exit', 1); --- 591,595 ---- */ function _getUserSettings($id=null) { ! if(!$_SESSION['OBJ_user']->username && !($id && $_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_users'))) { $message = $_SESSION['translate']->it('Access to edit settings was denied.'); $error = new PHPWS_Error('phpwsbb', 'PHPWSBB_Manager::_getSettings()', $message, 'exit', 1); *************** *** 899,903 **** // Create form table to manage user ranking information ! $tags['RANK_TBL_ROWS'] = ''; $opts['find'] = array('RANKROW_RANK_ID', 'RANKROW_RANK_TITLE', 'RANKROW_RANK_MIN', 'RANKROW_RANK_SPECIAL'); foreach ($this->_user_ranks as $rank) { --- 899,903 ---- // Create form table to manage user ranking information ! $tags['RANK_SPECIAL_ROWS'] = $tags['RANK_MEMBER_ROWS'] = ''; $opts['find'] = array('RANKROW_RANK_ID', 'RANKROW_RANK_TITLE', 'RANKROW_RANK_MIN', 'RANKROW_RANK_SPECIAL'); foreach ($this->_user_ranks as $rank) { *************** *** 1330,1334 **** } elseif(is_array($id) && !empty($id['user_id'])) { $result = $id; ! } elseif(!$result = $GLOBALS['core']->getRow('SELECT * FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u ON ( u.user_id = i.user_id ) WHERE i.user_id = '.$id)) { // If no record was found, create one $result = array(); --- 1330,1334 ---- } elseif(is_array($id) && !empty($id['user_id'])) { $result = $id; ! } elseif(!$result = $GLOBALS['core']->getRow('SELECT * FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u ON ( u.user_id = i.user_id ) LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_user_uservar AS v ON ( v.user_id = u.user_id AND v.varName="MOD_phpwsbb") WHERE i.user_id = '.$id)) { // If no record was found, create one $result = array(); |