[xoops-cvslog 128] CVS update: xoops2jp/html/modules/system/admin/groups

Zurück zum Archiv-Index

onokazu onoka****@users*****
2005年 6月 11日 (土) 11:32:51 JST


Index: xoops2jp/html/modules/system/admin/groups/groupform.php
diff -u xoops2jp/html/modules/system/admin/groups/groupform.php:1.2 xoops2jp/html/modules/system/admin/groups/groupform.php:1.3
--- xoops2jp/html/modules/system/admin/groups/groupform.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/groups/groupform.php	Sat Jun 11 11:32:51 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: groupform.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: groupform.php,v 1.3 2005/06/11 02:32:51 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -95,6 +95,7 @@
 $fct_hidden = new XoopsFormHidden("fct", "groups");
 $submit_button = new XoopsFormButton("", "groupsubmit", $submit_value, "submit");
 $form = new XoopsThemeForm($form_title, "groupform", "admin.php");
+$form->addElement(new XoopsFormToken(XoopsMultiTokenHandler::quickCreate('groups_'.$op_value)));
 $form->addElement($name_text);
 $form->addElement($desc_text);
 $form->addElement($s_cat_checkbox);
Index: xoops2jp/html/modules/system/admin/groups/groups.php
diff -u xoops2jp/html/modules/system/admin/groups/groups.php:1.2 xoops2jp/html/modules/system/admin/groups/groups.php:1.3
--- xoops2jp/html/modules/system/admin/groups/groups.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/groups/groups.php	Sat Jun 11 11:32:51 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: groups.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: groups.php,v 1.3 2005/06/11 02:32:51 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -30,7 +30,18 @@
 // ------------------------------------------------------------------------- //
 
 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-	exit("Access Denied");
+    exit("Access Denied");
+}
+
+/**
+ * Display error message & exit (Tentative)
+ */
+function system_groups_error($message)
+{
+    xoops_cp_header();
+    xoops_error($message);
+    xoops_cp_footer();
+    exit();
 }
 
 /*********************************************************/
