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"));
}
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 ($removeusers) {
$phpgw->db->query("select account_id,account_groups from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__);
while ($phpgw->db->next_record()) {
$groups[$phpgw->db->f("account_id")] = $phpgw->db->f("account_groups");
$old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
@reset($old_group_list);
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__);
@ -42,22 +35,20 @@
$group_name = $phpgw->db->f("group_name");
$phpgw->db->query("select count(*) from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__);
$phpgw->db->next_record();
if ($phpgw->db->f(0) != 0) {
$old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
if ($old_group_list) {
$phpgw->common->phpgw_header();
echo parse_navbar();
echo '<p><center>';
echo lang("Sorry, the follow users are still a member of the group x",$group_name)
echo lang("Sorry, the follow users are still a member of the group x",$group_name)
. '<br>' . lang("They must be removed before you can continue")
. '</td></tr>';
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 ($phpgw->db->next_record()) {
echo '<tr><td><a href="' . $phpgw->link("editaccount.php","account_=" . $phpgw->db->f("account_id")) . '">' . $phpgw->db->f("loginid") . '</a></tr></td>';
while (list(,$id) = each($old_group_list)) {
echo '<tr><td><a href="' . $phpgw->link("editaccount.php","account_=" . $id) . '">' . $phpgw->common->grab_owner_name($id) . '</a></tr></td>';
}
echo "</table></center>";
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"));
$phpgw->common->phpgw_exit();
}
} else {
$phpgw->common->phpgw_header();
echo parse_navbar();
$p->set_var("message_display",lang("Are you sure you want to delete this group ?"));
$p->parse("messages","message_row");
$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>');
$p->pparse("out","body");
$phpgw->common->phpgw_footer();
}
$phpgw->common->phpgw_header();
echo parse_navbar();
$phpgw->template->set_var("message",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>');
$phpgw->template->set_var("no",'<a href="' . $phpgw->link("groups.php") . '">' . lang("No") . '</a>');
$phpgw->template->pparse("out","body");
$phpgw->common->phpgw_footer();
?>

View File

@ -65,21 +65,20 @@
$phpgw->db->query("update groups set group_name='$n_group' where group_id=$group_id");
}
$old_group_list = $phpgw->acl->get_ids_for_location("$group_id",1,"phpgw_group","u");
@reset($old_group_list);
while($old_group_list && $id = each($old_group_list)) {
$phpgw->acl->delete("phpgw_group","$group_id",intval($id[1]),"u");
}
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->next_record();
$account_lid = $phpgw->db->f("account_lid");
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]);
}
$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
$phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$account_lid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__);
// The following sets any default preferences needed for new applications..
// This is smart enough to know if previous preferences were selected, use them.
// The following sets any default preferences needed for new applications..
// This is smart enough to know if previous preferences were selected, use them.
$pref = CreateObject('phpgwapi.preferences',intval($n_users[$i]));
$t = $pref->get_preferences();

View File

@ -43,7 +43,7 @@
}
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("SELECT group_id FROM groups WHERE group_name='$n_group'");
@ -62,12 +62,7 @@
$apps->save_apps();
for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]);
$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]);
$phpgw->acl->add("phpgw_group","$group_id",$n_users[$i],"u",1);
$pref = CreateObject('phpgwapi.preferences',intval($n_users[$i]));
$t = $pref->get_preferences();

View File

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