[imp] Adding Contact from Global to Personal Abook
Rob Wiltbank
chade at hopi.dtcc.edu
Wed Aug 13 05:09:16 PDT 2003
I'm attempting to modify the address book to allow folks to add contacts
from a global addressbook (LDAP) to their personal addressbook (local
sql). I'm nearing the end, but I'm having an issue with one thing...
The user looks up a name, clicks the add link, the addobject.php form is
populated with the user information from the lookup, however, when the
user clicks the save button, the resolves to a blank page. Going through
the addobjectaction.php, it seems to be gacking when it attempts to create
the key:
/* Create Object */
$key = $driver->addObject($object);
$driver seems to contain data, as well as $object, however, $key winds up
empty, and I believe that is what causes the actual save to fail.
I've included a patch with the code I have written so far -- any thoughts
or suggestions would be greatly appreciated.
Rob
--
*******************************************************************
* Rob Wiltbank * Delaware Technical & Community College *
* Application Specialist * Computer Services Department *
* chade at hopi.dtcc.edu * Wilmington Campus *
* 302.571.5398 * Lackey @ Large *
*******************************************************************
-------------- next part --------------
diff -urabB ../../horde.orig/turba/addobject.php ./addobject.php
--- ../../horde.orig/turba/addobject.php 2003-05-26 14:36:03.000000000 -0400
+++ ./addobject.php 2003-08-12 10:11:52.000000000 -0400
@@ -16,6 +16,25 @@
require_once TURBA_BASE . '/lib/ObjectView.php';
require_once TURBA_BASE . '/lib/AbstractObject.php';
+//
+// Added 8/11/03 by Rob
+// Add contact from global list.
+//
+// As long as we're at *least* sent and
+// email address we can build an entry.
+if (isset($_GET['incEmail'])) {
+ $incoming['Name'] = $_GET['incName'];
+ $incoming['Fullname'] = $_GET['incFullname'];
+ $incoming['Department'] = $_GET['incDepartment'];
+ $incoming['Givenname'] = $_GET['incGivenname'];
+ $incoming['Surname'] = $_GET['incSurname'];
+ $temparray = preg_split("/\?key=/", $_GET['incEmail']);
+ $incoming['Email'] = $temparray[0];
+ $key = htmlspecialchars($temparray[1]);
+}
+else
+ $incoming = NULL;
+
$title = _("Add a new contact");
$js_onLoad = null;
require TURBA_TEMPLATES . '/common-header.inc';
@@ -46,7 +65,7 @@
} else {
$object = new Turba_AbstractObject($driver);
$view = new Turba_ObjectView($object, TURBA_TEMPLATES . '/add/add.inc');
- $view->display();
+ $view->display($incoming); //Pass query string array.
}
} else {
include TURBA_TEMPLATES . '/add/select.inc';
diff -urabB ../../horde.orig/turba/displayobject.php ./displayobject.php
--- ../../horde.orig/turba/displayobject.php 2003-05-26 14:36:03.000000000 -0400
+++ ./displayobject.php 2003-08-12 09:55:37.000000000 -0400
@@ -31,7 +31,7 @@
require TURBA_BASE . '/status.php';
if (isset($view) && is_object($view)) {
- $view->display();
+ $view->display(NULL); //Pass NULL since view accepts argument.
}
require TURBA_TEMPLATES . '/common-footer.inc';
diff -urabB ../../horde.orig/turba/editobject.php ./editobject.php
--- ../../horde.orig/turba/editobject.php 2003-05-26 14:36:03.000000000 -0400
+++ ./editobject.php 2003-08-12 09:29:33.000000000 -0400
@@ -40,7 +40,7 @@
require TURBA_BASE . '/status.php';
if (isset($view) && is_object($view)) {
- $view->display();
+ $view->display(NULL);
}
require TURBA_TEMPLATES . '/common-footer.inc';
diff -urabB ../../horde.orig/turba/lib/ObjectView.php ./lib/ObjectView.php
--- ../../horde.orig/turba/lib/ObjectView.php 2002-04-12 12:10:07.000000000 -0400
+++ ./lib/ObjectView.php 2003-08-12 09:56:03.000000000 -0400
@@ -41,7 +41,12 @@
/**
* Renders the object into an HTML view.
*/
- function display()
+ //
+ // Added 8/11/03 by Rob
+ // Add contact from global list.
+ //
+ // @param $incoming Array containing query string information.
+ function display($incoming)
{
include TURBA_BASE . '/config/attributes.php';
diff -urabB ../../horde.orig/turba/templates/add/add.inc ./templates/add/add.inc
--- ../../horde.orig/turba/templates/add/add.inc 2003-05-26 14:36:03.000000000 -0400
+++ ./templates/add/add.inc 2003-08-12 10:13:28.000000000 -0400
@@ -41,7 +42,35 @@
</tr>
<?php
else:
+// (commented) $value = htmlspecialchars($this->object->getValue($key));
+// Added 8/11/03 by Rob
+// Add contact from global list.
+//
+// Populate form with global addressbook data.
+//
+ switch($key) {
+ case "fullname":
+ $value = $incoming['Fullname'];
+ break;
+ case "email":
+ $value = $incoming['Email'];
+ break;
+ case "name":
+ $value = $incoming['Name'];
+ break;
+ case "department":
+ $value = $incoming['Department'];
+ break;
+ case "surname":
+ $value = $incoming['Surname'];
+ break;
+ case "givenname":
+ $value = $incoming['Givenname'];
+ break;
+ default:
$value = htmlspecialchars($this->object->getValue($key));
+ break;
+ }
?>
<tr>
<td class="light" align="right"><b><?php echo $field['desc'] ?> </b></td>
diff -urabB ../../horde.orig/turba/templates/display/display.inc ./templates/display/display.inc
--- ../../horde.orig/turba/templates/display/display.inc 2003-05-26 14:36:03.000000000 -0400
+++ ./templates/display/display.inc 2003-08-12 10:44:02.000000000 -0400
@@ -88,6 +88,29 @@
}
}
$value = htmlspecialchars($this->object->getValue($key));
+
+ //
+ // Added 8/11/03 by Rob
+ // Add contact from global list.
+ //
+ // Grab contact information.
+ switch($key) {
+ case "name":
+ $incName = $value;
+ break;
+ case "fullname":
+ $incFullname = $value;
+ break;
+ case "department":
+ $incDepartment = $value;
+ break;
+ case "surname":
+ $incSurname = $value;
+ break;
+ case "givenname":
+ $incGivenname = $value;
+ break;
+ }
}
?>
<tr>
@@ -105,5 +128,22 @@
</tr>
<?php endif; ?>
+<?php if (!($this->object->isEditable())):
+ //
+ // Added 8/11/03 by Rob
+ // Add contact from global list.
+ //
+ // Assemble email address and build href link. Then,
+ // create the link.
+ $incEmail = $mailbox_host[0] . "@" . $mailbox_host[1];
+ $strLink = "addobject.php?incName=$incName&incFullname=$incFullname&incDepartment=$incDepartment&incSurname=$incSurname&incGivenname=$incGivenname&incEmail=$incEmail";
+?>
+<tr>
+ <td colspan="2" class="header" align="right"><span class="smallheader">
+ <?php echo Horde::link(Horde::applicationUrl($strLink . $url), _("Add"), 'menuitem') . _("Add") ?></a>
+ </span></td>
+</tr>
+
+<?php endif; ?>
</table>
</form>
More information about the imp
mailing list