mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
Now using accounts and acl classes
This commit is contained in:
parent
5e0ab90cb2
commit
11b69ed7af
@ -11,8 +11,13 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True,
|
||||
"currentapp" => "home", "noapi" => True);
|
||||
$phpgw_info["flags"] = array(
|
||||
"noheader" => True,
|
||||
"nonavbar" => True,
|
||||
"currentapp"=> "home",
|
||||
"noapi" => True
|
||||
);
|
||||
|
||||
include("../header.inc.php");
|
||||
include("./inc/functions.inc.php");
|
||||
|
||||
@ -29,6 +34,7 @@
|
||||
|
||||
$phpgw_info["server"]["auth_type"] = "ldap";
|
||||
$acct = CreateObject("phpgwapi.accounts");
|
||||
$applications = CreateObject("phpgwapi.applications");
|
||||
|
||||
$phpgw_setup->db->query("select config_name,config_value from phpgw_config where config_name like 'ldap%'",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record()) {
|
||||
@ -60,8 +66,8 @@
|
||||
if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
|
||||
$account_info[$i]["account_id"] = $info[$i]["uidnumber"][0];
|
||||
$account_info[$i]["account_lid"] = $info[$i]["uid"][0];
|
||||
$account_info[$i]["account_lastname"] = $info[$i]["givenname"][0];
|
||||
$account_info[$i]["account_firstname"] = $info[$i]["sn"][0];
|
||||
$account_info[$i]["account_firstname"] = $info[$i]["givenname"][0];
|
||||
$account_info[$i]["account_lastname"] = $info[$i]["sn"][0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,66 +87,57 @@
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
// This section is being modified to use the accounts and acl classes soon
|
||||
// Create a default group
|
||||
// Create the 'Default' group
|
||||
$defaultgroupid = mt_rand (100, 600000);
|
||||
$sql = "insert into phpgw_accounts";
|
||||
$sql .= "(account_id, account_lid, account_type, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status)";
|
||||
$sql .= "values (".$defaultgroupid.", 'Default', 'g', '".md5($passwd)."', 'Default', 'Group', ".time().", 'A')";
|
||||
$phpgw_setup->db->query($sql);
|
||||
// Give the group access to apps
|
||||
while ($app = each($s_apps)) {
|
||||
$sql = "DELETE FROM phpgw_acl WHERE acl_appname='".$app[1]."' AND acl_location='run' AND acl_account="
|
||||
. $defaultgroupid;
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
|
||||
$sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)"
|
||||
. " VALUES('".$app[1]."','run',".$defaultgroupid.",1)";
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
$acct = CreateObject('phpgwapi.accounts',$defaultgroupid);
|
||||
$acct->db = $phpgw_setup->db;
|
||||
|
||||
// Check if the group account is already there
|
||||
// Since the id above is random, this will fail on a reload
|
||||
$acct_exist = $acct->exists($defaultgroupid);
|
||||
if(!$acct_exist && $defaultgroupid) {
|
||||
$acct->create('g','Default',$passwd,'Default','Group','A',$defaultgroupid);
|
||||
}
|
||||
|
||||
$acl = CreateObject('phpgwapi.acl',$defaultgroupid);
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->read_repository();
|
||||
while ($app = each($s_apps)) {
|
||||
$acl->add($app[1],'run',1);
|
||||
}
|
||||
$acl->save_repository();
|
||||
|
||||
while ($account = each($account_info)) {
|
||||
// do some checks before we try to import the data
|
||||
if (!empty($account[1]["account_id"]) && !empty($account[1]["account_lid"]))
|
||||
/* // This is where each new user was given app rights, instead of per the group
|
||||
@reset($s_apps);
|
||||
while ($app = each($s_apps)) {
|
||||
$sql = "DELETE FROM phpgw_acl WHERE acl_appname='".$app[1]."' AND acl_location='run' AND acl_account="
|
||||
. $account[1]["account_id"];
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
$accounts = CreateObject("phpgwapi.accounts",$account[1]["account_id"]);
|
||||
$accounts->db = $phpgw_setup->db;
|
||||
|
||||
$sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)"
|
||||
. " VALUES('".$app[1]."','run',".$account[1]["account_id"].",1)";
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
} */
|
||||
$acl = CreateObject("phpgwapi.acl",intval($account[1]["account_id"]));
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->read_repository();
|
||||
|
||||
// Cleanup admin permissions
|
||||
$sql = "DELETE FROM phpgw_acl WHERE acl_appname='admin' AND acl_location='run' AND acl_account="
|
||||
. $account[1]["account_id"];
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
|
||||
// Give the user admin only if we asked for them to have it
|
||||
// Only give them admin if we asked for them to have it
|
||||
for ($a=0;$a<count($admins);$a++) {
|
||||
if ($admins[$a] == $account[1]["account_id"]) {
|
||||
$sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)"
|
||||
. " VALUES('admin','run',".$account[1]["account_id"].",1)";
|
||||
$phpgw_setup->db->query($sql ,__LINE__,__FILE__);
|
||||
$acl->add('admin','run',1);
|
||||
}
|
||||
}
|
||||
|
||||
// Actually create the account
|
||||
$phpgw_setup->db->query("SELECT account_id FROM phpgw_accounts WHERE account_id=" . $account[1]["account_id"]
|
||||
. " AND account_lid='" . $account[1]["account_lid"] . "'");
|
||||
if(!$phpgw_setup->db->num_rows() && $account[1]["account_lid"]) {
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_accounts (account_id,account_lid,account_pwd,account_type,"
|
||||
. "account_status,account_lastpwd_change) VALUES (" . $account[1]["account_id"] . ",'"
|
||||
. $account[1]["account_lid"] . "','x','u','A',".time().")",__LINE__,__FILE__);
|
||||
// Check if the account is already there
|
||||
$acct_exist = $accounts->exists($account[1]["account_id"]);
|
||||
|
||||
if(!$acct_exist && $account[1]["account_id"]) {
|
||||
$accounts->create('u', $account[1]["account_lid"], 'x',
|
||||
$account[1]["account_firstname"], $account[1]["account_lastname"],
|
||||
'A',$account[1]["account_id"]
|
||||
);
|
||||
}
|
||||
|
||||
// Now make them a member of the default group
|
||||
$sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)"
|
||||
. " VALUES('phpgw_group',".$defaultgroupid.",".$account[1]["account_id"].",'1')";
|
||||
$phpgw_setup->db->query($sql);
|
||||
// Now make them a member of the 'Default' group
|
||||
$acl->add("phpgw_group",$defaultgroupid,1);
|
||||
$acl->save_repository();
|
||||
}
|
||||
$setup_complete = True;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user