Exemplo n.º 1
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();
             $item['id'] = BackendMailengineModel::insertGroup($item);
             //--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"] = $item['id'];
                     $userGroup["user_id"] = $value;
                     //--Add user to the group
                     BackendMailengineModel::insertUserToGroup($userGroup);
                 }
             }
             BackendModel::triggerEvent($this->getModule(), 'after_add_group', $item);
             $this->redirect(BackendModel::createURLForAction('groups') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }