<!-- end SIDE NAV USER PANEL --> <!-- Tickets --> <!-- begin Users Management LINK --> <li id="auth"> <a href="<?php echo Yii::app()->request->baseUrl; ?> /dashboard"> <i class="fa fa-dashboard"></i> Dashboard </a> </li> <?php $user_role_type = Yii::app()->session['user_data']['user_role_type']; $modulist = ModulePermission::getAllmoduleList($user_role_type); ?> <?php if (in_array(SystemModules::getModuleIdBykey('ticket'), $modulist)) { ?> <li id="ticket"> <a href="<?php echo Yii::app()->request->baseUrl; ?> /ticket"> <i class="fa fa-ticket"></i> Ticket Management </a> </li> <?php }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = $this->loadModel($id); $status = ModulePermission::checkPermission($id); if ($status) { if (!isset($_GET['ajax'])) { Yii::app()->user->setFlash('type', 'warning'); Yii::app()->user->setFlash('message', 'Could Not Delete User Role Because User Role is Attached with Permission.'); } else { echo '<div class="alert alert-warning alert-dismissable" id="successmsg">Could Not Delete User Role Because User Role is Attached with Permission.</div>'; } } else { $model->delete(); if (!isset($_GET['ajax'])) { Yii::app()->user->setFlash('type', 'success'); Yii::app()->user->setFlash('message', 'User Role removed successfully.'); } else { echo '<div class="alert alert-success alert-dismissable" id="successmsg">User Role removed successfully.</div>'; } } }
public function checkPermission($roleType) { $data = ModulePermission::model()->count('user_role_type=' . $roleType); return $data; }
</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> </div> </div> <div class="row">
/** * 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 ModulePermission the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ModulePermission::model()->findAllByAttributes(array('user_role_type' => $id)); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function getUserType() { $gettype = ModulePermission::getUserRoleType(); $result = UserRoles::model()->findAll(array('select' => '*', 'condition' => 'user_role_type IN(' . $gettype . ')')); $list = array(); foreach ($result as $row) { if (Yii::app()->session['user_data']['user_role_type'] < $row['user_role_type']) { $list[$row['user_role_type']] = $row['user_role_name']; } } return $list; }
public function init() { $model = new Configuration(); $setmodel = $model->findAll(); Yii::app()->db->setactive(FALSE); foreach ($setmodel as $set) { if ($set->name == 'company_logo') { $this->company_logo = $set->value; } if ($set->name == 'site_name') { $this->site_name = $set->value; } if ($set->name == 'Host') { $this->Host = $set->value; } if ($set->name == 'Username') { $this->Username = $set->value; } if ($set->name == 'user_password') { $this->user_password = $set->value; } if ($set->name == 'from_smtp') { $this->from_smtp = $set->value; } if ($set->name == 'Site_email') { $this->site_email = $set->value; } if ($set->name == 'site_contact_no') { $this->site_contact_no = $set->value; } } if (!in_array(Yii::app()->controller->id, array('auth', 'app'))) { if (!isset(Yii::app()->session['user_data'])) { $this->redirect(Yii::app()->request->baseUrl . '/auth'); } else { if (strtotime(date('Y-m-d H:i:s')) > Yii::app()->session['session_time'] && isset(Yii::app()->session['user_data'])) { // $loginmodel = new LoginForm; // $loginmodel->UpdateLastLogoutTime(Yii::app()->session['user_data']['user_id']); // unset(Yii::app()->session['user_data']); // Yii::app()->user->logout(); } $user = Users::model()->findByAttributes(array('user_id' => Yii::app()->session['user_data']['user_id'])); Yii::app()->session['user_data'] = $user; $this->user_data = Yii::app()->session['user_data']; $role_name = UserRoles::model()->getRoleName($user->user_role_type); Yii::app()->user->name = $role_name; $user_role_type = Yii::app()->session['user_data']['user_role_type']; if ($user_role_type > 0) { $modulist = ModulePermission::getAllmoduleList($user_role_type); $module_id = SystemModules::getModuleIdBykey(Yii::app()->controller->id); if (!in_array($module_id, $modulist)) { $this->redirect(Yii::app()->request->baseUrl . '/auth'); } } } } else { if (Yii::app()->controller->id == "app") { $string = ltrim(strstr(Yii::app()->request->pathInfo, '/'), "/"); if (!in_array(ucfirst($string), array('AddOrder', 'AddUser', 'EmailComments', 'MailToUsers', 'EmailAssignee', 'EmailChangeTicketStatus'))) { echo json_encode(array("error" => true, 'error_code' => "401", "Message" => "Invalid Action")); exit; } } if (strtotime(date('Y-m-d H:i:s')) > Yii::app()->session['session_time'] && isset(Yii::app()->session['user_data'])) { // $loginmodel = new LoginForm; // $loginmodel->UpdateLastLogoutTime(Yii::app()->session['user_data']['user_id']); // unset(Yii::app()->session['user_data']); // Yii::app()->user->logout(); } } }