From 31f5e1a3f966fff893a80e58d82606687d630f94 Mon Sep 17 00:00:00 2001 From: skeeter Date: Fri, 9 Feb 2001 04:36:16 +0000 Subject: [PATCH] group admin except delete works --- admin/editgroup.php | 37 ++++++--------- admin/newgroup.php | 111 ++++++++++++++++++++++++-------------------- 2 files changed, 75 insertions(+), 73 deletions(-) diff --git a/admin/editgroup.php b/admin/editgroup.php index 2c7fb0e0ed..2d5af0815b 100755 --- a/admin/editgroup.php +++ b/admin/editgroup.php @@ -18,8 +18,8 @@ $phpgw_info["flags"]["currentapp"] = "admin"; include("../header.inc.php"); - $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); - +$debugme = "on"; + function is_odd($n) { $ln = substr($n,-1); @@ -55,7 +55,7 @@ if($app[1]) { $apps->add($app[0]); if(!$apps_before[$app[0]]) { - $apps_after[] = $app[0]; + $new_apps[] = $app[0]; } } } @@ -86,14 +86,14 @@ $t = $pref->read_repository(); $docommit = False; - for ($j=1;$jcommon->hook_single('add_def_pref', $apps_after[$j]); + $phpgw->common->hook_single('add_def_pref', $new_apps[$j]); $docommit = True; } } @@ -102,10 +102,8 @@ } } - $sep = $phpgw->common->filesystem_separator(); - if ($old_group_name <> $n_group) { - $basedir = $phpgw_info['server']['files_dir'] . $sep . 'groups' . $sep; + $basedir = $phpgw_info['server']['files_dir'] . SEP . 'groups' . SEP; if (! @rename($basedir . $old_group_name, $basedir . $n_group)) { $cd = 39; } else { @@ -122,6 +120,8 @@ } } + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); + $p->set_file(array('form' => 'groups_form.tpl')); if ($error) { @@ -133,17 +133,12 @@ } if ($submit) { - $p->set_var('group_name_value',$n_group_name); +// $p->set_var('group_name_value',$n_group_name); for ($i=0; $idb->query('SELECT account_lid FROM phpgw_accounts WHERE account_id='.$group_id,__LINE__,__FILE__); - $phpgw->db->next_record(); - - $p->set_var('group_name_value',$phpgw->db->f('account_id')); - $group_user = $phpgw->acl->get_ids_for_location($group_id,1,'phpgw_group'); while ($user = each($group_user)) { @@ -151,18 +146,14 @@ } $apps = CreateObject('phpgwapi.applications',intval($group_id)); - $apps->read_repository(); $db_perms = $apps->read_account_specific(); } - $phpgw->db->query('SELECT * FROM phpgw_accounts WHERE account_id='.$group_id,__LINE__,__FILE__); - $phpgw->db->next_record(); - $p->set_var('form_action',$phpgw->link('editgroup.php')); $p->set_var('hidden_vars',''); $p->set_var('lang_group_name',lang('group name')); - $p->set_var('group_name_value',$phpgw->db->f('account_lid')); + $p->set_var('group_name_value',$phpgw->accounts->id2name($group_id)); $phpgw->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_status !='L' AND account_type='u'"); $phpgw->db->next_record(); @@ -206,7 +197,7 @@ $perm_html .= '' . lang($perm_display[$i][1]) . '' . '' . ' True, "nonavbar" => True); + $phpgw_info['flags'] = array('noheader' => True, 'nonavbar' => True); } - $phpgw_info["flags"]["currentapp"] = "admin"; - include("../header.inc.php"); + $phpgw_info['flags']['currentapp'] = 'admin'; + include('../header.inc.php'); function is_odd($n) { @@ -29,43 +29,52 @@ } } - $phpgw->template->set_file(array("form" => "groups_form.tpl")); - if ($submit) { - $phpgw->db->query("select count(*) from groups where group_name='" . $n_group . "'"); - $phpgw->db->next_record(); - - if ($phpgw->db->f(0) != 0) { - $error = "
" . lang("Sorry, that group name has already been taken."); - } + if (! $n_group) { - $error = "
" . lang("You must enter a group name."); + $error = '
' . lang('You must enter a group name.'); + } else { + $phpgw->db->query("select count(*) from phpgw_accounts where account_lid='" . $n_group . "'"); + $phpgw->db->next_record(); + + if ($phpgw->db->f(0) != 0) { + $error = '
' . lang('Sorry, that group name has already been taken.'); + } } if (! $error) { - $phpgw->db->lock(array("groups","phpgw_acl","preferences")); + $phpgw->db->lock(array('phpgw_accounts','preferences','phpgw_config','phpgw_applications','phpgw_hooks','phpgw_sessions','phpgw_acl')); + while(1) { + $group_id = mt_rand (1000, 60000); + $phpgw->db->query("SELECT account_id FROM phpgw_accounts WHERE account_id=$group_id",__LINE__,__FILE__); + if(!$phpgw->db->num_rows()) { break; } + } - $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->next_record(); + $phpgw->db->query("INSERT INTO phpgw_accounts(account_id,account_lid,account_type) " + ."VALUES($group_id,'$n_group','g')"); - $group_id = $phpgw->db->f("group_id"); - - $apps = CreateObject('phpgwapi.applications',array(intval($group_id),'g')); + $apps = CreateObject('phpgwapi.applications',intval($group_id)); + $apps->update_data(Array()); @reset($n_group_permissions); while($app = each($n_group_permissions)) { if($app[1]) { - $apps->add_app($app[0]); + $apps->add($app[0]); $new_apps[] = $app[0]; } } - $apps->save_apps(); - + $apps->save_repository(); + + $acl = CreateObject('phpgwapi.acl',$group_id); + $acl->read_repository(); for ($i=0; $iacl->add("phpgw_group","$group_id",$n_users[$i],"u",1); + $acl->add_repository('phpgw_group',$group_id,$n_users[$i],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='" . $phpgw->accounts->id2name(intval($n_users[$i])) . "@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__); $pref = CreateObject('phpgwapi.preferences',intval($n_users[$i])); - $t = $pref->get_preferences(); + $t = $pref->read_repository(); $docommit = False; for ($j=0;$jcommit(); + $pref->save_repository(); } } - $sep = $phpgw->common->filesystem_separator(); - - $basedir = $phpgw_info["server"]["files_dir"] . $sep . "groups" . $sep; + $basedir = $phpgw_info["server"]["files_dir"] . SEP . "groups" . SEP; $cd = 31; @@ -100,45 +107,49 @@ } } + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); + + $p->set_file(array("form" => "groups_form.tpl")); + if ($error) { $phpgw->common->phpgw_header(); echo parse_navbar(); - $phpgw->template->set_var("error","

$error
"); + $p->set_var("error","

$error
"); } else { - $phpgw->template->set_var("error",""); + $p->set_var("error",""); } - $phpgw->template->set_var("form_action",$phpgw->link("newgroup.php")); - $phpgw->template->set_var("hidden_vars",""); - $phpgw->template->set_var("lang_group_name",lang("New group name")); - $phpgw->template->set_var("group_name_value",""); + $p->set_var("form_action",$phpgw->link("newgroup.php")); + $p->set_var("hidden_vars",""); + $p->set_var("lang_group_name",lang("New group name")); + $p->set_var("group_name_value",""); - $phpgw->db->query("select count(*) from accounts where account_status !='L'"); + $phpgw->db->query("select count(*) from phpgw_accounts where account_status !='L' AND account_type='u'"); $phpgw->db->next_record(); if ($phpgw->db->f(0) < 5) { - $phpgw->template->set_var("select_size",$phpgw->db->f(0)); + $p->set_var("select_size",$phpgw->db->f(0)); } else { - $phpgw->template->set_var("select_size","5"); + $p->set_var("select_size","5"); } - $phpgw->template->set_var("lang_include_user",lang("Select users for inclusion")); + $p->set_var("lang_include_user",lang("Select users for inclusion")); for ($i=0; $idb->query("SELECT account_id,account_firstname,account_lastname,account_lid FROM accounts where " - . "account_status != 'L' ORDER BY account_lastname,account_firstname,account_lid asc"); + $phpgw->db->query("SELECT account_id,account_firstname,account_lastname,account_lid FROM phpgw_accounts WHERE " + . "account_status != 'L' AND account_type='u' ORDER BY account_lastname,account_firstname,account_lid asc"); while ($phpgw->db->next_record()) { - $user_list .= ""; + $user_list .= ''; } - $phpgw->template->set_var("user_list",$user_list); + $p->set_var("user_list",$user_list); - $phpgw->template->set_var("lang_permissions",lang("Permissions this group has")); + $p->set_var("lang_permissions",lang("Permissions this group has")); $i = 0; $sorted_apps = $phpgw_info["apps"]; @@ -179,10 +190,10 @@ $i++; } - $phpgw->template->set_var("permissions_list",$perm_html); - $phpgw->template->set_var("lang_submit_button",lang("Create Group")); + $p->set_var("permissions_list",$perm_html); + $p->set_var("lang_submit_button",lang("Create Group")); - $phpgw->template->pparse("out","form"); + $p->pparse("out","form"); $phpgw->common->phpgw_footer(); ?>