[Fusionforge-commits] r10670 - trunk/src/common/include
Roland Mas
lolando at libremir.placard.fr.eu.org
Fri Sep 24 16:43:48 CEST 2010
Author: lolando
Date: 2010-09-24 16:43:48 +0200 (Fri, 24 Sep 2010)
New Revision: 10670
Modified:
trunk/src/common/include/Group.class.php
trunk/src/common/include/User.class.php
Log:
Less SQL (and fewer references to the user_group table), more code reuse
Modified: trunk/src/common/include/Group.class.php
===================================================================
--- trunk/src/common/include/Group.class.php 2010-09-24 14:32:11 UTC (rev 10669)
+++ trunk/src/common/include/Group.class.php 2010-09-24 14:43:48 UTC (rev 10670)
@@ -1915,6 +1915,12 @@
return false;
}
$found_role->removeUser ($user) ;
+ if (!$SYS->sysGroupRemoveUser($this->getID(),$user_id)) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+
} else {
$res = db_query_params ('DELETE FROM user_group WHERE group_id=$1 AND user_id=$2',
array ($this->getID(),
Modified: trunk/src/common/include/User.class.php
===================================================================
--- trunk/src/common/include/User.class.php 2010-09-24 14:32:11 UTC (rev 10669)
+++ trunk/src/common/include/User.class.php 2010-09-24 14:43:48 UTC (rev 10670)
@@ -669,15 +669,12 @@
} else {
$this->data_array['status']=$status;
if ($status == 'D') {
- // Remove this user from all groups
- $res = db_query_params ('DELETE FROM user_group WHERE user_id=$1',
- array ($this->getID())) ;
- if (!$res) {
- $this->setError('ERROR - Could Not Propogate Deleted Status: '.db_error());
- db_rollback();
- return false;
+ $projects = $this->getGroups() ;
+ foreach ($projects as $p) {
+ $p->removeUser ($this->getID()) ;
}
}
+
$hook_params = array ();
$hook_params['user'] = $this;
$hook_params['user_id'] = $this->getID();
@@ -1197,19 +1194,11 @@
*
* @param boolean The session value.
*/
- function setLoggedIn($val=true) {
- $this->is_logged_in=$val;
+ function setLoggedIn ($val=true) {
+ $this->is_logged_in = $val;
+
if ($val) {
- //if this is the logged in user, see if they are a super user
- $result = db_query_params ('SELECT count(*) AS count FROM user_group WHERE user_id=$1 AND group_id=1 AND admin_flags=$2',
- array ($this->getID(),
- 'A')) ;
- if (!$result) {
- $this->is_super_user=false;
- return;
- }
- $row_count = db_fetch_array($result);
- $this->is_super_user = ($row_count['count'] > 0);
+ $this->is_super_user = forge_check_global_perm_for_user ($this, 'forge_admin') ;
}
}
More information about the Fusionforge-commits
mailing list