public function newUserModule($id) { $model = new sUserModule(); if (isset($_POST['sUserModule'])) { $model->attributes = $_POST['sUserModule']; if (is_array(@$_POST['sUserModule']['s_module_id'])) { foreach ($_POST['sUserModule']['s_module_id'] as $item) { $model = new sUserModule(); $model->s_user_id = $id; $model->s_module_id = $item; $model->s_matrix_id = $_POST['sUserModule']['s_matrix_id']; $model->save(); } $this->refresh(); } } return $model; }
public function getListed() { $subitems = array(); $model = sUserModule::model()->find(array('condition' => 's_module_id = ' . $this->id . ' AND s_user_id = ' . Yii::app()->user->id)); if ($model != null or Yii::app()->user->name == 'admin') { if ($this->childs) { foreach ($this->childs as $child) { $subitems[] = $child->getListed(); } } $returnarray = array('label' => $this->title, 'url' => array($this->link)); if ($subitems != array()) { $returnarray = array_merge($returnarray, array('items' => $subitems)); } return $returnarray; } }
private static function loadItems1($type) { self::$_items1[$type] = array(); if (Yii::app()->user->id === null) { self::$_items1[$type][1] = 'nonregisteraction'; } else { $model = sUserModule::model()->findBySql('SELECT a.id, a.s_matrix_id FROM s_user_module a WHERE a.s_user_id = ' . Yii::app()->user->id . ' AND a.s_module_id = ' . $type . ''); if ($model === null) { self::$_items1[$type][1] = 'nonregisteraction'; } else { if (Yii::app()->user->name != 'admin') { if ($model->s_matrix_id == 1) { //viewer self::$_items1[$type][1] = 'index'; self::$_items1[$type][2] = 'view'; self::$_items1[$type][3] = 'admin'; } elseif ($model->s_matrix_id == 4) { //Approval Level, Update Only, Create and Delete REJECTED self::$_items1[$type][1] = 'index'; self::$_items1[$type][2] = 'view'; self::$_items1[$type][3] = 'admin'; self::$_items1[$type][4] = 'update'; self::$_items1[$type][5] = 'updateg'; self::$_items1[$type][6] = 'updateh'; } elseif ($model->s_matrix_id == 8) { //Approval++ Level, Update+Create but Delete REJECTED self::$_items1[$type][1] = 'index'; self::$_items1[$type][2] = 'view'; self::$_items1[$type][3] = 'admin'; self::$_items1[$type][5] = 'update'; self::$_items1[$type][7] = 'updateg'; self::$_items1[$type][8] = 'updateh'; self::$_items1[$type][9] = 'create'; } } } } }
<?php $this->widget('bootstrap.widgets.BootGridView', array('id' => 'mat-user-module-grid', 'dataProvider' => sUserModule::model()->searchUser($model->id), 'itemsCssClass' => 'table table-striped table-bordered', 'template' => '{items}{pager}', 'columns' => array(array('class' => 'bootstrap.widgets.BootButtonColumn', 'template' => '{delete}', 'deleteButtonUrl' => 'Yii::app()->createUrl("sUser/deleteModule",array("id"=>$data->id))'), array('class' => 'bootstrap.widgets.BootButtonColumn', 'template' => '{myupdate}', 'buttons' => array('myupdate' => array('label' => '<i class="icon-pencil"></i>', 'url' => ' Yii::app()->createUrl("/sUser/updateModule", array("id"=>$data->id, "s_user_id"=>$data->s_user_id, "asDialog"=>1,"gridId"=>$this->grid->id)) ', 'click' => 'function(){$("#cru-frame").attr("src",$(this).attr("href")); $("#cru-dialog").dialog("open"); return false;} '))), array('name' => 'id', 'header' => 'Sort', 'value' => '$data->s_module->sort'), array('name' => 's_module_id', 'type' => 'raw', 'value' => 'CHtml::link($data->s_module->title,Yii::app()->createUrl("/sModule/view",array("id"=>$data->s_module->id)))'), array('name' => 's_matrix_id', 'value' => '$data->s_matrix->level')))); ?> <hr> <?php $this->renderPartial('_formModuleAdd', array('model' => $modelModule)); ?> <?php //--------------------- begin new code -------------------------- // add the (closed) dialog for the iframe $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'cru-dialog', 'options' => array('title' => 'Update Detail', 'autoOpen' => false, 'modal' => true, 'width' => '70%', 'height' => '400'))); ?> <iframe id="cru-frame" width="100%" height="100%"></iframe> <?php $this->endWidget(); //--------------------- end new code -------------------------- ?>
public function loadModelUserModule($id) { $model = sUserModule::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }