Update acl_prefs, many minor formatting changes

This commit is contained in:
Miles Lott 2001-02-19 12:14:25 +00:00
parent e385245ecf
commit d77aeef420
10 changed files with 313 additions and 230 deletions

View File

@ -1,6 +1,6 @@
<?php
/**************************************************************************\
* phpGroupWare - Addressbook *
* phpGroupWare - Calendar *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
@ -11,243 +11,310 @@
/* $Id$ */
$phpgw_info['flags'] = array('currentapp' => 'addressbook', 'enable_nextmatchs_class' => True, 'noappheader' => True, 'noappfooter' => True);
include('../header.inc.php');
$phpgw_flags = Array(
'currentapp' => 'addressbook',
'enable_nextmatchs_class' => True,
'noappheader' => True,
'noappfooter' => True
);
$private_acl = True;
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if($private_acl == True)
{
define(PHPGW_ACL_PRIVATE,16);
}
$private_acl = True;
function check_acl($label,$id,$acl,$rights,$right)
{
global $phpgw_info, $p;
if($private_acl == True)
{
define(PHPGW_ACL_PRIVATE,16);
}
$p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']');
if ($rights & $right) {
$p->set_var($acl.'_selected',' checked');
} else {
$p->set_var($acl.'_selected','');
}
}
function check_acl($label,$id,$acl,$rights,$right)
{
global $phpgw_info, $p;
$p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']');
if ($rights & $right)
{
$p->set_var($acl.'_selected',' checked');
}
else
{
$p->set_var($acl.'_selected','');
}
}
function display_row($bg_color,$label,$id,$name) {
global $p;
global $phpgw;
global $phpgw_info;
global $acl;
global $private_acl;
function display_row($bg_color,$label,$id,$name)
{
global $phpgw_info, $acl, $private_acl, $p;
$p->set_var('row_color',$bg_color);
$p->set_var('user',$name);
$rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']);
$p->set_var('row_color',$bg_color);
$p->set_var('user',$name);
$rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']);
check_acl($label,$id,'read',$rights,PHPGW_ACL_READ);
check_acl($label,$id,'read',$rights,PHPGW_ACL_READ);
check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD);
check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD);
check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT);
check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT);
check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE);
check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE);
if($private_acl == True)
{
check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE);
}
if($private_acl == True)
{
check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE);
}
$p->parse('row','acl_row',True);
}
$p->parse('row','acl_row',True);
}
if(!isset($owner) || !$phpgw_info['user']['apps']['admin']) {
$owner = $phpgw_info['user']['account_id'];
}
$groups = $phpgw->accounts->memberships($owner);
$acl = CreateObject('phpgwapi.acl',intval($owner));
$acl->read_repository();
if(!isset($owner) || !$phpgw_info['user']['apps']['admin'])
{
$owner = $phpgw_info['user']['account_id'];
}
$acct = CreateObject('phpgwapi.accounts',$owner);
$groups = $acct->memberships($owner);
unset($acct);
$acl = CreateObject('phpgwapi.acl',intval($owner));
$acl->read_repository();
if ($submit) {
$to_remove = unserialize(urldecode($processed));
for($i=0;$i<count($to_remove);$i++) {
$acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
}
// Group records
$group_variable = 'g_'.$phpgw_info['flags']['currentapp'];
if ($submit)
{
$to_remove = unserialize(urldecode($processed));
for($i=0;$i<count($to_remove);$i++)
{
$acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
}
// Group records
$group_variable = 'g_'.$phpgw_info['flags']['currentapp'];
@reset($$group_variable);
while(list($group_id,$acllist) = each($$group_variable)) {
$totalacl = 0;
while(list($right,$permission) = each($acllist)) {
$totalacl += $right;
}
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl);
}
@reset($$group_variable);
while(list($group_id,$acllist) = each($$group_variable))
{
$totalacl = 0;
while(list($right,$permission) = each($acllist))
{
$totalacl += $right;
}
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl);
}
// User records
$user_variable = 'u_'.$phpgw_info['flags']['currentapp'];
// User records
$user_variable = 'u_'.$phpgw_info['flags']['currentapp'];
@reset($$user_variable);
while(list($user_id,$acllist) = each($$user_variable)) {
$totalacl = 0;
while(list($right,$permission) = each($acllist)) {
$totalacl += $right;
}
$acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl);
}
$acl->save_repository();
}
@reset($$user_variable);
while(list($user_id,$acllist) = each($$user_variable))
{
$totalacl = 0;
while(list($right,$permission) = each($acllist))
{
$totalacl += $right;
}
$acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl);
}
$acl->save_repository();
}
$processed = Array();
$processed = Array();
$total = 0;
$total = 0;
if(!isset($start)) {
$start = 0;
}
if(!isset($start))
{
$start = 0;
}
if(!$start) {
$s_groups = 0;
$s_users = 0;
}
if(!$start)
{
$s_groups = 0;
$s_users = 0;
}
if(!isset($s_groups)) {
$s_groups = 0;
}
if(!isset($s_groups))
{
$s_groups = 0;
}
if(!isset($s_users)) {
$s_users = 0;
}
if(!isset($s_users))
{
$s_users = 0;
}
if(!isset($query)) {
$query = "";
}
if(!isset($query))
{
$query = "";
}
if(!isset($maxm)) {
$maxm = $phpgw_info['user']['preferences']['common']['maxmatchs'];
}
if(!isset($maxm))
{
$maxm = $phpgw_info['user']['preferences']['common']['maxmatchs'];
}
if(!isset($totalentries)) {
$totalentries = count($groups);
$db = $phpgw->db;
$db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'");
$db->next_record();
$totalentries += intval($db->f(0));
}
if(!isset($totalentries))
{
$totalentries = count($groups);
$db = $phpgw->db;
$db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'");
$db->next_record();
$totalentries += intval($db->f(0));
}
$p = CreateObject('phpgwapi.Template',$phpgw_info['server']['app_tpl']);
if($private_acl == True)
{
$p->set_file(array('preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan_private.tpl',
'acl_row' => 'preference_acl_row_private.tpl'));
$p = CreateObject('phpgwapi.Template',$phpgw_info['server']['app_tpl']);
if($private_acl == True)
{
$templates = Array (
'preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan_private.tpl',
'acl_row' => 'preference_acl_row_private.tpl'
);
}
else
{
$p->set_file(array('preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan.tpl',
'acl_row' => 'preference_acl_row.tpl'));
$templates = Array (
'preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan.tpl',
'acl_row' => 'preference_acl_row.tpl'
);
}
// $p->set_var('errors','<p><center><b>This does nothing at this time!<br>Strictly as a template for use!</b></center>');
$p->set_var('errors','');
$p->set_var('title','<p><b>'.lang($phpgw_info["flags"]["currentapp"]." preferences").' - '.lang("acl").':</b><hr><p>');
$p->set_file($templates);
// $p->set_var('errors','<p><center><b>This does nothing at this time!<br>Strictly as a template for use!</b></center>');
$p->set_var('action_url',$phpgw->link(''));
$p->set_var('bg_color',$phpgw_info['theme']['th_bg']);
$p->set_var('submit_lang',lang('submit'));
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n"
. ' <input type="hidden" name="query" value="'.$query.'">'."\n"
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n";
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n"
. ' <input type="hidden" name="query" value="'.$query.'">'."\n"
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n";
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
if(isset($query_result) && $query_result)
$common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
$var = Array(
'errors' => '',
'title' => '<p><b>'.lang($phpgw_info['flags']['currentapp'].' preferences').' - '.lang('acl').':</b><hr><p>',
'action_url' => $phpgw->link(''),
'bg_color' => $phpgw_info['theme']['th_bg'],
'submit_lang' => lang('submit'),
'common_hidden_vars_form' => $common_hidden_vars
);
$p->set_var($var);
$p->set_var('common_hidden_vars',$common_hidden_vars);
$p->set_var(array('read_lang' => lang('Read'),
'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'),
'delete_lang' => lang('Delete')));
if(isset($query_result) && $query_result)
{
$common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
}
$p->set_var('common_hidden_vars',$common_hidden_vars);
$var = Array(
'read_lang' => lang('Read'),
'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'),
'delete_lang' => lang('Delete')
);
$p->set_var($var);
if($private_acl == True)
{
$p->set_var('private_lang',lang('Private'));
}
if($private_acl == True)
{
$p->set_var('private_lang',lang('Private'));
}
if(intval($s_groups) <> count($groups)) {
$p->set_var('string',lang('Groups'));
$p->parse('row','row_colspan',True);
if(intval($s_groups) <> count($groups))
{
$p->set_var('string',lang('Groups'));
$p->parse('row','row_colspan',True);
reset($groups);
for($k=0;$k<count($groups);$k++) {
$group = $groups[$k];
$go = True;
if($query) {
if(!strpos(' '.$group['account_id'].' ',$query)) {
$go = False;
}
}
if($go) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
display_row($tr_color,'g_',$group['account_id'],$group['account_name']);
$s_groups++;
$processed[] = $group['account_id'];
$total++;
if($total == $maxm) break;
}
}
}
reset($groups);
for($k=0;$k<count($groups);$k++)
{
$group = $groups[$k];
$go = True;
if($query)
{
if(!strpos(' '.$group['account_id'].' ',$query))
{
$go = False;
}
}
if($go)
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
display_row($tr_color,'g_',$group['account_id'],$group['account_name']);
$s_groups++;
$processed[] = $group['account_id'];
$total++;
if($total == $maxm)
{
break;
}
}
}
}
if($total <> $maxm) {
if(!is_object($db)) {
$db = $phpgw->db;
}
if($total <> $maxm)
{
if(!is_object($db))
{
$db = $phpgw->db;
}
$db->query("select account_id, account_firstname, account_lastname, account_lid FROM phpgw_accounts WHERE account_type='u' ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__);
$users = $db->num_rows();
if($total <> $maxm) {
if($users) {
$p->set_var('string',ucfirst(lang('Users')));
$p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record()) {
$go = True;
if($query) {
$name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' ';
if(!strpos($name,$query)) {
$go = False;
}
}
if($go) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f('account_id');
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
$s_users++;
$processed[] = $id;
$total++;
if($total == $maxm) break;
}
}
}
}
}
$db->query("select account_id, account_firstname, account_lastname, account_lid FROM phpgw_accounts WHERE account_type='u' ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__);
$users = $db->num_rows();
if($total <> $maxm)
{
if($users)
{
$p->set_var('string',ucfirst(lang('Users')));
$p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record())
{
$go = True;
if($query)
{
$name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' ';
if(!strpos($name,$query))
{
$go = False;
}
}
if($go)
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f('account_id');
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
$s_users++;
$processed[] = $id;
$total++;
if($total == $maxm)
{
break;
}
}
}
}
}
}
$extra_parms = '&s_users='.$s_users.'&s_groups='.$s_groups.'&maxm='.$maxm.'&totalentries='.$totalentries.'&total='.($start + $total).'&owner='.$owner;
$p->set_var('nml',$phpgw->nextmatchs->left('',$start,$totalentries,$extra_parms));
$p->set_var('nmr',$phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms));
$extra_parms = '&s_users='.$s_users.'&s_groups='.$s_groups.'&maxm='.$maxm.'&totalentries='.$totalentries.'&total='.($start + $total).'&owner='.$owner;
$p->set_var('search_value',(isset($query) && $query?$query:''));
$p->set_var('search',lang('search'));
$var = Array(
'nml' => $phpgw->nextmatchs->left('',$start,$totalentries,$extra_parms),
'nmr' => $phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms),
'search_value' => (isset($query) && $query?$query:''),
'search' => lang('search'),
'processed' => urlencode(serialize($processed))
);
$p->set_var($var);
$p->set_var('processed',urlencode(serialize($processed)));
$p->pparse('out','preferences');
$phpgw->common->phpgw_footer();
$p->pparse('out','preferences');
$phpgw->common->phpgw_footer();
?>

