コード例 #1
0
 /**
  * Store ionic user id to database and echo json result
  */
 public function process_parameter()
 {
     $params = $_REQUEST;
     if (isset($params['do-ionic-user-cron']) === true) {
         $sendPush = new Ionic_User_Send_Push();
         $sendPush->send_scheduled_push_notification();
         exit;
     }
     if (empty($params['ionic-user-id']) === false) {
         if (empty($params['action']) === true) {
             echo json_encode(array('success' => false, 'message' => 'Missing action'));
             exit;
         }
         $userIdManager = new Ionic_User_UserId_Manager();
         switch ($params['action']) {
             case 'store':
                 $result = $userIdManager->store_userId($params['ionic-user-id']);
                 self::echo_result($result, $params['action']);
                 exit;
             case 'delete':
                 $result = $userIdManager->delete_userId($params['ionic-user-id']);
                 self::echo_result($result, $params['action']);
                 exit;
             default:
                 echo json_encode(array('success' => false, 'message' => 'Not allowed action'));
                 exit;
         }
     }
 }
コード例 #2
0
 public function admin_menu_options()
 {
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     // Store / load data from / to options
     $storeData = self::store_option(self::OPTION_NAME, $_POST);
     $options = self::load_options(self::OPTION_NAME);
     $totalUserIds = Ionic_User_UserId_Manager::get_total_userIds();
     if (filter_input(INPUT_POST, 'store-scheduled-push')) {
         if (filter_input(INPUT_POST, 'scheduled-send-to-all')) {
             $userIds = 'all';
         } else {
             $userIds = filter_input(INPUT_POST, 'scheduled-user-ids');
         }
         $scheduledStoreReturn = Ionic_User_Scheduled_Manager::store_scheduled(filter_input(INPUT_POST, 'scheduled-date'), filter_input(INPUT_POST, 'scheduled-time'), filter_input(INPUT_POST, 'scheduled-text'), $userIds);
         if (is_wp_error($scheduledStoreReturn)) {
             $error = $scheduledStoreReturn->get_error_message();
         }
     }
     if (filter_input(INPUT_GET, 'deleteScheduledId')) {
         Ionic_User_Scheduled_Manager::delete_scheduled(filter_input(INPUT_GET, 'deleteScheduledId'));
     }
     if (filter_input(INPUT_POST, 'send-push')) {
         // Send push notification
         if (filter_input(INPUT_POST, 'send-to-all') !== null) {
             $userIds = Ionic_User_UserId_Manager::get_all_userIds();
         } else {
             $userIds = explode(';', filter_input(INPUT_POST, 'send-user-ids'));
         }
         $sendPushReturn = Ionic_User_Send_Push::send_push_notification(filter_input(INPUT_POST, 'send-text'), $userIds, $options);
         if (is_wp_error($sendPushReturn)) {
             $error = $sendPushReturn->get_error_message();
         }
     }
     $tab = $_REQUEST['tab'] ? $_REQUEST['tab'] : 'settings';
     if ($tab === 'userIds') {
         $pagenum = filter_input(INPUT_GET, 'pagenum') ? absint(filter_input(INPUT_GET, 'pagenum')) : 1;
         $userIdsPages = Ionic_User_UserId_Manager::get_userIds_page_links($pagenum);
     }
     if ($tab === 'scheduled') {
         $pagenum = filter_input(INPUT_GET, 'pagenum') ? absint(filter_input(INPUT_GET, 'pagenum')) : 1;
         $scheduledPages = Ionic_User_Scheduled_Manager::get_scheduled_page_links($pagenum);
     }
     if ($tab === 'history') {
         $pagenum = filter_input(INPUT_GET, 'pagenum') ? absint(filter_input(INPUT_GET, 'pagenum')) : 1;
         $historyPages = Ionic_User_History_Manager::get_history_page_links($pagenum);
     }
     $template = IUP_PLUGIN_DIR_PATH . 'assets/html/iup-admin-' . $tab . '.html';
     if (is_file($template) === true) {
         require $template;
     }
 }
コード例 #3
0
 /**
  * @return WP_Error
  */
 public function send_scheduled_push_notification()
 {
     $scheduledManager = new Ionic_User_Scheduled_Manager();
     $result = $scheduledManager->get_passed_scheduled();
     foreach ($result as $row) {
         if ($row->userIds === 'all') {
             $userIds = Ionic_User_UserId_Manager::get_all_userIds();
         } else {
             $userIds = explode(';', $row->userIds);
         }
         $scheduledManager->delete_scheduled($row->id);
         $this->send_push_notification($row->text, $userIds, $this->load_options());
     }
 }