/**
  * 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('adminuser.update');
     $model = $this->loadModel($id);
     $allRole = AdminRole::getAllRole();
     $model->scenario = 'update';
     unset($model->password);
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['AdminUser'])) {
         if ($_POST['AdminUser']['password'] == "") {
             // 不修改密码,改变场景
             $model->scenario = 'update_role';
         }
         $model->attributes = $_POST['AdminUser'];
         $model->update_time = time();
         $model->noHashPassword = $model->password;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
         $model->password = $model->noHashPassword;
     }
     $model->password = "";
     $model->password_repeat = "";
     $this->render('update', array('model' => $model, 'allRole' => $allRole));
 }
 /**
  * Add Organizations to this Project.  Contact users are set as the first
  * manager/writer found in the Organization.
  *
  * @param array   $orgs
  */
 public function add_orgs(array $orgs)
 {
     foreach ($orgs as $org) {
         $po = new ProjectOrg();
         $po->porg_org_id = $org->org_id;
         $po->porg_status = ProjectOrg::$STATUS_ACTIVE;
         $po->porg_contact_user_id = 1;
         // default
         // get the first related user who can writer and make them the contact.
         foreach ($org->UserOrg as $uo) {
             $mask = AdminRole::to_bitmask($uo->uo_ar_id);
             if ($mask & ACTION_ORG_PRJ_BE_CONTACT) {
                 $po->porg_contact_user_id = $uo->uo_user_id;
             }
         }
         $this->ProjectOrg[] = $po;
     }
 }
 /**
  * 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 = AdminRole::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }