[Jaws-commits] r13407 - in trunk/jaws/html/gadgets/Users/Model: . Admin

afz at jaws-project.com afz at jaws-project.com
Mon Aug 13 06:08:57 UTC 2012


Author: afz
Date: 2012-08-13 06:08:57 +0000 (Mon, 13 Aug 2012)
New Revision: 13407

Added:
   trunk/jaws/html/gadgets/Users/Model/Admin/
   trunk/jaws/html/gadgets/Users/Model/Admin/GroupACL.php
   trunk/jaws/html/gadgets/Users/Model/Admin/Settings.php
   trunk/jaws/html/gadgets/Users/Model/Admin/UserACL.php
   trunk/jaws/html/gadgets/Users/Model/Admin/UsersGroup.php
Removed:
   trunk/jaws/html/gadgets/Users/Model/GroupACL.php
   trunk/jaws/html/gadgets/Users/Model/Settings.php
   trunk/jaws/html/gadgets/Users/Model/UserACL.php
   trunk/jaws/html/gadgets/Users/Model/UsersGroup.php
Log:
[Users]: restructure users model

Copied: trunk/jaws/html/gadgets/Users/Model/Admin/GroupACL.php (from rev 13400, trunk/jaws/html/gadgets/Users/Model/GroupACL.php)
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/Admin/GroupACL.php	                        (rev 0)
+++ trunk/jaws/html/gadgets/Users/Model/Admin/GroupACL.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -0,0 +1,90 @@
+<?php
+/**
+ * Users Core Gadget
+ *
+ * @category   GadgetModel
+ * @package    Users
+ * @author     Jonathan Hernandez <ion at suavizado.com>
+ * @author     Ali Fazelzadeh <afz at php.net>
+ * @copyright  2004-2012 Jaws Development Group
+ * @license    http://www.gnu.org/copyleft/lesser.html
+ */
+class UsersAdminModel_GroupACL extends Jaws_Model
+{
+    /**
+     * Returns an array with the ACL keys of a given group
+     *
+     * @access  public
+     * @param   int     $guid   Group's ID
+     * @return  array   Array with ACL Keys
+     */
+    function GetGroupACLKeys($guid)
+    {
+        $acls = $GLOBALS['app']->ACL->GetGroupAclPermissions($guid);
+        $perms = array();
+        if (is_array($acls)) {
+            foreach ($acls as $gadget => $keys) {
+                if (!Jaws_Gadget::IsGadgetUpdated($gadget)) {
+                    continue;
+                }
+
+                $g = $GLOBALS['app']->LoadGadget($gadget, 'Info');
+                if (Jaws_Error::IsError($g)) {
+                    continue;
+                }
+
+                if (!isset($perms[$gadget])) {
+                    $perms[$gadget] = array();
+                    $perms[$gadget]['name'] = _t(strtoupper($gadget).'_NAME');
+                }
+
+                foreach ($keys as $k) {
+                    $aclkey = '/ACL'.str_replace('/ACL/groups/'.$guid, '', $k['name']);
+                    $perms[$gadget][$aclkey] = array(
+                        'desc'  => $g->GetACLDescription($aclkey),
+                        'value' => $k['value'],
+                        'name'  => $k['name'],
+                    );
+                }
+            }
+
+            ksort($perms);
+            return $perms;
+        }
+
+        return false;
+    }
+
+    /**
+     * Saves only the modified ACL group keys
+     *
+     * @access  public
+     * @param   int     $guid   Group ID
+     * @param   array   $keys   ACL Keys
+     */
+    function UpdateGroupACL($guid, $keys)
+    {
+        require_once JAWS_PATH . 'include/Jaws/User.php';
+        $userModel = new Jaws_User();
+
+        if ($group = $userModel->GetGroupInfoById($guid)) {
+            $GLOBALS['app']->ACL->LoadAllFiles();
+            $GLOBALS['app']->ACL->LoadKeysOf($guid, 'groups');
+            foreach ($keys as $key => $value) {
+                if (is_null($value)) {
+                    $GLOBALS['app']->ACL->DeleteKey($key);
+                } else {
+                    $valueString = ($value === true)? 'true' : 'false';
+                    if (is_null($GLOBALS['app']->ACL->Get($key))) {
+                        $GLOBALS['app']->ACL->NewKey($key, $valueString);
+                    } else {
+                        $GLOBALS['app']->ACL->Set($key, $valueString);
+                    }
+                }
+            }
+            return true;
+        }
+        return new Jaws_Error(_t('USERS_GROUPS_GROUP_NOT_EXIST'), _t('USERS_NAME'));
+    }
+
+}
\ No newline at end of file

Copied: trunk/jaws/html/gadgets/Users/Model/Admin/Settings.php (from rev 13400, trunk/jaws/html/gadgets/Users/Model/Settings.php)
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/Admin/Settings.php	                        (rev 0)
+++ trunk/jaws/html/gadgets/Users/Model/Admin/Settings.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Users Core Gadget
+ *
+ * @category   GadgetModel
+ * @package    Users
+ * @author     Jonathan Hernandez <ion at suavizado.com>
+ * @author     Ali Fazelzadeh <afz at php.net>
+ * @copyright  2004-2012 Jaws Development Group
+ * @license    http://www.gnu.org/copyleft/lesser.html
+ */
+class UsersAdminModel_Settings extends Jaws_Model
+{
+    /**
+     * Save user config settings
+     *
+     * @access  public
+     * @param   string  $method     Authentication method
+     * @param   string  $anon       Anonymous users can auto-register
+     * @param   string  $repetitive Anonymous can register by repetitive email
+     * @param   string  $act        Activation type
+     * @param   integer $type       User's type
+     * @param   integer $group      Default group of anonymous registered user
+     * @param   string  $recover    Users can recover their passwords
+     * @return  boolean Success/Failure
+     */
+    function SaveSettings($method, $anon, $repetitive, $act, $group, $recover)
+    {
+        $xss = $GLOBALS['app']->loadClass('XSS', 'Jaws_XSS');
+
+        $method     = $xss->parse($method);
+        $anon       = $xss->parse($anon);
+        $repetitive = $xss->parse($repetitive);
+        $recover    = $xss->parse($recover);
+
+        $res = true;
+        if ($GLOBALS['app']->Session->GetPermission('Users', 'ManageAuthenticationMethod')) {
+            $methods = Jaws::getAuthMethods();
+            if ($methods !== false && in_array($method, $methods)) {
+                $res = $GLOBALS['app']->Registry->Set('/config/auth_method', $method);
+            }
+        }
+        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_register', $anon);
+        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_repetitive_email', $repetitive);
+        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_activation', $act);
+        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_group', (int)$group);
+        $res = $res && $GLOBALS['app']->Registry->Set('/gadgets/Users/password_recovery', $recover);
+        if ($res) {
+            $GLOBALS['app']->Registry->Commit('Users');
+            $GLOBALS['app']->Registry->Commit('core');
+            $GLOBALS['app']->ACL->Commit('core');
+            return true;
+        }
+
+        return new Jaws_Error(_t('USERS_PROPERTIES_CANT_UPDATE'), _t('USERS_NAME'));
+    }
+
+}
\ No newline at end of file

