/**
  * Update a user::role assignment.
  * The only attributes that can be changed are bizrule and data.
  * Ajax only method
  */
 public function actionUpdate()
 {
     $authAssignment = new AuthAssignment('upate');
     // $authAssignment is a CFormModel
     $form = $authAssignment->getForm();
     if ($form->submitted($form->uniqueId)) {
         // there is no submit button from the juiDialog, so use the form id
         $response = array();
         if ($authAssignment->save()) {
             $response['content'] = Yii::t('RbamModule.rbam', '"{user}::{role}" assignment updated.', array('{role}' => $authAssignment->itemName, '{user}' => $authAssignment->userName));
         } else {
             $errors = array();
             foreach ($authAssignment->getErrors() as $attribute => $attributeErrors) {
                 foreach ($attributeErrors as $error) {
                     $errors[] = array('attribute' => $attribute, 'label' => $authAssignment->getAttributeLabel($attribute), 'error' => $error);
                 }
             }
             $response = compact('errors');
         }
         header('Content-type: application/json');
         echo CJSON::encode($response);
         Yii::app()->end();
     }
 }
	/**
	* Update an auth item.
	* Note: The item's type can not be changed.
	*/
	public function actionManage($item) {
		$item = $this->authManager->getEAuthItem($item);
		if (empty($item))
			throw new CHttpException(404, Yii::t('RbamModule.rbam','Authorisation item not found.'));
			
		$authItem = new AuthItem('update'); // $authItem is a CFormModel
		$attributes = array();
  	foreach ($authItem->getAttributes() as $name=>$value)
	  	$authItem->$name = $item->$name;
	  
		$form = $authItem->getForm(!in_array($item->name, $this->getModule()->getDefaultRoles()));
		if ($form->submitted($form->uniqueId)) {
			$response = array();
			if ($authItem->save($item)) {
				$response['content'] = Yii::t('RbamModule.rbam','"{item}" {type} updated.', array(
					'{item}'=>$item->name,
					'{type}'=>$this->type($item->type, true)
				));
				if ($item->name!==$_POST['AuthItem']['oldName'])
					$response['redirect'] = $this->createUrl($this->action->id, array('item'=>$item->name));
			}
			else {
				$errors = array();
				foreach ($authItem->getErrors() as $attribute=>$attributeErrors)
					foreach ($attributeErrors as $error)
						$errors[] = array(
							'attribute'=>$attribute,
							'label'=>$authItem->getAttributeLabel($attribute),
							'error'=>$error
						);
				$response = compact('errors');
			}
			header('Content-type: application/json');
			echo CJSON::encode($response);
	  	Yii::app()->end();
		}
		
		if (Yii::app()->getUser()->checkAccess($this->getModule()->authAssignmentsManagerRole)) {
			$authAssignment = new AuthAssignment('upate'); // $authAssignment is a CFormModel
			$assignmentForm = $authAssignment->getForm();			
		}
		else
			$assignmentForm = null;

		$this->pageTitle = $this->_pageTitle($this->action->id, array(
			'{item}'=>$item->name,
			'{type}'=>$this->type($item->type, true, true)
		));
		$this->breadcrumbs = array(
			'RBAM'=>array('rbam/index'),
			$this->_pageTitle('index')=>array('index'),
			$this->pageTitle
		);

		$this->render('form', compact('item', 'form', 'assignmentForm'));
	}