/** Edit a system role */ public function editsystemroleAction() { $form = new SystemRoleForm(); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $roles = new Roles(); $updateData = array('role' => $form->getValue('role'), 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms()); $where = array(); $where[] = $roles->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $update = $roles->update($updateData, $where); $this->_flashMessenger->addMessage($form->getValue('role') . '\'s details updated.'); $this->_redirect('/admin/systemroles/'); } else { $form->populate($formData); } } else { // find id is expected in $params['id'] $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $roles = new Roles(); $roles = $roles->fetchRow('id=' . $id); $form->populate($roles->toArray()); } } }
function findRolesCandidats($annee) { $t = new Roles(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->from('unite_role')->join('unite_type', 'unite_type.id = unite_role.type', array())->join('unite', 'unite.type = unite_type.id', array())->joinLeft('appartenance', 'appartenance.role = unite_role.id AND ' . 'appartenance.unite = unite.id AND ' . ('(' . $db->quoteInto('appartenance.debut < ?', Strass_Controller_Action_Helper_Annee::dateFin($annee)) . ' AND ' . $db->quoteInto('(appartenance.fin IS NULL OR appartenance.fin < ?)', Strass_Controller_Action_Helper_Annee::dateFin($annee)) . ')'), array())->where('unite.id = ?', $this->id)->where('appartenance.id IS NULL'); return $t->fetchAll($s); }
function findRolesCandidats($unite, $filter_current = true) { $t = new Roles(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->from('unite_role')->join('unite_type', 'unite_type.id = unite_role.type', array())->join('unite', 'unite.type = unite_type.id', array())->where('unite.id = ?', $unite->id); if ($filter_current) { $s->joinLeft('appartenance', 'appartenance.role = unite_role.id AND ' . 'appartenance.unite = unite.id AND ' . $db->quoteInto('appartenance.individu', $this->id), array())->where('appartenance.id IS NULL'); } return $t->fetchAll($s); }