Copied: trunk/jaws/html/gadgets/Users/Model/Admin/UserACL.php (from rev 13400, trunk/jaws/html/gadgets/Users/Model/UserACL.php)
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/Admin/UserACL.php	                        (rev 0)
+++ trunk/jaws/html/gadgets/Users/Model/Admin/UserACL.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -0,0 +1,109 @@
+<?php
+/**
+ * Users Core Gadget
+ *
+ * @category   GadgetModel
+ * @package    Users
+ * @author     Jonathan Hernandez <ion at suavizado.com>
+ * @author     Ali Fazelzadeh <afz at php.net>
+ * @copyright  2004-2012 Jaws Development Group
+ * @license    http://www.gnu.org/copyleft/lesser.html
+ */
+class UsersAdminModel_UserACL extends Jaws_Model
+{
+    /**
+     * Get ACL permissions of a given user
+     *
+     * @access  public
+     * @param   string  $username  Username
+     * @return  array   Array with ACL Keys
+     */
+    function GetUserACLKeys($username)
+    {
+        $acls = $GLOBALS['app']->ACL->GetAclPermissions($username, false);
+        $perms = array();
+        if (is_array($acls)) {
+            foreach ($acls as $gadget => $keys) {
+                $g = $GLOBALS['app']->LoadGadget($gadget, 'Info');
+                if (Jaws_Error::IsError($g)) {
+                    continue;
+                }
+
+                if (!Jaws_Gadget::IsGadgetUpdated($gadget)) {
+                    continue;
+                }
+
+                if (!isset($perms[$gadget])) {
+                    $perms[$gadget] = array();
+                    $perms[$gadget]['name'] = _t(strtoupper($gadget).'_NAME');
+                }
+
+                foreach ($keys as $k) {
+                    $aclkey = '/ACL'.str_replace('/ACL/users/'.$username, '', $k['name']);
+
+                    $perms[$gadget][$aclkey] = array(
+                        'desc'  => $g->GetACLDescription($aclkey),
+                        'value' => $k['value'],
+                        'name'  => $k['name'],
+                    );
+                }
+            }
+
+            ksort($perms);
+            return $perms;
+        }
+
+        return false;
+    }
+
+    /**
+     * Saves only the modified ACL user keys
+     *
+     * @access  public
+     * @param   int     $uid    User' ID
+     * @param   array   $keys   ACL Keys
+     * @return  boolean Success/Failure(Jaws_Error)
+     */
+    function UpdateUserACL($uid, $keys)
+    {
+        require_once JAWS_PATH . 'include/Jaws/User.php';
+        $userModel = new Jaws_User();
+        $currentUser = $GLOBALS['app']->Session->GetAttribute('user');
+        if ($user = $userModel->GetUser((int)$uid)) {
+            //Load user keys
+            $GLOBALS['app']->ACL->LoadAllFiles();
+            $GLOBALS['app']->ACL->LoadKeysOf($user['username'], 'users');
+            foreach($keys as $key => $value) {
+                //check user permission for this key
+                $expkey = explode('/', $key);
+                $aclkey = end($expkey);
+                $gadget = prev($expkey);
+                if (!$GLOBALS['app']->Session->GetPermission($gadget, $aclkey)) {
+                    continue;
+                }
+
+                //Get the current value
+                if ($key == '/ACL/users/' . $user['username'] . '/gadgets/ControlPanel/default' &&
+                    $value === false && $uid == $currentUser)
+                {
+                    return new Jaws_Error(_t('USERS_USERS_CANT_AUTO_TURN_OFF_CP'), _t('USERS_NAME'));
+                }
+
+                if (is_null($value)) {
+                    $GLOBALS['app']->ACL->DeleteKey($key);
+                } else {
+                    $valueString = ($value === true)? 'true' : 'false';
+                    if (is_null($GLOBALS['app']->ACL->Get($key))) {
+                        $GLOBALS['app']->ACL->NewKey($key, $valueString);
+                    } else {
+                        $GLOBALS['app']->ACL->Set($key, $valueString);
+                    }
+                }
+            }
+            return true;
+        }
+
+        return new Jaws_Error(_t('USERS_USER_NOT_EXIST'), _t('USERS_NAME'));
+    }
+
+}
\ No newline at end of file

Copied: trunk/jaws/html/gadgets/Users/Model/Admin/UsersGroup.php (from rev 13400, trunk/jaws/html/gadgets/Users/Model/UsersGroup.php)
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/Admin/UsersGroup.php	                        (rev 0)
+++ trunk/jaws/html/gadgets/Users/Model/Admin/UsersGroup.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Users Core Gadget
+ *
+ * @category   GadgetModel
+ * @package    Users
+ * @author     Jonathan Hernandez <ion at suavizado.com>
+ * @author     Ali Fazelzadeh <afz at php.net>
+ * @copyright  2004-2012 Jaws Development Group
+ * @license    http://www.gnu.org/copyleft/lesser.html
+ */
+class UsersAdminModel_UsersGroup extends Jaws_Model
+{
+    /**
+     * Add a group of user (by they ids) to a certain group
+     *
+     * @access  public
+     * @param   int     $guid  Group's ID
+     * @param   array   $users Array with user id
+     * @return  array   Response (notice or error)
+     */
+    function AddUsersToGroup($guid, $users)
+    {
+        require_once JAWS_PATH . 'include/Jaws/User.php';
+        $userModel = new Jaws_User();
+
+        $group = $userModel->GetGroupInfoById($guid);
+        if (!$group) {
+            return new Jaws_Error(_t('USERS_GROUPS_GROUP_NOT_EXIST'), _t('USERS_NAME'));
+        }
+
+        $postedUsers = array();
+        foreach ($users as $k => $v) {
+            $postedUsers[$v] = $v;
+        }
+
+        $list = $userModel->GetUsers();
+        foreach ($list as $user) {
+            if ($userModel->UserIsInGroup($user['id'], $guid)) {
+                if (!isset($postedUsers[$user['id']])) {
+                    if (!$GLOBALS['app']->Session->IsSuperAdmin() && $user['superadmin']) {
+                        continue;
+                    }
+                    $userModel->DeleteUserFromGroup($user['id'], $guid);
+                }
+            } else {
+                if (isset($postedUsers[$user['id']])) {
+                    $userModel->AddUserToGroup($user['id'], $guid);
+
+                }
+            }
+        }
+        return true;
+    }
+
+}
\ No newline at end of file

