alecpl
2011-06-16 cc90ed1f84174a89039feb6906775778e0c4eb18
- Add addressbook name in contact info frame (#1487958)


7 files modified
84 ■■■■ changed files
program/include/rcube_addressbook.php 5 ●●●●● patch | view | raw | blame | history
program/include/rcube_contacts.php 10 ●●●●● patch | view | raw | blame | history
program/include/rcube_ldap.php 48 ●●●● patch | view | raw | blame | history
program/steps/addressbook/func.inc 1 ●●●● patch | view | raw | blame | history
program/steps/addressbook/show.inc 9 ●●●●● patch | view | raw | blame | history
skins/default/addressbook.css 7 ●●●●● patch | view | raw | blame | history
skins/default/templates/contact.html 4 ●●●● patch | view | raw | blame | history
program/include/rcube_addressbook.php
@@ -47,6 +47,11 @@
    protected $error;
    /**
     * Returns addressbook name (e.g. for addressbooks listing)
     */
    abstract function get_name();
    /**
     * Save a search string for future listings
     *
     * @param mixed Search params to use in listing method, obtained by get_search_set()
program/include/rcube_contacts.php
@@ -41,6 +41,7 @@
    private $user_id = 0;
    private $filter = null;
    private $result = null;
    private $name;
    private $cache;
    private $table_cols = array('name', 'email', 'firstname', 'surname');
    private $fulltext_cols = array('name', 'firstname', 'surname', 'middlename', 'nickname',
@@ -76,6 +77,15 @@
    /**
     * Returns addressbook name
     */
     function get_name()
     {
        return $this->name;
     }
    /**
     * Save a search string for future listings
     *
     * @param  string SQL params to use in listing method
program/include/rcube_ldap.php
@@ -296,6 +296,7 @@
    *
    * @param string Bind DN
    * @param string Bind password
     *
    * @return boolean True on success, False on error
    */
    private function _bind($dn, $pass)
@@ -338,10 +339,20 @@
    /**
     * Returns address book name
     *
     * @return string Address book name
     */
    function get_name()
    {
        return $this->prop['name'];
    }
    /**
    * Set internal list page
    *
    * @param  number  Page number to list
    * @access public
     * @param number $page Page number to list
    */
    function set_page($page)
    {
@@ -352,8 +363,7 @@
    /**
    * Set internal page size
    *
    * @param  number  Number of messages to display on one page
    * @access public
     * @param number $size Number of messages to display on one page
    */
    function set_pagesize($size)
    {
@@ -364,7 +374,7 @@
    /**
    * Save a search string for future listings
    *
    * @param string Filter string
     * @param string $filter Filter string
    */
    function set_search_set($filter)
    {
@@ -399,6 +409,7 @@
    *
    * @param  array  List of cols to show
    * @param  int    Only return this number of records
     *
    * @return array  Indexed list of contact records, each a hash array
    */
    function list_records($cols=null, $subset=0)
@@ -585,6 +596,7 @@
    *
    * @param mixed   Record identifier
    * @param boolean Return as associative array
     *
    * @return mixed  Hash array or rcube_result_set with all record fields
    */
    function get_record($dn, $assoc=false)
@@ -624,6 +636,7 @@
     * If input not valid, the message to display can be fetched using get_error()
     *
     * @param array Assoziative array with data to save
     *
     * @return boolean True if input is valid, False if not.
     */
    public function validate($save_data)
@@ -643,6 +656,7 @@
    * Create a new contact record
    *
    * @param array    Hash array with save data
     *
    * @return encoded record ID on success, False on error
    */
    function insert($save_cols)
@@ -702,6 +716,7 @@
    *
    * @param mixed Record identifier
    * @param array Hash array with save data
     *
    * @return boolean True on success, False on error
    */
    function update($id, $save_cols)
@@ -713,6 +728,7 @@
        $newdata = array();
        $replacedata = array();
        $deletedata = array();
        foreach ($this->fieldmap as $col => $fld) {
            $val = $save_cols[$col];
            if ($fld) {
@@ -819,6 +835,7 @@
    * Mark one or more contact records as deleted
    *
    * @param array  Record identifiers
     *
    * @return boolean True on success, False on error
    */
    function delete($ids)
@@ -857,8 +874,6 @@
    /**
    * Execute the LDAP search based on the stored credentials
    *
    * @access private
    */
    private function _exec_search($count = false)
    {
@@ -917,7 +932,7 @@
    /**
    * @access private
     * Converts LDAP entry into an array
    */
    private function _ldap2result($rec)
    {
@@ -947,7 +962,7 @@
    /**
    * @access private
     * Return real field name (from fields map)
    */
    private function _map_field($field)
    {
@@ -956,9 +971,9 @@
    /**
    * @access private
     * Returns unified attribute name (resolving aliases)
    */
    private function _attr_name($name)
    private static function _attr_name($name)
    {
        // list of known attribute aliases
        $aliases = array(
@@ -973,7 +988,7 @@
    /**
    * @access private
     * Prints debug info to the log
    */
    private function _debug($str)
    {
@@ -983,9 +998,14 @@
    /**
    * @static
     * Quotes attribute value string
     *
     * @param string $str Attribute value
     * @param bool   $dn  True if the attribute is a DN
     *
     * @return string Quoted string
    */
    private function _quote_string($str, $dn=false)
    private static function _quote_string($str, $dn=false)
    {
        // take firt entry if array given
        if (is_array($str))
program/steps/addressbook/func.inc
@@ -81,6 +81,7 @@
    $OUTPUT->set_env('address_sources', $js_list);
    $OUTPUT->set_pagetitle(rcube_label('addressbook'));
    $_SESSION['addressbooks_count'] = count($js_list);
    $CONTACTS = rcmail_contact_source($source, true);
}
program/steps/addressbook/show.inc
@@ -32,6 +32,15 @@
    $OUTPUT->set_env('cid', $record['ID']);
}
// get address book name (for display)
if ($_SESSION['addressbooks_count'] > 1) {
    $name = $CONTACTS->get_name();
    if (!$name && $source == 0) {
        $name = rcube_label('personaladrbook');
    }
    $OUTPUT->set_env('sourcename', $name);
}
// return raw photo of the given contact
if ($RCMAIL->action == 'photo') {
    if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) {
skins/default/addressbook.css
@@ -384,3 +384,10 @@
{
    padding: 2px;
}
#sourcename
{
  color: #666;
  font-size: 10px;
  margin-left: 2px;
}
skins/default/templates/contact.html
@@ -9,6 +9,10 @@
<div id="contact-title" class="boxtitle"><roundcube:label name="contactproperties" /></div>
<div id="contact-details" class="boxcontent">
  <roundcube:if condition="strlen(env:sourcename)" />
    <div id="sourcename"><roundcube:label name="addressbook" />: <roundcube:var name="env:sourcename" /></div>
  <roundcube:endif />
  <div id="contactphoto"><roundcube:object name="contactphoto" id="contactpic" placeholder="/images/contactpic.png" /></div>
  <roundcube:object name="contacthead" id="contacthead" />
  <div style="clear:both"></div>