now completely acl based

This commit is contained in:
skeeter 2001-02-01 04:02:01 +00:00
parent 7c785a6a33
commit e77271dde8
4 changed files with 38 additions and 53 deletions

View File

@ -18,23 +18,16 @@
Header("Location: " . $phpgw->link("groups.php")); Header("Location: " . $phpgw->link("groups.php"));
} }
include("../header.inc.php"); include("../header.inc.php");
$phpgw->template->set_file(array("body" => "delete_common.tpl")); $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p->set_file(array("body" => "delete_common.tpl"));
if ((($group_id) && ($confirm)) || $removeusers) { if ((($group_id) && ($confirm)) || $removeusers) {
if ($removeusers) { if ($removeusers) {
$phpgw->db->query("select account_id,account_groups from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__); $old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
while ($phpgw->db->next_record()) { @reset($old_group_list);
$groups[$phpgw->db->f("account_id")] = $phpgw->db->f("account_groups"); while($old_group_list && $id = each($old_group_list)) {
$phpgw->acl->delete("phpgw_group","$group_id",intval($id[1]),"u");
} }
while ($user = each($groups)) {
$user_[1] = ereg_replace(",$group_id:[0-9]+,",",",$user[1]);
if ($user_[1] == ",") {
$user_[1] = "";
}
$phpgw->db->query("update accounts set account_groups='$user_[1]' where account_id=$user[0]",__LINE__,__FILE__);
}
$confirm = True;
} }
$phpgw->db->query("select group_name from groups where group_id=$group_id",__LINE__,__FILE__); $phpgw->db->query("select group_name from groups where group_id=$group_id",__LINE__,__FILE__);
@ -42,9 +35,8 @@
$group_name = $phpgw->db->f("group_name"); $group_name = $phpgw->db->f("group_name");
$phpgw->db->query("select count(*) from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__); $old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
$phpgw->db->next_record(); if ($old_group_list) {
if ($phpgw->db->f(0) != 0) {
$phpgw->common->phpgw_header(); $phpgw->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
@ -55,9 +47,8 @@
echo '<table border="0"><tr><td>'; echo '<table border="0"><tr><td>';
$phpgw->db->query("select account_id,account_lid from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__); while (list(,$id) = each($old_group_list)) {
while ($phpgw->db->next_record()) { echo '<tr><td><a href="' . $phpgw->link("editaccount.php","account_=" . $id) . '">' . $phpgw->common->grab_owner_name($id) . '</a></tr></td>';
echo '<tr><td><a href="' . $phpgw->link("editaccount.php","account_=" . $phpgw->db->f("account_id")) . '">' . $phpgw->db->f("loginid") . '</a></tr></td>';
} }
echo "</table></center>"; echo "</table></center>";
echo "<a href=\"" . $phpgw->link("deletegroup.php","group_id=" . $group_id . "&removeusers=True") echo "<a href=\"" . $phpgw->link("deletegroup.php","group_id=" . $group_id . "&removeusers=True")
@ -83,17 +74,20 @@
} }
Header("Location: " . $phpgw->link("groups.php","cd=$cd")); Header("Location: " . $phpgw->link("groups.php","cd=$cd"));
$phpgw->common->phpgw_exit();
} }
} } else {
$phpgw->common->phpgw_header(); $phpgw->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
$phpgw->template->set_var("message",lang("Are you sure you want to delete this group ?")); $p->set_var("message_display",lang("Are you sure you want to delete this group ?"));
$phpgw->template->set_var("yes",'<a href="' . $phpgw->link("deletegroup.php","group_id=$group_id&confirm=true") . '">' . lang("Yes") . '</a>'); $p->parse("messages","message_row");
$phpgw->template->set_var("no",'<a href="' . $phpgw->link("groups.php") . '">' . lang("No") . '</a>'); $p->set_var("yes",'<a href="' . $phpgw->link("deletegroup.php","group_id=$group_id&confirm=true") . '">' . lang("Yes") . '</a>');
$p->set_var("no",'<a href="' . $phpgw->link("groups.php") . '">' . lang("No") . '</a>');
$phpgw->template->pparse("out","body"); $p->pparse("out","body");
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
}
?> ?>

View File

@ -65,16 +65,15 @@
$phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id"); $phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id");
} }
for ($i=0; $i<count($n_users);$i++) { $old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
$phpgw->db->query("SELECT account_groups, account_lid FROM accounts WHERE account_id=".$n_users[$i]); @reset($old_group_list);
$phpgw->db->next_record(); while($old_group_list && $id = each($old_group_list)) {
$account_lid = $phpgw->db->f("account_lid"); $phpgw->acl->delete("phpgw_group","$group_id",intval($id[1]),"u");
if(strpos($phpgw->db->f("account_groups"),$group_id.":0,") == 0) {
$user_groups = $phpgw->db->f("account_groups") . ",$group_id:0,";
$user_groups = ereg_replace(",,",",",$user_groups);
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
} }
for ($i=0; $i<count($n_users);$i++) {
$phpgw->acl->add("phpgw_group","$group_id",$n_users[$i],"u",1);
// If the user is logged in, it will force a refresh of the session_info // 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__); $phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$account_lid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__);

View File

@ -43,7 +43,7 @@
} }
if (! $error) { if (! $error) {
$phpgw->db->lock(array("accounts","groups","phpgw_acl","preferences")); $phpgw->db->lock(array("groups","phpgw_acl","preferences"));
$phpgw->db->query("INSERT INTO groups (group_name) VALUES ('$n_group')"); $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'");
@ -62,12 +62,7 @@
$apps->save_apps(); $apps->save_apps();
for ($i=0; $i<count($n_users);$i++) { for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]); $phpgw->acl->add("phpgw_group","$group_id",$n_users[$i],"u",1);
$phpgw->db->next_record();
$user_groups = $phpgw->db->f("account_groups") . ",$group_id:0,";
$user_groups = ereg_replace(",,",",",$user_groups);
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
$pref = CreateObject('phpgwapi.preferences',intval($n_users[$i])); $pref = CreateObject('phpgwapi.preferences',intval($n_users[$i]));
$t = $pref->get_preferences(); $t = $pref->get_preferences();

View File

@ -210,18 +210,15 @@
if ($app == False){ if ($app == False){
$app = $phpgw_info["flags"]["currentapp"]; $app = $phpgw_info["flags"]["currentapp"];
} }
$sql = "select acl_account from phpgw_acl where acl_appname = '$app' and "; $sql = "select acl_account, acl_rights from phpgw_acl where acl_appname = '$app' and ";
$sql .= "acl_account_type = '".$id_type."' and acl_location = ".$location; $sql .= "acl_account_type = '".$id_type."' and acl_location = '".$location."'";
$this->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
$rights = 0; $rights = 0;
if ($this->db->num_rows() == 0 ){ return False; } if ($this->db->num_rows() == 0 ){ return False; }
while ($this->db->next_record()) { while ($this->db->next_record()) {
if ($this->db->f("acl_rights") == 0){ return False; }
$rights |= $this->db->f("acl_rights"); $rights |= $this->db->f("acl_rights");
if (!!($rights & $required) == True){ if (!!($rights & $required) == True){
$accounts[] = $this->db->f("acl_account"); $accounts[] = $this->db->f("acl_account");
}else{
return False;
} }
} }
return $accounts; return $accounts;