Re: some client cleanups
Bo Daley <[email protected]>
| Newsgroups | gmane.comp.horde.whups |
|---|---|
| Message-ID | <[email protected]> |
Quoting Chuck Hagenbuch <[email protected]>: > This is what $registry->hasMethod() is for - just check for the clients/ api. thanks for the tip -- I just added in this registry check in the appropriate places, so clients can be optional again. bo. -- Whups mailing list Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
clients_optional.diff
(text/diff, 17.8 KB)
Index: admin.php
===================================================================
RCS file: /repository/whups/admin.php,v
retrieving revision 1.46
diff -u -r1.46 admin.php
--- admin.php 8 Aug 2003 12:55:04 -0000 1.46
+++ admin.php 11 Aug 2003 04:04:01 -0000
@@ -293,29 +293,31 @@
$vars->getVar('subjectlist'), $vars->getVar('subjects'),
$vars->getVar('versioned'));
if (!is_a($result, 'PEAR_Error')) {
- /* Update client links. */
- $clients = $vars->getVar('clients');
- $clientsource = $GLOBALS['registry']->call('clients/getClientSource');
- require_once HORDE_BASE . '/lib/Links.php';
- $links = &Horde_Links::singleton($registry->getApp());
- $from_application = 'projects';
- $from_parameters = array('module_id' => $vars->getVar('module'));
- $to_application = 'contacts';
- $link_type = 'client';
- /* Delete all current client links for this module. */
- $delete_status = $links->deleteLink($from_application, $from_parameters, $to_application, '*', $link_type);
+ if ($GLOBALS['registry']->hasMethod('clients/getClientSource')) {
+ /* Update client links. */
+ $clients = $vars->getVar('clients');
+ $clientsource = $GLOBALS['registry']->call('clients/getClientSource');
+ require_once HORDE_BASE . '/lib/Links.php';
+ $links = &Horde_Links::singleton($registry->getApp());
+ $from_application = 'projects';
+ $from_parameters = array('module_id' => $vars->getVar('module'));
+ $to_application = 'contacts';
+ $link_type = 'client';
+ /* Delete all current client links for this module. */
+ $delete_status = $links->deleteLink($from_application, $from_parameters, $to_application, '*', $link_type);
- /* Now add in all the new client links. */
- foreach ($clients as $client) {
- $to_parameters = array('source' => $clientsource, 'id' => $client);
- $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
- if (is_a($status, 'PEAR_Error')) {
- $notification->push($status, 'horde.error');
- } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
- $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
- $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
- } else {
- $notification->push(_("Link added."), 'horde.success');
+ /* Now add in all the new client links. */
+ foreach ($clients as $client) {
+ $to_parameters = array('source' => $clientsource, 'id' => $client);
+ $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
+ if (is_a($status, 'PEAR_Error')) {
+ $notification->push($status, 'horde.error');
+ } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
+ $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
+ $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
+ } else {
+ $notification->push(_("Link added."), 'horde.success');
+ }
}
}
Index: create.php
===================================================================
RCS file: /repository/whups/create.php,v
retrieving revision 1.37
diff -u -r1.37 create.php
--- create.php 8 Aug 2003 12:55:04 -0000 1.37
+++ create.php 11 Aug 2003 04:04:01 -0000
@@ -152,33 +152,35 @@
$message .= _("An appropriate person has been notified of this request.");
$notification->push($message, 'horde.success');
- /* Add a link from this ticket to the selected client. */
- if (!empty($info['client'])) {
- $clientsource = $GLOBALS['registry']->call('clients/getClientSource');
- require_once HORDE_BASE . '/lib/Links.php';
- $links = &Horde_Links::singleton($registry->getApp());
+ if ($GLOBALS['registry']->hasMethod('clients/getClientSource')) {
+ /* Add a link from this ticket to the selected client. */
+ if (!empty($info['client'])) {
+ $clientsource = $GLOBALS['registry']->call('clients/getClientSource');
+ require_once HORDE_BASE . '/lib/Links.php';
+ $links = &Horde_Links::singleton($registry->getApp());
- // $tid needs to be a string to match properly.
- $from_parameters = array('ticket_id' => (string)$tid);
- $from_application = 'projects';
- $to_application = 'contacts';
- $link_type = 'client';
+ // $tid needs to be a string to match properly.
+ $from_parameters = array('ticket_id' => (string)$tid);
+ $from_application = 'projects';
+ $to_application = 'contacts';
+ $link_type = 'client';
- /* Now add in the new client link(s). */
- $clients = $info['client'];
- if (!is_array($clients)) {
- $clients = array($clients);
- }
- foreach ($clients as $client_id) {
- $to_parameters = array('source' => $clientsource, 'id' => (string)$client_id);
- $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
- if (is_a($status, 'PEAR_Error')) {
- $notification->push($status, 'horde.error');
- } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
- $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
- $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
- } else {
- $notification->push(_("Link added."), 'horde.success');
+ /* Now add in the new client link(s). */
+ $clients = $info['client'];
+ if (!is_array($clients)) {
+ $clients = array($clients);
+ }
+ foreach ($clients as $client_id) {
+ $to_parameters = array('source' => $clientsource, 'id' => (string)$client_id);
+ $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
+ if (is_a($status, 'PEAR_Error')) {
+ $notification->push($status, 'horde.error');
+ } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
+ $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
+ $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
+ } else {
+ $notification->push(_("Link added."), 'horde.success');
+ }
}
}
}
Index: details.php
===================================================================
RCS file: /repository/whups/details.php,v
retrieving revision 1.52
diff -u -r1.52 details.php
--- details.php 8 Aug 2003 12:55:04 -0000 1.52
+++ details.php 11 Aug 2003 04:04:01 -0000
@@ -347,7 +347,10 @@
$form->addAttributes($attributes);
$details['user_id_requester'] = Whups::formatUser($details['user_id_requester']);
$details['user_id_owner'] = Whups::getOwners($ticket);
- $details['client_name'] = Whups::getClients($details['module'], $ticket);
+ $client_name = Whups::getClients($details['module'], $ticket);
+ if (!empty($client_name)) {
+ $details['client_name'] = $client_name;
+ }
$RENDERER->beginInactive(sprintf(_("Ticket %s Details"), $ticket));
$RENDERER->renderFormInactive($form, new Horde_Form_Vars($details));
Index: search.php
===================================================================
RCS file: /repository/whups/search.php,v
retrieving revision 1.48
diff -u -r1.48 search.php
--- search.php 8 Aug 2003 12:55:04 -0000 1.48
+++ search.php 11 Aug 2003 04:04:01 -0000
@@ -46,13 +46,15 @@
if (Auth::getAuth()) {
$moduleInfo = $whups->getModule($info['module']);
$moduleName = !empty($moduleInfo['name']) ? $moduleInfo['name'] : _("Any");
- $clientInfo = $whups->getClientDetails($info['client']);
- $clientName = '';
- foreach ($clientInfo as $client) {
- $clientName .= !empty($clientName) ? ', ' . $client['name'] : $client['name'];
- }
- if (empty($clientName)) {
- $clientName = _("Any");
+ if ($GLOBALS['registry']->hasMethod('clients/getClient')) {
+ $clientInfo = $whups->getClientDetails($info['client']);
+ $clientName = '';
+ foreach ($clientInfo as $client) {
+ $clientName .= !empty($clientName) ? ', ' . $client['name'] : $client['name'];
+ }
+ if (empty($clientName)) {
+ $clientName = _("Any");
+ }
}
$idName = $vars->getVar('id') ? $vars->getVar('id') : _("Any");
$categories = $whups->getCategories();
@@ -93,7 +95,11 @@
array(urlencode(session_name()),
'__formToken_' . $form->getName(),
'_formvars'));
- $whups->saveSearch(sprintf(_("Module: %s, Client: %s, Ticket: %s, Category: %s, Type: %s"), $moduleName, $clientName, $idName, $catName, $typeName), $qUrl);
+ if (!empty($clientName)) {
+ $whups->saveSearch(sprintf(_("Module: %s, Client: %s, Ticket: %s, Category: %s, Type: %s"), $moduleName, $clientName, $idName, $catName, $typeName), $qUrl);
+ } else {
+ $whups->saveSearch(sprintf(_("Module: %s, Ticket: %s, Category: %s, Type: %s"), $moduleName, $idName, $catName, $typeName), $qUrl);
+ }
}
// Munge the search criteria into acceptability.
Index: docs/INSTALL
===================================================================
RCS file: /repository/whups/docs/INSTALL,v
retrieving revision 1.6
diff -u -r1.6 INSTALL
--- docs/INSTALL 8 Aug 2003 12:55:06 -0000 1.6
+++ docs/INSTALL 11 Aug 2003 04:04:02 -0000
@@ -48,12 +48,6 @@
Whups store its data in an SQL database. Build PHP with whichever
SQL driver you require; see the Horde INSTALL file for details.
- 3. A working Turba installation.
-
- Whups uses Turba address books to store information about
- clients. You must configure Turba and specify one of your
- address books as your 'Client' address book.
-
INSTALLING Whups
----------------
@@ -153,6 +147,20 @@
- Adding a ticket
- Assigning a ticket
- Closing a ticket
+
+5. Configuring Clients
+
+ Whups allows clients to be allocated to modules and to tickets. To use
+ clients you must have a working installation of Turba, and it must be
+ configured so that one of your address books is designated as the client
+ source.
+
+ To do this, click the "Configuration" icon in the Horde administration
+ menu, then select "Address Book" from the list of applications. Under
+ the heading "Name of client address book" you should enter the name of
+ the Turba address book in your system that contains your clients'
+ contact details. See the Turba documentation for more information about
+ configuring address books.
OBTAINING SUPPORT
Index: lib/Create.php
===================================================================
RCS file: /repository/whups/lib/Create.php,v
retrieving revision 1.39
diff -u -r1.39 Create.php
--- lib/Create.php 8 Aug 2003 12:55:07 -0000 1.39
+++ lib/Create.php 11 Aug 2003 04:04:02 -0000
@@ -59,14 +59,16 @@
$typetype = 'enum';
$type_params = array($types);
}
- if (count($clientlist) == 0) {
- $clienttype = 'invalid';
- $client_params = array(_("There are no clients associated with this module; until there are, you cannot create any tickets in this module."));
- } else {
- $clienttype = 'multienum';
- $client_params = array($clientlist);
+ if ($GLOBALS['registry']->hasMethod('clients/clientSearch')) {
+ if (count($clientlist) == 0) {
+ $clienttype = 'invalid';
+ $client_params = array(_("There are no clients associated with this module; until there are, you cannot create any tickets in this module."));
+ } else {
+ $clienttype = 'multienum';
+ $client_params = array($clientlist);
+ }
+ $this->addVariable(_("Client"), 'client', $clienttype, true, false, null, $client_params);
}
- $this->addVariable(_("Client"), 'client', $clienttype, true, false, null, $client_params);
$this->addVariable(_("Ticket Type"), 'type', $typetype, true, false, null, $type_params);
if (!empty($info['versioned'])) {
Index: lib/Driver.php
===================================================================
RCS file: /repository/whups/lib/Driver.php,v
retrieving revision 1.56
diff -u -r1.56 Driver.php
--- lib/Driver.php 8 Aug 2003 12:55:07 -0000 1.56
+++ lib/Driver.php 11 Aug 2003 04:04:02 -0000
@@ -73,23 +73,25 @@
{
/* Get client data from the clients API provider. */
$clients = array();
- $args = array('addresses' => array(''),
- 'fields' => array('name'));
- $results = $GLOBALS['registry']->call('clients/clientSearch', $args);
- $clientlist = $results[''];
- if (!empty($clientlist)) {
- foreach ($clientlist as $client) {
- $clients[$client['id']] = $client['name'];
+ if ($GLOBALS['registry']->hasMethod('clients/clientSearch')) {
+ $args = array('addresses' => array(''),
+ 'fields' => array('name'));
+ $results = $GLOBALS['registry']->call('clients/clientSearch', $args);
+ $clientlist = $results[''];
+ if (!empty($clientlist)) {
+ foreach ($clientlist as $client) {
+ $clients[$client['id']] = $client['name'];
+ }
+ }
+ if (!empty($module)) {
+ $clients = $this->filterClientLinks('module', $clients, $module);
+ }
+ if (!empty($ticket)) {
+ $clients = $this->filterClientLinks('ticket', $clients, $ticket);
+ }
+ if (is_a('PEAR_Error', $clients)) {
+ $notification->push(_("Could not access client list."));
}
- }
- if (!empty($module)) {
- $clients = $this->filterClientLinks('module', $clients, $module);
- }
- if (!empty($ticket)) {
- $clients = $this->filterClientLinks('ticket', $clients, $ticket);
- }
- if (is_a('PEAR_Error', $clients)) {
- $notification->push(_("Could not access client list."));
}
return $clients;
@@ -99,11 +101,14 @@
{
/* Gets client records from the client API. Records must
* minimally have a 'key' and a 'name' attribute. */
+
$results = array();
- /* Get client data from the client provider. */
- foreach ($clients as $client_id) {
- $args = array('key' => $client_id);
- $results[] = $GLOBALS['registry']->call('contacts/getClient', $args);
+ if ($GLOBALS['registry']->hasMethod('clients/getClient')) {
+ /* Get client data from the client provider. */
+ foreach ($clients as $client_id) {
+ $args = array('key' => $client_id);
+ $results[] = $GLOBALS['registry']->call('clients/getClient', $args);
+ }
}
return $results;
Index: lib/Search.php
===================================================================
RCS file: /repository/whups/lib/Search.php,v
retrieving revision 1.58
diff -u -r1.58 Search.php
--- lib/Search.php 8 Aug 2003 12:55:07 -0000 1.58
+++ lib/Search.php 11 Aug 2003 04:04:02 -0000
@@ -38,15 +38,17 @@
$this->addVariable(_("Ticket ID"), 'id', 'intlist', false);
$this->addVariable(_("Module Name"), 'module', $modtype, false, false, null, $type_params);
- $clients = Whups::getClients('', '', 'array');
- if (count($clients)) {
- $clienttype = 'multienum';
- $type_params = array($clients);
- } else {
- $clienttype = 'invalid';
- $type_params = array(_("There are no clients which you can search."));
+ if ($GLOBALS['registry']->hasMethod('clients/clientSearch')) {
+ $clients = Whups::getClients('', '', 'array');
+ if (count($clients)) {
+ $clienttype = 'multienum';
+ $type_params = array($clients);
+ } else {
+ $clienttype = 'invalid';
+ $type_params = array(_("There are no clients which you can search."));
+ }
+ $this->addVariable(_("Client"), 'client', $clienttype, false, false, null, $type_params);
}
- $this->addVariable(_("Client"), 'client', $clienttype, false, false, null, $type_params);
$cats = &$this->addVariable(_("Tickets which are"), 'category', 'multienum', false, false, _("If you don't select any categories, no filtering will be done on ticket category."), array($whups->getCategories(), 4));
$cats->setDefault(array('unconfirmed', 'new', 'assigned'));