function editAction() { // page title $this->view->title = "Profil de l'administrateur"; // get param $administratorID = $this->_getParam('administratorID'); $order = $this->_getParam('order'); $tablePage = $this->_getParam('tablePage'); $search = $this->_getParam('search'); $paramsArray = array("order" => $order, "tablePage" => $tablePage, "search" => $search); // get user data $userData = Cible_FunctionsAdministrators::getAdministratorData($administratorID); // get group data $groupsData = Cible_FunctionsAdministrators::getAllAdministratorGroups(); /********** ACTIONS ***********/ $returnLink = $this->view->url(array('controller' => 'administrator', 'action' => 'index', 'administratorID' => null)); $form = new FormExtranetUser(array('baseDir' => $this->view->baseUrl(), 'cancelUrl' => "{$returnLink}"), $groupsData->toArray()); $this->view->assign('administratorID', $administratorID); $this->view->assign('form', $form); if (!$this->_request->isPost()) { $userGroups = Cible_FunctionsAdministrators::getAllUserGroups($administratorID); $groupIDArray = array(); $i = 0; foreach ($userGroups as $userGroup) { $groupIDArray[$i] = $userGroup['EUG_GroupID']; $i++; } $form->getElement('groups')->setValue($groupIDArray); $form->populate($userData->toArray()); } else { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // validate username is unique $findUser = new ExtranetUsers(); $select = $findUser->select()->where('EU_Username = ?', $userData['EU_Username'])->where('EU_ID <> ?', $administratorID); $findUserData = $findUser->fetchAll($select); // username is allready use if ($findUserData->count() > 0) { $form->getElement('EU_Username')->addError('Un autre utilisateur possède déjà ce nom d\'utilisateur'); } else { $userData['EU_LName'] = $form->getValue('EU_LName'); $userData['EU_FName'] = $form->getValue('EU_FName'); $userData['EU_Email'] = $form->getValue('EU_Email'); $userData['EU_Username'] = $form->getValue('EU_Username'); if ($form->getValue('EU_Password') != "") { $userData['EU_Password'] = md5($form->getValue('EU_Password')); } $userData->save(); // delete all user and group association for that user $userGroups = new ExtranetUsersGroups(); $where = 'EUG_UserID = ' . $administratorID; $userGroups->delete($where); // insert all user and group association for that user if ($formData['groups']) { foreach ($formData['groups'] as $group) { $userGroupAssociationData = new ExtranetUsersGroups(); $row = $userGroupAssociationData->createRow(); $row->EUG_UserID = $administratorID; $row->EUG_GroupID = $group; $row->save(); } } header("location:" . $returnLink); } } } }
function deleteAction() { // set page title $this->view->title = "Supprimer un groupe d'administrateur"; // get params $administratorGroupID = (int) $this->_getParam('administratorGroupID'); if ($this->_request->isPost()) { // if is set delete, then delete $delete = isset($_POST['delete']); $returnLink = $this->view->url(array('controller' => 'administrator-group', 'action' => 'index', 'administratorGroupID' => null)); if ($delete && $administratorGroupID > 0) { // delete group $group = new ExtranetGroups(); $where = 'EG_ID = ' . $administratorGroupID; $group->delete($where); // delete group index $groupIndex = new ExtranetGroupsIndex(); $where = 'EGI_GroupID = ' . $administratorGroupID; $groupIndex->delete($where); // delete Extranet_Groups_Pages_Permissions $groupPagesPermissions = new ExtranetGroupsPagesPermissions(); $where = 'EGPP_GroupID = ' . $administratorGroupID; $groupPagesPermissions->delete($where); // delete Extranet_UsersGroups $groupUsers = new ExtranetUsersGroups(); $where = 'EUG_GroupID = ' . $administratorGroupID; $groupUsers->delete($where); } header("location:" . $returnLink); } else { if ($administratorGroupID > 0) { $administratorGroup = new ExtranetGroupsIndex(); $this->view->group = $administratorGroup->fetchRow('EGI_GroupID=' . $administratorGroupID . ' AND EGI_LanguageID = ' . Zend_Registry::get("languageID")); } } }