Example #1
0
 public function __construct($dbid)
 {
     $dbh = rcmail::get_instance()->db;
     $this->ready = $dbh && !$dbh->is_error();
     $this->groups = true;
     $this->readonly = false;
     $this->id = $dbid;
     $this->config = self::carddavconfig($dbid);
     $prefs = carddav_common::get_adminsettings();
     if ($this->config['presetname']) {
         if ($prefs[$this->config['presetname']]['readonly']) {
             $this->readonly = true;
         }
     }
     $this->coltypes = array('name' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('name'), 'category' => 'main'), 'firstname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('firstname'), 'category' => 'main'), 'surname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('surname'), 'category' => 'main'), 'email' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('email'), 'subtypes' => array('home', 'work', 'other', 'internet'), 'category' => 'main'), 'middlename' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('middlename'), 'category' => 'main'), 'prefix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('nameprefix'), 'category' => 'main'), 'suffix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('namesuffix'), 'category' => 'main'), 'nickname' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('nickname'), 'category' => 'main'), 'jobtitle' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('jobtitle'), 'category' => 'main'), 'organization' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('organization'), 'category' => 'main'), 'department' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('department'), 'category' => 'main'), 'gender' => array('type' => 'select', 'limit' => 1, 'label' => rcube_label('gender'), 'options' => array('male' => rcube_label('male'), 'female' => rcube_label('female')), 'category' => 'personal'), 'phone' => array('type' => 'text', 'size' => 40, 'maxlength' => 20, 'label' => rcube_label('phone'), 'subtypes' => array('home', 'home2', 'work', 'work2', 'mobile', 'cell', 'main', 'homefax', 'workfax', 'car', 'pager', 'video', 'assistant', 'other'), 'category' => 'main'), 'address' => array('type' => 'composite', 'label' => rcube_label('address'), 'subtypes' => array('home', 'work', 'other'), 'childs' => array('street' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('street'), 'category' => 'main'), 'locality' => array('type' => 'text', 'size' => 28, 'maxlength' => 50, 'label' => rcube_label('locality'), 'category' => 'main'), 'zipcode' => array('type' => 'text', 'size' => 8, 'maxlength' => 15, 'label' => rcube_label('zipcode'), 'category' => 'main'), 'region' => array('type' => 'text', 'size' => 12, 'maxlength' => 50, 'label' => rcube_label('region'), 'category' => 'main'), 'country' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('country'), 'category' => 'main')), 'category' => 'main'), 'birthday' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('birthday'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'), 'anniversary' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('anniversary'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'), 'website' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('website'), 'subtypes' => array('homepage', 'work', 'blog', 'profile', 'other'), 'category' => 'main'), 'notes' => array('type' => 'textarea', 'size' => 40, 'rows' => 15, 'maxlength' => 500, 'label' => rcube_label('notes'), 'limit' => 1), 'photo' => array('type' => 'image', 'limit' => 1, 'category' => 'main'), 'assistant' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('assistant'), 'category' => 'personal'), 'manager' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('manager'), 'category' => 'personal'), 'spouse' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('spouse'), 'category' => 'personal'));
     /* }}} */
     $this->addextrasubtypes();
 }
Example #2
0
 function cd_save($args)
 {
     $this->add_texts('localization/', false);
     if ($args['section'] != 'cd_preferences') {
         return;
     }
     $prefs = carddav_common::get_adminsettings();
     if (isset($prefs['_GLOBAL']['hide_preferences']) && $prefs['_GLOBAL']['hide_preferences'] === TRUE) {
         return;
     }
     // update existing in DB
     $abooks = carddav_backend::get_dbrecord($_SESSION['user_id'], 'id,presetname', 'addressbooks', false, 'user_id');
     foreach ($abooks as $abook) {
         $abookid = $abook['id'];
         if (isset($_POST[$abookid . "_cd_delete"])) {
             self::delete_abook($abookid);
         } else {
             $newset = array('name' => get_input_value($abookid . "_cd_name", RCUBE_INPUT_POST), 'username' => get_input_value($abookid . "_cd_username", RCUBE_INPUT_POST, true), 'url' => get_input_value($abookid . "_cd_url", RCUBE_INPUT_POST), 'active' => isset($_POST[$abookid . '_cd_active']) ? 1 : 0, 'refresh_time' => get_input_value($abookid . "_cd_refresh_time", RCUBE_INPUT_POST));
             // only set the password if the user entered a new one
             $password = get_input_value($abookid . "_cd_password", RCUBE_INPUT_POST, true);
             if (strlen($password) > 0) {
                 $newset['password'] = $password;
             }
             // remove admin only settings
             foreach ($newset as $pref => $value) {
                 if (self::no_override($pref, $abook, $prefs)) {
                     unset($newset[$pref]);
                 }
             }
             self::update_abook($abookid, $newset);
         }
     }
     // add a new address book?
     $new = get_input_value('new_cd_name', RCUBE_INPUT_POST);
     if ((!array_key_exists('_GLOBAL', $prefs) || !$prefs['_GLOBAL']['fixed']) && strlen($new) > 0) {
         $srv = get_input_value('new_cd_url', RCUBE_INPUT_POST);
         $usr = get_input_value('new_cd_username', RCUBE_INPUT_POST, true);
         $pass = get_input_value('new_cd_password', RCUBE_INPUT_POST, true);
         $pass = self::$helper->encrypt_password($pass);
         $abname = get_input_value('new_cd_name', RCUBE_INPUT_POST);
         $discovery = new carddav_discovery();
         $srvs = $discovery->find_addressbooks($srv, $usr, $pass);
         if (is_array($srvs) && count($srvs) > 0) {
             foreach ($srvs as $srv) {
                 self::$helper->debug("ADDING ABOOK " . print_r($srv, true));
                 $this_abname = $abname;
                 if ($srv['name']) {
                     $this_abname .= ' (' . $srv['name'] . ')';
                 }
                 self::insert_abook(array('name' => $this_abname, 'username' => $usr, 'password' => $pass, 'url' => $srv['href'], 'refresh_time' => get_input_value('new_cd_refresh_time', RCUBE_INPUT_POST)));
             }
         } else {
             $args['abort'] = true;
             $args['message'] = $abname . ': ' . $this->gettext('cd_err_noabfound');
         }
     }
     return $args;
 }