Esempio n. 1
0
 /**
  * Loads a particular operation
  * @throws CHttpException if the model doesn't exist
  * @param $slug the slug of the operation to load
  * @return AAuthOperation
  */
 public function loadModel($slug)
 {
     $model = AAuthOperation::model()->findBySlug($slug);
     if (!is_object($model)) {
         throw new CHttpException(404, "No such operation");
     }
     return $model;
 }
Esempio n. 2
0
    <p>These operations belong to this task.</p>
    <?php 
$csrfData = json_encode(array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken));
$ajax = CHtml::ajax(array("url" => array("setOperations", "slug" => $model->slug), "type" => "POST", "data" => 'js:(function(){
									var data = ' . $csrfData . ';
									data.operations = $("#selectedOperations").sortable("toArray");
									return data;
								}())', "success" => "function(res){\r\n\t\t\t\t\t\t\t\t\t\$('#unselectedOperations li.ui-state-highlight').\r\n\t\t\t\t\t\t\t\t\t\tremoveClass('ui-state-highlight').\r\n\t\t\t\t\t\t\t\t\t\taddClass('ui-state-default');\r\n\t\t\t\t\t\t\t\t\t\$('#selectedOperations li.ui-state-default').\r\n\t\t\t\t\t\t\t\t\t\tremoveClass('ui-state-default').\r\n\t\t\t\t\t\t\t\t\t\taddClass('ui-state-highlight');\r\n\t\t\t\t\t\t\t\t}"));
$selectedOperations = array();
foreach ($model->getChildren(AAuthItem::AUTH_OPERATION) as $item) {
    $item = AAuthItem::model()->findByPk($item->name);
    $selectedOperations[$item->name] = CHtml::link($item->name, array("operation/view", "name" => $item->name), array("title" => $item->description));
}
$unselectedOperations = array();
foreach (AAuthOperation::model()->findAll() as $item) {
    if (isset($selectedOperations[$item->name])) {
        continue;
    }
    $unselectedOperations[$item->name] = CHtml::link($item->name, array("operation/view", "name" => $item->name), array("title" => $item->description));
}
$this->widget('zii.widgets.jui.CJuiSortable', array('id' => "selectedOperations", 'itemTemplate' => '<li id="{id}" class="ui-state-highlight"><span class="ui-icon ui-icon-arrowthick-2-e-w left"></span>&nbsp;&nbsp;{content}</li>', 'items' => $selectedOperations, 'options' => array('connectWith' => '#unselectedOperations', 'update' => 'js:function(event,ui){ ' . $ajax . ' }', 'delay' => 300)));
?>
</div>
<div class='grid_6 omega'>
    <h4>Unselected Operations</h4>

    <p>These operations do not belong to this task.</p>
    <?php 
$this->widget('zii.widgets.jui.CJuiSortable', array('id' => "unselectedOperations", 'itemTemplate' => '<li id="{id}" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-e-w left"></span>&nbsp;&nbsp;{content}</li>', 'items' => $unselectedOperations, 'options' => array('connectWith' => '#selectedOperations', 'delay' => 300)));
?>