public function initAdmin() { $this->setImport(array('admin.models.*', 'admin.components.*', 'admin.widgets.*')); $module = SystemModules::model()->find('name = :name', array(':name' => $this->id)); if ($module) { $this->_module_id = $module->id; } }
/** * Delete module by Pk */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { $model = SystemModules::model()->findByPk($_GET['id']); if ($model) { $model->delete(); } if (!Yii::app()->request->isAjaxRequest) { $this->redirect('index'); } } }
/** * Find and load module menu files. */ protected function findMenuFiles() { $result = array(); $installedModules = SystemModules::model()->findAll(array('select' => 'name')); foreach ($installedModules as $module) { $filePath = Yii::getPathOfAlias('application.modules.' . $module->name . '.config') . DIRECTORY_SEPARATOR . 'menu.php'; if (file_exists($filePath)) { $result = CMap::mergeArray($result, require $filePath); } } return $result; }
public static function getModuleIdBykey($key) { $result = SystemModules::model()->findByAttributes(array('module_key' => ucfirst($key)))->module_id; return $result; }
/** * Check if module is installed * @param string $name * @return boolean */ public static function isModuleInstalled($name) { return (bool) SystemModules::model()->count('name=:name', array(':name' => $name)); }
public function getAllmodule($userType) { $data = ModulePermission::model()->findAllByAttributes(array('user_role_type' => $userType)); $list = array(); foreach ($data as $row) { $list[] = SystemModules::model()->findByPk($row['module_id'])->module_name; } $str = implode(" , ", $list); return $str; }
echo CHtml::textField('ModulePermission[user_role_type]', UserRoles::getRoleName($_GET['id']), array("readonly" => "readonly", 'class' => 'form-control')); ?> </div> </div> <?php } ?> <div class="form-group"> <?php ?> <label class="required col-sm-3 control-label" for="classified_id" style="valign:top;padding-right: 8px;" > Module List <span class="required">*</span></label> <div class="col-sm-9"> <div class="row"> <?php $modulelist = CHtml::listData(SystemModules::model()->findAll(), 'module_id', 'module_name'); if (isset($_GET['id']) && !empty($_GET['id'])) { $id = $_GET['id']; $data = ModulePermission::model()->findAllByAttributes(array('user_role_type' => $id)); $selected_keys = array_keys(CHtml::listData($data, 'module_id', 'module_permission_id')); echo CHtml::checkBoxList('ModulePermission[module_id]', $selected_keys, $modulelist, array('template' => '<div class="col-sm-6 removeBR checkbox_list">{input} {label}</div>')); } else { echo CHtml::checkBoxList('ModulePermission[module_id]', '', $modulelist, array('template' => '<div class="col-sm-6 removeBR checkbox_list">{input} {label}</div>')); } ?> </div> <div style="" id="classified_error" class="text-red"></div> </div> </div> </div>
/** * 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 $id the ID of the model to be loaded * @return SystemModules the loaded model * @throws CHttpException */ public function loadModel($id) { $model = SystemModules::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }