diff --git a/admin/deletegroup.php b/admin/deletegroup.php index 3a1787648a..b763b0d322 100755 --- a/admin/deletegroup.php +++ b/admin/deletegroup.php @@ -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 '

'; - 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) . '
' . lang("They must be removed before you can continue") . ''; echo ''; + while (list(,$id) = each($old_group_list)) { + echo ''; } echo "
'; - $phpgw->db->query("select account_id,account_lid from accounts where account_groups like '%$group_id%'",__LINE__,__FILE__); - while ($phpgw->db->next_record()) { - echo '
' . $phpgw->db->f("loginid") . '
' . $phpgw->common->grab_owner_name($id) . '
"; echo "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",'' . lang("Yes") . ''); + $p->set_var("no",'' . lang("No") . ''); + + $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",'' . lang("Yes") . ''); - $phpgw->template->set_var("no",'' . lang("No") . ''); - - $phpgw->template->pparse("out","body"); - - $phpgw->common->phpgw_footer(); ?> diff --git a/admin/editgroup.php b/admin/editgroup.php index 35082ed67b..2dca16c602 100755 --- a/admin/editgroup.php +++ b/admin/editgroup.php @@ -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; $idb->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(); diff --git a/admin/newgroup.php b/admin/newgroup.php index 0eb39bfa70..5e226aeebf 100755 --- a/admin/newgroup.php +++ b/admin/newgroup.php @@ -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; $idb->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(); diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index ebd83b8826..19286987b1 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -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;