diff --git a/admin/editgroup.php b/admin/editgroup.php index 33963f33e1..da509ca6bd 100755 --- a/admin/editgroup.php +++ b/admin/editgroup.php @@ -18,6 +18,8 @@ $phpgw_info["flags"]["currentapp"] = "admin"; include("../header.inc.php"); +$debugme = "on"; + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); function is_odd($n) @@ -35,12 +37,12 @@ } if ($submit) { - $phpgw->db->query("SELECT account_lid FROM phpgw_accounts WHERE account_id=$group_id"); + $phpgw->db->query("SELECT account_lid FROM phpgw_accounts WHERE account_id=$group_id",__LINE__,__FILE__); $phpgw->db->next_record(); $old_group_name = $phpgw->db->f("account_lid"); - $phpgw->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_lid='" . $n_group . "'"); + $phpgw->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_lid='" . $n_group . "'",__LINE__,__FILE__); $phpgw->db->next_record(); if ($phpgw->db->f(0) != 0 && $n_group != $old_group_name) { @@ -48,63 +50,68 @@ } if (! $error) { - $phpgw->db->lock(array("accounts","groups","preferences","config","applications","phpgw_hooks","phpgw_sessions","phpgw_acl")); - $apps = CreateObject('phpgwapi.applications',array(intval($group_id),'g')); - $apps->read_installed_apps(); + $phpgw->db->lock(array('phpgw_accounts','preferences','config','applications','phpgw_hooks','phpgw_sessions','phpgw_acl')); + $apps = CreateObject('phpgwapi.applications',intval($group_id)); $apps_before = $apps->read_account_specific(); - $apps->account_apps = Array(Array()); + $apps->update_data(Array()); while($app = each($n_group_permissions)) { if($app[1]) { - $apps->add_app($app[0]); + $apps->add($app[0]); if(!$apps_before[$app[0]]) { $apps_after[] = $app[0]; } } } - $apps->save_apps(); + $apps->save_repository(); if($old_group_name <> $n_group) { - $phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id"); + $phpgw->db->query("UPDATE phpgw_accounts SET account_lid='$n_group' WHERE account_id=$group_id",__LINE__,__FILE__); } - $old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u"); + $acl = CreateObject('phpgwapi.acl',$group_id); + $acl->read_repository(); + $old_group_list = $acl->get_ids_for_location($group_id,1,'phpgw_group'); @reset($old_group_list); - while($old_group_list && $id = each($old_group_list)) { - $phpgw->acl->delete("phpgw_group","$group_id",intval($id[1]),"u"); + while($old_group_list && $user_id = each($old_group_list)) { + $acl->delete_repository('phpgw_group',$group_id,$user_id[1]); } for ($i=0; $iacl->add("phpgw_group","$group_id",$n_users[$i],"u",1); + $acl->add_repository('phpgw_group',$group_id,$n_users[$i],1); + $phpgw->db->query("SELECT account_lid FROM phpgw_accounts WHERE account_id=".$n_users[$i],__LINE__,__FILE__); + $phpgw->db->next_record(); + $acccount_lid = $phpgw->db->f('account_lid'); + // If the user is logged in, it will force a refresh of the session_info $phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$account_lid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__); // The following sets any default preferences needed for new applications.. // This is smart enough to know if previous preferences were selected, use them. $pref = CreateObject('phpgwapi.preferences',intval($n_users[$i])); - $t = $pref->get_preferences(); + $t = $pref->read_repository(); $docommit = False; for ($j=1;$jcommon->hook_single("add_def_pref", $apps_after[$j]); + $phpgw->common->hook_single('add_def_pref', $apps_after[$j]); $docommit = True; } } if ($docommit) { - $pref->commit(); + $pref->save_repository(); } } $sep = $phpgw->common->filesystem_separator(); if ($old_group_name <> $n_group) { - $basedir = $phpgw_info["server"]["files_dir"] . $sep . "groups" . $sep; + $basedir = $phpgw_info['server']['files_dir'] . $sep . 'groups' . $sep; if (! @rename($basedir . $old_group_name, $basedir . $n_group)) { $cd = 39; } else { @@ -116,73 +123,73 @@ $phpgw->db->unlock(); - Header("Location: " . $phpgw->link("groups.php","cd=$cd")); + Header('Location: ' . $phpgw->link('groups.php','cd='.$cd)); $phpgw->common->phpgw_exit(); } } - $p->set_file(array("form" => "groups_form.tpl")); + $p->set_file(array('form' => 'groups_form.tpl')); if ($error) { $phpgw->common->phpgw_header(); echo parse_navbar(); - $p->set_var("error","

$error
"); + $p->set_var('error','

'.$error.'
'); } else { - $p->set_var("error",""); + $p->set_var('error',''); } if ($submit) { - $p->set_var("group_name_value",$n_group_name); + $p->set_var('group_name_value',$n_group_name); for ($i=0; $idb->query("SELECT account_lid FROM phpgw_accounts WHERE account_id=$group_id"); + $phpgw->db->query('SELECT account_lid FROM phpgw_accounts WHERE account_id='.$group_id,__LINE__,__FILE__); $phpgw->db->next_record(); - $p->set_var("group_name_value",$phpgw->db->f("account_id")); + $p->set_var('group_name_value',$phpgw->db->f('account_id')); - $group_user = $phpgw->acl->get_ids_for_location($group_id,1,'phpgw_group','u'); + $group_user = $phpgw->acl->get_ids_for_location($group_id,1,'phpgw_group'); while ($user = each($group_user)) { - $selected_users[$user[1]] = " selected"; + $selected_users[$user[1]] = ' selected'; } - $apps = CreateObject('phpgwapi.applications',array(intval($group_id),'g')); - $apps->read_installed_apps(); + $apps = CreateObject('phpgwapi.applications',intval($group_id)); + $apps->read_repository(); $db_perms = $apps->read_account_specific(); } - $phpgw->db->query("SELECT * FROM phpgw_accounts WHERE account_id=$group_id"); + $phpgw->db->query('SELECT * FROM phpgw_accounts WHERE account_id='.$group_id,__LINE__,__FILE__); $phpgw->db->next_record(); - $p->set_var("form_action",$phpgw->link("editgroup.php")); - $p->set_var("hidden_vars",""); + $p->set_var('form_action',$phpgw->link('editgroup.php')); + $p->set_var('hidden_vars',''); - $p->set_var("lang_group_name",lang("group name")); - $p->set_var("group_name_value",$phpgw->db->f("account_lid")); + $p->set_var('lang_group_name',lang('group name')); + $p->set_var('group_name_value',$phpgw->db->f('account_lid')); $phpgw->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_status !='L' AND account_type='u'"); $phpgw->db->next_record(); if ($phpgw->db->f(0) < 5) { - $p->set_var("select_size",$phpgw->db->f(0)); + $p->set_var('select_size',$phpgw->db->f(0)); } else { - $p->set_var("select_size","5"); + $p->set_var('select_size','5'); } - $p->set_var("lang_include_user",lang("Select users for inclusion")); + $p->set_var('lang_include_user',lang('Select users for inclusion')); $phpgw->db->query("SELECT account_id,account_firstname,account_lastname,account_lid FROM phpgw_accounts WHERE " . "account_status != 'L' AND account_type='u' ORDER BY account_lastname,account_firstname,account_lid asc"); while ($phpgw->db->next_record()) { - $user_list .= ""; + $user_list .= ''; } - $p->set_var("user_list",$user_list); + $p->set_var('user_list',$user_list); $p->set_var("lang_permissions",lang("Permissions this group has")); diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index 01f9973226..8faf58ded9 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -270,15 +270,15 @@ It should use the values in the $this->data global $phpgw, $phpgw_info; if ($account_id == False){ $account_id = $this->account_id; } $sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = '$location' and "; - $sql .= "acl_account = ".$account_id; + $sql .= 'acl_account = '.$account_id; $this->db->query($sql ,__LINE__,__FILE__); $rights = 0; if ($this->db->num_rows() == 0 ){ return False; } while ($this->db->next_record()) { - if ($this->db->f("acl_rights") == 0){ return False; } - $rights |= $this->db->f("acl_rights"); + if ($this->db->f('acl_rights') == 0){ return False; } + $rights |= $this->db->f('acl_rights'); if (!!($rights & $required) == True){ - $apps[] = $this->db->f("acl_appname"); + $apps[] = $this->db->f('acl_appname'); } } return $apps; diff --git a/phpgwapi/inc/class.applications.inc.php b/phpgwapi/inc/class.applications.inc.php index 276fa120b1..c241a1079a 100755 --- a/phpgwapi/inc/class.applications.inc.php +++ b/phpgwapi/inc/class.applications.inc.php @@ -35,7 +35,7 @@ { global $phpgw, $phpgw_info; $this->db = $phpgw->db; - if ($account_id == False){ $this->account_id = $account_id; } + if ($account_id != False){ $this->account_id = $account_id; } } /**************************************************************************\ @@ -72,7 +72,7 @@ while($app = each($apps)) { $this->data[$app[1]] = array("title" => $phpgw_info["apps"][$app[1]]["title"], "name" => $app[1], "enabled" => True, "status" => $phpgw_info["apps"][$app[1]]["status"]); } - } elseif(gettype($apps) == "string") { + } elseif(gettype($apps)) { $this->data[$apps] = array("title" => $phpgw_info["apps"][$apps]["title"], "name" => $apps, "enabled" => True, "status" => $phpgw_info["apps"][$apps]["status"]); } reset($this->data); @@ -97,11 +97,11 @@ function save_repository(){ global $phpgw; - $num_rows = $phpgw->acl->delete("%%", "run", $this->account_id); + $num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id); reset($this->data); while($app = each($this->data)) { if(!$this->is_system_enabled($app[0])) { continue; } - $phpgw->acl->add($app[0],'run',$this->account_id,1); + $phpgw->acl->add_repository($app[0],'run',$this->account_id,1); } reset($this->data); return $this->data; @@ -126,13 +126,14 @@ function read_account_specific() { global $phpgw, $phpgw_info; - if (gettype($phpgw_info["apps"]) != "array") { + if (gettype($phpgw_info['apps']) != 'array') { $this->read_installed_apps(); } - @reset($phpgw_info["apps"]); - while ($app = each($phpgw_info["apps"])) { - if ($phpgw->acl->check_specific("run",1,$app[0], $this->account_id) && $this->is_system_enabled($app[0])) { - $this->data[$app[0]] = array("title" => $phpgw_info["apps"][$app[0]]["title"], "name" => $app[0], "enabled" => True, "status" => $phpgw_info["apps"][$app[0]]["status"]); + $app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id); + @reset($app_list); + while ($app = each($app_list)) { + if ($this->is_system_enabled($app[1])) { + $this->data[$app[1]] = array('title' => $phpgw_info['apps'][$app[1]]['title'], 'name' => $app[1], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[1]]['status']); } } reset($this->data); @@ -168,4 +169,4 @@ } } } -?> \ No newline at end of file +?>