View File

@ -23,7 +23,6 @@
$phpgw_info["flags"]["enable_addressbook_class"] = True;
include("../header.inc.php");
#$t = new Template($phpgw_info["server"]["app_tpl"]);
$t = new Template($phpgw->common->get_tpl_dir("addressbook"));
$t->set_file(array("add" => "add.tpl"));
@ -83,7 +82,6 @@
addressbook_add_entry($phpgw_info["user"]["account_id"],$fields);
$ab_id = addressbook_get_lastid();
//Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"]."/addressbook/","cd=14"));
Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter=$filter&start=$start"));
$phpgw->common->phpgw_exit();
}

View File

@ -13,7 +13,10 @@
/* $Id$ */
if ($confirm) {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True
);
}
$phpgw_info["flags"]["currentapp"] = "addressbook";
@ -26,7 +29,7 @@
$this = CreateObject("phpgwapi.contacts");
$fields = $this->read_single_entry($ab_id,array("owner" => "owner"));
$owner = $fields[0]["owner"];
//$record_owner = $fields[0]["owner"];
$t = new Template($phpgw->common->get_tpl_dir("addressbook"));
$t->set_file(array("delete" => "delete.tpl"));

View File

@ -13,7 +13,10 @@
/* $Id$ */
if ($submit || ! $ab_id) {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True
);
}
$phpgw_info["flags"]["currentapp"] = "addressbook";

