示例#1
0
 public function send_urgent_notice($source, $id, $subject, $message, $data = array())
 {
     require_once $GLOBALS['ithemes_sync_path'] . '/server.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/settings.php';
     $timestamp = time();
     $notice = compact('source', 'id', 'subject', 'message', 'data', 'timestamp');
     $notices = $this->get_urgent_notices();
     $notices[] = $notice;
     $options = $GLOBALS['ithemes-sync-settings']->get_options();
     $errors = false;
     foreach ($options['authentications'] as $user_id => $user) {
         $result = Ithemes_Sync_Server::send_urgent_notices($user_id, $user['username'], $user['key'], $notices);
         if (!is_wp_error($result) && is_array($result) && !empty($result['success'])) {
             continue;
         } else {
             $errors = true;
             $this->set_urgent_notices($notices);
             break;
         }
     }
     if (!empty($errors)) {
         return $result;
     } else {
         $this->clear_urgent_notices();
         return true;
     }
     return new WP_Error('unknown-response', __('The Sync server returned an unknown response.', 'it-l10n-ithemes-sync'));
 }
示例#2
0
 private function deauthenticate($data)
 {
     require_once $GLOBALS['ithemes_sync_path'] . '/server.php';
     $options = $GLOBALS['ithemes-sync-settings']->get_options();
     $user_details = $GLOBALS['ithemes-sync-settings']->get_authentication_details($data['user']);
     $result = Ithemes_Sync_Server::deauthenticate($data['user'], $user_details['username'], $user_details['key']);
     if (is_wp_error($result) && 'authentication' != $result->get_error_code()) {
         $heading = __('The user could not be unsynced.', 'it-l10n-ithemes-sync');
         $message = $result->get_error_message();
         $this->add_error_message($heading, $message);
         return;
     }
     $result = $GLOBALS['ithemes-sync-settings']->remove_authentication($data['user'], $user_details['username']);
     if (is_wp_error($result)) {
         $heading = __('The user could not be unsynced.', 'it-l10n-ithemes-sync');
         $message = $result->get_error_message();
         $this->add_error_message($heading, $message);
         return;
     }
     $heading = __('The user was successfully unsynced.', 'it-l10n-ithemes-sync');
     $this->add_success_message($heading);
 }
示例#3
0
 public function do_ping_check($user_id = false)
 {
     require_once dirname(__FILE__) . '/server.php';
     if (empty($user_id)) {
         $user_id = current(array_keys($this->options['authentications']));
     }
     $authentication = $this->get_authentication_details($user_id);
     if (empty($authentication)) {
         return new WP_Error('ithemes-sync-invalid-user', __('A valid user was unable to be found. A valid user is required in order to do a successful ping.', 'it-l10n-ithemes-sync'));
     }
     $result = Ithemes_Sync_Server::validate($user_id, $authentication['username'], $authentication['key']);
     if (is_wp_error($result) || !is_array($result) || !isset($result['success']) || !$result['success']) {
         return false;
     }
     return true;
 }