forked from extern/egroupware
implementation of applications class
This commit is contained in:
parent
31f38a5d8e
commit
abf8c3bcd9
@ -134,12 +134,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$userData = $phpgw->accounts->read_userData($account_id);
|
$userData = $phpgw->accounts->read_userData($account_id);
|
||||||
$db_perms = $phpgw->accounts->read_apps($userData["account_lid"]);
|
|
||||||
|
|
||||||
if (! $submit) {
|
if (! $submit) {
|
||||||
$n_loginid = $userData["account_lid"];
|
$n_loginid = $userData["account_lid"];
|
||||||
$n_firstname = $userData["firstname"];
|
$n_firstname = $userData["firstname"];
|
||||||
$n_lastname = $userData["lastname"];
|
$n_lastname = $userData["lastname"];
|
||||||
|
$apps = CreateObject('phpgwapi.applications',intval($userData["account_id"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phpgw_info["server"]["account_repository"] == "ldap") {
|
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>'
|
$perm_html .= '<tr bgcolor="'.$phpgw_info["theme"]["row_on"].'"><td>' . lang($perm_display[$i][1]) . '</td>'
|
||||||
. '<td><input type="checkbox" name="new_permissions['
|
. '<td><input type="checkbox" name="new_permissions['
|
||||||
. $perm_display[$i][0] . ']" value="True"';
|
. $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 .= " checked";
|
||||||
}
|
}
|
||||||
$perm_html .= "></td>";
|
$perm_html .= "></td>";
|
||||||
@ -224,7 +224,7 @@
|
|||||||
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
|
$perm_html .= '<td>' . lang($perm_display[$i][1]) . '</td>'
|
||||||
. '<td><input type="checkbox" name="new_permissions['
|
. '<td><input type="checkbox" name="new_permissions['
|
||||||
. $perm_display[$i][0] . ']" value="True"';
|
. $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 .= " checked";
|
||||||
}
|
}
|
||||||
$perm_html .= "></td></tr>\n";
|
$perm_html .= "></td></tr>\n";
|
||||||
|
@ -37,13 +37,14 @@
|
|||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
// $phpgw->db->lock(array("accounts","groups","preferences","config","applications","phpgw_hooks","phpgw_sessions"));
|
// $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);
|
if($old_group_name <> $n_group) {
|
||||||
$apps = $phpgw->accounts->add_app("",True);
|
$phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id");
|
||||||
$apps_after = explode(":",$apps);
|
}
|
||||||
|
|
||||||
$phpgw->db->query("update groups set group_name='$n_group', group_apps='" . $apps
|
|
||||||
. "' where group_id=$group_id");
|
|
||||||
|
|
||||||
for ($i=0; $i<count($n_users);$i++) {
|
for ($i=0; $i<count($n_users);$i++) {
|
||||||
$phpgw->db->query("SELECT account_groups, account_lid FROM accounts WHERE account_id=".$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++) {
|
for ($i=0; $i<count($n_users); $i++) {
|
||||||
$selected_users[$n_user[$i]] = " selected";
|
$selected_users[$n_user[$i]] = " selected";
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i=0; $i<count($n_group_permissions); $i++) {
|
|
||||||
$selected_permissions[$n_group_permissions[$i]] = " selected";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$phpgw->db->query("select group_name from groups where group_id=$group_id");
|
$phpgw->db->query("select group_name from groups where group_id=$group_id");
|
||||||
$phpgw->db->next_record();
|
$phpgw->db->next_record();
|
||||||
@ -132,11 +129,9 @@
|
|||||||
$selected_users[$phpgw->db->f("account_id")] = " selected";
|
$selected_users[$phpgw->db->f("account_id")] = " selected";
|
||||||
}
|
}
|
||||||
|
|
||||||
$gp = $phpgw->accounts->read_group_apps($group_id);
|
$apps = CreateObject('phpgwapi.applications');
|
||||||
|
$apps->read_group_apps($group_id);
|
||||||
for ($i=0; $i<count($gp); $i++) {
|
$db_perms = $apps->get_group_array($group_id);
|
||||||
$selected_permissions[$gp[$i]] = " selected";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$phpgw->db->query("select * from groups where group_id=$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("user_list",$user_list);
|
||||||
|
|
||||||
$phpgw->template->set_var("lang_permissions",lang("Permissions this group has"));
|
$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"])) {
|
while ($permission = each($phpgw_info["apps"])) {
|
||||||
if ($permission[1]["enabled"]) {
|
if ($permission[1]["enabled"]) {
|
||||||
$permissions_list .= "<option value=\"" . $permission[0] . "\""
|
$perm_display[$i][0] = $permission[0];
|
||||||
. $selected_permissions[$permission[0]] . ">"
|
$perm_display[$i][1] = $permission[1]["title"];
|
||||||
. $permission[1]["title"] . "</option>";
|
$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"> </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->set_var("lang_submit_button",lang("submit changes"));
|
||||||
|
|
||||||
$phpgw->template->pparse("out","form");
|
$phpgw->template->pparse("out","form");
|
||||||
|
@ -184,22 +184,21 @@
|
|||||||
|
|
||||||
$phpgw->db->lock(array("accounts"));
|
$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,"
|
$sql = "insert into accounts (account_id,account_lid,account_pwd,account_firstname,"
|
||||||
. "account_lastname,account_permissions,account_groups,account_status,"
|
. "account_lastname,account_groups,account_status,account_lastpwd_change) "
|
||||||
. "account_lastpwd_change) values ('" . $account_info["account_id"] . "','"
|
. "values ('" . $account_info["account_id"] . "','" . $account_info["loginid"]
|
||||||
. $account_info["loginid"] . "','x','". addslashes($account_info["firstname"]) . "','"
|
. "','x','". addslashes($account_info["firstname"]) . "','"
|
||||||
. addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
|
. addslashes($account_info["lastname"]) . "',"
|
||||||
. "','" . $account_info["groups"] . "','A',0)";
|
. "'" . $phpgw->accounts->groups_array_to_string($account_info["groups"]) . "','A',0)";
|
||||||
|
|
||||||
$phpgw->db->query($sql,__LINE__,__FILE__);
|
$phpgw->db->query($sql,__LINE__,__FILE__);
|
||||||
$phpgw->db->unlock();
|
$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();
|
$sep = $phpgw->common->filesystem_separator();
|
||||||
|
|
||||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||||
|
@ -72,21 +72,19 @@
|
|||||||
|
|
||||||
$phpgw->db->lock(array("accounts","preferences"));
|
$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,"
|
$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"]) . "','"
|
. $account_info["loginid"] . "','" . md5($account_info["passwd"]) . "','"
|
||||||
. addslashes($account_info["firstname"]) . "','". addslashes($account_info["lastname"])
|
. 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();
|
$phpgw->db->unlock();
|
||||||
|
|
||||||
|
$apps = CreateObject('phpgwapi.applications',$account_info["loginid"]);
|
||||||
|
$apps->add_user($account_info["permissions"]);
|
||||||
|
$apps->save_user();
|
||||||
|
|
||||||
$sep = $phpgw->common->filesystem_separator();
|
$sep = $phpgw->common->filesystem_separator();
|
||||||
|
|
||||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||||
|
@ -61,16 +61,17 @@
|
|||||||
if (! $error) {
|
if (! $error) {
|
||||||
$cd = account_add(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
$cd = account_add(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||||
"passwd" => $n_passwd,
|
"passwd" => $n_passwd, "groups" => $n_groups));
|
||||||
"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__);
|
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
|
||||||
$phpgw->db->next_record();
|
$phpgw->db->next_record();
|
||||||
$apps = explode(":",$phpgw->db->f("account_permissions"));
|
|
||||||
$pref = CreateObject('phpgwapi.preferences',intval($phpgw->db->f("account_id")));
|
$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");
|
$phpgw->common->hook_single("add_def_pref", "admin");
|
||||||
for ($i=1;$i<sizeof($apps) - 1;$i++) {
|
while($apps = each($apps_array)) {
|
||||||
if($apps[$i]<>"admin")
|
if($apps[0]<>"admin")
|
||||||
$phpgw->common->hook_single("add_def_pref", $apps[$i]);
|
$phpgw->common->hook_single("add_def_pref", $apps[0]);
|
||||||
}
|
}
|
||||||
$pref->commit();
|
$pref->commit();
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@
|
|||||||
if (! $error) {
|
if (! $error) {
|
||||||
$phpgw->db->lock(array("accounts","groups"));
|
$phpgw->db->lock(array("accounts","groups"));
|
||||||
|
|
||||||
$phpgw->accounts->add_app($n_group_permissions);
|
$apps = CreateObject('phpgwapi.applications');
|
||||||
$apps = $phpgw->accounts->add_app("",True);
|
$app_string = $apps->add_group($group_id,$n_group_permissions);
|
||||||
$phpgw->db->query("INSERT INTO groups (group_name,group_apps) VALUES "
|
$apps->save_group($group_id);
|
||||||
. "('$n_group','"
|
|
||||||
. $apps . "')");
|
$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->query("SELECT group_id FROM groups WHERE group_name='$n_group'");
|
||||||
$phpgw->db->next_record();
|
$phpgw->db->next_record();
|
||||||
$group_con = $phpgw->db->f("group_id");
|
$group_con = $phpgw->db->f("group_id");
|
||||||
@ -129,19 +129,48 @@
|
|||||||
}
|
}
|
||||||
$phpgw->template->set_var("user_list",$user_list);
|
$phpgw->template->set_var("user_list",$user_list);
|
||||||
|
|
||||||
$phpgw->template->set_var("lang_permissions",lang("Select permissions this group will have"));
|
$phpgw->template->set_var("lang_permissions",lang("Permissions this group has"));
|
||||||
for ($i=0; $i<count($n_group_permissions); $i++) {
|
|
||||||
$selected_permissions[$n_group_permissions[$i]] = " selected";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$sorted_apps = $phpgw_info["apps"];
|
||||||
|
@asort($sorted_apps);
|
||||||
|
@reset($sorted_apps);
|
||||||
while ($permission = each($phpgw_info["apps"])) {
|
while ($permission = each($phpgw_info["apps"])) {
|
||||||
if ($permission[1]["enabled"]) {
|
if ($permission[1]["enabled"]) {
|
||||||
$permissions_list .= "<option value=\"" . $permission[0] . "\""
|
$perm_display[$i][0] = $permission[0];
|
||||||
. $selected_permissions[$permission[0]] . ">"
|
$perm_display[$i][1] = $permission[1]["title"];
|
||||||
. $permission[1]["title"] . "</option>";
|
$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"> </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->set_var("lang_submit_button",lang("Create Group"));
|
||||||
|
|
||||||
$phpgw->template->pparse("out","form");
|
$phpgw->template->pparse("out","form");
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{lang_permissions}</td>
|
<td>{lang_permissions}</td>
|
||||||
<td><select name="n_group_permissions[]" multiple size="5">
|
<td><table width="100%" border="0" cols="4">
|
||||||
{permissions_list}
|
{permissions_list}
|
||||||
</select>
|
</table></td>
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{lang_permissions}</td>
|
<td>{lang_permissions}</td>
|
||||||
<td><select name="n_group_permissions[]" multiple size="5">
|
<td><table width="100%" border="0" cols="4">
|
||||||
{permissions_list}
|
{permissions_list}
|
||||||
</select>
|
</table></td>
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -73,7 +73,8 @@
|
|||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
|
||||||
$phpgw_info["user"]["groups"] = explode (",",$db->f("account_groups"));
|
$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"]["lastlogin"] = $db->f("account_lastlogin");
|
||||||
$phpgw_info["user"]["lastloginfrom"] = $db->f("account_lastloginfrom");
|
$phpgw_info["user"]["lastloginfrom"] = $db->f("account_lastloginfrom");
|
||||||
$phpgw_info["user"]["lastpasswd_change"] = $db->f("account_lastpwd_change");
|
$phpgw_info["user"]["lastpasswd_change"] = $db->f("account_lastpwd_change");
|
||||||
@ -123,7 +124,8 @@
|
|||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
|
||||||
$userData["groups"] = explode (",",$db->f("account_groups"));
|
$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["lastlogin"] = $db->f("account_lastlogin");
|
||||||
$userData["lastloginfrom"] = $db->f("account_lastloginfrom");
|
$userData["lastloginfrom"] = $db->f("account_lastloginfrom");
|
||||||
$userData["lastpasswd_change"] = $db->f("account_lastpwd_change");
|
$userData["lastpasswd_change"] = $db->f("account_lastpwd_change");
|
||||||
@ -138,7 +140,7 @@
|
|||||||
$db2 = $phpgw->db;
|
$db2 = $phpgw->db;
|
||||||
|
|
||||||
if (gettype($lid) == "integer") {
|
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->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__);
|
||||||
$db2->next_record();
|
$db2->next_record();
|
||||||
$gl = explode(",",$db2->f("account_groups"));
|
$gl = explode(",",$db2->f("account_groups"));
|
||||||
@ -146,7 +148,7 @@
|
|||||||
$gl = $phpgw_info["user"]["groups"];
|
$gl = $phpgw_info["user"]["groups"];
|
||||||
}
|
}
|
||||||
} else {
|
} 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->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
|
||||||
$db2->next_record();
|
$db2->next_record();
|
||||||
$gl = explode(",",$db2->f("account_groups"));
|
$gl = explode(",",$db2->f("account_groups"));
|
||||||
|
@ -38,9 +38,8 @@
|
|||||||
}
|
}
|
||||||
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
|
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
|
||||||
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
|
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
|
||||||
$this->apps = $this->read_apps($phpgw_info["user"]["userid"]);
|
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
|
||||||
|
$phpgw_info["user"]["apps"] = $apps->apps_enabled();
|
||||||
$phpgw_info["user"]["apps"] = $this->apps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// use this if you make any changes to phpgw_info, including preferences, config table changes, etc
|
// use this if you make any changes to phpgw_info, including preferences, config table changes, etc
|
||||||
|
@ -46,7 +46,8 @@
|
|||||||
$phpgw_info["user"]["fullname"] = $db2->f("account_firstname") . " "
|
$phpgw_info["user"]["fullname"] = $db2->f("account_firstname") . " "
|
||||||
. $db2->f("account_lastname");
|
. $db2->f("account_lastname");
|
||||||
$phpgw_info["user"]["groups"] = explode (",", $db2->f("account_groups"));
|
$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"]["lastlogin"] = $db2->f("account_lastlogin");
|
||||||
$phpgw_info["user"]["lastloginfrom"] = $db2->f("account_lastloginfrom");
|
$phpgw_info["user"]["lastloginfrom"] = $db2->f("account_lastloginfrom");
|
||||||
$phpgw_info["user"]["lastpasswd_change"] = $db2->f("account_lastpwd_change");
|
$phpgw_info["user"]["lastpasswd_change"] = $db2->f("account_lastpwd_change");
|
||||||
@ -70,7 +71,8 @@
|
|||||||
$userData["fullname"] = $db2->f("account_firstname") . " "
|
$userData["fullname"] = $db2->f("account_firstname") . " "
|
||||||
. $db2->f("account_lastname");
|
. $db2->f("account_lastname");
|
||||||
$userData["groups"] = explode(",", $db2->f("account_groups"));
|
$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["lastlogin"] = $db2->f("account_lastlogin");
|
||||||
$userData["lastloginfrom"] = $db2->f("account_lastloginfrom");
|
$userData["lastloginfrom"] = $db2->f("account_lastloginfrom");
|
||||||
$userData["lastpasswd_change"] = $db2->f("account_lastpwd_change");
|
$userData["lastpasswd_change"] = $db2->f("account_lastpwd_change");
|
||||||
@ -86,7 +88,7 @@
|
|||||||
$db2 = $phpgw->db;
|
$db2 = $phpgw->db;
|
||||||
|
|
||||||
if (gettype($lid) == "integer") {
|
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->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__);
|
||||||
$db2->next_record();
|
$db2->next_record();
|
||||||
$gl = explode(",",$db2->f("account_groups"));
|
$gl = explode(",",$db2->f("account_groups"));
|
||||||
@ -94,7 +96,7 @@
|
|||||||
$gl = $phpgw_info["user"]["groups"];
|
$gl = $phpgw_info["user"]["groups"];
|
||||||
}
|
}
|
||||||
} else {
|
} 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->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
|
||||||
$db2->next_record();
|
$db2->next_record();
|
||||||
$gl = explode(",",$db2->f("account_groups"));
|
$gl = explode(",",$db2->f("account_groups"));
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
var $status = Array();
|
var $status = Array();
|
||||||
var $user_apps = Array();
|
var $user_apps = Array();
|
||||||
var $group_apps = Array(Array());
|
var $group_apps = Array(Array());
|
||||||
|
var $app_perms = Array(Array());
|
||||||
|
var $apps_loaded = False;
|
||||||
|
|
||||||
function applications($lid=0)
|
function applications($lid=0)
|
||||||
{
|
{
|
||||||
@ -36,24 +38,33 @@
|
|||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
$db2 = $phpgw->db;
|
$db2 = $phpgw->db;
|
||||||
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
|
// $db3 = $phpgw->db;
|
||||||
$apps_enabled = False;
|
if(($this->is_type($lid,"integer") && $lid == $phpgw_info["user"]["account_id"]) ||
|
||||||
while ($db2->next_record()) {
|
($this->is_type($lid,"string") && $lid == $phpgw_info["user"]["user_id"])) {
|
||||||
if($apps_enabled) $apps_enabled = True;
|
$load_info = True;
|
||||||
$name = $db2->f("app_name");
|
}
|
||||||
$title = $db2->f("app_title");
|
if(!$this->apps_loaded) {
|
||||||
$status = $db2->f("app_enabled");
|
$this->apps_loaded = True;
|
||||||
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
|
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
|
||||||
|
$apps_enabled = False;
|
||||||
$this->set_var("enabled",1,$name);
|
while ($db2->next_record()) {
|
||||||
$this->set_var("status",$db2->f("app_status"),$name);
|
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) {
|
if($apps_enabled && $lid) {
|
||||||
$owner_found = False;
|
$owner_found = False;
|
||||||
if($this->is_type($lid,"integer")) {
|
if($this->is_type($lid,"integer")) {
|
||||||
$owner_id = $lid;
|
$owner_id = $lid;
|
||||||
$owner_found = True;
|
$owner_found = True;
|
||||||
} else {
|
} elseif($this->is_type($lid,"string")) {
|
||||||
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$lid."'",__LINE__,__FILE__);
|
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$lid."'",__LINE__,__FILE__);
|
||||||
if($db2->num_rows()) {
|
if($db2->num_rows()) {
|
||||||
$db2->next_record();
|
$db2->next_record();
|
||||||
@ -62,9 +73,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($owner_found) {
|
if($owner_found) {
|
||||||
$this->set_var("account_id",$lid);
|
$this->account_id = $owner_id;
|
||||||
$this->read_user_apps($this->get_var("account_id"));
|
$this->read_user_group_apps($this->account_id);
|
||||||
$this->read_group_apps($this->get_var("account_id"));
|
$this->read_user_apps($this->account_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,10 +95,8 @@
|
|||||||
if($this->$var) {
|
if($this->$var) {
|
||||||
return $this->$var;
|
return $this->$var;
|
||||||
}
|
}
|
||||||
} else {
|
} elseif($this->$var[$index]) {
|
||||||
if($this->$var[$index]) {
|
return $this->$var[$index];
|
||||||
return $this->$var[$index];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
@ -102,14 +111,14 @@
|
|||||||
return $return_apps;
|
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)
|
function read_user_apps($lid)
|
||||||
{
|
{
|
||||||
global $phpgw;
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
$db2 = $phpgw->db;
|
$db2 = $phpgw->db;
|
||||||
|
|
||||||
@ -118,88 +127,136 @@
|
|||||||
} else {
|
} else {
|
||||||
$db2->query("select account_permissions from accounts where account_lid='$lid'",__LINE__,__FILE__);
|
$db2->query("select account_permissions from accounts where account_lid='$lid'",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
$db2->next_record();
|
if($db2->num_rows()) {
|
||||||
|
$db2->next_record();
|
||||||
$apps = explode(":",$db2->f("account_permissions"));
|
$apps = explode(":",$db2->f("account_permissions"));
|
||||||
for ($i=0; $i<count($apps); $i++) {
|
if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Account Permissions - ".$db2->f("aaccount_permissions")." -->\n";
|
||||||
if ($this->get_var("enabled",$apps[$i]) == 1) {
|
for ($i=1; $i<count($apps)-1; $i++) {
|
||||||
$this->set_var("user_apps[]",$apps[$i]);
|
if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Reading user app - ".$apps[$i]." -->\n";
|
||||||
$this->set_var("enabled",2,$apps[$i]);
|
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;
|
global $phpgw;
|
||||||
|
|
||||||
$groups = $phpgw->accounts->read_groups($lid);
|
$groups = $phpgw->accounts->read_groups($lid);
|
||||||
|
|
||||||
for ($i=1; $i<(count($groups)-1); $i++) {
|
if($groups) {
|
||||||
$ga = explode(":",$groups[$i]);
|
while ($group = each($groups)) {
|
||||||
$group_array[$ga[0]] = $ga[1];
|
$this->read_group_apps($group[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ($group = each($group_array)) {
|
function read_group_apps($group_id)
|
||||||
$db2->query("select group_apps from groups where group_id=".$group[0],__LINE__,__FILE__);
|
{
|
||||||
$db2->next_record();
|
global $phpgw;
|
||||||
|
|
||||||
$apps = explode(":",$db2->f("group_apps"));
|
$db2 = $phpgw->db;
|
||||||
for ($i=0;$i<count($apps);$i++) {
|
|
||||||
if ($this->get_var("enabled",$apps[$i]) == 1) {
|
$db2->query("select group_apps from groups where group_id=".$group_id,__LINE__,__FILE__);
|
||||||
$this->set_var("group_apps[".$group[0]."][]",$apps[$i]);
|
$db2->next_record();
|
||||||
$this->set_var("enabled",2,$apps[$i]);
|
|
||||||
}
|
$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)
|
function is_system_enabled($appname)
|
||||||
{
|
{
|
||||||
return $this->get_var("enabled",$appname) >= 1;
|
return $this->enabled[$appname] >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_user_enabled($appname)
|
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)
|
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()
|
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)
|
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)
|
function is_user($appname)
|
||||||
{
|
{
|
||||||
return $this->get_var("user_apps",$appname) == $appname;
|
return $this->user_apps[$appname];
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_group($group_id,$appname)
|
function add_group($group_id,$appname)
|
||||||
{
|
{
|
||||||
if ($this->get_var("enabled",$appname) && !$this->is_group($group_id,$appname)) {
|
if($this->is_type($appname,"array")) {
|
||||||
$this->set_var("group_apps[".$group_id."][]",$appname);
|
while($app = each($appname)) {
|
||||||
$this->set_var("enabled",2,$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)
|
function add_user($appname)
|
||||||
{
|
{
|
||||||
if ($this->get_var("enabled",$appname) && !$this->is_user($appname)) {
|
if($this->is_type($appname,"array")) {
|
||||||
$this->set_var("user_apps[]",$appname);
|
while($app = each($appname)) {
|
||||||
$this->set_var("enabled",2,$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)
|
function delete_group($group_id,$appname)
|
||||||
@ -230,9 +287,9 @@
|
|||||||
{
|
{
|
||||||
global $phpgw;
|
global $phpgw;
|
||||||
|
|
||||||
if($this->get_var("account_id")) {
|
if($this->account_id) {
|
||||||
$db2 = $phpgw->db;
|
$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__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
class phpgw
|
class phpgw
|
||||||
{
|
{
|
||||||
var $accounts;
|
var $accounts;
|
||||||
|
var $applications;
|
||||||
var $acl;
|
var $acl;
|
||||||
var $auth;
|
var $auth;
|
||||||
var $db;
|
var $db;
|
||||||
@ -112,10 +113,12 @@
|
|||||||
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
|
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
|
||||||
$this->accounts = CreateObject("phpgwapi.accounts");
|
$this->accounts = CreateObject("phpgwapi.accounts");
|
||||||
$this->preferences = CreateObject("phpgwapi.preferences");
|
$this->preferences = CreateObject("phpgwapi.preferences");
|
||||||
|
$this->applications = CreateObject("phpgwapi.applications");
|
||||||
$this->session = CreateObject("phpgwapi.sessions");
|
$this->session = CreateObject("phpgwapi.sessions");
|
||||||
if ($phpgw_info["flags"]["currentapp"] == "login") {
|
if ($phpgw_info["flags"]["currentapp"] == "login") {
|
||||||
$log = explode("@",$login);
|
$log = explode("@",$login);
|
||||||
$this->preferences = CreateObject("phpgwapi.preferences", $log[0]);
|
$this->preferences = CreateObject("phpgwapi.preferences", $log[0]);
|
||||||
|
$this->applications = CreateObject("phpgwapi.applications", $log[0]);
|
||||||
}else{
|
}else{
|
||||||
if (! $this->session->verify()) {
|
if (! $this->session->verify()) {
|
||||||
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
|
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
|
||||||
@ -124,6 +127,7 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$this->preferences = CreateObject("phpgwapi.preferences", intval($phpgw_info["user"]["account_id"]));
|
$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");
|
$this->translation = CreateObject("phpgwapi.translation");
|
||||||
|
Loading…
Reference in New Issue
Block a user