Aleksander Machniak
2015-08-07 1b39d9a6c744a393e7930c2493cc2ddc9c9e95bf
program/lib/Roundcube/rcube_ldap.php
@@ -1,6 +1,6 @@
<?php
/*
/**
 +-----------------------------------------------------------------------+
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2006-2013, The Roundcube Dev Team                       |
@@ -239,10 +239,9 @@
        $this->_connect();
    }
    /**
    * Establish a connection to the LDAP server
    */
     * Establish a connection to the LDAP server
     */
    private function _connect()
    {
        $rcube = rcube::get_instance();
@@ -439,7 +438,6 @@
        return $this->ready;
    }
    /**
     * Close connection to LDAP server
     */
@@ -450,7 +448,6 @@
        }
    }
    /**
     * Returns address book name
     *
@@ -460,7 +457,6 @@
    {
        return $this->prop['name'];
    }
    /**
     * Set internal list page
@@ -484,7 +480,6 @@
        $this->ldap->set_vlv_page($this->list_page, $this->page_size);
    }
    /**
     * Set internal sort settings
     *
@@ -497,7 +492,6 @@
            $this->sort_col = $this->coltypes[$sort_col]['attributes'][0];
    }
    /**
     * Save a search string for future listings
     *
@@ -507,7 +501,6 @@
    {
        $this->filter = $filter;
    }
    /**
     * Getter for saved search properties
@@ -519,7 +512,6 @@
        return $this->filter;
    }
    /**
     * Reset all saved results and search parameters
     */
@@ -530,14 +522,13 @@
        $this->filter = '';
    }
    /**
     * List the current set of contact records
     *
     * @param  array  List of cols to show
     * @param  int    Only return this number of records
     * @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
     * @return array Indexed list of contact records, each a hash array
     */
    function list_records($cols=null, $subset=0)
    {
@@ -736,7 +727,6 @@
        return strcmp($a[$this->sort_col][0], $b[$this->sort_col][0]);
    }
    /**
     * Search contacts
     *
@@ -843,13 +833,12 @@
            }
            else {
                // map address book fields into ldap attributes
                $me         = $this;
                $attributes = array();
                array_walk($fields, function($field) use ($me, &$attributes) {
                    if ($me->coltypes[$field] && ($attrs = (array)$me->coltypes[$field]['attributes'])) {
                        $attributes = array_merge($attributes, $attrs);
                foreach ((array) $fields as $field) {
                    if ($this->coltypes[$field] && ($attrs = $this->coltypes[$field]['attributes'])) {
                        $attributes = array_merge($attributes, (array) $attrs);
                    }
                });
                }
            }
            // compose a full-text-like search filter
@@ -892,7 +881,6 @@
        return $this->result;
    }
    /**
     * Count number of available contacts in database
     *
@@ -920,7 +908,6 @@
        return new rcube_result_set($count, ($this->list_page-1) * $this->page_size);
    }
    /**
     * Return the last result set
@@ -989,7 +976,6 @@
        return $err;
    }
    /**
     * Check the given data before saving.
@@ -1062,15 +1048,17 @@
        return true;
    }
    /**
     * Create a new contact record
     *
     * @param array    Hash array with save data
     * @param array Associative array with save data
     *  Keys:   Field name with optional section in the form FIELD:SECTION
     *  Values: Field value. Can be either a string or an array of strings for multiple values
     * @param boolean True to check for duplicates first
     *
     * @return encoded record ID on success, False on error
     * @return mixed The created record ID on success, False on error
     */
    function insert($save_cols)
    function insert($save_cols, $check = false)
    {
        // Map out the column names to their LDAP ones to build the new entry.
        $newentry = $this->_map_data($save_cols);
@@ -1131,7 +1119,6 @@
        return $dn;
    }
    /**
     * Update a specific contact record
@@ -1314,7 +1301,6 @@
        return $newdn ? $newdn : true;
    }
    /**
     * Mark one or more contact records as deleted
     *
@@ -1363,7 +1349,6 @@
        return count($ids);
    }
    /**
     * Remove all contact records
@@ -1433,7 +1418,6 @@
        }
    }
    /**
     * Converts LDAP entry into an array
     */
@@ -1492,7 +1476,6 @@
        return $out;
    }
    /**
     * Return LDAP attribute(s) for the given field
     */
@@ -1500,7 +1483,6 @@
    {
        return (array)$this->coltypes[$field]['attributes'];
    }
    /**
     * Convert a record data set into LDAP field attributes
@@ -2043,7 +2025,6 @@
        return $default;
    }
    /**
     * HTML-safe DN string encoding
     *
@@ -2070,5 +2051,4 @@
        $str = str_pad(strtr($str, '-_', '+/'), strlen($str) % 4, '=', STR_PAD_RIGHT);
        return base64_decode($str);
    }
}