@@ -38,158 +49,167 @@
 /*********************************************************/
 function displayGroups()
 {
-	xoops_cp_header();
-	//OpenTable();
-	echo "<h4 style='text-align:left'>"._AM_EDITADG."</h4>";
-	$member_handler =& xoops_gethandler('member');
-	$groups =& $member_handler->getGroups();
+    xoops_cp_header();
+    //OpenTable();
+    echo "<h4 style='text-align:left'>"._AM_EDITADG."</h4>";
+    $member_handler =& xoops_gethandler('member');
+    $groups =& $member_handler->getGroups();
         echo "<table class='outer' width='40%' cellpadding='4' cellspacing='1'><tr><th colspan='2'>"._AM_EDITADG."</th></tr>";
-	$count = count($groups);
-	for ($i = 0; $i < $count; $i++) {
-		$id = $groups[$i]->getVar('groupid');
+    $count = count($groups);
+    for ($i = 0; $i < $count; $i++) {
+        $id = $groups[$i]->getVar('groupid');
                 echo '<tr><td class="head">'.$groups[$i]->getVar('name').'</td>';
-		echo '<td class="even"><a href="admin.php?fct=groups&amp;op=modify&amp;g_id='.$id.'">'._AM_MODIFY.'</a>';
-		if (XOOPS_GROUP_ADMIN == $id || XOOPS_GROUP_USERS == $id || XOOPS_GROUP_ANONYMOUS == $id) {
-			echo '</td></tr>';
-		} else {
-			echo '&nbsp;<a href="admin.php?fct=groups&amp;op=del&amp;g_id='.$id.'">'._AM_DELETE.'</a></td></tr>';
-		}
-	}
-	echo "</table>";
-	$name_value = "";
-	$desc_value = "";
-	$s_cat_value = '';
-	$a_mod_value = array();
-	$r_mod_value = array();
-	$r_block_value = array();
-	$op_value = "add";
-	$submit_value = _AM_CREATENEWADG;
-	$g_id_value = "";
-	$type_value = "";
-	$form_title = _AM_CREATENEWADG;
-	include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
-	//CloseTable();
-	xoops_cp_footer();
+        echo '<td class="even"><a href="admin.php?fct=groups&amp;op=modify&amp;g_id='.$id.'">'._AM_MODIFY.'</a>';
+        if (XOOPS_GROUP_ADMIN == $id || XOOPS_GROUP_USERS == $id || XOOPS_GROUP_ANONYMOUS == $id) {
+            echo '</td></tr>';
+        } else {
+            echo '&nbsp;<a href="admin.php?fct=groups&amp;op=del&amp;g_id='.$id.'">'._AM_DELETE.'</a></td></tr>';
+        }
+    }
+    echo "</table>";
+    $name_value = "";
+    $desc_value = "";
+    $s_cat_value = '';
+    $a_mod_value = array();
+    $r_mod_value = array();
+    $r_block_value = array();
+    $op_value = "add";
+    $submit_value = _AM_CREATENEWADG;
+    $g_id_value = "";
+    $type_value = "";
+    $form_title = _AM_CREATENEWADG;
+    include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
+    //CloseTable();
+    xoops_cp_footer();
 }
 
 function modifyGroup($g_id)
 {
-	$userstart = $memstart = 0;
-	if ( !empty($_POST['userstart']) ) {
-		$userstart = intval($_POST['userstart']);
-	} elseif (!empty($_GET['userstart'])) {
-		$userstart = intval($_GET['userstart']);
-	}
-	if ( !empty($_POST['memstart']) ) {
-		$memstart = intval($_POST['memstart']);
-	} elseif (!empty($_GET['memstart'])) {
-		$memstart = intval($_GET['memstart']);
-	}
-	xoops_cp_header();
-	//OpenTable();
-	echo '<a href="admin.php?fct=groups">'. _AM_GROUPSMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'. _AM_MODIFYADG.'<br /><br />';
-	$member_handler =& xoops_gethandler('member');
-	$thisgroup =& $member_handler->getGroup($g_id);
-	$name_value = $thisgroup->getVar("name", "E");
-	$desc_value = $thisgroup->getVar("description", "E");
-	$moduleperm_handler =& xoops_gethandler('groupperm');
-	$a_mod_value =& $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
-	$r_mod_value =& $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
-	$r_block_value =& XoopsBlock::getAllBlocksByGroup($thisgroup->getVar("groupid"), false);
-	$op_value = "update";
-	$submit_value = _AM_UPDATEADG;
-	$g_id_value = $thisgroup->getVar("groupid");
-	$type_value = $thisgroup->getVar("group_type", "E");
-	$form_title = _AM_MODIFYADG;
-	if (XOOPS_GROUP_ADMIN == $g_id) {
-		$s_cat_disable = true;
-	}
-
-	$sysperm_handler =& xoops_gethandler('groupperm');
-	$s_cat_value =& $sysperm_handler->getItemIds('system_admin', $g_id);
-
-	include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
-	echo "<br /><h4 style='text-align:left'>"._AM_EDITMEMBER."</h4>";
-	$usercount = $member_handler->getUserCount(new Criteria('level', 0, '>'));
-	$member_handler =& xoops_gethandler('member');
-	$membercount = $member_handler->getUserCountByGroup($g_id);
-	if ($usercount < 200 && $membercount < 200) {
-		// do the old way only when counts are small
-		$mlist = array();
-		$members =& $member_handler->getUsersByGroup($g_id, false);
-		if (count($members) > 0) {
-		    $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
-		    $member_criteria->setSort('uname');
-		    $mlist = $member_handler->getUserList($member_criteria);
-		}
-		$criteria = new Criteria('level', 0, '>');
-		$criteria->setSort('uname');
-		$userslist =& $member_handler->getUserList($criteria);
-		$users =& array_diff($userslist, $mlist);
-		echo '<table class="outer">
-		<tr><th align="center">'._AM_NONMEMBERS.'<br />';
-
-		echo '</th><th></th><th align="center">'._AM_MEMBERS.'<br />';
-		echo '</th></tr>
-		<tr><td class="even">
-		<form action="admin.php" method="post">
-		<select name="uids[]" size="10" multiple="multiple">'."\n";
-		foreach ($users as $u_id => $u_name) {
-			echo '<option value="'.$u_id.'">'.$u_name.'</option>'."\n";
-		}
-		echo '</select>';
-		echo "</td><td align='center' class='odd'>
-		<input type='hidden' name='op' value='addUser' />
-		<input type='hidden' name='fct' value='groups' />
-		<input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
-		<input type='submit' name='submit' value='"._AM_ADDBUTTON."' />
-		</form><br />
-		<form action='admin.php' method='post' />
-		<input type='hidden' name='op' value='delUser' />
-		<input type='hidden' name='fct' value='groups' />
-		<input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
-		<input type='submit' name='submit' value='"._AM_DELBUTTON."' />
-		</td>
-		<td class='even'>";
-		echo "<select name='uids[]' size='10' multiple='multiple'>";
-		foreach ($mlist as $m_id => $m_name) {
-			echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
-		}
-		echo "</select>";
-		echo '</td></tr>
-		</form>
-		</table>';
-	} else {
-		$members =& $member_handler->getUsersByGroup($g_id, false, 200, $memstart);
-		$mlist = array();
-		if (count($members) > 0) {
-		    $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
-		    $member_criteria->setSort('uname');
-		    $mlist = $member_handler->getUserList($member_criteria);
-		}
-		echo '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=findusers&amp;group='.$g_id.'">'._AM_FINDU4GROUP.'</a><br />';
-		echo '<form action="admin.php" method="post">
-		<table class="outer">
-		<tr><th align="center">'._AM_MEMBERS.'<br />';
-		$nav = new XoopsPageNav($membercount, 200, $memstart, "memstart", "fct=groups&amp;op=modify&amp;g_id=".$g_id);
-		echo $nav->renderNav(4);
-		echo "</th></tr>
-		<tr><td class='even' align='center'>
-		<input type='hidden' name='op' value='delUser' />
-		<input type='hidden' name='fct' value='groups' />
-		<input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
-		<input type='hidden' name='memstart' value='".$memstart."' />
-		<select name='uids[]' size='10' multiple='multiple'>";
-		foreach ($mlist as $m_id => $m_name ) {
-			echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
-		}
-		echo "</select><br />
-		<input type='submit' name='submit' value='"._DELETE."' />
-		</td></tr>
-		</table>
-		</form>";
-	}
-	//CloseTable();
-	xoops_cp_footer();
+    $userstart = $memstart = 0;
+    if ( !empty($_POST['userstart']) ) {
+        $userstart = intval($_POST['userstart']);
+    } elseif (!empty($_GET['userstart'])) {
+        $userstart = intval($_GET['userstart']);
+    }
+    if ( !empty($_POST['memstart']) ) {
+        $memstart = intval($_POST['memstart']);
+    } elseif (!empty($_GET['memstart'])) {
+        $memstart = intval($_GET['memstart']);
+    }
+    xoops_cp_header();
+    //OpenTable();
+    echo '<a href="admin.php?fct=groups">'. _AM_GROUPSMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'. _AM_MODIFYADG.'<br /><br />';
+    $member_handler =& xoops_gethandler('member');
+    $thisgroup =& $member_handler->getGroup($g_id);
+    $name_value = $thisgroup->getVar("name", "E");
+    $desc_value = $thisgroup->getVar("description", "E");
+    $moduleperm_handler =& xoops_gethandler('groupperm');
+    $a_mod_value =& $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
+    $r_mod_value =& $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
+    $r_block_value =& XoopsBlock::getAllBlocksByGroup($thisgroup->getVar("groupid"), false);
+    $op_value = "update";
+    $submit_value = _AM_UPDATEADG;
+    $g_id_value = $thisgroup->getVar("groupid");
+    $type_value = $thisgroup->getVar("group_type", "E");
+    $form_title = _AM_MODIFYADG;
+    if (XOOPS_GROUP_ADMIN == $g_id) {
+        $s_cat_disable = true;
+    }
+
+    $sysperm_handler =& xoops_gethandler('groupperm');
+    $s_cat_value =& $sysperm_handler->getItemIds('system_admin', $g_id);
+
+    include XOOPS_ROOT_PATH."/modules/system/admin/groups/groupform.php";
+    echo "<br /><h4 style='text-align:left'>"._AM_EDITMEMBER."</h4>";
+    $usercount = $member_handler->getUserCount(new Criteria('level', 0, '>'));
+    $member_handler =& xoops_gethandler('member');
+    $membercount = $member_handler->getUserCountByGroup($g_id);
+    $token=&XoopsMultiTokenHandler::quickCreate('groups_User');
+    if ($usercount < 200 && $membercount < 200) {
+        // do the old way only when counts are small
+        $mlist = array();
+        $members =& $member_handler->getUsersByGroup($g_id, false);
+        if (count($members) > 0) {
+            $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
+            $member_criteria->setSort('uname');
+            $mlist = $member_handler->getUserList($member_criteria);
+        }
+        $criteria = new Criteria('level', 0, '>');
+        $criteria->setSort('uname');
+        $userslist =& $member_handler->getUserList($criteria);
+        $users =& array_diff($userslist, $mlist);
+        echo '<table class="outer">
+        <tr><th align="center">'._AM_NONMEMBERS.'<br />';
+        echo '</th><th></th><th align="center">'._AM_MEMBERS.'<br />';
+        echo '</th></tr>
+        <tr><td class="even">
+        <form action="admin.php" method="post">';
+
+        echo $token->getHtml();
+
+        echo '<select name="uids[]" size="10" multiple="multiple">'."\n";
+        foreach ($users as $u_id => $u_name) {
+            echo '<option value="'.$u_id.'">'.$u_name.'</option>'."\n";
+        }
+        echo '</select>';
+
+
+        echo "</td><td align='center' class='odd'>
+        <input type='hidden' name='op' value='addUser' />
+        <input type='hidden' name='fct' value='groups' />
+        <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
+        <input type='submit' name='submit' value='"._AM_ADDBUTTON."' />
+        </form><br />
+        <form action='admin.php' method='post' />";
+
+        echo $token->getHtml();
+
+        echo "<input type='hidden' name='op' value='delUser' />
+        <input type='hidden' name='fct' value='groups' />
+        <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
+        <input type='submit' name='submit' value='"._AM_DELBUTTON."' />
+        </td>
+        <td class='even'>";
+        echo "<select name='uids[]' size='10' multiple='multiple'>";
+        foreach ($mlist as $m_id => $m_name) {
+            echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
+        }
+        echo "</select>";
+        echo '</td></tr>
+        </form>
+        </table>';
+    } else {
+        $members =& $member_handler->getUsersByGroup($g_id, false, 200, $memstart);
+        $mlist = array();
+        if (count($members) > 0) {
+            $member_criteria = new Criteria('uid', "(".implode(',', $members).")", "IN");
+            $member_criteria->setSort('uname');
+            $mlist = $member_handler->getUserList($member_criteria);
+        }
+        echo '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=findusers&amp;group='.$g_id.'">'._AM_FINDU4GROUP.'</a><br />';
+        echo '<form action="admin.php" method="post">
+        <table class="outer">
+        <tr><th align="center">'._AM_MEMBERS.'<br />';
+        $nav = new XoopsPageNav($membercount, 200, $memstart, "memstart", "fct=groups&amp;op=modify&amp;g_id=".$g_id);
+        echo $token->getHtml();
+        echo $nav->renderNav(4);
+        echo "</th></tr>
+        <tr><td class='even' align='center'>
+        <input type='hidden' name='op' value='delUser' />
+        <input type='hidden' name='fct' value='groups' />
+        <input type='hidden' name='groupid' value='".$thisgroup->getVar("groupid")."' />
+        <input type='hidden' name='memstart' value='".$memstart."' />
+        <select name='uids[]' size='10' multiple='multiple'>";
+        foreach ($mlist as $m_id => $m_name ) {
+            echo '<option value="'.$m_id.'">'.$m_name.'</option>'."\n";
+        }
+        echo "</select><br />
+        <input type='submit' name='submit' value='"._DELETE."' />
+        </td></tr>
+        </table>
+        </form>";
+    }
+    //CloseTable();
+    xoops_cp_footer();
 }
 ?>
