]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/steps/addressbook/func.inc
Imported Upstream version 0.2~stable
[roundcube.git] / program / steps / addressbook / func.inc
index 068fdb762bfc17e39624737f27f181f79e8354e9..d87c2f892ebf02bd15ff269bbf0c7e986b342e55 100644 (file)
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: func.inc 1412 2008-05-21 07:45:54Z alec $
+ $Id: func.inc 1939 2008-10-05 07:18:15Z alec $
 
 */
 
 // 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 if (strtolower($CONFIG['address_book_type']) == 'ldap') {
-    // Get the first LDAP address book.
-    $source = key((array)$CONFIG['ldap_public']);
-    $prop = current((array)$CONFIG['ldap_public']);
-    $CONTACTS = new rcube_ldap($prop);
-} else {
-    $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
-} // end else
+$CONTACTS = $RCMAIL->get_address_book(($source = get_input_value('_source', RCUBE_INPUT_GPC)));
 
 $CONTACTS->set_pagesize($CONFIG['pagesize']);
 
@@ -52,9 +43,11 @@ $js_list = array();
 if (strtolower($CONFIG['address_book_type']) != 'ldap') {
   // 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['writable']);
+}
+if (is_array($CONFIG['ldap_public'])) {
+  foreach ($CONFIG['ldap_public'] as $id => $prop)
+    $js_list[$id] = array('id' => $id, 'readonly' => !$prop['writable']);
+}
 $OUTPUT->set_env('address_sources', $js_list);
 
 
@@ -65,31 +58,15 @@ function rcmail_directory_list($attrib)
   if (!$attrib['id'])
     $attrib['id'] = 'rcmdirectorylist';
 
+  $out = '';
   $local_id = '0';
   $current = get_input_value('_source', RCUBE_INPUT_GPC);
-  $line_templ = '<li id="%s" class="%s"><a href="%s"' .
-    ' onclick="return %s.command(\'list\',\'%s\',this)"' .
-    ' onmouseover="return %s.focus_folder(\'%s\')"' .
-    ' onmouseout="return %s.unfocus_folder(\'%s\')"' .
-    ' onmouseup="return %s.folder_mouse_up(\'%s\')">%s'.
-    "</a></li>\n";
+  $line_templ = html::tag('li', array('id' => 'rcmli%s', 'class' => '%s'),
+    html::a(array('href' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
     
-  // allow the following attributes to be added to the <ul> tag
-  $out = '<ul' . create_attrib_string($attrib, array('style', 'class', 'id')) . ">\n";
   if (strtolower($CONFIG['address_book_type']) != 'ldap') {
-    $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'));
+    $out .= sprintf($line_templ, $local_id, (!$current ? 'selected' : ''),
+      Q(rcmail_url(null, array('_source' => $local_id))), $local_id, rcube_label('personaladrbook'));
   } // end if
   else {
     // DB address book not used, see if a source is set, if not use the
@@ -99,30 +76,16 @@ function rcmail_directory_list($attrib)
     } // end if
   } // end else
   
-  foreach ((array)$CONFIG['ldap_public'] as $id => $prop)
-  {
+  foreach ((array)$CONFIG['ldap_public'] as $id => $prop) {
     $js_id = JQ($id);
     $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id);
-    $out .= sprintf($line_templ,
-      'rcmli'.$dom_id,
-      $current == $id ? 'selected' : '',
-      Q(rcmail_url('list', array('_source' => $id))),
-      JS_OBJECT_NAME,
-      $js_id,
-      JS_OBJECT_NAME,
-      $js_id,
-      JS_OBJECT_NAME,
-      $js_id,
-      JS_OBJECT_NAME,
-      $js_id,
-      !empty($prop['name']) ? Q($prop['name']) : Q($id));
+    $out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''),
+      Q(rcmail_url(null, array('_source' => $id))), $js_id, (!empty($prop['name']) ? Q($prop['name']) : Q($id)));
   }
   
-  $out .= '</ul>';
-
   $OUTPUT->add_gui_object('folderlist', $attrib['id']);
   
-  return $out;
+  return html::tag('ul', $attrib, $out, html::$common_attrib);
 }
 
 
@@ -151,7 +114,7 @@ function rcmail_contacts_list($attrib)
   $OUTPUT->include_script('list.js');
   
   // add some labels to client
-  rcube_add_label('deletecontactconfirm');
+  $OUTPUT->add_label('deletecontactconfirm');
   
   return $out;
   }
@@ -189,11 +152,11 @@ function rcmail_contact_frame($attrib)
     $attrib['id'] = 'rcmcontactframe';
     
   $attrib['name'] = $attrib['id'];
-  $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
 
   $OUTPUT->set_env('contentframe', $attrib['name']);
   $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
-  return '<iframe'. $attrib_str . '></iframe>';
+
+  return html::iframe($attrib);
   }
 
 
@@ -206,13 +169,7 @@ function rcmail_rowcount_display($attrib)
 
   $OUTPUT->add_gui_object('countdisplay', $attrib['id']);
 
-  // allow the following attributes to be added to the <span> tag
-  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
-
-  $out = '<span' . $attrib_str . '>';
-  $out .= rcmail_get_rowcount_text();
-  $out .= '</span>';
-  return $out;
+  return html::span($attrib, rcmail_get_rowcount_text());
   }
 
 
@@ -240,6 +197,7 @@ function rcmail_get_rowcount_text()
   return $out;
   }
 
+
 $OUTPUT->set_pagetitle(rcube_label('addressbook'));
   
 // register UI objects