/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $oAclRota = new AclRota();
     $oAclTipoUsuarioRota = new AclTipoUsuarioRota();
     $oAclTipoUsuarioRota->acl_tipo_usuario_id = $id;
     if (isset($_POST['AclTipoUsuario'])) {
         $model->attributes = $_POST['AclTipoUsuario'];
         if ($model->save()) {
             $oAclTipoUsuarioRota->salvarTipoUsuarioRotas($_POST);
         }
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('update', array('model' => $model, 'aAclRotas' => $oAclRota->getAclRotasArray(), 'aAclTipoUsuarioRotas' => $oAclTipoUsuarioRota->retornaRotasPorTipoUsuario()));
 }
示例#2
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $oAclTipoUsuarioRota = AclTipoUsuarioRota::model()->findByAttributes(array('acl_rota_id' => $this->acl_rota_id, 'acl_tipo_usuario_id' => $this->acl_tipo_usuario_id));
         if (!empty($oAclTipoUsuarioRota)) {
             return false;
         }
     }
     return parent::beforeSave();
 }
示例#3
0
 public function actionSetarRotaAdmin()
 {
     $oRotas = AclRota::model()->findAll();
     foreach ($oRotas as $rota) {
         $oTipoUsuarioRota = new AclTipoUsuarioRota();
         $oTipoUsuarioRota->acl_rota_id = $rota->id;
         $oTipoUsuarioRota->acl_tipo_usuario_id = 1;
         $oTipoUsuarioRota->save();
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return AclTipoUsuarioRota the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = AclTipoUsuarioRota::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#5
0
文件: Usuario.php 项目: bgstation/erp
 public function carregarPermissoes()
 {
     $oAclTipoUsuarioRota = AclTipoUsuarioRota::model()->naoExcluido()->findAllByAttributes(array('acl_tipo_usuario_id' => $this->acl_tipo_usuario_id));
     $_aPermissoes = array();
     if (!empty($oAclTipoUsuarioRota)) {
         if (!empty($_SESSION[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')])) {
             unset($_SESSION[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')]);
         }
         foreach ($oAclTipoUsuarioRota as $aclTipoUsuarioRota) {
             $_aPermissoes[base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcesso')][base64_encode('PermissoesAcessoUsuario')][base64_encode($aclTipoUsuarioRota->rota->controller)][base64_encode('actions')][] = base64_encode($aclTipoUsuarioRota->rota->action);
         }
         Yii::app()->user->setState('__' . base64_encode(Yii::app()->params['projeto'] . '_PermissoesAcessoUsuario'), $_aPermissoes);
     }
 }