Deleted: trunk/jaws/html/gadgets/Users/Model/GroupACL.php
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/GroupACL.php	2012-08-13 06:03:43 UTC (rev 13406)
+++ trunk/jaws/html/gadgets/Users/Model/GroupACL.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -1,90 +0,0 @@
-<?php
-/**
- * Users Core Gadget
- *
- * @category   GadgetModel
- * @package    Users
- * @author     Jonathan Hernandez <ion at suavizado.com>
- * @author     Ali Fazelzadeh <afz at php.net>
- * @copyright  2004-2012 Jaws Development Group
- * @license    http://www.gnu.org/copyleft/lesser.html
- */
-class UsersAdminModel_GroupACL extends Jaws_Model
-{
-    /**
-     * Returns an array with the ACL keys of a given group
-     *
-     * @access  public
-     * @param   int     $guid   Group's ID
-     * @return  array   Array with ACL Keys
-     */
-    function GetGroupACLKeys($guid)
-    {
-        $acls = $GLOBALS['app']->ACL->GetGroupAclPermissions($guid);
-        $perms = array();
-        if (is_array($acls)) {
-            foreach ($acls as $gadget => $keys) {
-                if (!Jaws_Gadget::IsGadgetUpdated($gadget)) {
-                    continue;
-                }
-
-                $g = $GLOBALS['app']->LoadGadget($gadget, 'Info');
-                if (Jaws_Error::IsError($g)) {
-                    continue;
-                }
-
-                if (!isset($perms[$gadget])) {
-                    $perms[$gadget] = array();
-                    $perms[$gadget]['name'] = _t(strtoupper($gadget).'_NAME');
-                }
-
-                foreach ($keys as $k) {
-                    $aclkey = '/ACL'.str_replace('/ACL/groups/'.$guid, '', $k['name']);
-                    $perms[$gadget][$aclkey] = array(
-                        'desc'  => $g->GetACLDescription($aclkey),
-                        'value' => $k['value'],
-                        'name'  => $k['name'],
-                    );
-                }
-            }
-
-            ksort($perms);
-            return $perms;
-        }
-
-        return false;
-    }
-
-    /**
-     * Saves only the modified ACL group keys
-     *
-     * @access  public
-     * @param   int     $guid   Group ID
-     * @param   array   $keys   ACL Keys
-     */
-    function UpdateGroupACL($guid, $keys)
-    {
-        require_once JAWS_PATH . 'include/Jaws/User.php';
-        $userModel = new Jaws_User();
-
-        if ($group = $userModel->GetGroupInfoById($guid)) {
-            $GLOBALS['app']->ACL->LoadAllFiles();
-            $GLOBALS['app']->ACL->LoadKeysOf($guid, 'groups');
-            foreach ($keys as $key => $value) {
-                if (is_null($value)) {
-                    $GLOBALS['app']->ACL->DeleteKey($key);
-                } else {
-                    $valueString = ($value === true)? 'true' : 'false';
-                    if (is_null($GLOBALS['app']->ACL->Get($key))) {
-                        $GLOBALS['app']->ACL->NewKey($key, $valueString);
-                    } else {
-                        $GLOBALS['app']->ACL->Set($key, $valueString);
-                    }
-                }
-            }
-            return true;
-        }
-        return new Jaws_Error(_t('USERS_GROUPS_GROUP_NOT_EXIST'), _t('USERS_NAME'));
-    }
-
-}
\ No newline at end of file

