mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
new hook file for preferences
This commit is contained in:
parent
e9d9507a09
commit
ea66a64a46
5
addressbook/inc/hook_admin_add_def_pref.inc.php
Executable file
5
addressbook/inc/hook_admin_add_def_pref.inc.php
Executable file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$phpgw->preferences->add_newuser("addressbook","company","addressbook_True");
|
||||
$phpgw->preferences->add_newuser("addressbook","lastname","addressbook_True");
|
||||
$phpgw->preferences->add_newuser("addressbook","firstname","addressbook_True");
|
||||
?>
|
@ -51,27 +51,76 @@
|
||||
}
|
||||
|
||||
if (! $totalerrors) {
|
||||
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||
$phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_id = ".$account_id);
|
||||
$phpgw->db->next_record();
|
||||
$apps_before = $phpgw->db->f("account_permissions");
|
||||
|
||||
while ($permission = each($new_permissions)) {
|
||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||
$phpgw->accounts->add_app($permission[0]);
|
||||
}
|
||||
}
|
||||
$apps_after = $phpgw->accounts->add_app("",True);
|
||||
if($apps_before <> $apps_after) {
|
||||
$after_apps = explode(":",$apps_after);
|
||||
for ($i=1;$i<=count($after_apps);$i++) {
|
||||
if (!strpos(" ".$apps_before." ",$after_apps) {
|
||||
$new_apps[] = $after_apps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd, "account_status" => $n_account_status,
|
||||
"old_loginid" => $old_loginid, "account_id" => rawurldecode($account_id),
|
||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||
|
||||
// The following sets any default preferences needed for new applications..
|
||||
// This is smart enough to know if previous preferences were selected, use them.
|
||||
if (count($new_apps)) {
|
||||
if ($account_id <> $phpgw_info["user"]["account_id"]) {
|
||||
$phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner=".$account_id,__FILE__,__LINE__);
|
||||
$phpgw->db->next_record();
|
||||
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value");
|
||||
} else {
|
||||
$phpgw_newuser["user"]["preferences"] = $phpgw_info["user"]["preferences"]
|
||||
}
|
||||
$docommit = False;
|
||||
for ($j=0;$j<count($new_apps);$j++) {
|
||||
if (!$phpgw_newuser["user"]["preferences"][$new_apps[$j]]) {
|
||||
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]);
|
||||
$docommit = True;
|
||||
}
|
||||
}
|
||||
if ($docommit) {
|
||||
if ($account_id <> $phpgw_info["user"]["account_id"]) {
|
||||
$phpgw->preferences->commit_user($account_id);
|
||||
} else {
|
||||
$phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"];
|
||||
unset($phpgw_newuser);
|
||||
$phpgw->preferences->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
||||
exit;
|
||||
}
|
||||
|
||||
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
||||
exit;
|
||||
} // if $submit
|
||||
|
||||
$phpgw->template->set_file(array("form" => "account_form.tpl"));
|
||||
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
|
||||
if ($totalerrors) {
|
||||
$phpgw->template->set_var("error_messages","<center>" . $phpgw->common->error_list($error) . "</center>");
|
||||
} else {
|
||||
$phpgw->template->set_var("error_messages","");
|
||||
}
|
||||
|
||||
$phpgw->template->set_file(array("form" => "account_form.tpl"));
|
||||
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
|
||||
$userData = $phpgw->accounts->read_userData($account_id);
|
||||
$db_perms = $phpgw->accounts->read_apps($userData["account_lid"]);
|
||||
|
@ -40,10 +40,22 @@
|
||||
if (! $error) {
|
||||
$phpgw->db->lock(array("accounts","groups"));
|
||||
|
||||
$phpgw->accounts->add_app($n_group_permissions);
|
||||
$phpgw->db->query("update groups set group_name='$n_group', group_apps='"
|
||||
. $phpgw->accounts->add_app("",True)
|
||||
. "' where group_id=$group_id");
|
||||
$phpgw->db->query("SELECT group_apps FROM groups WHERE group_id=".$group_id,__FILE__,__LINE__);
|
||||
$phpgw->db->next_record();
|
||||
$apps_before = $phpgw->db->f("group_apps")
|
||||
$phpgw->accounts->add_app($n_group_permissions);
|
||||
$apps_after = $phpgw->accounts->add_app("",True);
|
||||
|
||||
if($apps_before <> $apps_after) {
|
||||
$after_apps = explode(":",$apps_after);
|
||||
for ($i=1;$i<=count($after_apps);$i++) {
|
||||
if (!strpos(" ".$apps_before." ",$after_apps) {
|
||||
$new_apps[] = $after_apps;
|
||||
}
|
||||
}
|
||||
}
|
||||
$phpgw->db->query("update groups set group_name='$n_group', group_apps='" . $apps_after
|
||||
. "' where group_id=$group_id");
|
||||
$phpgw->db->query("SELECT group_id FROM groups WHERE group_name='$n_group'");
|
||||
$phpgw->db->next_record();
|
||||
$group_con = $phpgw->db->f("group_id");
|
||||
@ -55,6 +67,35 @@
|
||||
|
||||
$user_groups = ereg_replace(",,",",",$user_groups);
|
||||
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
|
||||
|
||||
// The following sets any default preferences needed for new applications..
|
||||
// This is smart enough to know if previous preferences were selected, use them.
|
||||
if (count($new_apps)) {
|
||||
if ($n_users[$i] <> $phpgw_info["user"]["account_id"]) {
|
||||
if(is_array($phpgw_newuser)) unset($phpgw_newuser);
|
||||
$phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner=".$n_users[$i],__FILE__,__LINE__);
|
||||
$phpgw->db->next_record();
|
||||
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value");
|
||||
} else {
|
||||
$phpgw_newuser["user"]["preferences"] = $phpgw_info["user"]["preferences"]
|
||||
}
|
||||
$docommit = False;
|
||||
for ($j=0;$j<count($new_apps);$j++) {
|
||||
if (!$phpgw_newuser["user"]["preferences"][$new_apps[$j]]) {
|
||||
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]);
|
||||
$docommit = True;
|
||||
}
|
||||
}
|
||||
if ($docommit) {
|
||||
if ($n_users[$i] <> $phpgw_info["user"]["account_id"]) {
|
||||
$phpgw->preferences->commit_user($n_users[$i]);
|
||||
} else {
|
||||
$phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"];
|
||||
unset($phpgw_newuser);
|
||||
$phpgw->preferences->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
|
@ -182,8 +182,7 @@
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
add_default_preferences($account_info["account_id"]);
|
||||
$phpgw->db->lock(array("accounts","preferences"));
|
||||
$phpgw->db->lock(array("accounts"));
|
||||
|
||||
while ($permission = each($account_info["permissions"])) {
|
||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||
|
@ -85,12 +85,6 @@
|
||||
. "','" . $phpgw->accounts->add_app("",True) . "','" . $account_info["groups"] . "','A',0)";
|
||||
|
||||
$phpgw->db->query($sql);
|
||||
|
||||
$phpgw->db->query("select account_id from accounts where account_lid='"
|
||||
. $account_info["loginid"] . "'");
|
||||
$phpgw->db->next_record();
|
||||
add_default_preferences($phpgw->db->f("account_id"));
|
||||
|
||||
$phpgw->db->unlock();
|
||||
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
@ -167,6 +161,8 @@
|
||||
function account_delete($account_id)
|
||||
{
|
||||
global $phpgw;
|
||||
global $phpgw_info;
|
||||
|
||||
|
||||
$phpgw->db->query("select account_lid from accounts where account_id=$account_id");
|
||||
$phpgw->db->next_record();
|
||||
|
8
admin/inc/hook_admin_add_def_pref.inc.php
Executable file
8
admin/inc/hook_admin_add_def_pref.inc.php
Executable file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$phpgw->preferences->add_newuser("common","maxmatchs","15");
|
||||
$phpgw->preferences->add_newuser("common","theme","default");
|
||||
$phpgw->preferences->add_newuser("common","tz_offset","0");
|
||||
$phpgw->preferences->add_newuser("common","dateformat","m/d/Y");
|
||||
$phpgw->preferences->add_newuser("common","timeformat","12");
|
||||
$phpgw->preferences->add_newuser("common","lang","en");
|
||||
?>
|
@ -16,29 +16,6 @@
|
||||
include("../header.inc.php");
|
||||
include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
|
||||
|
||||
function add_default_preferences($account_id)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
/* $phpgw->common->preferences_add($account_id,"maxmatchs","common","15");
|
||||
$phpgw->common->preferences_add($account_id,"theme","common","default");
|
||||
$phpgw->common->preferences_add($account_id,"tz_offset","common","0");
|
||||
$phpgw->common->preferences_add($account_id,"dateformat","common","m/d/Y");
|
||||
$phpgw->common->preferences_add($account_id,"timeformat","common","12");
|
||||
$phpgw->common->preferences_add($account_id,"lang","common","en");
|
||||
$phpgw->common->preferences_add($account_id,"company","addressbook","True");
|
||||
$phpgw->common->preferences_add($account_id,"lastname","addressbook","True");
|
||||
$phpgw->common->preferences_add($account_id,"firstname","addressbook","True"); */
|
||||
|
||||
// Even if they don't have access to the calendar, we will add these.
|
||||
// Its better then the calendar being all messed up, they will be deleted
|
||||
// the next time the update there preferences.
|
||||
/* $phpgw->common->preferences_add($account_id,"weekstarts","calendar","Monday");
|
||||
$phpgw->common->preferences_add($account_id,"workdaystarts","calendar","9");
|
||||
$phpgw->common->preferences_add($account_id,"workdayends","calendar","17"); */
|
||||
}
|
||||
|
||||
|
||||
if ($submit) {
|
||||
$totalerrors = 0;
|
||||
|
||||
@ -75,7 +52,15 @@
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd,
|
||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||
|
||||
$phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_lid='$n_loginid'");
|
||||
$phpgw->db->next_record();
|
||||
$apps = explode(":",$phpgw->db->f("account_permissions"));
|
||||
$phpgw->common->hook_single("add_def_pref", "admin");
|
||||
for($i=1;$i<=sizeof($apps);$i++) {
|
||||
$appname = $apps[$i];
|
||||
$phpgw->common->hook_single("add_def_pref", $appname);
|
||||
}
|
||||
$phpgw->preferences->commit_newuser($n_loginid);
|
||||
Header("Location: " . $phpgw->link("accounts.php","cd=$cd"));
|
||||
exit;
|
||||
}
|
||||
|
@ -56,6 +56,21 @@
|
||||
. addslashes($n_app_name) . "','" . addslashes($n_app_title) . "',"
|
||||
. "$n_app_status,$app_order)",__LINE__,__FILE__);
|
||||
|
||||
$phpgw->db->query("SELECT preference_owner, preference_value FROM preferences");
|
||||
if($phpgw->db->num_rows()) {
|
||||
while($phpgw->db->next_record()) {
|
||||
if($phpgw->db->f("preference_owner") != $phpgw_info["user"]["account_id"] {
|
||||
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value");
|
||||
$phpgw->common->hook_single("add_def_pref", $n_app_name);
|
||||
$phpgw->preferences->commit_user($phpgw->db->f("preference_owner"));
|
||||
} else {
|
||||
$phpgw->common->hook_single("add_def_pref", $n_app_name);
|
||||
$phpgw_info["user"]["preferences"]["$n_app_name"] = $phpgw_newuser["user"]["preferences"]["$n_app_name"];
|
||||
unset($phpgw_newuser);
|
||||
$phpgw->preferences->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Header("Location: " . $phpgw->link("applications.php"));
|
||||
exit;
|
||||
} else {
|
||||
|
8
calendar/inc/hook_admin_add_def_pref.inc.php
Executable file
8
calendar/inc/hook_admin_add_def_pref.inc.php
Executable file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$phpgw->preferences->add_newuser("calendar","weekstarts","Monday");
|
||||
$phpgw->preferences->add_newuser("calendar","workdaystarts","9");
|
||||
$phpgw->preferences->add_newuser("calendar","workdayends","17");
|
||||
$phpgw->preferences->add_newuser("calendar","defaultcalendar","index.php");
|
||||
$phpgw->preferences->add_newuser("calendar","defaultfilter","all");
|
||||
$phpgw->preferences->add_newuser("calendar","mainscreen_showevents","Y");
|
||||
?>
|
@ -230,6 +230,50 @@
|
||||
global $phpgw_info;
|
||||
$phpgw_info["user"]["preferences"][$app_name] = array();
|
||||
}
|
||||
|
||||
// This will commit preferences for a new user
|
||||
function commit_newuser($n_loginid) {
|
||||
global $phpgw;
|
||||
|
||||
$db = $phpgw->db;
|
||||
$db->lock(array("accounts"));
|
||||
$db->query("SELECT account_id FROM accounts WHERE account_lid='".$n_loginid."'");
|
||||
$db->next_record();
|
||||
$id = $db->f("account_id");
|
||||
$db->unlock();
|
||||
$this->commit_user($id);
|
||||
}
|
||||
|
||||
// This will commit preferences for a new user
|
||||
function commit_user($id) {
|
||||
global $phpgw_newuser, $phpgw;
|
||||
|
||||
$db = $phpgw->db;
|
||||
$db->lock(array("preferences"));
|
||||
$db->query("SELECT * FROM preferences WHERE preference_owner=".$id);
|
||||
if($db->num_rows()) {
|
||||
$db->query("UPDATE preferences SET preference_value = '"
|
||||
. serialize($phpgw_newuser["user"]["preferences"])
|
||||
. "' WHERE preference_owner=".$id,__LINE__,__FILE__);
|
||||
} else {
|
||||
$db->query("insert into preferences (preference_owner,preference_value) values ("
|
||||
. $id.",'".serialize($phpgw_newuser["user"]["preferences"])."')",__LINE__,__FILE__);
|
||||
}
|
||||
$db->unlock();
|
||||
unset($phpgw_newuser);
|
||||
}
|
||||
|
||||
// This will add all preferences within a certain app for a new user
|
||||
function add_newuser($app_name,$var,$value="") {
|
||||
global $phpgw_newuser;
|
||||
|
||||
if (! $value) {
|
||||
global $$var;
|
||||
$value = $$var;
|
||||
}
|
||||
|
||||
$phpgw_newuser["user"]["preferences"][$app_name][$var] = $value;
|
||||
}
|
||||
} //end of preferences class
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user