/**
  * 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)
 {
     $this->checkAccess('adminrole.update');
     $model = $this->loadModel($id);
     if ($id == 1 || $model->title == '超级管理员' || $model->actions == '*') {
         $this->redirect(array('admin'));
     }
     $array = explode(',', $model->actions);
     $allActions = AdminActions::getAllActions();
     foreach ($allActions as $k => $action) {
         foreach ($array as $item) {
             if ($action['action'] == $item) {
                 $allActions[$k]['selected'] = "checked";
             }
         }
     }
     // 下拉列表
     Tree::$arr = $allActions;
     $tree = Tree::getTree(0, "<label class='checkbox'><input type='checkbox' name='AdminRole[actions][]' id='AdminRole_actions_\$id' data-id='\$id' data-parent-id='\$parent_id' value='\$action' \$selected><label for='AdminRole_actions_\$id'>\$spacer\$name</label></label>", -1, true);
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['AdminRole'])) {
         $model->attributes = $_POST['AdminRole'];
         $model->actions = implode(',', $model->actions);
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'tree' => $tree));
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = AdminActions::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }