Exemple #1
0
 public function process()
 {
     list($success, $form) = $this->process_form(array('nux_pass', 'nux_service', 'nux_email', 'nux_name'));
     if ($success) {
         if (Nux_Quick_Services::exists($form['nux_service'])) {
             $details = Nux_Quick_Services::details($form['nux_service']);
             $details['name'] = $form['nux_name'];
             Hm_IMAP_List::add(array('name' => $details['name'], 'server' => $details['server'], 'port' => $details['port'], 'tls' => $details['tls'], 'user' => $form['nux_email'], 'pass' => $form['nux_pass']));
             $servers = Hm_IMAP_List::dump(false, true);
             $ids = array_keys($servers);
             $new_id = array_pop($ids);
             $imap = Hm_IMAP_List::connect($new_id, false);
             if ($imap && $imap->get_state() == 'authenticated') {
                 if (isset($details['smtp'])) {
                     Hm_SMTP_List::add(array('name' => $details['name'], 'server' => $details['smtp']['server'], 'port' => $details['smtp']['port'], 'tls' => $details['smtp']['tls'], 'user' => $form['nux_email'], 'pass' => $form['nux_pass']));
                     $this->session->record_unsaved('SMTP server added');
                     $smtp_servers = Hm_SMTP_List::dump(false, true);
                     $this->user_config->set('smtp_servers', $smtp_servers);
                 }
                 $this->user_config->set('imap_servers', $servers);
                 Hm_IMAP_List::clean_up();
                 $user_data = $this->user_config->dump();
                 if (!empty($user_data)) {
                     $this->session->set('user_data', $user_data);
                 }
                 $this->session->record_unsaved('IMAP server added');
                 $this->session->record_unsaved('SMTP server added');
                 $this->session->secure_cookie($this->request, 'hm_reload_folders', '1');
                 Hm_Msgs::add('E-mail account successfully added');
                 $msgs = Hm_Msgs::get();
                 if (!empty($msgs)) {
                     $this->session->secure_cookie($this->request, 'hm_msgs', base64_encode(serialize($msgs)), 0);
                 }
                 $this->session->close_early();
                 $this->out('nux_account_added', true);
             } else {
                 Hm_IMAP_List::del($new_id);
                 Hm_Msgs::add('ERRAuthentication failed');
             }
         }
     }
 }
Exemple #2
0
 public function process()
 {
     if (strpos($this->config->get('modules', ''), 'imap') !== false) {
         $updated = false;
         $contact_store = new Hm_Contact_Store($this->user_config);
         $contact_store = fetch_gmail_contacts($this->config, $contact_store);
     }
     if (count($contact_store->dump()) > 0) {
         $this->out('gmail_contacts', $contact_store);
     }
     if ($updated > 0) {
         $servers = Hm_IMAP_List::dump(false, true);
         $this->user_config->set('imap_servers', $servers);
         $this->session->set('user_data', $this->user_config->dump());
     }
 }
Exemple #3
0
 /**
  * Remove an IMAP server completely, used on the servers page
  */
 public function process()
 {
     if (isset($this->request->post['imap_delete'])) {
         list($success, $form) = $this->process_form(array('imap_server_id'));
         if ($success) {
             $res = Hm_IMAP_List::del($form['imap_server_id']);
             if ($res) {
                 $this->out('deleted_server_id', $form['imap_server_id']);
                 Hm_Msgs::add('Server deleted');
                 $this->session->record_unsaved('IMAP server deleted');
                 Hm_Page_Cache::flush($this->session);
             }
         } else {
             $this->out('old_form', $form);
         }
     }
 }