Exemplo n.º 1
0
 /**
  * Processes bulk actions, delete, activate, deactivate
  */
 function process_bulk_action()
 {
     $subscribersBatch = isset($_POST['subscriberId']) ? is_array($_POST['subscriberId']) ? $_POST['subscriberId'] : NULL : NULL;
     $subscriberId = isset($_GET['id']) && is_numeric($_GET['id']) ? $_GET['id'] : NULL;
     try {
         switch ($this->current_action()) {
             case 'delete':
                 if (!empty($subscribersBatch)) {
                     $this->subscribers->deleteBatch($subscribersBatch);
                     $this->addNotice('updated', 'Subscriber(s) successfully deleted!');
                 } elseif (isset($_GET['action']) && is_numeric($_GET['id'])) {
                     $this->subscribers->deleteUser($_GET['id']);
                     $this->addNotice('updated', 'Subscriber successfully deleted!');
                 }
                 break;
             case 'activate':
                 if (!empty($subscribersBatch)) {
                     $this->subscribers->activateBatch($subscribersBatch);
                     $this->addNotice('updated', 'Subscriber(s) successfully activated!');
                 } elseif (isset($_GET['action']) && is_numeric($_GET['id'])) {
                     $this->subscribers->activateUser($_GET['id']);
                     $this->addNotice('updated', 'Subscriber successfully activated!');
                 }
                 break;
             case 'deactivate':
                 if (!empty($subscribersBatch)) {
                     $this->subscribers->deactivateBatch($subscribersBatch);
                     $this->addNotice('updated', 'Subscriber(s) successfully deactivated!');
                 } elseif (isset($_GET['action']) && is_numeric($_GET['id'])) {
                     $this->subscribers->deactivateUser($_GET['id']);
                     $this->addNotice('updated', 'Subscriber successfully deactivated!');
                 }
                 break;
             case 'deactivateRegistered':
                 $this->subscribers->deactivateRegisteredUserById($_GET['id']);
                 $this->addNotice('updated', 'Subscriber successfully deactivated!');
                 break;
         }
     } catch (RepositarySubscribersException $e) {
         $this->addNotice('error', $e->getMessage());
     }
 }