using static methods for the hooks (you need to update addressbook or call Admin >> Register hooks!)

This commit is contained in:
Ralf Becker 2008-04-25 18:59:00 +00:00
parent 4ecce4f5ae
commit 684d6551f2
2 changed files with 68 additions and 44 deletions

View File

@ -1,41 +1,26 @@
<?php <?php
/** /**
* Addressbook - admin, preferences and sidebox-menus * Addressbook - admin, preferences and sidebox-menus and other hooks
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @package addressbook * @package addressbook
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright (c) 2006 by Ralf Becker <RalfBecker@outdoor-training.de> * @copyright (c) 2006-8 by Ralf Becker <RalfBecker@outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
/** /**
* Class containing admin, preferences and sidebox-menus (used as hooks) * Class containing admin, preferences and sidebox-menus and other hooks
*
* @package addressbook
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright (c) 2006 by Ralf Becker <RalfBecker@outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/ */
class contacts_admin_prefs class addressbook_hooks
{ {
var $contact_repository = 'sql';
/**
* constructor
*/
function contacts_admin_prefs()
{
if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap') $this->contact_repository = 'ldap';
}
/** /**
* hooks to build projectmanager's sidebox-menu plus the admin and preferences sections * hooks to build projectmanager's sidebox-menu plus the admin and preferences sections
* *
* @param string/array $args hook args * @param string/array $args hook args
*/ */
function all_hooks($args) static function all_hooks($args)
{ {
$appname = 'addressbook'; $appname = 'addressbook';
$location = is_array($args) ? $args['location'] : $args; $location = is_array($args) ? $args['location'] : $args;
@ -71,7 +56,7 @@ class contacts_admin_prefs
'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), 'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') 'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True')
); );
if ($this->contact_repository == 'ldap' || $GLOBALS['egw_info']['server']['deny_user_grants_access']) if ($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' || $GLOBALS['egw_info']['server']['deny_user_grants_access'])
{ {
unset($file['Grant Access']); unset($file['Grant Access']);
} }
@ -121,7 +106,7 @@ class contacts_admin_prefs
/** /**
* populates $GLOBALS['settings'] for the preferences * populates $GLOBALS['settings'] for the preferences
*/ */
function settings() static function settings()
{ {
$GLOBALS['settings']['add_default'] = array( $GLOBALS['settings']['add_default'] = array(
'type' => 'select', 'type' => 'select',
@ -179,7 +164,7 @@ class contacts_admin_prefs
'admin' => false, 'admin' => false,
); );
if ($this->contact_repository == 'sql') if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
{ {
$GLOBALS['settings']['private_addressbook'] = array( $GLOBALS['settings']['private_addressbook'] = array(
'type' => 'check', 'type' => 'check',
@ -272,7 +257,7 @@ class contacts_admin_prefs
/** /**
* add an Addressbook tab to Admin >> Edit user * add an Addressbook tab to Admin >> Edit user
*/ */
function edit_user() static function edit_user()
{ {
global $menuData; global $menuData;
@ -284,4 +269,43 @@ class contacts_admin_prefs
' title="'.htmlspecialchars(lang('Edit extra account-data in the addressbook')).'"', ' title="'.htmlspecialchars(lang('Edit extra account-data in the addressbook')).'"',
); );
} }
/**
* Hook called by link-class to include calendar in the appregistry of the linkage
*
* @param array/string $location location and other parameters (not used)
* @return array with method-names
*/
static function search_link($location)
{
return array(
'query' => 'addressbook.bocontacts.link_query',
'title' => 'addressbook.bocontacts.link_title',
'titles' => 'addressbook.bocontacts.link_titles',
'view' => array(
'menuaction' => 'addressbook.uicontacts.view'
),
'view_id' => 'contact_id',
'add' => array(
'menuaction' => 'addressbook.uicontacts.edit'
),
'add_app' => 'link_app',
'add_id' => 'link_id',
'add_popup' => '850x440',
);
}
/**
* Register contacts as calendar resources (items which can be sheduled by the calendar)
*
* @param array $args hook-params (not used)
* @return array
*/
static function calendar_resources($args)
{
return array(
'type' => 'c',// one char type-identifiy for this resources
'info' => 'addressbook.bocontacts.calendar_info',// info method, returns array with id, type & name for a given id
);
}
} }

View File

@ -10,7 +10,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['addressbook']['name'] = 'addressbook'; $setup_info['addressbook']['name'] = 'addressbook';
$setup_info['addressbook']['title'] = 'Addressbook'; $setup_info['addressbook']['title'] = 'Addressbook';
$setup_info['addressbook']['version'] = '1.5'; $setup_info['addressbook']['version'] = '1.5.001';
$setup_info['addressbook']['app_order'] = 4; $setup_info['addressbook']['app_order'] = 4;
$setup_info['addressbook']['enable'] = 1; $setup_info['addressbook']['enable'] = 1;
@ -30,15 +30,15 @@ $setup_info['addressbook']['maintainer_email'] = 'egroupware-developers@lists.so
$setup_info['addressbook']['tables'] = array(); // addressbook tables are in the API! $setup_info['addressbook']['tables'] = array(); // addressbook tables are in the API!
/* The hooks this app includes, needed for hooks registration */ /* The hooks this app includes, needed for hooks registration */
$setup_info['addressbook']['hooks']['admin'] = 'addressbook.contacts_admin_prefs.all_hooks'; $setup_info['addressbook']['hooks']['admin'] = 'addressbook_hooks::all_hooks';
$setup_info['addressbook']['hooks']['preferences'] = 'addressbook.contacts_admin_prefs.all_hooks'; $setup_info['addressbook']['hooks']['preferences'] = 'addressbook_hooks::all_hooks';
$setup_info['addressbook']['hooks']['sidebox_menu'] = 'addressbook.contacts_admin_prefs.all_hooks'; $setup_info['addressbook']['hooks']['sidebox_menu'] = 'addressbook_hooks::all_hooks';
$setup_info['addressbook']['hooks']['settings'] = 'addressbook.contacts_admin_prefs.settings'; $setup_info['addressbook']['hooks']['settings'] = 'addressbook_hooks::settings';
$setup_info['addressbook']['hooks'][] = 'home'; $setup_info['addressbook']['hooks'][] = 'home';
$setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.bocontacts.deleteaccount'; $setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.bocontacts.deleteaccount';
$setup_info['addressbook']['hooks']['search_link'] = 'addressbook.bocontacts.search_link'; $setup_info['addressbook']['hooks']['search_link'] = 'addressbook_hooks::search_link';
$setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook.bocontacts.calendar_resources'; $setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook_hooks::calendar_resources';
$setup_info['addressbook']['hooks']['edit_user'] = 'addressbook.contacts_admin_prefs.edit_user'; $setup_info['addressbook']['hooks']['edit_user'] = 'addressbook_hooks::edit_user';
$setup_info['addressbook']['hooks'][] = 'config'; $setup_info['addressbook']['hooks'][] = 'config';
/* Dependencies for this app to work */ /* Dependencies for this app to work */