Deleted: trunk/jaws/html/gadgets/Users/Model/Settings.php
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/Settings.php	2012-08-13 06:03:43 UTC (rev 13406)
+++ trunk/jaws/html/gadgets/Users/Model/Settings.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -1,58 +0,0 @@
-<?php
-/**
- * Users Core Gadget
- *
- * @category   GadgetModel
- * @package    Users
- * @author     Jonathan Hernandez <ion at suavizado.com>
- * @author     Ali Fazelzadeh <afz at php.net>
- * @copyright  2004-2012 Jaws Development Group
- * @license    http://www.gnu.org/copyleft/lesser.html
- */
-class UsersAdminModel_Settings extends Jaws_Model
-{
-    /**
-     * Save user config settings
-     *
-     * @access  public
-     * @param   string  $method     Authentication method
-     * @param   string  $anon       Anonymous users can auto-register
-     * @param   string  $repetitive Anonymous can register by repetitive email
-     * @param   string  $act        Activation type
-     * @param   integer $type       User's type
-     * @param   integer $group      Default group of anonymous registered user
-     * @param   string  $recover    Users can recover their passwords
-     * @return  boolean Success/Failure
-     */
-    function SaveSettings($method, $anon, $repetitive, $act, $group, $recover)
-    {
-        $xss = $GLOBALS['app']->loadClass('XSS', 'Jaws_XSS');
-
-        $method     = $xss->parse($method);
-        $anon       = $xss->parse($anon);
-        $repetitive = $xss->parse($repetitive);
-        $recover    = $xss->parse($recover);
-
-        $res = true;
-        if ($GLOBALS['app']->Session->GetPermission('Users', 'ManageAuthenticationMethod')) {
-            $methods = Jaws::getAuthMethods();
-            if ($methods !== false && in_array($method, $methods)) {
-                $res = $GLOBALS['app']->Registry->Set('/config/auth_method', $method);
-            }
-        }
-        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_register', $anon);
-        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_repetitive_email', $repetitive);
-        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_activation', $act);
-        $res = $res && $GLOBALS['app']->Registry->Set('/config/anon_group', (int)$group);
-        $res = $res && $GLOBALS['app']->Registry->Set('/gadgets/Users/password_recovery', $recover);
-        if ($res) {
-            $GLOBALS['app']->Registry->Commit('Users');
-            $GLOBALS['app']->Registry->Commit('core');
-            $GLOBALS['app']->ACL->Commit('core');
-            return true;
-        }
-
-        return new Jaws_Error(_t('USERS_PROPERTIES_CANT_UPDATE'), _t('USERS_NAME'));
-    }
-
-}
\ No newline at end of file

Deleted: trunk/jaws/html/gadgets/Users/Model/UserACL.php
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/UserACL.php	2012-08-13 06:03:43 UTC (rev 13406)
+++ trunk/jaws/html/gadgets/Users/Model/UserACL.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -1,109 +0,0 @@
-<?php
-/**
- * Users Core Gadget
- *
- * @category   GadgetModel
- * @package    Users
- * @author     Jonathan Hernandez <ion at suavizado.com>
- * @author     Ali Fazelzadeh <afz at php.net>
- * @copyright  2004-2012 Jaws Development Group
- * @license    http://www.gnu.org/copyleft/lesser.html
- */
-class UsersAdminModel_UserACL extends Jaws_Model
-{
-    /**
-     * Get ACL permissions of a given user
-     *
-     * @access  public
-     * @param   string  $username  Username
-     * @return  array   Array with ACL Keys
-     */
-    function GetUserACLKeys($username)
-    {
-        $acls = $GLOBALS['app']->ACL->GetAclPermissions($username, false);
-        $perms = array();
-        if (is_array($acls)) {
-            foreach ($acls as $gadget => $keys) {
-                $g = $GLOBALS['app']->LoadGadget($gadget, 'Info');
-                if (Jaws_Error::IsError($g)) {
-                    continue;
-                }
-
-                if (!Jaws_Gadget::IsGadgetUpdated($gadget)) {
-                    continue;
-                }
-
-                if (!isset($perms[$gadget])) {
-                    $perms[$gadget] = array();
-                    $perms[$gadget]['name'] = _t(strtoupper($gadget).'_NAME');
-                }
-
-                foreach ($keys as $k) {
-                    $aclkey = '/ACL'.str_replace('/ACL/users/'.$username, '', $k['name']);
-
-                    $perms[$gadget][$aclkey] = array(
-                        'desc'  => $g->GetACLDescription($aclkey),
-                        'value' => $k['value'],
-                        'name'  => $k['name'],
-                    );
-                }
-            }
-
-            ksort($perms);
-            return $perms;
-        }
-
-        return false;
-    }
-
-    /**
-     * Saves only the modified ACL user keys
-     *
-     * @access  public
-     * @param   int     $uid    User' ID
-     * @param   array   $keys   ACL Keys
-     * @return  boolean Success/Failure(Jaws_Error)
-     */
-    function UpdateUserACL($uid, $keys)
-    {
-        require_once JAWS_PATH . 'include/Jaws/User.php';
-        $userModel = new Jaws_User();
-        $currentUser = $GLOBALS['app']->Session->GetAttribute('user');
-        if ($user = $userModel->GetUser((int)$uid)) {
-            //Load user keys
-            $GLOBALS['app']->ACL->LoadAllFiles();
-            $GLOBALS['app']->ACL->LoadKeysOf($user['username'], 'users');
-            foreach($keys as $key => $value) {
-                //check user permission for this key
-                $expkey = explode('/', $key);
-                $aclkey = end($expkey);
-                $gadget = prev($expkey);
-                if (!$GLOBALS['app']->Session->GetPermission($gadget, $aclkey)) {
-                    continue;
-                }
-
-                //Get the current value
-                if ($key == '/ACL/users/' . $user['username'] . '/gadgets/ControlPanel/default' &&
-                    $value === false && $uid == $currentUser)
-                {
-                    return new Jaws_Error(_t('USERS_USERS_CANT_AUTO_TURN_OFF_CP'), _t('USERS_NAME'));
-                }
-
-                if (is_null($value)) {
-                    $GLOBALS['app']->ACL->DeleteKey($key);
-                } else {
-                    $valueString = ($value === true)? 'true' : 'false';
-                    if (is_null($GLOBALS['app']->ACL->Get($key))) {
-                        $GLOBALS['app']->ACL->NewKey($key, $valueString);
-                    } else {
-                        $GLOBALS['app']->ACL->Set($key, $valueString);
-                    }
-                }
-            }
-            return true;
-        }
-
-        return new Jaws_Error(_t('USERS_USER_NOT_EXIST'), _t('USERS_NAME'));
-    }
-
-}
\ No newline at end of file

