| 1 | <?php |
|---|
| 2 | // $Id: groups.php,v 1.5 2006/05/01 02:37:29 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|---|
| 29 | // Project: The XOOPS Project // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | |
|---|
| 32 | if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|---|
| 33 | exit("Access Denied"); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * Display error message & exit (Tentative) |
|---|
| 38 | */ |
|---|
| 39 | function system_groups_error($message) |
|---|
| 40 | { |
|---|
| 41 | xoops_cp_header(); |
|---|
| 42 | xoops_error($message); |
|---|
| 43 | xoops_cp_footer(); |
|---|
| 44 | exit(); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | /*********************************************************/ |
|---|
| 48 | /* Admin/Authors Functions */ |
|---|
| 49 | /*********************************************************/ |
|---|
| 50 | function displayGroups() |
|---|
| 51 | { |
|---|
| 52 | xoops_cp_header(); |
|---|
| 53 | //OpenTable(); |
|---|
| 54 | echo "<h4 style='text-align:left'>"._AM_EDITADG."</h4>"; |
|---|
| 55 | $member_handler =& xoops_gethandler('member'); |
|---|
| 56 | $groups = $member_handler->getGroups(); |
|---|
| 57 | echo "<table class='outer' width='40%' cellpadding='4' cellspacing='1'><tr><th colspan='2'>"._AM_EDITADG."</th></tr>"; |
|---|
| 58 | $count = count($groups); |
|---|
| 59 | for ($i = 0; $i < $count; $i++) { |
|---|
| 60 | $id = $groups[$i]->getVar('groupid'); |
|---|
| 61 | echo '<tr><td class="head">'.$groups[$i]->getVar('name').'</td>'; |
|---|
| 62 | echo '<td class="even"><a href="admin.php?fct=groups&op=modify&g_id='.$id.'">'._AM_MODIFY.'</a>'; |
|---|
| 63 | if (XOOPS_GROUP_ADMIN == $id || XOOPS_GROUP_USERS == $id || XOOPS_GROUP_ANONYMOUS == $id) { |
|---|
| 64 | echo '</td></tr>'; |
|---|
| 65 | } else { |
|---|
| 66 | echo ' <a href="admin.php?fct=groups&op=del&g_id='.$id.'">'._AM_DELETE.'</a></td></tr>'; |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | echo "</table>"; |
|---|
| 70 | $name_value = ""; |
|---|
| 71 | $desc_value = ""; |
|---|
| 72 | $s_cat_value = ''; |
|---|
| 73 | $a_mod_value = array(); |
|---|
| 74 | $r_mod_value = array(); |
|---|
| 75 | $r_block_value = array(); |
|---|
| 76 | $op_value = "add"; |
|---|
| 77 | $submit_value = _AM_CREATENEWADG; |
|---|
| 78 | $g_id_value = ""; |
|---|
| 79 | $type_value = ""; |
|---|
| 80 | $form_title = _AM_CREATENEWADG; |
|---|
| 81 | include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php"; |
|---|
| 82 | //CloseTable(); |
|---|
| 83 | xoops_cp_footer(); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | function modifyGroup($g_id) |
|---|
| 87 | { |
|---|
| 88 | $userstart = $memstart = 0; |
|---|
| 89 | if ( !empty($_POST['userstart']) ) { |
|---|
| 90 | $userstart = intval($_POST['userstart']); |
|---|
| 91 | } elseif (!empty($_GET['userstart'])) { |
|---|
| 92 | $userstart = intval($_GET['userstart']); |
|---|
| 93 | } |
|---|
| 94 | if ( !empty($_POST['memstart']) ) { |
|---|
| 95 | $memstart = intval($_POST['memstart']); |
|---|
| 96 | } elseif (!empty($_GET['memstart'])) { |
|---|
| 97 | $memstart = intval($_GET['memstart']); |
|---|
| 98 | } |
|---|
| 99 | xoops_cp_header(); |
|---|
| 100 | //OpenTable(); |
|---|
| 101 | echo '<a href="admin.php?fct=groups">'. _AM_GROUPSMAIN .'</a> <span style="font-weight:bold;">»»</span> '. _AM_MODIFYADG.'<br /><br />'; |
|---|
| 102 | $member_handler =& xoops_gethandler('member'); |
|---|
| 103 | $thisgroup =& $member_handler->getGroup($g_id); |
|---|
| 104 | $name_value = $thisgroup->getVar("name", "E"); |
|---|
| 105 | $desc_value = $thisgroup->getVar("description", "E"); |
|---|
| 106 | $moduleperm_handler =& xoops_gethandler('groupperm'); |
|---|
| 107 | $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid')); |
|---|
| 108 | $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid')); |
|---|
| 109 | $r_block_value =& XoopsBlock::getAllBlocksByGroup($thisgroup->getVar("groupid"), false); |
|---|
| 110 | $op_value = "update"; |
|---|
| 111 | $submit_value = _AM_UPDATEADG; |
|---|
| 112 | $g_id_value = $thisgroup->getVar("groupid"); |
|---|
| 113 | $type_value = $thisgroup->getVar("group_type", "E"); |
|---|
| 114 | $form_title = _AM_MODIFYADG; |
|---|
| 115 | if (XOOPS_GROUP_ADMIN == $g_id) { |
|---|
| 116 | $s_cat_disable = true; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | $sysperm_handler =& xoops_gethandler('groupperm'); |
|---|
| 120 | $s_cat_value = $sysperm_handler->getItemIds('system_admin', $g_id); |
|---|
| 121 | |
|---|
| 122 | include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php"; |
|---|
| 123 | echo "<br /><h4 style='text-align:left'>"._AM_EDITMEMBER."</h4>"; |
|---|
| 124 | $usercount = $member_handler->getUserCount(new Criteria('level', 0, '>')); |
|---|
| 125 | $member_handler =& xoops_gethandler('member'); |
|---|
| 126 | $membercount = $member_handler->getUserCountByGroup($g_id); |
|---|
| 127 | $token=&XoopsMultiTokenHandler::quickCreate('groups_User'); |
|---|
| 128 | if ($usercount < 200 && $membercount < 200) { |
|---|
| 129 | // do the old way only when counts are small |
|---|
| 130 | $mlist = array(); |
|---|
| 131 | $members = $member_handler->getUsersByGroup($g_id, false); |
|---|
| 132 | if (count($members) > 0) { |
|---|
| 133 | $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN"); |
|---|
| 134 | $member_criteria->setSort('uname'); |
|---|
| 135 | $mlist = $member_handler->getUserList($member_criteria); |
|---|
| 136 | } |
|---|
| 137 | $criteria = new Criteria('level', 0, '>'); |
|---|
| 138 | $criteria->setSort('uname'); |
|---|
| 139 | $userslist = $member_handler->getUserList($criteria); |
|---|
| 140 | $users = array_diff($userslist, $mlist); |
|---|
| 141 | echo '<table class="outer"> |
|---|
| 142 | <tr><th align="center">'._AM_NONMEMBERS.'<br />'; |
|---|
| 143 | echo '</th><th></th><th align="center">'._AM_MEMBERS.'<br />'; |
|---|
| 144 | echo '</th></tr> |
|---|
| 145 | <tr><td class="even"> |
|---|
| 146 | <form action="admin.php" method="post">'; |
|---|
| 147 | |
|---|
| 148 | echo $token->getHtml(); |
|---|
| 149 | |
|---|
| 150 | echo '<select name="uids[]" size="10" multiple="multiple">'."\n"; |
|---|
| 151 | foreach ($users as $u_id => $u_name) { |
|---|
| 152 | echo '<option value="'.$u_id.'">'.$u_name.'</option>'."\n"; |
|---|
| 153 | } |
|---|
| 154 | echo '</select>'; |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | echo "</td><td align='center' class='odd'> |
|---|
| 158 | <input type='hidden' name='op' value='addUser' /> |
|---|
| 159 | <input type='hidden' name='fct' value='groups' /> |
|---|
| 160 | <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' /> |
|---|
| 161 | <input type='submit' name='submit' value='"._AM_ADDBUTTON."' /> |
|---|
| 162 | </form><br /> |
|---|
| 163 | <form action='admin.php' method='post' />"; |
|---|
| 164 | |
|---|
| 165 | echo $token->getHtml(); |
|---|
| 166 | |
|---|
| 167 | echo "<input type='hidden' name='op' value='delUser' /> |
|---|
| 168 | <input type='hidden' name='fct' value='groups' /> |
|---|
| 169 | <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' /> |
|---|
| 170 | <input type='submit' name='submit' value='"._AM_DELBUTTON."' /> |
|---|
| 171 | </td> |
|---|
| 172 | <td class='even'>"; |
|---|
| 173 | echo "<select name='uids[]' size='10' multiple='multiple'>"; |
|---|
| 174 | foreach ($mlist as $m_id => $m_name) { |
|---|
| 175 | echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n"; |
|---|
| 176 | } |
|---|
| 177 | echo "</select>"; |
|---|
| 178 | echo '</td></tr> |
|---|
| 179 | </form> |
|---|
| 180 | </table>'; |
|---|
| 181 | } else { |
|---|
| 182 | $members =& $member_handler->getUsersByGroup($g_id, false, 200, $memstart); |
|---|
| 183 | $mlist = array(); |
|---|
| 184 | if (count($members) > 0) { |
|---|
| 185 | $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN"); |
|---|
| 186 | $member_criteria->setSort('uname'); |
|---|
| 187 | $mlist = $member_handler->getUserList($member_criteria); |
|---|
| 188 | } |
|---|
| 189 | echo '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=findusers&group='.$g_id.'">'._AM_FINDU4GROUP.'</a><br />'; |
|---|
| 190 | echo '<form action="admin.php" method="post"> |
|---|
| 191 | <table class="outer"> |
|---|
| 192 | <tr><th align="center">'._AM_MEMBERS.'<br />'; |
|---|
| 193 | $nav = new XoopsPageNav($membercount, 200, $memstart, "memstart", "fct=groups&op=modify&g_id=".$g_id); |
|---|
| 194 | echo $token->getHtml(); |
|---|
| 195 | echo $nav->renderNav(4); |
|---|
| 196 | echo "</th></tr> |
|---|
| 197 | <tr><td class='even' align='center'> |
|---|
| 198 | <input type='hidden' name='op' value='delUser' /> |
|---|
| 199 | <input type='hidden' name='fct' value='groups' /> |
|---|
| 200 | <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' /> |
|---|
| 201 | <input type='hidden' name='memstart' value='".$memstart."' /> |
|---|
| 202 | <select name='uids[]' size='10' multiple='multiple'>"; |
|---|
| 203 | foreach ($mlist as $m_id => $m_name ) { |
|---|
| 204 | echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n"; |
|---|
| 205 | } |
|---|
| 206 | echo "</select><br /> |
|---|
| 207 | <input type='submit' name='submit' value='"._DELETE."' /> |
|---|
| 208 | </td></tr> |
|---|
| 209 | </table> |
|---|
| 210 | </form>"; |
|---|
| 211 | } |
|---|
| 212 | //CloseTable(); |
|---|
| 213 | xoops_cp_footer(); |
|---|
| 214 | } |
|---|
| 215 | ?> |
|---|