Example #1
0
 public function preInsert($event)
 {
     $token = substr(md5(uniqid()), 0, 6);
     while (RoleTable::getInstance()->findOneBy('token', $token)) {
         $token = substr(md5(uniqid()), 0, 6);
     }
     $this->token = $token;
 }
Example #2
0
 public function load()
 {
     /** @var RoleFilter[] $roleFilters  */
     $roleFilters = RoleFilterTable::getInstance()->findBy('decision_id', $this->decision_id);
     $this->roles = RoleTable::getInstance()->findBy('decision_id', $this->decision_id);
     foreach ($roleFilters as $roleFilter) {
         $this->data[] = $roleFilter->role_id;
     }
 }
 public function up()
 {
     $roles = RoleTable::getInstance()->createQuery('r')->groupBy('token')->having('COUNT(id) >= 2')->execute();
     while ($roles->count()) {
         foreach ($roles as $role) {
             $token = substr(md5(uniqid()), 0, 6);
             while (RoleTable::getInstance()->findOneBy('token', $token)) {
                 $token = substr(md5(uniqid()), 0, 6);
             }
             $role->token = $token;
             $role->save();
         }
         $roles = RoleTable::getInstance()->createQuery('r')->groupBy('token')->having('COUNT(id) >= 2')->execute();
     }
 }
Example #4
0
 public function executeList(sfWebRequest $request)
 {
     $account_id = $this->getUser()->getAttribute('account_id');
     $this->roles = RoleTable::getInstance()->findByAccountId($account_id);
 }
Example #5
0
 public function executeMemberJson()
 {
     $this->asso = $this->getRoute()->getObject();
     $this->membres = AssoMemberTable::getInstance()->getMembres($this->asso)->execute();
     $this->roles = RoleTable::getInstance()->findAll();
 }
Example #6
0
 public function getAlternativeMeasurementCreateResponse(sfGuardUser $user)
 {
     /** @var sfWebRequest $request */
     $request = $this->getRequest();
     $role = RoleTable::getInstance()->getOneForUser($user, $request->getParameter('role_id'));
     if (is_object($role)) {
         $plannedMeasurement = new PlannedAlternativeMeasurement();
         $plannedMeasurement->Role = $role;
         $plannedMeasurement->criterion_id = $request->getParameter('criterion_id');
         $plannedMeasurement->alternative_id = $request->getParameter('alternative_id');
         try {
             $plannedMeasurement->save();
             $result = array('status' => 'success', 'result' => $plannedMeasurement->getAPIData());
         } catch (sfException $ex) {
             $result = array('status' => 'error', 'error' => $ex->getMessage());
         }
     } else {
         $result = array('status' => 'error', 'error' => sprintf('Project with id %d does not exist', $request->getParameter('decision_id')));
     }
     return $result;
 }
 public function configure()
 {
     parent::configure();
     unset($this['semestre_id'], $this['asso_id'], $this['user_id']);
     $this->widgetSchema['role_id'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Role'), 'add_empty' => false, 'query' => RoleTable::getInstance()->getUnsecureRole()));
 }
Example #8
0
 public function workflow_edit($id)
 {
     parent::load('model', 'workflow');
     parent::load('model', 'order');
     parent::load('model', 'system/contrib/auth');
     $workflow = WorkflowTable::getInstance()->find($id);
     $all_roles = RoleTable::getInstance()->findAll();
     $workflow_roles = array_filter(explode(',', $workflow->roles));
     $options = array();
     foreach ($all_roles as $ar) {
         $options[$ar['id']] = $ar['name'];
     }
     if ($this->is_post()) {
         $workflow->roles = sprintf(',%s,', implode(',', $_POST['roles']));
         $workflow->save();
         HTTPRedirect::flash_to('manager/workflow_permission', '编辑工作流程权限成功', $this->smarty);
     }
     $this->smarty->assign('roles', $workflow_roles);
     $this->smarty->assign('workflow', $workflow);
     $this->smarty->assign('all_roles', $options);
     $this->smarty->display('manager/order/workflow_edit');
 }
Example #9
0
 public function executeEditUserProjectRole(sfWebRequest $request)
 {
     $this->forward404Unless($this->user = Doctrine::getTable('User')->find(array($request->getParameter('uid'))), sprintf('Object user does not exist (%s).', $request->getParameter('uid')));
     $this->forward404Unless($this->project = Doctrine::getTable('Project')->find(array($request->getParameter('id'))), sprintf('Object project does not exist (%s).', $request->getParameter('id')));
     $account_id = $this->getUser()->getAttribute('account_id');
     if ($this->project->account_id != $account_id || $this->user->account_id != $account_id) {
         $this->redirect('default/secure');
     }
     $this->roles = RoleTable::getInstance()->findByAccountId($account_id);
 }