mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:49:10 +01:00
Feature to display a list of addresses from a given adressbook within the sitemanager
you may choose all addressbooks (which the Sitemanager user is allowed to see). NOTE the anonymous user, respectively the user you assigned for anonymous access must have sufficient rights for the addressbook(s) to be shown. This is provided by Stefan Becker Bugfix for broken Move2Adressbook callback
This commit is contained in:
parent
3304616642
commit
594fa7df4b
96
addressbook/inc/class.addressbook_display.inc.php
Executable file
96
addressbook/inc/class.addressbook_display.inc.php
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Addressbook - Sitemgr display form
|
||||||
|
*
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @author Stefan Becker <stefanBecker-AT-outdoor-training.de>
|
||||||
|
* @package addressbook
|
||||||
|
* @copyright (c) 2008 by Stefan Becker <StefanBecker-AT-outdoor-training.de>
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @version $Id: class.addressbook_display.inc.php 24099 2008-02-18 16:29:06Z stefanbecker $
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php');
|
||||||
|
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SiteMgr Display form for the addressbook
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class addressbook_display extends uicontacts
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Shows the Addressbook Entry and stores the submitted data
|
||||||
|
*
|
||||||
|
* @param array $content=null submitted eTemplate content
|
||||||
|
* @param int $addressbook=null int owner-id of addressbook to save contacts too
|
||||||
|
* @param array $fields=null field-names to show
|
||||||
|
* @param string $msg=null message to show after submitting the form
|
||||||
|
* @param string $email=null comma-separated email addresses
|
||||||
|
* @param string $tpl_name=null custom etemplate to use
|
||||||
|
* @param string $subject=null subject for email
|
||||||
|
* @return string html content
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
|
||||||
|
{
|
||||||
|
$query['sitemgr_display'] = ($readonlys['sitemgr_display'] ?$readonlys['sitemgr_display']:'addressbook.display');
|
||||||
|
$total = parent::get_rows($query,$rows,$readonlys);
|
||||||
|
$query['template'] = $query['sitemgr_display'].'.rows';
|
||||||
|
|
||||||
|
foreach($query['fields'] as $name)
|
||||||
|
{
|
||||||
|
$rows['show'][$name]=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function display($content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null)
|
||||||
|
{
|
||||||
|
$tpl_name=($tpl_name ? $tpl_name : 'addressbook.display');
|
||||||
|
$tpl = new etemplate($tpl_name);
|
||||||
|
|
||||||
|
$content = array(
|
||||||
|
'msg' => $msg ? $msg : $_GET['msg'],
|
||||||
|
);
|
||||||
|
$content['nm1'] = $GLOBALS['egw']->session->appsession(($tpl_name ? $tpl_name : 'index'),'addressbook');
|
||||||
|
$readonlys['sitemgr_display']=$tpl_name;
|
||||||
|
if (!is_array($content['nm1']))
|
||||||
|
{
|
||||||
|
$content['nm1'] = array(
|
||||||
|
'get_rows' => 'addressbook.addressbook_display.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
|
||||||
|
'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows
|
||||||
|
'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie
|
||||||
|
'start' => 0, // IO position in list
|
||||||
|
'cat_id' => '', // IO category, if not 'no_cat' => True
|
||||||
|
'no_cat' => 'True',
|
||||||
|
// 'options-cat_id' => array(lang('none')),
|
||||||
|
'search' => '', // IO search pattern
|
||||||
|
'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders)
|
||||||
|
'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
|
||||||
|
// 'col_filter' => array(), // IO array of column-name value pairs (optional for the filterheaders)
|
||||||
|
// 'filter_label' => lang('Addressbook'), // I label for filter (optional)
|
||||||
|
'filter' => $addressbook, // =All // IO filter, if not 'no_filter' => True
|
||||||
|
// 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options)
|
||||||
|
'no_filter' => True, // I disable the 1. filter (params are the same as for filter)
|
||||||
|
'no_filter2' => True, // I disable the 2. filter (params are the same as for filter)
|
||||||
|
// 'filter2_label' => lang('Distribution lists'), // IO filter2, if not 'no_filter2' => True
|
||||||
|
// 'filter2' => '', // IO filter2, if not 'no_filter2' => True
|
||||||
|
// 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options)
|
||||||
|
// 'filter2_onchange' => "if(this.value=='add') { add_new_list(document.getElementById(form::name('filter')).value); this.value='';} else this.form.submit();",
|
||||||
|
'lettersearch' => true,
|
||||||
|
'do_email' => $do_email,
|
||||||
|
'default_cols' => '!cat_id,contact_created_contact_modified',
|
||||||
|
'manual' => $do_email ? ' ' : false, // space for the manual icon
|
||||||
|
'no_columnselection' => True,
|
||||||
|
'csv_fields' => false,
|
||||||
|
);
|
||||||
|
|
||||||
|
$content['nm1']['fields'] = $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tpl->exec('addressbook.addressbook_display.display',$content,$sel_options,$readonlys,$preserv);
|
||||||
|
}
|
||||||
|
}
|
@ -265,7 +265,15 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
$sel_options['action']['infolog'] = lang('View linked InfoLog entries');
|
$sel_options['action']['infolog'] = lang('View linked InfoLog entries');
|
||||||
}
|
}
|
||||||
$sel_options['action'][lang('Move to addressbook:')] = $this->get_addressbooks(EGW_ACL_ADD);
|
if (($move2addressbooks=$this->get_addressbooks(EGW_ACL_ADD))) // do we have addressbooks, we should
|
||||||
|
{
|
||||||
|
foreach ($move2addressbooks as $m2a_id => $m2alabel)
|
||||||
|
{
|
||||||
|
$m2a['move_to_'.$m2a_id] = $m2alabel;
|
||||||
|
}
|
||||||
|
$sel_options['action'][lang('Move to addressbook:')] = $m2a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($add_lists = $this->get_lists(EGW_ACL_EDIT))) // do we have distribution lists?
|
if (($add_lists = $this->get_lists(EGW_ACL_EDIT))) // do we have distribution lists?
|
||||||
{
|
{
|
||||||
@ -450,7 +458,6 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
|
//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
|
||||||
$success = $failed = 0;
|
$success = $failed = 0;
|
||||||
|
|
||||||
if ($use_all || in_array($action,array('remove_from_list','delete_list')))
|
if ($use_all || in_array($action,array('remove_from_list','delete_list')))
|
||||||
{
|
{
|
||||||
// get the whole selection
|
// get the whole selection
|
||||||
@ -485,6 +492,10 @@ class uicontacts extends bocontacts
|
|||||||
if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
|
if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
|
||||||
//_debug_array($checked); exit;
|
//_debug_array($checked); exit;
|
||||||
|
|
||||||
|
if (substr($action,0,8) == 'move_to_')
|
||||||
|
{
|
||||||
|
$action = (int)substr($action,8);
|
||||||
|
}
|
||||||
if (substr($action,0,7) == 'to_list')
|
if (substr($action,0,7) == 'to_list')
|
||||||
{
|
{
|
||||||
$to_list = (int)substr($action,8);
|
$to_list = (int)substr($action,8);
|
||||||
@ -654,7 +665,6 @@ class uicontacts extends bocontacts
|
|||||||
$Ok = $this->add2list($id,$to_list) !== false;
|
$Ok = $this->add2list($id,$to_list) !== false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // move to an other addressbook
|
default: // move to an other addressbook
|
||||||
if (!(int)$action || !($this->grants[(string) (int) $action] & EGW_ACL_EDIT)) // might be ADD in the future
|
if (!(int)$action || !($this->grants[(string) (int) $action] & EGW_ACL_EDIT)) // might be ADD in the future
|
||||||
{
|
{
|
||||||
@ -701,7 +711,14 @@ class uicontacts extends bocontacts
|
|||||||
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
|
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
|
||||||
{
|
{
|
||||||
$do_email = $query['do_email'];
|
$do_email = $query['do_email'];
|
||||||
|
// is this wanted???
|
||||||
|
if ($query['sitemgr_display'])
|
||||||
|
{
|
||||||
|
$old_state = $GLOBALS['egw']->session->appsession($query['sitemgr_display'],'addressbook');
|
||||||
|
} else {
|
||||||
$old_state = $GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook');
|
$old_state = $GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook');
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->org_views[(string) $query['org_view']])) // we have an org view, reset the advanced search
|
if (isset($this->org_views[(string) $query['org_view']])) // we have an org view, reset the advanced search
|
||||||
{
|
{
|
||||||
if (is_array($query['search'])) unset($query['search']);
|
if (is_array($query['search'])) unset($query['search']);
|
||||||
@ -734,7 +751,12 @@ class uicontacts extends bocontacts
|
|||||||
{
|
{
|
||||||
$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
|
$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
|
||||||
}
|
}
|
||||||
$GLOBALS['egw']->session->appsession($do_email ? 'email' : 'index','addressbook',$query);
|
if ($query['sitemgr_display'])
|
||||||
|
{
|
||||||
|
$old_state = $GLOBALS['egw']->session->appsession($query['sitemgr_display'],'addressbook',$query);
|
||||||
|
} else {
|
||||||
|
$GLOBALS['egw']->session->appsession(($do_email ? 'email' : 'index'),'addressbook',$query);
|
||||||
|
}
|
||||||
// save the state of the index in the user prefs
|
// save the state of the index in the user prefs
|
||||||
$state = serialize(array(
|
$state = serialize(array(
|
||||||
'filter' => $query['filter'],
|
'filter' => $query['filter'],
|
||||||
@ -744,6 +766,12 @@ class uicontacts extends bocontacts
|
|||||||
'col_filter' => array('tid' => $query['col_filter']['tid']),
|
'col_filter' => array('tid' => $query['col_filter']['tid']),
|
||||||
'org_view' => $query['org_view'],
|
'org_view' => $query['org_view'],
|
||||||
));
|
));
|
||||||
|
if ($state != $this->prefs[($query['sitemgr_display'] ? $query['sitemgr_display'].'_state' : 'index_state')])
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->preferences->add('addressbook',($query['sitemgr_display'] ? $query['sitemgr_display'].'_state' : 'index_state'),$state);
|
||||||
|
// save prefs, but do NOT invalid the cache (unnecessary)
|
||||||
|
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
||||||
|
}
|
||||||
if ($state != $this->prefs[$do_email ? 'email_state' : 'index_state'])
|
if ($state != $this->prefs[$do_email ? 'email_state' : 'index_state'])
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->preferences->add('addressbook',$do_email ? 'email_state' : 'index_state',$state);
|
$GLOBALS['egw']->preferences->add('addressbook',$do_email ? 'email_state' : 'index_state',$state);
|
||||||
@ -803,8 +831,12 @@ class uicontacts extends bocontacts
|
|||||||
}
|
}
|
||||||
else // contacts view
|
else // contacts view
|
||||||
{
|
{
|
||||||
|
if ($query['sitemgr_display'])
|
||||||
|
{
|
||||||
|
$query['template'] = $query['sitemgr_display'].'.rows';
|
||||||
|
} else {
|
||||||
$query['template'] = $do_email ? 'addressbook.email.rows' : 'addressbook.index.rows';
|
$query['template'] = $do_email ? 'addressbook.email.rows' : 'addressbook.index.rows';
|
||||||
|
}
|
||||||
if ($query['org_view']) // view the contacts of one organisation only
|
if ($query['org_view']) // view the contacts of one organisation only
|
||||||
{
|
{
|
||||||
foreach(explode('|||',$query['org_view']) as $part)
|
foreach(explode('|||',$query['org_view']) as $part)
|
||||||
|
File diff suppressed because one or more lines are too long
94
addressbook/sitemgr/class.module_addressbook_display.inc.php
Executable file
94
addressbook/sitemgr/class.module_addressbook_display.inc.php
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Addressbook - Sitemgr contact form
|
||||||
|
*
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @author stefan Becker <StefanBecker-AT-outdoor-training.de>
|
||||||
|
* @package addressbook
|
||||||
|
* @copyright (c) 2008 by stefan Becker <StefanBecker-AT-outdoor-training.de>
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @version $Id: class.module_addressbook_display.inc.php 24028 2008-02-18 09:04:36Z stefanbecker $
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SiteMgr contact form for the addressbook
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class module_addressbook_display extends sitemgr_module
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @return module_addressbook_showcontactblock
|
||||||
|
*/
|
||||||
|
function module_addressbook_display()
|
||||||
|
{
|
||||||
|
$this->arguments = array(); // get's set in get_user_interface
|
||||||
|
$this->title = lang('Display Contact');
|
||||||
|
$this->description = lang('This module displays Block from a Adddressbook Group.');
|
||||||
|
|
||||||
|
$this->etemplate_method = 'addressbook.addressbook_display.display';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reimplemented to add the addressbook translations and fetch the addressbooks only if needed for the user-interface
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_user_interface()
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->translation->add_app('addressbook');
|
||||||
|
|
||||||
|
include_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
|
||||||
|
$uicontacts = new uicontacts();
|
||||||
|
|
||||||
|
$default = $fields = array(
|
||||||
|
'org_name' => lang('Company'),
|
||||||
|
'org_unit' => lang('Department'),
|
||||||
|
'n_fn' => lang('Prefix').', '.lang('Firstname').' + '.lang('Lastname'),
|
||||||
|
'sep1' => '----------------------------',
|
||||||
|
'email' => lang('email'),
|
||||||
|
'tel_work' => lang('work phone'),
|
||||||
|
'tel_cell' => lang('mobile phone'),
|
||||||
|
'tel_fax' => lang('fax'),
|
||||||
|
'tel_home' => lang('home phone'),
|
||||||
|
'url' => lang('url'),
|
||||||
|
'sep2' => '----------------------------',
|
||||||
|
'adr_one_street' => lang('street'),
|
||||||
|
'adr_one_street2' => lang('address line 2'),
|
||||||
|
'adr_one_locality' => lang('city').' + '.lang('zip code'),
|
||||||
|
'country' => lang('country'),
|
||||||
|
);
|
||||||
|
foreach($uicontacts->customfields as $name => $data)
|
||||||
|
{
|
||||||
|
$fields['#'.$name] = $data['label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->arguments = array(
|
||||||
|
'arg1' => array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => lang('Addressbook the contact should be shown').' ('.lang('The anonymous user needs read it!').')',
|
||||||
|
'options' => array(
|
||||||
|
'' => lang('All'),
|
||||||
|
)+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts!
|
||||||
|
),
|
||||||
|
'arg2' => array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => lang('Contact fields to show'),
|
||||||
|
'multiple' => true,
|
||||||
|
'options' => $fields,
|
||||||
|
'default' => $default,
|
||||||
|
'params' => array('size' => 9),
|
||||||
|
),
|
||||||
|
'arg5' => array(
|
||||||
|
'type' => 'textfield',
|
||||||
|
'label' => lang('Custom eTemplate for the contactform'),
|
||||||
|
'params' => array('size' => 40),
|
||||||
|
'default' => 'addressbook.display',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return parent::get_user_interface();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user