implementation of applications class

This commit is contained in:
skeeter 2001-01-21 01:26:23 +00:00
parent 31f38a5d8e
commit abf8c3bcd9
13 changed files with 257 additions and 139 deletions

View File

@ -134,12 +134,12 @@
}
$userData = $phpgw->accounts->read_userData($account_id);
$db_perms = $phpgw->accounts->read_apps($userData["account_lid"]);
if (! $submit) {
$n_loginid = $userData["account_lid"];
$n_firstname = $userData["firstname"];
$n_lastname = $userData["lastname"];
$apps = CreateObject('phpgwapi.applications',intval($userData["account_id"]));
}
if ($phpgw_info["server"]["account_repository"] == "ldap") {
@ -210,7 +210,7 @@
$perm_html .= '<tr bgcolor="'.$phpgw_info["theme"]["row_on"].'"><td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="new_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($new_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
if ($new_permissions[$perm_display[$i][0]] || $apps->user_apps[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td>";
@ -224,7 +224,7 @@
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="new_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($new_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
if ($new_permissions[$perm_display[$i][0]] || $apps->user_apps[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td></tr>\n";

View File

@ -37,13 +37,14 @@
if (! $error) {
// $phpgw->db->lock(array("accounts","groups","preferences","config","applications","phpgw_hooks","phpgw_sessions"));
$apps = CreateObject('phpgwapi.applications');
$app_string = $apps->add_group($group_id,$n_group_permissions);
$apps->save_group($group_id);
$apps_after = explode(":",$app_string);
$phpgw->accounts->add_app($n_group_permissions);
$apps = $phpgw->accounts->add_app("",True);
$apps_after = explode(":",$apps);
$phpgw->db->query("update groups set group_name='$n_group', group_apps='" . $apps
. "' where group_id=$group_id");
if($old_group_name <> $n_group) {
$phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id");
}
for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups, account_lid FROM accounts WHERE account_id=".$n_users[$i]);
@ -116,10 +117,6 @@
for ($i=0; $i<count($n_users); $i++) {
$selected_users[$n_user[$i]] = " selected";
}
for ($i=0; $i<count($n_group_permissions); $i++) {
$selected_permissions[$n_group_permissions[$i]] = " selected";
}
} else {
$phpgw->db->query("select group_name from groups where group_id=$group_id");
$phpgw->db->next_record();
@ -132,11 +129,9 @@
$selected_users[$phpgw->db->f("account_id")] = " selected";
}
$gp = $phpgw->accounts->read_group_apps($group_id);
for ($i=0; $i<count($gp); $i++) {
$selected_permissions[$gp[$i]] = " selected";
}
$apps = CreateObject('phpgwapi.applications');
$apps->read_group_apps($group_id);
$db_perms = $apps->get_group_array($group_id);
}
$phpgw->db->query("select * from groups where group_id=$group_id");
@ -170,14 +165,48 @@
$phpgw->template->set_var("user_list",$user_list);
$phpgw->template->set_var("lang_permissions",lang("Permissions this group has"));
$i = 0;
$sorted_apps = $phpgw_info["apps"];
@asort($sorted_apps);
@reset($sorted_apps);
while ($permission = each($phpgw_info["apps"])) {
if ($permission[1]["enabled"]) {
$permissions_list .= "<option value=\"" . $permission[0] . "\""
. $selected_permissions[$permission[0]] . ">"
. $permission[1]["title"] . "</option>";
$perm_display[$i][0] = $permission[0];
$perm_display[$i][1] = $permission[1]["title"];
$i++;
}
}
$phpgw->template->set_var("permissions_list",$permissions_list);
$perm_html = "";
for ($i=0;$i<200;) { // The $i<200 is only used for a brake
if (! $perm_display[$i][1]) break;
$perm_html .= '<tr bgcolor="'.$phpgw_info["theme"]["row_on"].'"><td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="n_group_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($n_group_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td>";
$i++;
if ($i == count($perm_display) && is_odd(count($perm_display))) {
$perm_html .= '<td colspan="2">&nbsp;</td></tr>';
}
if (! $perm_display[$i][1]) break;
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="n_group_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($n_group_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td></tr>\n";
$i++;
}
$phpgw->template->set_var("permissions_list",$perm_html);
$phpgw->template->set_var("lang_submit_button",lang("submit changes"));
$phpgw->template->pparse("out","form");

View File

@ -184,22 +184,21 @@
$phpgw->db->lock(array("accounts"));
while ($permission = each($account_info["permissions"])) {
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
$phpgw->accounts->add_app($permission[0]);
}
}
$sql = "insert into accounts (account_id,account_lid,account_pwd,account_firstname,"
. "account_lastname,account_permissions,account_groups,account_status,"
. "account_lastpwd_change) values ('" . $account_info["account_id"] . "','"
. $account_info["loginid"] . "','x','". addslashes($account_info["firstname"]) . "','"
. addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
. "','" . $account_info["groups"] . "','A',0)";
. "account_lastname,account_groups,account_status,account_lastpwd_change) "
. "values ('" . $account_info["account_id"] . "','" . $account_info["loginid"]
. "','x','". addslashes($account_info["firstname"]) . "','"
. addslashes($account_info["lastname"]) . "',"
. "'" . $phpgw->accounts->groups_array_to_string($account_info["groups"]) . "','A',0)";
$phpgw->db->query($sql,__LINE__,__FILE__);
$phpgw->db->unlock();
$apps = CreateObject('phpgwapi.applications',$account_info["account_id"]);
$apps->add_user($account_info["permissions"]);
$apps->save_user();
$sep = $phpgw->common->filesystem_separator();
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;

View File

@ -72,21 +72,19 @@
$phpgw->db->lock(array("accounts","preferences"));
while ($permission = each($account_info["permissions"])) {
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
$phpgw->accounts->add_app($permission[0]);
}
}
$sql = "insert into accounts (account_lid,account_pwd,account_firstname,account_lastname,"
. "account_permissions,account_groups,account_status,account_lastpwd_change) values ('"
. "account_groups,account_status,account_lastpwd_change) values ('"
. $account_info["loginid"] . "','" . md5($account_info["passwd"]) . "','"
. addslashes($account_info["firstname"]) . "','". addslashes($account_info["lastname"])
. "','" . $phpgw->accounts->add_app("",True) . "','" . $account_info["groups"] . "','A',0)";
. "','" . $phpgw->accounts->groups_array_to_string($account_info["groups"]) . "','A',0)";
$phpgw->db->query($sql);
$phpgw->db->query($sql,__LINE__,__FILE__);
$phpgw->db->unlock();
$apps = CreateObject('phpgwapi.applications',$account_info["loginid"]);
$apps->add_user($account_info["permissions"]);
$apps->save_user();
$sep = $phpgw->common->filesystem_separator();
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;

View File

@ -61,16 +61,17 @@
if (! $error) {
$cd = account_add(array("loginid" => $n_loginid, "permissions" => $new_permissions,
"firstname" => $n_firstname, "lastname" => $n_lastname,
"passwd" => $n_passwd,
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
$phpgw->db->query("SELECT account_permissions, account_id FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
"passwd" => $n_passwd, "groups" => $n_groups));
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
$phpgw->db->next_record();
$apps = explode(":",$phpgw->db->f("account_permissions"));
$pref = CreateObject('phpgwapi.preferences',intval($phpgw->db->f("account_id")));
$apps_object = CreateObject('phpgwapi.applications',intval($phpgw->db->f("account_id")));
$apps_array = $apps_object->apps_enabled();
$phpgw->common->hook_single("add_def_pref", "admin");
for ($i=1;$i<sizeof($apps) - 1;$i++) {
if($apps[$i]<>"admin")
$phpgw->common->hook_single("add_def_pref", $apps[$i]);
while($apps = each($apps_array)) {
if($apps[0]<>"admin")
$phpgw->common->hook_single("add_def_pref", $apps[0]);
}
$pref->commit();

View File

@ -35,11 +35,11 @@
if (! $error) {
$phpgw->db->lock(array("accounts","groups"));
$phpgw->accounts->add_app($n_group_permissions);
$apps = $phpgw->accounts->add_app("",True);
$phpgw->db->query("INSERT INTO groups (group_name,group_apps) VALUES "
. "('$n_group','"
. $apps . "')");
$apps = CreateObject('phpgwapi.applications');
$app_string = $apps->add_group($group_id,$n_group_permissions);
$apps->save_group($group_id);
$phpgw->db->query("INSERT INTO groups (group_name) VALUES ('$n_group')");
$phpgw->db->query("SELECT group_id FROM groups WHERE group_name='$n_group'");
$phpgw->db->next_record();
$group_con = $phpgw->db->f("group_id");
@ -129,19 +129,48 @@
}
$phpgw->template->set_var("user_list",$user_list);
$phpgw->template->set_var("lang_permissions",lang("Select permissions this group will have"));
for ($i=0; $i<count($n_group_permissions); $i++) {
$selected_permissions[$n_group_permissions[$i]] = " selected";
}
$phpgw->template->set_var("lang_permissions",lang("Permissions this group has"));
$i = 0;
$sorted_apps = $phpgw_info["apps"];
@asort($sorted_apps);
@reset($sorted_apps);
while ($permission = each($phpgw_info["apps"])) {
if ($permission[1]["enabled"]) {
$permissions_list .= "<option value=\"" . $permission[0] . "\""
. $selected_permissions[$permission[0]] . ">"
. $permission[1]["title"] . "</option>";
$perm_display[$i][0] = $permission[0];
$perm_display[$i][1] = $permission[1]["title"];
$i++;
}
}
$phpgw->template->set_var("permissions_list",$permissions_list);
$perm_html = "";
for ($i=0;$i<200;) { // The $i<200 is only used for a brake
if (! $perm_display[$i][1]) break;
$perm_html .= '<tr bgcolor="'.$phpgw_info["theme"]["row_on"].'"><td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="n_group_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($n_group_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td>";
$i++;
if ($i == count($perm_display) && is_odd(count($perm_display))) {
$perm_html .= '<td colspan="2">&nbsp;</td></tr>';
}
if (! $perm_display[$i][1]) break;
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
. '<td><input type="checkbox" name="n_group_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($n_group_permissions[$perm_display[$i][0]] || $db_perms[$perm_display[$i][0]]) {
$perm_html .= " checked";
}
$perm_html .= "></td></tr>\n";
$i++;
}
$phpgw->template->set_var("permissions_list",$perm_html);
$phpgw->template->set_var("lang_submit_button",lang("Create Group"));
$phpgw->template->pparse("out","form");

View File

@ -17,10 +17,9 @@
<tr>
<td>{lang_permissions}</td>
<td><select name="n_group_permissions[]" multiple size="5">
{permissions_list}
</select>
</td>
<td><table width="100%" border="0" cols="4">
{permissions_list}
</table></td>
</tr>
<tr>

View File

@ -17,10 +17,9 @@
<tr>
<td>{lang_permissions}</td>
<td><select name="n_group_permissions[]" multiple size="5">
{permissions_list}
</select>
</td>
<td><table width="100%" border="0" cols="4">
{permissions_list}
</table></td>
</tr>
<tr>

View File

@ -73,7 +73,8 @@
$db->next_record();
$phpgw_info["user"]["groups"] = explode (",",$db->f("account_groups"));
$phpgw_info["user"]["app_perms"] = explode (":",$db->f("account_permissions"));
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
$phpgw_info["user"]["app_perms"] = $apps->app_perms;
$phpgw_info["user"]["lastlogin"] = $db->f("account_lastlogin");
$phpgw_info["user"]["lastloginfrom"] = $db->f("account_lastloginfrom");
$phpgw_info["user"]["lastpasswd_change"] = $db->f("account_lastpwd_change");
@ -123,7 +124,8 @@
$db->next_record();
$userData["groups"] = explode (",",$db->f("account_groups"));
$userData["app_perms"] = explode (":",$db->f("account_permissions"));
$apps = CreateObject('phpgwapi.applications',intval($userData["account_lid"]));
$userData["app_perms"] = $apps->app_perms;
$userData["lastlogin"] = $db->f("account_lastlogin");
$userData["lastloginfrom"] = $db->f("account_lastloginfrom");
$userData["lastpasswd_change"] = $db->f("account_lastpwd_change");
@ -138,7 +140,7 @@
$db2 = $phpgw->db;
if (gettype($lid) == "integer") {
if ($phpgw_info["user"]["account_id"] != $lid) {
if ($phpgw_info["user"]["account_id"] != $lid || !$phpgw_info["user"]["groups"]) {
$db2->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__);
$db2->next_record();
$gl = explode(",",$db2->f("account_groups"));
@ -146,7 +148,7 @@
$gl = $phpgw_info["user"]["groups"];
}
} else {
if ($phpgw_info["user"]["userid"] != $lid) {
if ($phpgw_info["user"]["userid"] != $lid || !$phpgw_info["user"]["groups"]) {
$db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
$db2->next_record();
$gl = explode(",",$db2->f("account_groups"));

View File

@ -38,9 +38,8 @@
}
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
$this->apps = $this->read_apps($phpgw_info["user"]["userid"]);
$phpgw_info["user"]["apps"] = $this->apps;
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
$phpgw_info["user"]["apps"] = $apps->apps_enabled();
}
// use this if you make any changes to phpgw_info, including preferences, config table changes, etc

View File

@ -46,7 +46,8 @@
$phpgw_info["user"]["fullname"] = $db2->f("account_firstname") . " "
. $db2->f("account_lastname");
$phpgw_info["user"]["groups"] = explode (",", $db2->f("account_groups"));
$phpgw_info["user"]["app_perms"] = explode (":", $db2->f("account_permissions"));
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
$phpgw_info["user"]["app_perms"] = $apps->app_perms;
$phpgw_info["user"]["lastlogin"] = $db2->f("account_lastlogin");
$phpgw_info["user"]["lastloginfrom"] = $db2->f("account_lastloginfrom");
$phpgw_info["user"]["lastpasswd_change"] = $db2->f("account_lastpwd_change");
@ -70,7 +71,8 @@
$userData["fullname"] = $db2->f("account_firstname") . " "
. $db2->f("account_lastname");
$userData["groups"] = explode(",", $db2->f("account_groups"));
$userData["app_perms"] = explode(":", $db2->f("account_permissions"));
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
$userData["app_perms"] = $apps->app_perms;
$userData["lastlogin"] = $db2->f("account_lastlogin");
$userData["lastloginfrom"] = $db2->f("account_lastloginfrom");
$userData["lastpasswd_change"] = $db2->f("account_lastpwd_change");
@ -86,7 +88,7 @@
$db2 = $phpgw->db;
if (gettype($lid) == "integer") {
if ($phpgw_info["user"]["account_id"] != $lid) {
if ($phpgw_info["user"]["account_id"] != $lid || !$phpgw_info["user"]["groups"]) {
$db2->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__);
$db2->next_record();
$gl = explode(",",$db2->f("account_groups"));
@ -94,7 +96,7 @@
$gl = $phpgw_info["user"]["groups"];
}
} else {
if ($phpgw_info["user"]["userid"] != $lid) {
if ($phpgw_info["user"]["userid"] != $lid || !$phpgw_info["user"]["groups"]) {
$db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
$db2->next_record();
$gl = explode(",",$db2->f("account_groups"));

View File

@ -29,6 +29,8 @@
var $status = Array();
var $user_apps = Array();
var $group_apps = Array(Array());
var $app_perms = Array(Array());
var $apps_loaded = False;
function applications($lid=0)
{
@ -36,24 +38,33 @@
global $phpgw_info;
$db2 = $phpgw->db;
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
$apps_enabled = False;
while ($db2->next_record()) {
if($apps_enabled) $apps_enabled = True;
$name = $db2->f("app_name");
$title = $db2->f("app_title");
$status = $db2->f("app_enabled");
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
$this->set_var("enabled",1,$name);
$this->set_var("status",$db2->f("app_status"),$name);
// $db3 = $phpgw->db;
if(($this->is_type($lid,"integer") && $lid == $phpgw_info["user"]["account_id"]) ||
($this->is_type($lid,"string") && $lid == $phpgw_info["user"]["user_id"])) {
$load_info = True;
}
if(!$this->apps_loaded) {
$this->apps_loaded = True;
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
$apps_enabled = False;
while ($db2->next_record()) {
if(!$apps_enabled) $apps_enabled = True;
$name = $db2->f("app_name");
if($load_info) {
$title = $db2->f("app_title");
$status = $db2->f("app_enabled");
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
}
$this->enabled[$name] = 1;
$this->status[$name] = $db2->f("app_status");
}
}
if($apps_enabled && $lid) {
$owner_found = False;
if($this->is_type($lid,"integer")) {
$owner_id = $lid;
$owner_found = True;
} else {
} elseif($this->is_type($lid,"string")) {
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$lid."'",__LINE__,__FILE__);
if($db2->num_rows()) {
$db2->next_record();
@ -62,9 +73,9 @@
}
}
if($owner_found) {
$this->set_var("account_id",$lid);
$this->read_user_apps($this->get_var("account_id"));
$this->read_group_apps($this->get_var("account_id"));
$this->account_id = $owner_id;
$this->read_user_group_apps($this->account_id);
$this->read_user_apps($this->account_id);
}
}
}
@ -84,10 +95,8 @@
if($this->$var) {
return $this->$var;
}
} else {
if($this->$var[$index]) {
return $this->$var[$index];
}
} elseif($this->$var[$index]) {
return $this->$var[$index];
}
return False;
}
@ -102,14 +111,14 @@
return $return_apps;
}
function is_type($lid,$type)
function is_type($variable,$type)
{
return (strtoupper(gettype($lid)) == strtoupper($type));
return (strtoupper(gettype($variable)) == strtoupper($type));
}
function read_user_apps($lid)
{
global $phpgw;
global $phpgw, $phpgw_info;
$db2 = $phpgw->db;
@ -118,88 +127,136 @@
} else {
$db2->query("select account_permissions from accounts where account_lid='$lid'",__LINE__,__FILE__);
}
$db2->next_record();
$apps = explode(":",$db2->f("account_permissions"));
for ($i=0; $i<count($apps); $i++) {
if ($this->get_var("enabled",$apps[$i]) == 1) {
$this->set_var("user_apps[]",$apps[$i]);
$this->set_var("enabled",2,$apps[$i]);
if($db2->num_rows()) {
$db2->next_record();
$apps = explode(":",$db2->f("account_permissions"));
if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Account Permissions - ".$db2->f("aaccount_permissions")." -->\n";
for ($i=1; $i<count($apps)-1; $i++) {
if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Reading user app - ".$apps[$i]." -->\n";
if ($this->enabled[$apps[$i]] == 1) {
$this->user_apps[$apps[$i]] = $apps[$i];
$this->enabled[$apps[$i]] = 2;
$this->app_perms[] = $apps[$i];
}
}
}
}
function read_group_apps($lid)
function read_user_group_apps($lid)
{
global $phpgw;
$groups = $phpgw->accounts->read_groups($lid);
for ($i=1; $i<(count($groups)-1); $i++) {
$ga = explode(":",$groups[$i]);
$group_array[$ga[0]] = $ga[1];
if($groups) {
while ($group = each($groups)) {
$this->read_group_apps($group[0]);
}
}
}
while ($group = each($group_array)) {
$db2->query("select group_apps from groups where group_id=".$group[0],__LINE__,__FILE__);
$db2->next_record();
function read_group_apps($group_id)
{
global $phpgw;
$apps = explode(":",$db2->f("group_apps"));
for ($i=0;$i<count($apps);$i++) {
if ($this->get_var("enabled",$apps[$i]) == 1) {
$this->set_var("group_apps[".$group[0]."][]",$apps[$i]);
$this->set_var("enabled",2,$apps[$i]);
}
$db2 = $phpgw->db;
$db2->query("select group_apps from groups where group_id=".$group_id,__LINE__,__FILE__);
$db2->next_record();
$apps = explode(":",$db2->f("group_apps"));
for ($i=1;$i<count($apps) - 1;$i++) {
if ($this->enabled[$apps[$i]] == 1) {
$this->group_apps[$group_id][$apps[$i]] = $apps[$i];
$this->enabled[$apps[$i]] = 2;
$this->app_perms[] = $apps[$i];
}
}
}
function is_system_enabled($appname)
{
return $this->get_var("enabled",$appname) >= 1;
return $this->enabled[$appname] >= 1;
}
function is_user_enabled($appname)
{
return $this->get_var("enabled",$appname) == 2;
return $this->enabled[$appname] == 2;
}
function get_group_array($group_id)
{
return $this->group_apps[$group_id];
}
function group_app_string($group_id)
{
return ":".implode(":",$this->get_var("group_apps",$group_id)).":";
reset($this->group_apps[$group_id]);
while($app = each($this->group_apps[$group_id])) {
$group_apps[] = $app[1];
}
return ":".implode(":",$group_apps).":";
}
function user_app_string()
{
return ":".implode(":",$this->get_var("user_apps")).":";
reset($this->user_apps);
while($app = each($this->user_apps)) {
$user_apps[] = $app[1];
}
return ":".implode(":",$user_apps).":";
}
function is_group($group_id,$appname)
{
return $this->get_var("group_apps[".$group_id."]",$appname) == $appname;
return $this->group_apps[$group_id][$appname];
}
function is_user($appname)
{
return $this->get_var("user_apps",$appname) == $appname;
return $this->user_apps[$appname];
}
function add_group($group_id,$appname)
{
if ($this->get_var("enabled",$appname) && !$this->is_group($group_id,$appname)) {
$this->set_var("group_apps[".$group_id."][]",$appname);
$this->set_var("enabled",2,$appname);
if($this->is_type($appname,"array")) {
while($app = each($appname)) {
$this->add_group_app($group_id,$app[0]);
}
return $this->group_app_string($group_id);
} elseif($this->is_type($appname,"string")) {
$this->add_group_app($group_id,$appname);
return $this->group_app_string($group_id);
}
}
function add_group_app($group_id,$appname)
{
if ($this->enabled[$appname] && !$this->is_group($group_id,$appname)) {
$this->group_apps[$group_id][] = $appname;
$this->enabled[$appname] = 2;
}
return $this->group_app_string($group_id);
}
function add_user($appname)
{
if ($this->get_var("enabled",$appname) && !$this->is_user($appname)) {
$this->set_var("user_apps[]",$appname);
$this->set_var("enabled",2,$appname);
if($this->is_type($appname,"array")) {
while($app = each($appname)) {
$this->add_user_app($app[0]);
}
return $this->user_app_string($group_id);
} elseif($this->is_type($appname,"string")) {
$this->add_user_app($group_id,$appname);
return $this->user_app_string($group_id);
}
}
function add_user_app($appname)
{
if ($this->enabled[$appname] && !$this->is_user($appname)) {
$this->user_apps[] =$appname;
$this->enabled[$appname] = 2;
}
return $this->user_app_string();
}
function delete_group($group_id,$appname)
@ -230,9 +287,9 @@
{
global $phpgw;
if($this->get_var("account_id")) {
if($this->account_id) {
$db2 = $phpgw->db;
$db2->query("UPDATE account SET account_permissions = '".$this->user_app_string()."' WHERE account_id=".$this->get_var("account_id"),__LINE__,__FILE__);
$db2->query("UPDATE account SET account_permissions = '".$this->user_app_string()."' WHERE account_id=".$this->account_id,__LINE__,__FILE__);
}
}
}

View File

@ -37,6 +37,7 @@
class phpgw
{
var $accounts;
var $applications;
var $acl;
var $auth;
var $db;
@ -112,10 +113,12 @@
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
$this->accounts = CreateObject("phpgwapi.accounts");
$this->preferences = CreateObject("phpgwapi.preferences");
$this->applications = CreateObject("phpgwapi.applications");
$this->session = CreateObject("phpgwapi.sessions");
if ($phpgw_info["flags"]["currentapp"] == "login") {
$log = explode("@",$login);
$this->preferences = CreateObject("phpgwapi.preferences", $log[0]);
$this->applications = CreateObject("phpgwapi.applications", $log[0]);
}else{
if (! $this->session->verify()) {
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
@ -124,6 +127,7 @@
exit;
}
$this->preferences = CreateObject("phpgwapi.preferences", intval($phpgw_info["user"]["account_id"]));
$this->applications = CreateObject("phpgwapi.applications", intval($phpgw_info["user"]["account_id"]));
}
$this->translation = CreateObject("phpgwapi.translation");