View File

@ -38,10 +38,10 @@
"org_name" => "company name", //company
"org_unit" => "department", //division
"title" => "title",
"n_given" => "first name", //firstname
"n_family" => "last name", //lastname
"n_middle" => "middle name",
"n_prefix" => "prefix",
"n_given" => "first name", //firstname
"n_middle" => "middle name",
"n_family" => "last name", //lastname
"n_suffix" => "suffix",
"label" => "label",
"adr_street" => "street",
@ -160,31 +160,31 @@
$country = $fields["adr_countryname"];
$timezone = $fields["tz"];
$bday = $fields["bday"];
$notes = $fields["notes"];
$notes = stripslashes($fields["notes"]);
$company = $fields["org_name"];
$department = $fields["org_unit"];
$url = $fields["url"];
//$access = $fields["access"];
if ($format != "view") {
$email = "<input name=\"email\" value=\"$email\">";
$email = "<input name=\"email\" value=\"$email\">";
$firstname = "<input name=\"firstname\" value=\"$firstname\">";
$lastname = "<input name=\"lastname\" value=\"$lastname\">";
$middle = "<input name=\"middle\" value=\"$middle\">";
$prefix = "<input name=\"prefix\" value=\"$prefix\" size=\"10\">";
$suffix = "<input name=\"suffix\" value=\"$suffix\" size=\"10\">";
$title = "<input name=\"title\" value=\"$title\">";
$hphone = "<input name=\"hphone\" value=\"$hphone\">";
$wphone = "<input name=\"wphone\" value=\"$wphone\">";
$fax = "<input name=\"fax\" value=\"$fax\">";
$pager = "<input name=\"pager\" value=\"$pager\">";
$mphone = "<input name=\"mphone\" value=\"$mphone\">";
$ophone = "<input name=\"ophone\" value=\"$ophone\">";
$street = "<input name=\"street\" value=\"$street\">";
$hphone = "<input name=\"hphone\" value=\"$hphone\">";
$wphone = "<input name=\"wphone\" value=\"$wphone\">";
$fax = "<input name=\"fax\" value=\"$fax\">";
$pager = "<input name=\"pager\" value=\"$pager\">";
$mphone = "<input name=\"mphone\" value=\"$mphone\">";
$ophone = "<input name=\"ophone\" value=\"$ophone\">";
$street = "<input name=\"street\" value=\"$street\">";
$address2 = "<input name=\"address2\" value=\"$address2\">";
$city = "<input name=\"city\" value=\"$city\">";
$state = "<input name=\"state\" value=\"$state\">";
$zip = "<input name=\"zip\" value=\"$zip\">";
$city = "<input name=\"city\" value=\"$city\">";
$state = "<input name=\"state\" value=\"$state\">";
$zip = "<input name=\"zip\" value=\"$zip\">";
$country = "<input name=\"country\" value=\"$country\">";
/*

View File

@ -15,7 +15,8 @@
$phpgw_info["flags"] = array(
"currentapp" => "addressbook",
"enable_contacts_class" => True,
"enable_nextmatchs_class" => True);
"enable_nextmatchs_class" => True
);
include("../header.inc.php");

View File

@ -11,11 +11,13 @@
/* $Id$ */
$phpgw_info["flags"] = array("noheader" => True,
"nonavbar" => True,
"currentapp" => "addressbook",
"enable_addressbook_class" => True,
"enable_nextmatchs_class" => True);
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True,
"currentapp" => "addressbook",
"enable_addressbook_class" => True,
"enable_nextmatchs_class" => True
);
include("../header.inc.php");

