/**
  * Execute the action.
  *
  * @return	void
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     $this->profileId = $this->getParameter('profile_id', 'int');
     // does the item exists
     if ($this->id !== null && BackendProfilesModel::existsProfileGroup($this->id)) {
         // does profile exists
         if ($this->profileId !== null && BackendProfilesModel::exists($this->profileId)) {
             // call parent, this will probably add some general CSS/JS or other required files
             parent::execute();
             // get data
             $this->getData();
             // load the form
             $this->loadForm();
             // validate the form
             $this->validateForm();
             // parse
             $this->parse();
             // display the page
             $this->display();
         } else {
             $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
Exemple #2
0
 /**
  * Execute the action.
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendProfilesModel::exists($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get item
         $profile = BackendProfilesModel::get($this->id);
         // already blocked? Prolly want to unblock then
         if ($profile['status'] === 'blocked') {
             // set profile status to active
             BackendProfilesModel::update($this->id, array('status' => 'active'));
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_unblock', array('id' => $this->id));
             // redirect
             $this->redirect(BackendModel::createURLForAction('index') . '&report=profile-unblocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
         } else {
             // delete profile session that may be active
             BackendProfilesModel::deleteSession($this->id);
             // set profile status to blocked
             BackendProfilesModel::update($this->id, array('status' => 'blocked'));
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_block', array('id' => $this->id));
             // redirect
             $this->redirect(BackendModel::createURLForAction('index') . '&report=profile-blocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
 /**
  * Execute the action.
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exists
     if ($this->id !== null && BackendProfilesModel::exists($this->id)) {
         parent::execute();
         $this->loadForm();
         $this->validateForm();
         $this->parse();
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
 /**
  * Execute the action.
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // action to execute
     $action = SpoonFilter::getGetValue('action', array('addToGroup', 'delete'), '');
     $ids = isset($_GET['id']) ? (array) $_GET['id'] : array();
     $newGroupId = SpoonFilter::getGetValue('newGroup', array_keys(BackendProfilesModel::getGroups()), '');
     // at least one id
     if (!empty($ids)) {
         // delete the given profiles
         if ($action === 'delete') {
             BackendProfilesModel::delete($ids);
             $report = 'deleted';
         } elseif ($action === 'addToGroup') {
             // for which we need a group of course
             if ($newGroupId != '') {
                 // set new status
                 foreach ($ids as $id) {
                     // profile must exist
                     if (BackendProfilesModel::exists($id)) {
                         // make sure the user is not already part of this group without an expiration date
                         foreach (BackendProfilesModel::getProfileGroups($id) as $existingGroup) {
                             // if he is, skip to the next user
                             if ($existingGroup['group_id'] === $newGroupId) {
                                 continue 2;
                             }
                         }
                         // OK, it's safe to add the user to this group
                         BackendProfilesModel::insertProfileGroup(array('profile_id' => $id, 'group_id' => $newGroupId, 'starts_on' => BackendModel::getUTCDate()));
                     }
                 }
                 // report
                 $report = 'added-to-group';
             } else {
                 $this->redirect(BackendModel::createURLForAction('index') . '&error=no-group-selected');
             }
         } else {
             $this->redirect(BackendModel::createURLForAction('index') . '&error=unknown-action');
         }
         // report
         $report = (count($ids) > 1 ? 'profiles-' : 'profile-') . $report;
         // redirect
         $this->redirect(BackendModel::createURLForAction('index', null, null, array('offset' => SpoonFilter::getGetValue('offset', null, ''), 'order' => SpoonFilter::getGetValue('order', null, ''), 'sort' => SpoonFilter::getGetValue('sort', null, ''), 'email' => SpoonFilter::getGetValue('email', null, ''), 'status' => SpoonFilter::getGetValue('status', null, ''), 'group' => SpoonFilter::getGetValue('group', null, ''))) . '&report=' . $report);
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=no-profiles-selected');
     }
 }