Deleted: trunk/jaws/html/gadgets/Users/Model/UsersGroup.php
===================================================================
--- trunk/jaws/html/gadgets/Users/Model/UsersGroup.php	2012-08-13 06:03:43 UTC (rev 13406)
+++ trunk/jaws/html/gadgets/Users/Model/UsersGroup.php	2012-08-13 06:08:57 UTC (rev 13407)
@@ -1,56 +0,0 @@
-<?php
-/**
- * Users Core Gadget
- *
- * @category   GadgetModel
- * @package    Users
- * @author     Jonathan Hernandez <ion at suavizado.com>
- * @author     Ali Fazelzadeh <afz at php.net>
- * @copyright  2004-2012 Jaws Development Group
- * @license    http://www.gnu.org/copyleft/lesser.html
- */
-class UsersAdminModel_UsersGroup extends Jaws_Model
-{
-    /**
-     * Add a group of user (by they ids) to a certain group
-     *
-     * @access  public
-     * @param   int     $guid  Group's ID
-     * @param   array   $users Array with user id
-     * @return  array   Response (notice or error)
-     */
-    function AddUsersToGroup($guid, $users)
-    {
-        require_once JAWS_PATH . 'include/Jaws/User.php';
-        $userModel = new Jaws_User();
-
-        $group = $userModel->GetGroupInfoById($guid);
-        if (!$group) {
-            return new Jaws_Error(_t('USERS_GROUPS_GROUP_NOT_EXIST'), _t('USERS_NAME'));
-        }
-
-        $postedUsers = array();
-        foreach ($users as $k => $v) {
-            $postedUsers[$v] = $v;
-        }
-
-        $list = $userModel->GetUsers();
-        foreach ($list as $user) {
-            if ($userModel->UserIsInGroup($user['id'], $guid)) {
-                if (!isset($postedUsers[$user['id']])) {
-                    if (!$GLOBALS['app']->Session->IsSuperAdmin() && $user['superadmin']) {
-                        continue;
-                    }
-                    $userModel->DeleteUserFromGroup($user['id'], $guid);
-                }
-            } else {
-                if (isset($postedUsers[$user['id']])) {
-                    $userModel->AddUserToGroup($user['id'], $guid);
-
-                }
-            }
-        }
-        return true;
-    }
-
-}
\ No newline at end of file



More information about the Jaws-commits mailing list