View File

@ -13,9 +13,15 @@
/* $Id$ */
if ($nolname || $nofname) {
$phpgw_info["flags"] = array("noheader" => False, "nonavbar" => False);
$phpgw_info["flags"] = array(
"noheader" => False,
"nonavbar" => False
);
} else {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True
);
}
$phpgw_info["flags"]["enable_addressbook_class"] = True;

View File

@ -11,4 +11,4 @@
/* $Id$ */
$phpgw_info["server"]["versions"]["addressbook"] = $phpgw_info["server"]["versions"]["phpgwapi"];
$phpgw_info["server"]["versions"]["addressbook"] = $phpgw_info["server"]["versions"]["phpgwapi"];

View File

@ -13,7 +13,10 @@
/* $Id$ */
if ($submit || ! $ab_id) {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True
);
}
$phpgw_info["flags"] = array(
@ -52,11 +55,11 @@
$qfields = $this->stock_contact_fields + $extrafields;
$fields = addressbook_read_entry($ab_id,$qfields);
$owner = $fields[0]["owner"];
$record_owner = $fields[0]["owner"];
$view_header = "<p>&nbsp;<b>" . lang("Address book - view") . "</b><hr><p>";
$view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
while ($column = each($columns_to_display)) { // each entry column
$columns_html .= "<tr><td><b>" . display_name($colname[$column[0]]) . "</b>:</td>";
$ref=$data="";
@ -90,10 +93,10 @@
*/
$columns_html .= '<tr><td colspan="4">&nbsp;</td></tr>'
. '<tr><td><b>' . lang("Record owner") . '</b></td><td>'
. $phpgw->common->grab_owner_name($owner) . '</td><td><b>'
. $phpgw->common->grab_owner_name($record_owner) . '</td><td><b>'
. $access_link . '</b></td><td></table>';
$editlink = $phpgw->common->check_owner($owner,"edit.php",lang("edit"),"ab_id=" . $ab_id . "&start=".$start."&sort=".$sort."&order=".$order);
$editlink = $phpgw->common->check_owner($record_owner,"edit.php",lang("edit"),"ab_id=" . $ab_id . "&start=".$start."&sort=".$sort."&order=".$order);
$vcardlink = '<form action="'.$phpgw->link("vcardout.php","ab_id=$ab_id&order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';
$donelink = '<form action="'.$phpgw->link("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort").'">';