Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendMailengineModel::existsGroup($this->id)) {
         parent::execute();
         $this->record = (array) BackendMailengineModel::getGroup($this->id);
         BackendMailengineModel::deleteGroup($this->id);
         BackendMailengineModel::deleteUserFromGroup($this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete_group', array('id' => $this->id));
         $this->redirect(BackendModel::createURLForAction('groups') . '&report=deleted&var=' . urlencode($this->record['title']));
     } else {
         $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing');
     }
 }
Example #2
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->isCorrect()) {
             $item['title'] = $fields['title']->getValue();
             BackendMailengineModel::updateGroup($this->id, $item);
             $item['id'] = $this->id;
             //--Delete users from the group
             BackendMailengineModel::deleteUserFromGroup($this->id);
             //--Check if there are users
             if (isset($fields["users"])) {
                 //--Get all the users
                 $users = $fields["users"]->getValue();
                 foreach ($users as $key => $value) {
                     $userGroup = array();
                     $userGroup["group_id"] = $this->id;
                     $userGroup["user_id"] = $value;
                     //--Add user to the group
                     BackendMailengineModel::insertUserToGroup($userGroup);
                 }
             }
             BackendModel::triggerEvent($this->getModule(), 'after_edit_group', $item);
             $this->redirect(BackendModel::createURLForAction('groups') . '&report=edited&highlight=row-' . $item['id']);
         }
     }
 }