17 include_once (
'Class.DbObj.php');
18 include_once (
'Class.QueryDb.php');
19 include_once (
'Class.Log.php');
20 include_once (
'Class.Application.php');
36 create table groups ( iduser int not null,
37 idgroup int not null);
38 create index groups_idx1 on groups(iduser);
39 create unique index groups_idx2 on groups(iduser,idgroup);
40 create trigger t_nogrouploop before insert or update on groups for each row execute procedure nogrouploop();";
59 $query->AddQuery(
"iduser='{$this->iduser}'");
60 $sql = sprintf(
"SELECT groups.idgroup as gid from groups, users where groups.idgroup=users.id and users.accounttype!='R' and groups.iduser=%d order by accounttype, lastname", $this->iduser);
62 $this->groups = $groupIds;
64 return (count($groupIds) > 0);
77 if (($this->iduser > 0) && ($uid > 0)) {
78 $err = $this->
exec_query(
"delete from groups where idgroup=" . $this->iduser .
" and iduser=$uid");
79 $err.= $this->
exec_query(
"delete from sessions where userid=$uid");
83 $err.= $g->exec_query(
"delete from groups where idgroup=" . $this->iduser .
" and iduser=$uid");
100 $err = $this->
exec_query(sprintf(
"select * from groups where idgroup=%s and iduser=%s", $this->idgroup, $this->iduser));
110 if ($uid) $u =
new Account(
"", $uid);
111 else $u =
new Account(
"", $this->iduser);
112 $u->updateMemberOf();
118 $g =
new Group($dbf);
121 $err = $g->exec_query(
"delete from groups where idgroup=" . $this->iduser .
" and iduser=" . $u->id);
124 $g->exec_query(
"delete from permission where computed");
127 $p->deletePermission($g->iduser, null, null,
true);
134 $err = $this->
exec_query(sprintf(
"delete from sessions where userid=%d", $this->iduser));
136 $u =
new Account(
"", $this->iduser);
138 $u->updateMemberOf();
145 $g =
new Group($dbf);
148 $err = $g->Add(
true);
151 $g->exec_query(
"delete from permission where computed");
154 $p->deletePermission($g->iduser, null, null,
true);
173 if ($this->syncAccount) {
174 $this->
exec_query(sprintf(
"delete from sessions where userid=%d", $this->iduser));
175 $this->
exec_query(
"delete from permission where computed");
178 simpleQuery($this->dbaccess,
"select * from users order by id", $tusers);
179 $u =
new Account($this->dbaccess);
180 foreach ($tusers as $tu) {
182 $u->updateMemberOf();
186 $cmd =
$wsh .
" --api=initViewPrivileges --reset-account=yes";
200 foreach ($this->groups as $k => $gid) {
201 $og =
new Group($this->dbaccess, $gid);
202 $allg = array_merge($allg, $og->GetAllGroups());
204 $allg = array_unique($allg);
214 $this->_initAllGroup();
218 if ($this->allgroups) {
219 foreach ($this->allgroups as $k => $v) {
220 if ($v[
"idgroup"] == $pgid) {
222 $groupsid[$uid] = $uid;
236 $this->_initAllGroup();
240 if ($this->allgroups) {
241 foreach ($this->allgroups as $k => $v) {
242 if ($v[
"iduser"] == $pgid) {
243 $gid = $v[
"idgroup"];
244 $groupsid[$gid] = $gid;
245 if (isset($this->levgid[$gid])) $this->levgid[$gid] = max($level, $this->levgid[$gid]);
246 else $this->levgid[$gid] = $level;
260 $this->levgid = array();
264 asort($this->levgid);
265 foreach ($this->levgid as $k => $v) {
266 if ($v == 0) $groupsid[$k] = $k;
267 else $uasid[$k] = $k;
272 private function _initAllGroup()
274 if (!isset($this->allgroups)) {
276 $list =
$query->Query(0, 0,
"TABLE",
"select * from groups where iduser in (select id from users where accounttype='G')");
278 foreach (
$list as $v) {
279 $this->allgroups[] = $v;
exec_query($sql, $lvl=0, $prepare=false)
getParentsGroupId($pgid, $level=0)
setSyncAccount($syncAccount)
SuppressUser($uid, $nopost=false)
resetAccountMemberOf($synchro=false)
foreach($argv as $arg) $cmd
getWshCmd($nice=false, $userid=0, $sudo=false)
getDirectParentsGroupId($pgid="", &$uasid)
if(($docid!==0)&&(!is_numeric($docid))) $query
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
bgexec($tcmd, &$result, &$err)
if($file) if($subject==""&&$file) if($subject=="") $err