Advertisement
fernandezekiel

Untitled

Nov 2nd, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public function loadConfiguration($id)
  2. {
  3. $model=UserGroupsConfiguration::model()->findByPk((int)$id);
  4. if($model===null)
  5. throw new CHttpException(404,Yii::t('userGroupsModule.admin','The requested rule does not exist.'));
  6. return $model;
  7. }
  8. private function configurationSave($formData)
  9. {
  10.  
  11. if (Yii::app()->user->pbac('userGroups.admin.admin')) {
  12. $successes = 0;
  13. foreach($formData as $configuration => $value) {
  14. $model = $this->loadConfiguration($configuration);
  15. $model->value = $value;
  16. if ($model->save())
  17. $successes++;
  18. }
  19. if ($successes == count($formData))
  20. Yii::app()->user->setFlash('configuration', Yii::t('userGroupsModule.admin','New Configurations Saved'));
  21. else
  22. Yii::app()->user->setFlash('configuration', Yii::t('userGroupsModule.admin','A problem occurred during the configuration save action'));
  23. } else
  24. Yii::app()->user->setFlash('configuration', Yii::t('userGroupsModule.admin','You are not allowed to change any configuration'));
  25.  
  26. $this->redirect(Yii::app()->baseUrl .'/userGroups/admin');
  27. }
  28.  
  29. public function actionIndex()
  30. {
  31. $confDataProvider = new CActiveDataProvider('UserGroupsConfiguration', array('pagination'=>array('pageSize' => 20),));
  32.  
  33. if(isset($_POST['UserGroupsConfiguration']))
  34. $this->configurationSave($_POST['UserGroupsConfiguration']);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement