home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / modules / system / admin / groups / groups.php < prev    next >
Encoding:
PHP Script  |  2005-11-03  |  9.8 KB  |  200 lines

  1. <?php
  2. // $Id: groups.php 2 2005-11-02 18:23:29Z skalpa $
  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. /* Admin/Authors Functions                               */
  38. /*********************************************************/
  39. function displayGroups()
  40. {
  41.     xoops_cp_header();
  42.     //OpenTable();
  43.     echo "<h4 style='text-align:left'>"._AM_EDITADG."</h4>";
  44.     $member_handler =& xoops_gethandler('member');
  45.     $groups =& $member_handler->getGroups();
  46.         echo "<table class='outer' width='40%' cellpadding='4' cellspacing='1'><tr><th colspan='2'>"._AM_EDITADG."</th></tr>";
  47.     $count = count($groups);
  48.     for ($i = 0; $i < $count; $i++) {
  49.         $id = $groups[$i]->getVar('groupid');
  50.                 echo '<tr><td class="head">'.$groups[$i]->getVar('name').'</td>';
  51.         echo '<td class="even"><a href="admin.php?fct=groups&op=modify&g_id='.$id.'">'._AM_MODIFY.'</a>';
  52.         if (XOOPS_GROUP_ADMIN == $id || XOOPS_GROUP_USERS == $id || XOOPS_GROUP_ANONYMOUS == $id) {
  53.             echo '</td></tr>';
  54.         } else {
  55.             echo ' <a href="admin.php?fct=groups&op=del&g_id='.$id.'">'._AM_DELETE.'</a></td></tr>';
  56.         }
  57.     }
  58.     echo "</table>";
  59.     $name_value = "";
  60.     $desc_value = "";
  61.     $s_cat_value = '';
  62.     $a_mod_value = array();
  63.     $r_mod_value = array();
  64.     $r_block_value = array();
  65.     $op_value = "add";
  66.     $submit_value = _AM_CREATENEWADG;
  67.     $g_id_value = "";
  68.     $type_value = "";
  69.     $form_title = _AM_CREATENEWADG;
  70.     include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
  71.     //CloseTable();
  72.     xoops_cp_footer();
  73. }
  74.  
  75. function modifyGroup($g_id)
  76. {
  77.     $userstart = $memstart = 0;
  78.     if ( !empty($_POST['userstart']) ) {
  79.         $userstart = intval($_POST['userstart']);
  80.     } elseif (!empty($_GET['userstart'])) {
  81.         $userstart = intval($_GET['userstart']);
  82.     }
  83.     if ( !empty($_POST['memstart']) ) {
  84.         $memstart = intval($_POST['memstart']);
  85.     } elseif (!empty($_GET['memstart'])) {
  86.         $memstart = intval($_GET['memstart']);
  87.     }
  88.     xoops_cp_header();
  89.     //OpenTable();
  90.     echo '<a href="admin.php?fct=groups">'. _AM_GROUPSMAIN .'</a> <span style="font-weight:bold;">»»</span> '. _AM_MODIFYADG.'<br /><br />';
  91.     $member_handler =& xoops_gethandler('member');
  92.     $thisgroup =& $member_handler->getGroup($g_id);
  93.     $name_value = $thisgroup->getVar("name", "E");
  94.     $desc_value = $thisgroup->getVar("description", "E");
  95.     $moduleperm_handler =& xoops_gethandler('groupperm');
  96.     $a_mod_value =& $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
  97.     $r_mod_value =& $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
  98.  
  99.     $gperm_handler =& xoops_gethandler('groupperm');
  100.     $r_block_value =& $gperm_handler->getItemIds('block_read', $g_id);
  101.     $op_value = "update";
  102.     $submit_value = _AM_UPDATEADG;
  103.     $g_id_value = $thisgroup->getVar("groupid");
  104.     $type_value = $thisgroup->getVar("group_type", "E");
  105.     $form_title = _AM_MODIFYADG;
  106.     if (XOOPS_GROUP_ADMIN == $g_id) {
  107.         $s_cat_disable = true;
  108.     }
  109.  
  110.     $sysperm_handler =& xoops_gethandler('groupperm');
  111.     $s_cat_value =& $sysperm_handler->getItemIds('system_admin', $g_id);
  112.  
  113.     include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
  114.     echo "<br /><h4 style='text-align:left'>"._AM_EDITMEMBER."</h4>";
  115.     $usercount = $member_handler->getUserCount(new Criteria('level', 0, '>'));
  116.     $member_handler =& xoops_gethandler('member');
  117.     $membercount = $member_handler->getUserCountByGroup($g_id);
  118.     if ($usercount < 200 && $membercount < 200) {
  119.         // do the old way only when counts are small
  120.         $mlist = array();
  121.         $members =& $member_handler->getUsersByGroup($g_id, false);
  122.         if (count($members) > 0) {
  123.             $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
  124.             $member_criteria->setSort('uname');
  125.             $mlist = $member_handler->getUserList($member_criteria);
  126.         }
  127.         $criteria = new Criteria('level', 0, '>');
  128.         $criteria->setSort('uname');
  129.         $userslist =& $member_handler->getUserList($criteria);
  130.         $users =& array_diff($userslist, $mlist);
  131.         echo '<table class="outer">
  132.         <tr><th align="center">'._AM_NONMEMBERS.'<br />';
  133.  
  134.         echo '</th><th></th><th align="center">'._AM_MEMBERS.'<br />';
  135.         echo '</th></tr>
  136.         <tr><td class="even">
  137.         <form action="admin.php" method="post">
  138.         <select name="uids[]" size="10" multiple="multiple">'."\n";
  139.         foreach ($users as $u_id => $u_name) {
  140.             echo '<option value="'.$u_id.'">'.$u_name.'</option>'."\n";
  141.         }
  142.         echo '</select>';
  143.         echo "</td><td align='center' class='odd'>
  144.         <input type='hidden' name='op' value='addUser' />
  145.         ".$GLOBALS['xoopsSecurity']->getTokenHTML()."
  146.         <input type='hidden' name='fct' value='groups' />
  147.         <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
  148.         <input type='submit' name='submit' value='"._AM_ADDBUTTON."' />
  149.         </form><br />
  150.         <form action='admin.php' method='post' />
  151.         <input type='hidden' name='op' value='delUser' />
  152.         ".$GLOBALS['xoopsSecurity']->getTokenHTML()."
  153.         <input type='hidden' name='fct' value='groups' />
  154.         <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
  155.         <input type='submit' name='submit' value='"._AM_DELBUTTON."' />
  156.         </td>
  157.         <td class='even'>";
  158.         echo "<select name='uids[]' size='10' multiple='multiple'>";
  159.         foreach ($mlist as $m_id => $m_name) {
  160.             echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
  161.         }
  162.         echo "</select>";
  163.         echo '</td></tr>
  164.         </form>
  165.         </table>';
  166.     } else {
  167.         $members =& $member_handler->getUsersByGroup($g_id, false, 200, $memstart);
  168.         $mlist = array();
  169.         if (count($members) > 0) {
  170.             $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
  171.             $member_criteria->setSort('uname');
  172.             $mlist = $member_handler->getUserList($member_criteria);
  173.         }
  174.         echo '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=findusers&group='.$g_id.'">'._AM_FINDU4GROUP.'</a><br />';
  175.         echo '<form action="admin.php" method="post">
  176.         <table class="outer">
  177.         <tr><th align="center">'._AM_MEMBERS.'<br />';
  178.         $nav = new XoopsPageNav($membercount, 200, $memstart, "memstart", "fct=groups&op=modify&g_id=".$g_id);
  179.         echo $nav->renderNav(4);
  180.         echo "</th></tr>
  181.         <tr><td class='even' align='center'>
  182.         <input type='hidden' name='op' value='delUser' />
  183.         <input type='hidden' name='fct' value='groups' />
  184.         <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
  185.         <input type='hidden' name='memstart' value='".$memstart."' />
  186.         ".$GLOBALS['xoopsSecurity']->getTokenHTML()."
  187.         <select name='uids[]' size='10' multiple='multiple'>";
  188.         foreach ($mlist as $m_id => $m_name ) {
  189.             echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
  190.         }
  191.         echo "</select><br />
  192.         <input type='submit' name='submit' value='"._DELETE."' />
  193.         </td></tr>
  194.         </table>
  195.         </form>";
  196.     }
  197.     //CloseTable();
  198.     xoops_cp_footer();
  199. }
  200. ?>