Example #1
0
 public function do_login()
 {
     $admin = Zopim_Admin::get_instance();
     $notices = Zopim_Notices::get_instance();
     if ($_POST[Zopim_Options::ZOPIM_OPTION_USERNAME] != '' && $_POST['zopimPassword'] != '') {
         $logindata = array('email' => $_POST[Zopim_Options::ZOPIM_OPTION_USERNAME], 'password' => $_POST['zopimPassword']);
         $loginresult = json_decode($admin->zopim_post_request(ZOPIM_LOGIN_URL, $logindata));
         if (isset($loginresult->error)) {
             $notices->add_notice('login_form', $this->get_message('login-fail'), 'error');
             update_option(Zopim_Options::ZOPIM_OPTION_SALT, 'wronglogin');
         } else {
             if (isset($loginresult->salt)) {
                 update_option(Zopim_Options::ZOPIM_OPTION_USERNAME, $_POST[Zopim_Options::ZOPIM_OPTION_USERNAME]);
                 update_option(Zopim_Options::ZOPIM_OPTION_SALT, $loginresult->salt);
                 $account = $admin->zopim_get_account_details(get_option(Zopim_Options::ZOPIM_OPTION_SALT));
                 if (isset($account)) {
                     update_option(Zopim_Options::ZOPIM_OPTION_CODE, $account->account_key);
                     if (get_option('zopimGreetings') == '') {
                         $jsongreetings = json_encode($account->settings->greetings);
                         update_option('zopimGreetings', $jsongreetings);
                     }
                 }
             } else {
                 update_option(Zopim_Options::ZOPIM_OPTION_SALT, '');
                 $notices->add_notice('login_form', $this->get_message('wp-login-error'), 'error');
             }
         }
     } else {
         update_option(Zopim_Options::ZOPIM_OPTION_SALT, "wronglogin");
         $notices->add_notice('login_form', $this->get_message('login-fail'), 'error');
     }
 }
Example #2
0
 /**
  * [get_instance description]
  * @return [type] [description]
  */
 public static function get_instance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 private function __construct()
 {
     spl_autoload_register(array(&$this, 'autoload'));
     if (is_admin()) {
         Zopim_Admin::get_instance();
     }
     add_action('wp_footer', array('Zopim_Widget', 'zopimme'));
     add_action('plugins_loaded', array(&$this, 'load_textdomain'));
 }