[Vtigercrm-commits] [vtiger-commits] r6121 - /vtigercrm/trunk/modules/Users/SaveGroup.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed May 17 08:56:02 EDT 2006
Author: don
Date: Wed May 17 06:55:58 2006
New Revision: 6121
Log:
Duplicate handling done
Modified:
vtigercrm/trunk/modules/Users/SaveGroup.php
Modified: vtigercrm/trunk/modules/Users/SaveGroup.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveGroup.php (original)
+++ vtigercrm/trunk/modules/Users/SaveGroup.php Wed May 17 06:55:58 2006
@@ -14,60 +14,76 @@
$groupName = trim($_REQUEST['groupName']);
$description = $_REQUEST['description'];
-function groupexists($groupName)
-{
- global $adb;
- $query = "select * from groups where groupname='".$groupName."'";
- $result = $adb->query($query);
- if($adb->query_result($result,0,"groupname")==$groupName)
- {
- return true;
- }
- else
- {
- return false;
- }
+$mode = $_REQUEST['mode'];
+
+if(isset($_REQUEST['dup_check']) && $_REQUEST['dup_check']!='')
+{
+ if($mode != 'edit')
+ {
+ $query = 'select groupname from groups where groupname="'.$groupName.'"';
+ }
+ else
+ {
+ $groupid = $_REQUEST['groupid'];
+ $query = 'select groupname from groups where groupname="'.$groupName.'" and groupid !='.$groupid;
+
+ }
+ $result = $adb->query($query);
+ if($adb->num_rows($result) > 0)
+ {
+ echo 'A Group in the specified name "'.$groupName.'" already exists';
+ die;
+ }else
+ {
+ echo 'SUCESS';
+ die;
+ }
+
}
+
+
+
+
function constructGroupMemberArray($member_array)
+{
+ global $adb;
+
+ $groupMemberArray=Array();
+ $roleArray=Array();
+ $roleSubordinateArray=Array();
+ $groupArray=Array();
+ $userArray=Array();
+
+ foreach($member_array as $member)
{
- global $adb;
+ $memSubArray=explode('::',$member);
+ if($memSubArray[0] == 'groups')
+ {
+ $groupArray[]=$memSubArray[1];
+ }
+ if($memSubArray[0] == 'roles')
+ {
+ $roleArray[]=$memSubArray[1];
+ }
+ if($memSubArray[0] == 'rs')
+ {
+ $roleSubordinateArray[]=$memSubArray[1];
+ }
+ if($memSubArray[0] == 'users')
+ {
+ $userArray[]=$memSubArray[1];
+ }
+ }
- $groupMemberArray=Array();
- $roleArray=Array();
- $roleSubordinateArray=Array();
- $groupArray=Array();
- $userArray=Array();
+ $groupMemberArray['groups']=$groupArray;
+ $groupMemberArray['roles']=$roleArray;
+ $groupMemberArray['rs']=$roleSubordinateArray;
+ $groupMemberArray['users']=$userArray;
- foreach($member_array as $member)
- {
- $memSubArray=explode('::',$member);
- if($memSubArray[0] == 'groups')
- {
- $groupArray[]=$memSubArray[1];
- }
- if($memSubArray[0] == 'roles')
- {
- $roleArray[]=$memSubArray[1];
- }
- if($memSubArray[0] == 'rs')
- {
- $roleSubordinateArray[]=$memSubArray[1];
- }
- if($memSubArray[0] == 'users')
- {
- $userArray[]=$memSubArray[1];
- }
- }
+ return $groupMemberArray;
- $groupMemberArray['groups']=$groupArray;
- $groupMemberArray['roles']=$roleArray;
- $groupMemberArray['rs']=$roleSubordinateArray;
- $groupMemberArray['users']=$userArray;
-
- return $groupMemberArray;
-
- }
+}
if(isset($_REQUEST['returnaction']) && $_REQUEST['returnaction'] != '')
{
@@ -91,21 +107,11 @@
}
elseif(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'create')
{
- if(!groupexists($groupName))
- {
- $selected_col_string = $_REQUEST['selectedColumnsString'];
- $member_array = explode(';',$selected_col_string);
- $groupMemberArray=constructGroupMemberArray($member_array);
- $groupId=createGroup($groupName,$groupMemberArray,$description);
- //Inserting into role Table
- //$roleId = createRole($rolename,$parentRoleId,$profile_array);
- $loc = "Location: index.php?action=".$returnaction."&parenttab=Settings&module=Users&groupId=".$groupId;
- }
- else
- {
- $loc = "Location: index.php?action=createnewgroup&parenttab=Settings&module=Users&groupname=".$groupName."&desc=".$description."&error=true";
- }
-
+ $selected_col_string = $_REQUEST['selectedColumnsString'];
+ $member_array = explode(';',$selected_col_string);
+ $groupMemberArray=constructGroupMemberArray($member_array);
+ $groupId=createGroup($groupName,$groupMemberArray,$description);
+ $loc = "Location: index.php?action=".$returnaction."&parenttab=Settings&module=Users&groupId=".$groupId;
}
More information about the vtigercrm-commits
mailing list