\ No newline at end of file
Index: xoops2jp/html/modules/system/admin/groups/main.php
diff -u xoops2jp/html/modules/system/admin/groups/main.php:1.2 xoops2jp/html/modules/system/admin/groups/main.php:1.3
--- xoops2jp/html/modules/system/admin/groups/main.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/groups/main.php	Sat Jun 11 11:32:51 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: main.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: main.php,v 1.3 2005/06/11 02:32:51 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -30,210 +30,235 @@
 // ------------------------------------------------------------------------- //
 
 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-	exit("Access Denied");
+    exit("Access Denied");
 } else {
-	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php';
-	include_once XOOPS_ROOT_PATH."/modules/system/admin/groups/groups.php";
-	$op = "display";
-	if ( isset($_POST) ) {
-		foreach ( $_POST as $k => $v ) {
-			$$k = $v;
-  		}
-	}
-	if ( isset($_GET['op']) ) {
-		if ($_GET['op'] == "modify" || $_GET['op'] == "del") {
-			$op = $_GET['op'];
-			$g_id = $_GET['g_id'];
-		}
-	}
-
-	// from finduser section
-	if ( !empty($memberslist_id) && is_array($memberslist_id) ) {
-		$op = "addUser";
-		$uids =& $memberslist_id;
-	}
-
-	switch ($op) {
-   	case "modify":
-		include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
-       	modifyGroup($g_id);
-   	 	break;
-   	case "update":
-		$system_catids = empty($system_catids) ? array() : $system_catids;
-		$admin_mids = empty($admin_mids) ? array() : $admin_mids;
-		$read_mids = empty($read_mids) ? array() : $read_mids;
-		$read_bids = empty($read_bids) ? array() : $read_bids;
-		$member_handler =& xoops_gethandler('member');
-		$group =& $member_handler->getGroup($g_id);
-		$group->setVar('name', $name);
-		$group->setVar('description', $desc);
-		// if this group is not one of the default groups
-		if (!in_array($group->getVar('groupid'), array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS))) {
-			if (count($system_catids) > 0) {
-				$group->setVar('group_type', 'Admin');
-			} else {
-				$group->setVar('group_type', '');
-			}
-		}
-		if (!$member_handler->insertGroup($group)) {
-			xoops_cp_header();
-			echo $group->getHtmlErrors();
-			xoops_cp_footer();
-		} else {
-			$groupid = $group->getVar('groupid');
-			$gperm_handler =& xoops_gethandler('groupperm');
-			$criteria = new CriteriaCompo(new Criteria('gperm_groupid', $groupid));
-			$criteria->add(new Criteria('gperm_modid', 1));
-			$criteria2 = new CriteriaCompo(new Criteria('gperm_name', 'system_admin'));
-			$criteria2->add(new Criteria('gperm_name', 'module_admin'), 'OR');
-			$criteria2->add(new Criteria('gperm_name', 'module_read'), 'OR');
-			$criteria2->add(new Criteria('gperm_name', 'block_read'), 'OR');
-			$criteria->add($criteria2);
-			$gperm_handler->deleteAll($criteria);
-			if (count($system_catids) > 0) {
-				array_push($admin_mids, 1);
-				foreach ($system_catids as $s_cid) {
-					$sysperm =& $gperm_handler->create();
-					$sysperm->setVar('gperm_groupid', $groupid);
-					$sysperm->setVar('gperm_itemid', $s_cid);
-					$sysperm->setVar('gperm_name', 'system_admin');
-					$sysperm->setVar('gperm_modid', 1);
-					$gperm_handler->insert($sysperm);
-				}
-			}
-			foreach ($admin_mids as $a_mid) {
-				$modperm =& $gperm_handler->create();
-				$modperm->setVar('gperm_groupid', $groupid);
-				$modperm->setVar('gperm_itemid', $a_mid);
-				$modperm->setVar('gperm_name', 'module_admin');
-				$modperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($modperm);
-			}
-			array_push($read_mids, 1);
-			foreach ($read_mids as $r_mid) {
-				$modperm =& $gperm_handler->create();
-				$modperm->setVar('gperm_groupid', $groupid);
-				$modperm->setVar('gperm_itemid', $r_mid);
-				$modperm->setVar('gperm_name', 'module_read');
-				$modperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($modperm);
-			}
-			foreach ($read_bids as $r_bid) {
-				$blockperm =& $gperm_handler->create();
-				$blockperm->setVar('gperm_groupid', $groupid);
-				$blockperm->setVar('gperm_itemid', $r_bid);
-				$blockperm->setVar('gperm_name', 'block_read');
-				$blockperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($blockperm);
-			}
-			redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
-		}
-       	break;
-	case "add":
-		if (!$name) {
-		    xoops_cp_header();
-			echo _AM_UNEED2ENTER;
-			xoops_cp_footer();
-			exit();
-		}
-		$system_catids = empty($system_catids) ? array() : $system_catids;
-		$admin_mids = empty($admin_mids) ? array() : $admin_mids;
-		$read_mids = empty($read_mids) ? array() : $read_mids;
-		$read_bids = empty($read_bids) ? array() : $read_bids;
-		$member_handler =& xoops_gethandler('member');
-		$group =& $member_handler->createGroup();
-		$group->setVar("name", $name);
-		$group->setVar("description", $desc);
-		if (count($system_catids) > 0) {
-			$group->setVar("group_type", 'Admin');
-		}
-		if (!$member_handler->insertGroup($group)) {
-			xoops_cp_header();
-			echo $group->getHtmlErrors();
-			xoops_cp_footer();
-		} else {
-			$groupid = $group->getVar('groupid');
-			$gperm_handler =& xoops_gethandler('groupperm');
-			if (count($system_catids) > 0) {
-				array_push($admin_mids, 1);
-				foreach ($system_catids as $s_cid) {
-					$sysperm =& $gperm_handler->create();
-					$sysperm->setVar('gperm_groupid', $groupid);
-					$sysperm->setVar('gperm_itemid', $s_cid);
-					$sysperm->setVar('gperm_name', 'system_admin');
-					$sysperm->setVar('gperm_modid', 1);
-					$gperm_handler->insert($sysperm);
-				}
-			}
-			foreach ($admin_mids as $a_mid) {
-				$modperm =& $gperm_handler->create();
-				$modperm->setVar('gperm_groupid', $groupid);
-				$modperm->setVar('gperm_itemid', $a_mid);
-				$modperm->setVar('gperm_name', 'module_admin');
-				$modperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($modperm);
-			}
-			array_push($read_mids, 1);
-			foreach ($read_mids as $r_mid) {
-				$modperm =& $gperm_handler->create();
-				$modperm->setVar('gperm_groupid', $groupid);
-				$modperm->setVar('gperm_itemid', $r_mid);
-				$modperm->setVar('gperm_name', 'module_read');
-				$modperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($modperm);
-			}
-			foreach ($read_bids as $r_bid) {
-				$blockperm =& $gperm_handler->create();
-				$blockperm->setVar('gperm_groupid', $groupid);
-				$blockperm->setVar('gperm_itemid', $r_bid);
-				$blockperm->setVar('gperm_name', 'block_read');
-				$blockperm->setVar('gperm_modid', 1);
-				$gperm_handler->insert($blockperm);
-			}
-			redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
-		}
+    include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php';
+    include_once XOOPS_ROOT_PATH."/modules/system/admin/groups/groups.php";
+    $op = "display";
+
+    if ( isset($_GET['op']) ) {
+        if ($_GET['op'] == "modify" || $_GET['op'] == "del") {
+            $op = $_GET['op'];
+            $g_id = $_GET['g_id'];
+        }
+    } elseif (isset($_POST['op'])) {
+        $op = $_POST['op'];
+    }
+
+    // from finduser section
+    if ( !empty($_POST['memberslist_id']) && is_array($_POST['memberslist_id']) ) {
+        $op = "addUser";
+        $_POST['uids'] = $_POST['memberslist_id'];
+    }
+
+    switch ($op) {
+    case "modify":
+        include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
+        modifyGroup($g_id);
+        break;
+    case "update":
+		if(!XoopsMultiTokenHandler::quickValidate('groups_update'))
+			system_groups_error("Ticket Error");
+
+        $g_id = !empty($_POST['g_id']) ? intval($_POST['g_id']) : 0;
+        if ($g_id <= 0) {
+            exit();
+        }
+        $system_catids = empty($_POST['system_catids']) ? array() : $_POST['system_catids'];
+        $admin_mids = empty($_POST['admin_mids']) ? array() : $_POST['admin_mids'];
+        $read_mids = empty($_POST['read_mids']) ? array() : $_POST['read_mids'];
+        $read_bids = empty($_POST['read_bids']) ? array() : $_POST['read_bids'];
+        $member_handler =& xoops_gethandler('member');
+        $group =& $member_handler->getGroup($g_id);
+        $group->setVar('name', $_POST['name']);
+        $group->setVar('description', $_POST['desc']);
+        // if this group is not one of the default groups
+        if (!in_array($group->getVar('groupid'), array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS))) {
+            if (count($system_catids) > 0) {
+                $group->setVar('group_type', 'Admin');
+            } else {
+                $group->setVar('group_type', '');
+            }
+        }
+        if (!$member_handler->insertGroup($group)) {
+            xoops_cp_header();
+            echo $group->getHtmlErrors();
+            xoops_cp_footer();
+        } else {
+            $groupid = $group->getVar('groupid');
+            $gperm_handler =& xoops_gethandler('groupperm');
+            $criteria = new CriteriaCompo(new Criteria('gperm_groupid', $groupid));
+            $criteria->add(new Criteria('gperm_modid', 1));
+            $criteria2 = new CriteriaCompo(new Criteria('gperm_name', 'system_admin'));
+            $criteria2->add(new Criteria('gperm_name', 'module_admin'), 'OR');
+            $criteria2->add(new Criteria('gperm_name', 'module_read'), 'OR');
+            $criteria2->add(new Criteria('gperm_name', 'block_read'), 'OR');
+            $criteria->add($criteria2);
+            $gperm_handler->deleteAll($criteria);
+            if (count($system_catids) > 0) {
+                array_push($admin_mids, 1);
+                foreach ($system_catids as $s_cid) {
+                    $sysperm =& $gperm_handler->create();
+                    $sysperm->setVar('gperm_groupid', $groupid);
+                    $sysperm->setVar('gperm_itemid', $s_cid);
+                    $sysperm->setVar('gperm_name', 'system_admin');
+                    $sysperm->setVar('gperm_modid', 1);
+                    $gperm_handler->insert($sysperm);
+                }
+            }
+            foreach ($admin_mids as $a_mid) {
+                $modperm =& $gperm_handler->create();
+                $modperm->setVar('gperm_groupid', $groupid);
+                $modperm->setVar('gperm_itemid', $a_mid);
+                $modperm->setVar('gperm_name', 'module_admin');
+                $modperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($modperm);
+            }
+            array_push($read_mids, 1);
+            foreach ($read_mids as $r_mid) {
+                $modperm =& $gperm_handler->create();
+                $modperm->setVar('gperm_groupid', $groupid);
+                $modperm->setVar('gperm_itemid', $r_mid);
+                $modperm->setVar('gperm_name', 'module_read');
+                $modperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($modperm);
+            }
+            foreach ($read_bids as $r_bid) {
+                $blockperm =& $gperm_handler->create();
+                $blockperm->setVar('gperm_groupid', $groupid);
+                $blockperm->setVar('gperm_itemid', $r_bid);
+                $blockperm->setVar('gperm_name', 'block_read');
+                $blockperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($blockperm);
+            }
+            redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
+        }
+        break;
+    case "add":
+		if(!XoopsMultiTokenHandler::quickValidate('groups_add'))
+			system_groups_error("Ticket Error");
+
+        $name = !empty($_POST['name']) ? trim($_POST['name']) : '';
+        if ($name == '') {
+            xoops_cp_header();
+            echo _AM_UNEED2ENTER;
+            xoops_cp_footer();
+            exit();
+        }
+        $system_catids = empty($_POST['system_catids']) ? array() : $_POST['system_catids'];
+        $admin_mids = empty($_POST['admin_mids']) ? array() : $_POST['admin_mids'];
+        $read_mids = empty($_POST['read_mids']) ? array() : $_POST['read_mids'];
+        $read_bids = empty($_POST['read_bids']) ? array() : $_POST['read_bids'];
+        $member_handler =& xoops_gethandler('member');
+        $group =& $member_handler->createGroup();
+        $group->setVar("name", $name);
+        $group->setVar("description", $_POST['desc']);
+        if (count($system_catids) > 0) {
+            $group->setVar("group_type", 'Admin');
+        }
+        if (!$member_handler->insertGroup($group)) {
+            xoops_cp_header();
+            echo $group->getHtmlErrors();
+            xoops_cp_footer();
+        } else {
+            $groupid = $group->getVar('groupid');
+            $gperm_handler =& xoops_gethandler('groupperm');
+            if (count($system_catids) > 0) {
+                array_push($admin_mids, 1);
+                foreach ($system_catids as $s_cid) {
+                    $sysperm =& $gperm_handler->create();
+                    $sysperm->setVar('gperm_groupid', $groupid);
+                    $sysperm->setVar('gperm_itemid', $s_cid);
+                    $sysperm->setVar('gperm_name', 'system_admin');
+                    $sysperm->setVar('gperm_modid', 1);
+                    $gperm_handler->insert($sysperm);
+                }
+            }
+            foreach ($admin_mids as $a_mid) {
+                $modperm =& $gperm_handler->create();
+                $modperm->setVar('gperm_groupid', $groupid);
+                $modperm->setVar('gperm_itemid', $a_mid);
+                $modperm->setVar('gperm_name', 'module_admin');
+                $modperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($modperm);
+            }
+            array_push($read_mids, 1);
+            foreach ($read_mids as $r_mid) {
+                $modperm =& $gperm_handler->create();
+                $modperm->setVar('gperm_groupid', $groupid);
+                $modperm->setVar('gperm_itemid', $r_mid);
+                $modperm->setVar('gperm_name', 'module_read');
+                $modperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($modperm);
+            }
+            foreach ($read_bids as $r_bid) {
+                $blockperm =& $gperm_handler->create();
+                $blockperm->setVar('gperm_groupid', $groupid);
+                $blockperm->setVar('gperm_itemid', $r_bid);
+                $blockperm->setVar('gperm_name', 'block_read');
+                $blockperm->setVar('gperm_modid', 1);
+                $gperm_handler->insert($blockperm);
+            }
+            redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
+        }
         break;
     case "del":
-		xoops_cp_header();
-		xoops_confirm(array('fct' => 'groups', 'op' => 'delConf', 'g_id' => $g_id), 'admin.php', _AM_AREUSUREDEL);
+        xoops_cp_header();
+        $member_handler =& xoops_gethandler('member');
+        $group =& $member_handler->getGroup($g_id);
+        xoops_token_confirm(array('fct' => 'groups', 'op' => 'delConf', 'g_id' => $g_id), 'admin.php', sprintf(_AM_AREUSUREDEL,$group->getVar('name')));
         xoops_cp_footer();
         break;
-	case "delConf":
-		if (intval($g_id) > 0 && !in_array($g_id, array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS))) {
-			$member_handler =& xoops_gethandler('member');
-			$group =& $member_handler->getGroup($g_id);
-			$member_handler->deleteGroup($group);
-			$gperm_handler =& xoops_gethandler('groupperm');
-			$gperm_handler->deleteByGroup($g_id);
-		}
-		redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
-		break;
-	case "addUser":
-		$member_handler =& xoops_gethandler('member');
-		$size = count($uids);
-		for ( $i = 0; $i < $size; $i++ ) {
-			$member_handler->addUserToGroup($groupid, $uids[$i]);
-		}
-		redirect_header("admin.php?fct=groups&amp;op=modify&amp;g_id=".$groupid."",0,_AM_DBUPDATED);
-		break;
-	case "delUser":
-		if (intval($groupid) > 0) {
-			$member_handler =& xoops_gethandler('member');
-			$memstart = isset($memstart) ? intval($memstart) : 0;
-			if ($groupid == XOOPS_GROUP_ADMIN) {
-            	if ($member_handler->getUserCountByGroup($groupid) > count($uids)){
-					$member_handler->removeUsersFromGroup($groupid, $uids);
-				}
-        	} else {
-				$member_handler->removeUsersFromGroup($groupid, $uids);
-			}
-			redirect_header('admin.php?fct=groups&amp;op=modify&amp;g_id='.$groupid.'&amp;memstart='.$memstart,0,_AM_DBUPDATED);
-		}
-		break;
-	case "display":
-    	default:
-		displayGroups();
-		break;
-	}
+    case "delConf":
+		if(!xoops_confirm_validate())
+			system_groups_error("Ticket Error");
+
+        $g_id = !empty($_POST['g_id']) ? intval($_POST['g_id']) : 0;
+        if ($g_id > 0 && !in_array($g_id, array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS))) {
+            $member_handler =& xoops_gethandler('member');
+            $group =& $member_handler->getGroup($g_id);
+            $member_handler->deleteGroup($group);
+            $gperm_handler =& xoops_gethandler('groupperm');
+            $gperm_handler->deleteByGroup($g_id);
+        }
+        redirect_header("admin.php?fct=groups&amp;op=adminMain",1,_AM_DBUPDATED);
+        break;
+    case "addUser":
+		if(!XoopsMultiTokenHandler::quickValidate('groups_User'))
+			system_groups_error("Ticket Error");
+
+        $member_handler =& xoops_gethandler('member');
+        $groupid = intval($_POST['groupid']);
+        if ($groupid > 0) {
+            $size = count($_POST['uids']);
+            for ( $i = 0; $i < $size; $i++ ) {
+                $member_handler->addUserToGroup($_POST['groupid'], $_POST['uids'][$i]);
+            }
+        }
+        redirect_header("admin.php?fct=groups&amp;op=modify&amp;g_id=".$groupid, 0, _AM_DBUPDATED);
+        break;
+    case "delUser":
+		if(!XoopsMultiTokenHandler::quickValidate('groups_User'))
+			system_groups_error("Ticket Error");
+
+        $groupid = !empty($_POST['groupid']) ? intval($_POST['groupid']) : 0;
+        if ($groupid > 0) {
+            $member_handler =& xoops_gethandler('member');
+            $memstart = isset($_POST['memstart']) ? intval($_POST['memstart']) : 0;
+            if ($groupid == XOOPS_GROUP_ADMIN) {
+                if ($member_handler->getUserCountByGroup($groupid) > count($_POST['uids'])){
+                    $member_handler->removeUsersFromGroup($groupid, $_POST['uids']);
+                }
+            } else {
+                $member_handler->removeUsersFromGroup($groupid, $_POST['uids']);
+            }
+            redirect_header('admin.php?fct=groups&amp;op=modify&amp;g_id='.$groupid.'&amp;memstart='.$memstart,0,_AM_DBUPDATED);
+        }
+        break;
+    case "display":
+        default:
+        displayGroups();
+        break;
+    }
 }
 ?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index