Example #1
0
 public function createOrganisationGroupAction()
 {
     $form = new Form_Admin_CreateOrganisationGroup();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (!$form->isValid($data)) {
             $form->populate($data);
         } else {
             $model = new Model_Wep();
             $userGroupModel = new User_Model_DbTable_UserGroup();
             $groupModel = new User_Model_DbTable_Group();
             $user['user_name'] = $data['group_identifier'] . '_group';
             $user['password'] = md5($data['password']);
             $user['role_id'] = 4;
             $user['email'] = $data['email'];
             $user['account_id'] = 0;
             $user['status'] = 1;
             $user_id = $model->insertRowsToTable('user', $user);
             $information['first_name'] = $data['first_name'];
             $information['middle_name'] = $data['middle_name'];
             $information['last_name'] = $data['last_name'];
             $information['user_id'] = $user_id;
             $profile_id = $model->insertRowsToTable('profile', $information);
             $group['name'] = $data['group_name'];
             $group['username'] = $data['group_identifier'];
             $group['user_id'] = $user_id;
             $group_id = $userGroupModel->insertUserGroup($group);
             $accountIds = $data['group_organisations'];
             foreach ($accountIds as $account_id) {
                 $groupModel->insertGroupWithAccountId($account_id, $group_id);
             }
             $this->_helper->FlashMessenger->addMessage(array('message' => "Organisation Group successfully created."));
             $this->_redirect('/admin/group-organisations');
         }
     }
 }