summaryrefslogtreecommitdiff
path: root/program/steps/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r--program/steps/addressbook/delete.inc5
-rw-r--r--program/steps/addressbook/edit.inc3
-rw-r--r--program/steps/addressbook/func.inc56
3 files changed, 45 insertions, 19 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index f91b9ac42..df1e4073e 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -19,7 +19,10 @@
*/
-if (($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $cid))
+if (($cid = get_input_value('_cid', RCUBE_INPUT_POST)) &&
+ (preg_match('/^[0-9]+(,[0-9]+)*$/', $cid) ||
+ preg_match('/^[a-zA-Z0-9=]+(,[a-zA-Z0-9=]+)*$/', $cid))
+ )
{
$deleted = $CONTACTS->delete($cid);
if (!$deleted)
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc
index 64eab86eb..9cda22b5b 100644
--- a/program/steps/addressbook/edit.inc
+++ b/program/steps/addressbook/edit.inc
@@ -91,6 +91,7 @@ function get_form_tags($attrib)
{
$hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
$hiddenfields->add(array('name' => '_action', 'value' => 'save', 'source' => get_input_value('_source', RCUBE_INPUT_GPC)));
+ $hiddenfields->add(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
if (($result = $CONTACTS->get_result()) && ($record = $result->first()))
$hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
@@ -117,4 +118,4 @@ if (!$CONTACTS->get_result() && template_exists('addcontact'))
// this will be executed if no template for addcontact exists
$OUTPUT->send('editcontact');
-?> \ No newline at end of file
+?>
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index 28b540ac8..a08b5510c 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -22,8 +22,17 @@
// instantiate a contacts object according to the given source
if (($source = get_input_value('_source', RCUBE_INPUT_GPC)) && isset($CONFIG['ldap_public'][$source]))
$CONTACTS = new rcube_ldap($CONFIG['ldap_public'][$source]);
-else
- $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
+else {
+ if (!$CONFIG["use_SQL_address_book"]) {
+ // Get the first LDAP address book.
+ $source = key((array)$CONFIG['ldap_public']);
+ $prop = current((array)$CONFIG['ldap_public']);
+ $CONTACTS = new rcube_ldap($prop);
+ } // end if
+ else {
+ $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
+ } // end else
+} // end else
$CONTACTS->set_pagesize($CONFIG['pagesize']);
@@ -42,9 +51,13 @@ $OUTPUT->set_env('source', $source ? $source : '0');
$OUTPUT->set_env('readonly', $CONTACTS->readonly, false);
// add list of address sources to client env
-$js_list = array("0" => array('id' => 0, 'readonly' => false));
+$js_list = array();
+if ($CONFIG["use_SQL_address_book"]) {
+ // We are using the DB address book, add it.
+ $js_list = array("0" => array('id' => 0, 'readonly' => false));
+} // end if
foreach ((array)$CONFIG['ldap_public'] as $id => $prop)
- $js_list[$id] = array('id' => $id, 'readonly' => !$prop['writeable']);
+ $js_list[$id] = array('id' => $id, 'readonly' => !$prop['writable']);
$OUTPUT->set_env('address_sources', $js_list);
@@ -66,19 +79,28 @@ function rcmail_directory_list($attrib)
// allow the following attributes to be added to the <ul> tag
$out = '<ul' . create_attrib_string($attrib, array('style', 'class', 'id')) . ">\n";
- $out .= sprintf($line_templ,
- 'rcmli'.$local_id,
- !$current ? 'selected' : '',
- Q(rcmail_url('list', array('_source' => 0))),
- JS_OBJECT_NAME,
- $local_id,
- JS_OBJECT_NAME,
- $local_id,
- JS_OBJECT_NAME,
- $local_id,
- JS_OBJECT_NAME,
- $local_id,
- rcube_label('personaladrbook'));
+ if ($CONFIG["use_SQL_address_book"]) {
+ $out .= sprintf($line_templ,
+ 'rcmli'.$local_id,
+ !$current ? 'selected' : '',
+ Q(rcmail_url('list', array('_source' => 0))),
+ JS_OBJECT_NAME,
+ $local_id,
+ JS_OBJECT_NAME,
+ $local_id,
+ JS_OBJECT_NAME,
+ $local_id,
+ JS_OBJECT_NAME,
+ $local_id,
+ rcube_label('personaladrbook'));
+ } // end if
+ else {
+ // DB address book not used, see if a source is set, if not use the
+ // first LDAP directory.
+ if (!$current) {
+ $current = key((array)$CONFIG['ldap_public']);
+ } // end if
+ } // end else
foreach ((array)$CONFIG['ldap_public'] as $id => $prop)
{