public function run(array $RecordAliases) { if (Yii::app()->user->isGuest) { Yii::app()->controller->redirect(Yii::app()->controller->createUrl('/site/login')); } $recordAliases = new RecordAliases(); $recordAliases->setAttributes($RecordAliases); $recordAliases->recordType = Yii::app()->controller->modelClass; $model = $recordAliases->getModel(); if (!Yii::app()->params->isAdmin && !Yii::app()->controller->checkPermissions($model, 'edit')) { Yii::app()->controller->denied(); } if ($recordAliases->validate()) { $recordAliases->save(); echo CJSON::encode(array('success' => array('alias' => $recordAliases->renderAlias(), 'rawAlias' => $recordAliases->alias, 'id' => $recordAliases->id, 'label' => $recordAliases->label))); } else { $model = $recordAliases->getModel(); echo CJSON::encode(array('failure' => CHtml::errorSummary($recordAliases))); } }
public function run(array $RecordAliases) { if (Yii::app()->user->isGuest) { Yii::app()->controller->redirect(Yii::app()->controller->createUrl('/site/login')); } $recordAliases = new RecordAliases(); $recordAliases->setAttributes($RecordAliases); $recordAliases->recordType = Yii::app()->controller->modelClass; $model = $recordAliases->getModel(); if (!Yii::app()->params->isAdmin && !Yii::app()->controller->checkPermissions($model, 'edit')) { Yii::app()->controller->denied(); } if ($recordAliases->validate()) { $recordAliases->save(); echo CJSON::encode(array('success' => array('alias' => $recordAliases->renderAlias(), 'id' => $recordAliases->id))); } else { $model = $recordAliases->getModel(); echo CJSON::encode(array('failure' => Yii::app()->controller->widget('RecordAliasesWidget', array('model' => $model, 'formOnly' => true, 'aliasModel' => $recordAliases), true))); } }