public function testRead() { $this->assertTrue($this->model->hasPermission('read', 9)); $this->assertTrue($this->model->hasPermission('read', 8)); $this->assertTrue($this->model->hasPermission('read', 7)); $this->assertTrue($this->model->hasPermission('read', 5)); $this->assertFalse($this->model->hasPermission('read', 3)); $this->assertFalse($this->model->hasPermission('read', 2)); $this->assertTrue($this->model->hasPermission('read', 1)); $this->assertTrue($this->model->hasPermission('read', NULL)); }
/** * Logs in the user using the given username and password in the model. * @return boolean whether login is successful */ public function login() { if ($this->_identity === null) { $this->_identity = new UserIdentity($this->username, $this->password); $this->_identity->authenticate(); } if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) { if (Yii::app()->session['attamps'] >= 3 && Yii::app()->session['exp'] > time()) { $this->addError('password', "You have already made 3 incorrect attempts. Now you can't sign in for next 15 min."); return false; } else { if (Yii::app()->session['attamps'] >= 3) { Yii::app()->session['attamps'] = 0; } } $user = Users::model()->findByAttributes(array('user_email' => $this->username, 'user_password' => md5($this->password))); if (!empty($user)) { if ($user->user_status == 1) { if ($this->rememberMe) { $user_id = new CHttpCookie('user_id', $user->user_id); $user_id->expire = time() + 3600 * 24 * 30; Yii::app()->request->cookies['user_id'] = $user_id; $user_role = new CHttpCookie('user_role', $user->user_role_type); $user_role->expire = time() + 3600 * 24 * 30; Yii::app()->request->cookies['user_role'] = $user_role; } //$this->setRights($user['user_accountTypeID']); $this->setConfiguration(); //print_r($rights);die; Yii::app()->session['attamps'] = 0; Yii::app()->session['user_data'] = $user; Yii::app()->session['session_time'] = strtotime(Date('Y-m-d H:i:s')) + 1200; $role_name = UserRoles::model()->getRoleName($user->user_role_type); Yii::app()->user->name = $role_name; return true; } else { $this->addError('password', 'Your Account Got Disabled By Admin.'); return false; } } else { Yii::app()->session['attamps'] = Yii::app()->session['attamps'] + 1; Yii::app()->session['exp'] = time() + 60 * 15; if (Yii::app()->session['attamps'] > 2) { $this->addError('password', "You have already made 3 incorrect attempts. Now you can't sign in for next 15 min."); return false; } $this->addError('password', 'Invalid Credentials'); return false; } } else { return false; } }
function actionEmailAssignee() { $template = Template::getTemplate('user_mail_on_assign_ticket_'); $subject = $template->template_subject; $message = $template->template_content; $userdata['website_url'] = Utils::getBaseUrl(); $results = TicketAssign::model()->findAllByAttributes(array(), array('condition' => 'send_mail = :send_mail AND status=1', 'params' => array('send_mail' => 0))); foreach ($results as $users) { $userInfo = Users::model()->findByPk($users->fwd_to); $ticket_id = $users->ticket_id; $userdata['ticket_id'] = $ticket_id; $userdata['user_name'] = $userInfo->user_name; $userdata['role_name'] = UserRoles::model()->getRoleName($users->fwd_by); $userdata['ticket_link'] = Utils::getBaseUrl() . "/ticket/view/" . base64_encode($ticket_id); $subject = $this->replace($userdata, $subject); $message = $this->replace($userdata, $message); $this->SendMail($userInfo->user_email, $userInfo->user_name, $subject, $message); $model = TicketAssign::model()->findByPk($users->id); $model->send_mail = 1; $model->update(); } }
</div> <?php } ?> <ul id="userTab" class="nav nav-tabs"> <li class="active"><a href="#users-list" data-toggle="tab"><i class="fa fa-list"></i> List of Users</a></li> <li class=""><a href="#users-add" data-toggle="tab"><i class="fa fa-plus-circle"></i> Add Users</a></li> </ul> <div id="userTabContent" class="tab-content"> <div class="tab-pane fade active in" id="users-list"> <div class="row"> <div class="col-md-12"> <div class="table-responsive"> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'users-grid', 'htmlOptions' => array('class' => 'dataTables_wrapper', 'role' => 'grid'), 'dataProvider' => $model->search(1), 'filter' => $model, 'columns' => array(array('header' => 'S. No.', 'name' => 'S. No.', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)', 'htmlOptions' => array('style' => 'text-align:center'), 'headerHtmlOptions' => array('style' => 'text-align: center;width:60px')), array('name' => 'user_name', 'value' => '$data->user_name', 'headerHtmlOptions' => array('style' => 'text-align: center;width:220px'), 'htmlOptions' => array('style' => 'text-align:justify;'), 'filter' => CHtml::activeTextField($model, 'user_name', array('placeholder' => $model->getAttributeLabel('user_name'), 'style' => 'font-style:italic', 'autocomplete' => 'off', 'class' => 'form-control'))), array('name' => 'user_email', 'value' => '$data->user_email', 'htmlOptions' => array('style' => 'text-align:justify;-ms-word-break: break-all;word-break: break-all;'), 'filter' => CHtml::activeTextField($model, 'user_email', array('placeholder' => $model->getAttributeLabel('user_email'), 'style' => 'font-style:italic', 'autocomplete' => 'off', 'class' => 'form-control')), 'headerHtmlOptions' => array('style' => 'text-align: center;width:220px')), array('name' => 'phone', 'value' => '$data->phone', 'htmlOptions' => array('style' => 'text-align:justify;-ms-word-break: break-all;word-break: break-all;'), 'filter' => CHtml::activeTextField($model, 'phone', array('placeholder' => $model->getAttributeLabel('phone'), 'style' => 'font-style:italic', 'autocomplete' => 'off', 'class' => 'form-control')), 'headerHtmlOptions' => array('style' => 'text-align: center;width:220px')), array('name' => 'skype', 'value' => '$data->skype', 'htmlOptions' => array('style' => 'text-align:justify;-ms-word-break: break-all;word-break: break-all;'), 'filter' => CHtml::activeTextField($model, 'skype', array('placeholder' => $model->getAttributeLabel('skype'), 'style' => 'font-style:italic', 'autocomplete' => 'off', 'class' => 'form-control')), 'headerHtmlOptions' => array('style' => 'text-align: center;width:220px')), array('header' => 'Tickets', 'value' => 'count(TicketAssign::model()->getTicketbyUser($data->user_id))', 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'text-align: center;width:60px')), array('name' => 'user_department_id', 'value' => 'Department::getDepartmentName($data->user_department_id)', 'htmlOptions' => array('style' => 'text-align:center;'), 'headerHtmlOptions' => array('style' => 'text-align: center;width:120px'), 'filter' => CHtml::activeDropDownList($model, 'user_department_id', Department::getDepartmentList(), array('style' => 'font-style:italic', 'class' => 'form-control', 'empty' => 'Please Select'))), array('name' => 'user_role_type', 'value' => 'UserRoles::getRoleName($data->user_role_type)', 'htmlOptions' => array('style' => 'text-align:center;'), 'headerHtmlOptions' => array('style' => 'text-align: center;width:120px'), 'filter' => CHtml::activeDropDownList($model, 'user_role_type', UserRoles::getUserType(), array('style' => 'font-style:italic', 'class' => 'form-control', 'empty' => 'Please Select'))), array('header' => 'Created By', 'headerHtmlOptions' => array('style' => 'text-align: center;width:130px'), 'value' => 'Users::getUserName($data->user_created_by_id)', 'htmlOptions' => array('style' => 'text-align:justify;')), array('name' => 'user_status', 'type' => 'raw', 'value' => '($data->user_status == 0) ? "<a class=\\"btn btn-xs btn-red\\" title=\\"Change Status\\" onclick=\\"change_status($data->user_id,1)\\" href=\\"javascript:void(0);\\"><i class=\\"fa fa-minus-square\\"></i></a>" : "<a class=\\"btn btn-xs btn-green\\" title=\\"Change Status\\" onclick=\\"change_status($data->user_id,0)\\" href=\\"javascript:void(0);\\">Change Status</a>"', 'htmlOptions' => array('style' => 'text-align:center;'), 'headerHtmlOptions' => array('style' => 'text-align: center;width:100px'), 'filter' => CHtml::activeDropDownList($model, 'user_status', array(0 => "Inactive", 1 => 'Active'), array('style' => 'font-style:italic', 'class' => 'form-control', 'empty' => 'Please Select'))), array('header' => 'Action', 'class' => 'CButtonColumn', 'deleteConfirmation' => 'Do you want to delete this User Record?', 'afterDelete' => 'function(link,success,data){ if(success) { $("#statusMsg").css("display", "block"); $("#statusMsg").html(data); $("#statusMsg").animate({opacity: 1.0}, 3000).fadeOut("fast");}}', 'headerHtmlOptions' => array('style' => 'text-align: center;width:60px'), 'htmlOptions' => array('style' => 'text-align:center;'), 'template' => '{update}{viewTicket}', 'buttons' => array('update' => array('label' => '<i class="fa fa-edit"></i>', 'options' => array('title' => 'Update'), 'imageUrl' => FALSE, 'url' => 'Yii::app()->createUrl("users/update", array("id" => base64_encode($data->user_id)))'), 'viewTicket' => array('label' => ' <i class="fa fa-search"></i>', 'options' => array('title' => 'View Ticket'), 'imageUrl' => FALSE, 'url' => 'Yii::app()->createUrl("ticket/index", array("user_id" => base64_encode($data->user_id)))'), 'delete' => array('label' => '<i class="fa fa-times"></i>', 'options' => array('title' => 'Delete', 'class' => 'remove'), 'imageUrl' => FALSE, 'url' => 'Yii::app()->createUrl("users/delete", array("id" => base64_encode($data->user_id)))')))), 'itemsCssClass' => 'table table-striped table-bordered table-hover dataTable', 'pagerCssClass' => 'dataTables_paginate paging_bootstrap', 'summaryCssClass' => 'dataTables_info', 'template' => '{items}<div class = "row"><div class = "col-xs-6">{summary}</div><div class = "col-xs-6">{pager}</div></div>', 'pager' => array('htmlOptions' => array('class' => 'pagination', 'id' => ''), 'header' => '', 'cssFile' => false, 'selectedPageCssClass' => 'active', 'previousPageCssClass' => 'prev', 'nextPageCssClass' => 'next', 'hiddenPageCssClass' => 'disabled', 'maxButtonCount' => 5), 'emptyText' => '<span class="text-danger text-center">No Record Found!</span>')); ?> </div> </div> </div> </div> <div class="tab-pane fade" id="users-add"> <div class="row"> <div class="col-md-12"> <?php $this->renderPartial('_form', array('model' => $model)); ?> </div>
echo $form->textField($model, 'phone', array('class' => 'form-control', 'value' => $user_email, 'readonly' => 'readonly')); echo $form->error($model, 'phone', array('class' => 'alert-danger')); ?> </div> <div class="form-group col-sm-6"> <?php echo $form->labelEx($model, 'skype'); ?> <?php echo $form->textField($model, 'skype', array('class' => 'form-control', 'value' => $user_email, 'readonly' => 'readonly')); echo $form->error($model, 'skype', array('class' => 'alert-danger')); ?> </div> <div class="form-group col-sm-6"> <?php $model->user_role_type = UserRoles::getRoleName($model->user_role_type); ?> <?php echo $form->labelEx($model, 'user_role_type'); ?> <?php echo $form->textField($model, 'user_role_type', array('class' => 'form-control', 'readonly' => 'readonly')); echo $form->error($model, 'user_email', array('class' => 'alert-danger')); ?> </div> <div class="form-group col-sm-6"> <?php $model->user_department_id = Department::getDepartmentName($model->user_department_id); ?> <?php echo $form->labelEx($model, 'user_department_id');
/** * Removes an admin from a contest * * @param Request $r * @return array * @throws InvalidDatabaseOperationException * @throws ForbiddenAccessException */ public static function apiRemoveAdmin(Request $r) { // Authenticate logged user self::authenticateRequest($r); // Check contest_alias Validators::isStringNonEmpty($r["contest_alias"], "contest_alias"); $r["user"] = UserController::resolveUser($r["usernameOrEmail"]); try { $r["contest"] = ContestsDAO::getByAlias($r["contest_alias"]); } catch (Exception $e) { // Operation failed in the data layer throw new InvalidDatabaseOperationException($e); } // Only admin is alowed to make modifications if (!Authorization::IsContestAdmin($r["current_user_id"], $r["contest"])) { throw new ForbiddenAccessException(); } // Check if admin to delete is actually an admin if (!Authorization::IsContestAdmin($r["user"]->getUserId(), $r["contest"])) { throw new NotFoundException(); } $contest_user = new UserRoles(); $contest_user->setContestId($r["contest"]->getContestId()); $contest_user->setUserId($r["user"]->getUserId()); $contest_user->setRoleId(CONTEST_ADMIN_ROLE); // Delete the role try { UserRolesDAO::delete($contest_user); } catch (Exception $e) { // Operation failed in the data layer throw new InvalidDatabaseOperationException($e); } return array("status" => "ok"); }
public function actionIndex() { $this->hasPrivilege(Acl::ACTION_VIEW); $this->pageTitle = Lang::t($this->resourceLabel . 's'); $this->showPageTitle = TRUE; $this->render('index', array('model' => UserRoles::model()->searchModel(array(), $this->settings[Constants::KEY_PAGINATION], 'name'))); }
/** * Removes an admin from a contest * * @param Request $r * @return array * @throws InvalidDatabaseOperationException * @throws ForbiddenAccessException */ public static function apiRemoveAdmin(Request $r) { // Authenticate logged user self::authenticateRequest($r); // Check whether problem exists Validators::isStringNonEmpty($r['problem_alias'], 'problem_alias'); $r['user'] = UserController::resolveUser($r['usernameOrEmail']); try { $r['problem'] = ProblemsDAO::getByAlias($r['problem_alias']); } catch (Exception $e) { // Operation failed in the data layer throw new InvalidDatabaseOperationException($e); } if (!Authorization::IsProblemAdmin($r['current_user_id'], $r['problem'])) { throw new ForbiddenAccessException(); } // Check if admin to delete is actually an admin if (!Authorization::IsProblemAdmin($r['user']->user_id, $r['problem'])) { throw new NotFoundException(); } $user_role = new UserRoles(); $user_role->setContestId($r['problem']->problem_id); $user_role->setUserId($r['user']->user_id); $user_role->setRoleId(PROBLEM_ADMIN_ROLE); // Delete the role try { UserRolesDAO::delete($user_role); } catch (Exception $e) { // Operation failed in the data layer throw new InvalidDatabaseOperationException($e); } return array('status' => 'ok'); }
</div> </div> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'role_id', array('class' => $label_class)); ?> <div class="<?php echo $input_class; ?> "> <p class="help-block"><?php echo Lang::t('Only applicable for user levels below SUPERADMIN'); ?> </p> <?php echo CHtml::activeDropDownList($model, 'role_id', UserRoles::model()->getListData('id', 'name'), array('class' => 'form-control')); ?> </div> </div> <?php } ?> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'email', array('class' => $label_class)); ?> <div class="<?php echo $input_class; ?> "> <?php
public function getAllUserRoles() { $url = $this->getUrl() . UserRoles::$ALL_USER_ROLE_LINK; $request = $this->setHeadersGet($url, $this->_oauthToken); $result = $this->doGet($request); if (array_key_exists('errors', $result)) { $errors_tmp = new Errors(); foreach ($result as $errorData) { $errors_tmp = Errors::fromArray($errorData); } $errors[] = $errors_tmp; return $errors; } else { return UserRoles::fromArray($result); } }
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(); } } }
public function actionCustomSearch() { $restrictedUsers = array(); $restrictedUsers = $_POST['restrictedUsers']; $ticket_id = $_POST['ticket_id']; $assigneeList = TicketAssign::model()->findAllByAttributes(array("ticket_id" => $ticket_id, "status" => 1)); foreach ($assigneeList as $row) { $restrictedUsers[] = $row['fwd_to']; } $username = $_POST['username']; $deparment = $_POST['department']; $emailid = $_POST['email_id']; $userList = Users::model()->getFilterUser($username, $deparment, $restrictedUsers, $emailid); if (!empty($userList)) { foreach ($userList as $row) { $userlist[$row['user_id']] = $row['user_name'] . " (" . $row['user_email'] . ", " . UserRoles::model()->getRoleName($row['user_role_type']) . ")"; } echo CHtml::checkBoxList('userlist', '', $userlist, array('template' => '<div class="col-sm-6 removeBR">{input} {label}</div>', 'class' => 'selectAssignee')); } else { echo "<div class='col-md-12'><div class='alert alert-danger'>No users found. </div></div>"; } }
<?php $create_url = Yii::app()->createAbsoluteUrl('/users/create'); $update_url = Yii::app()->createAbsoluteUrl('/users/update/' . base64_encode($model->user_id)); $form = $this->beginWidget('CActiveForm', array('id' => 'users-form', 'action' => $model->isNewRecord ? $create_url : $update_url, 'enableAjaxValidation' => TRUE, 'enableClientValidation' => TRUE, 'clientOptions' => array('validateOnSubmit' => TRUE, 'validateOnChange' => TRUE), 'htmlOptions' => array('autocomplete' => 'off', 'role' => 'form'), 'focus' => array($model, 'user_name'))); if ($model->isNewRecord) { $model->user_password = Utils::getRandomPassword(); } $list = Department::getDepartmentList(); $typelist = UserRoles::getUserType(); ?> <div class="row"> <div class="col-md-6"> <div class="row"> <div class="col-md-12"> <div class="form-horizontal"> <div class="form-group"> <?php echo $form->labelEx($model, 'user_name', array('class' => 'col-sm-3 control-label')); ?> <div class="col-sm-9"> <?php echo $form->textField($model, 'user_name', array('size' => 55, 'maxlength' => 55, 'class' => 'form-control', 'placeholder' => $model->getAttributeLabel('user_name'))); ?> <?php echo $form->error($model, 'user_name', array('class' => 'text-red')); ?> </div> </div> <div class="form-group"> <?php
/** * @return \yii\db\ActiveQuery */ public function getUserRole() { return $this->hasOne(UserRoles::className(), ['id' => 'user_role_id']); }
<?php echo $form->dropDownlist($model, 'user_role_type', $typelist, array('class' => 'form-control', 'empty' => 'Please Select ' . $model->getAttributeLabel('user_role_name'))); ?> <?php echo $form->error($model, 'user_role_type', array('class' => 'text-red')); ?> </div> </div> <?php } else { ?> <div class="form-group"> <label for="user_role_type col-sm-3 control-label">User Role Type</label> <div class="col-sm-9"> <?php 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');
/** * Returns array with annotations for controllers in Areas part of the project * Each array for controller contains classAnnotations and methodAnnotations * Method annotations contains annotations for all methods in the class * All Route annotations are grouped under "Routes" in annotations. Route annotations can be set for the class and * on methods. If there is annotation only on the class, it is ignored. */ public static function getAnnotations() { $filePaths = Annotations::getDirContents($_SERVER['DOCUMENT_ROOT']); $controllersFilePaths = Annotations::getControllersFilePaths($filePaths); $annotations = []; foreach ($controllersFilePaths as $controllersFilePath) { if (preg_match('/Application\\' . DIRECTORY_SEPARATOR . 'Areas\\' . DIRECTORY_SEPARATOR . '(.*?)\\' . DIRECTORY_SEPARATOR . 'Controllers\\' . DIRECTORY_SEPARATOR . '(.*?).php/', $controllersFilePath, $match)) { $area = $match[1]; $className = $match[2]; $fileName = $className . '.php'; require_once 'Application' . DIRECTORY_SEPARATOR . 'Areas' . DIRECTORY_SEPARATOR . $area . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR . $fileName; if (class_exists('SoftUni\\Application\\Areas\\' . $area . '\\Controllers\\' . $className)) { $annotations[$className] = []; $classRouteAnnotation = ''; $classAccessAnnotation = ''; $reflectionClass = new \ReflectionClass('SoftUni\\Application\\Areas\\' . $area . '\\Controllers\\' . $className); $doc = $reflectionClass->getDocComment(); if (preg_match_all('#@(.*?)\\n#s', $doc, $newAnnotations)) { foreach ($newAnnotations[1] as $newAnnotation) { if (preg_match('/Route\\((.*?)\\)/', $newAnnotation, $matches)) { $classRouteAnnotation = $matches[1]; } $userRoles = UserRoles::getAllRoles(); $pattern = join("|", $userRoles); if (preg_match('/' . $pattern . '/', $newAnnotation, $matches)) { $classAccessAnnotation = $matches[0]; } } } $methods = $reflectionClass->getMethods(); foreach ($methods as $method) { $methodName = $method->getName(); $methodAccessAnnotation = ''; $methodDoc = $method->getDocComment(); if (preg_match_all('#@(.*?)\\n#s', $methodDoc, $newMethodAnnotations)) { foreach ($newMethodAnnotations[1] as $newMethodAnnotation) { // Get Route Annotation if (preg_match('/Route\\((.*?)\\)/', $newMethodAnnotation, $matches1)) { $fullRouteAnnotation = $classRouteAnnotation . '/' . $matches1[1]; $fullRouteAnnotation = str_replace('"', '', $fullRouteAnnotation); $fullRouteAnnotation = str_replace("'", "", $fullRouteAnnotation); $annotations['Routes'][$fullRouteAnnotation] = [$className, $methodName]; } // Get Authorization Annotation $userRoles = UserRoles::getAllRoles(); $pattern = join("|", $userRoles); if (preg_match('/' . $pattern . '/', $newMethodAnnotation, $matches)) { if (UserRoles::getRoleNumber($classAccessAnnotation) > $matches[0]) { $methodAccessAnnotation = $classAccessAnnotation; } else { $methodAccessAnnotation = $matches[0]; } $annotations[$className][$methodName][] = array('Authorization' => $methodAccessAnnotation); } // Get HTTP Request Annotation $pattern = "/GET|POST|PUT|DELETE/"; if (preg_match($pattern, $newMethodAnnotation, $matches2)) { $annotations[$className][$methodName][] = array('HttpRequest' => $matches2[0]); } } } } } } //echo(json_encode($annotations, JSON_PRETTY_PRINT)); } self::$allAnnotations = $annotations; }
public function actionDashboard() { $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']; $this->render('dashboard', $data); }
public function getRole($id) { if (empty($id)) { return NULL; } $dept_id = UserRoles::model()->getScaler('name', '`id`=:t1', array(':t1' => $id)); return !empty($dept_id) ? $dept_id : NULL; }
public function getClientAssigneeList($id) { $assigneeList = TicketAssign::model()->findAllByAttributes(array("ticket_id" => $id, "status" => 1, 'user_role_type' => 5), array('condition' => 'fwd_to!=:id', 'params' => array('id' => Yii::app()->session['user_data']['user_id']))); if (!empty($assigneeList)) { $str = '<table class = "table table-bordered table-striped" > <tr><th style = "width:20px;" > #</th><th>Name</th><th>Email ID</th><th>Role</th><th style="max-width:120px;">Department</th><th>Assigned by</th><th style="width:60px;">Action</th></tr>'; $count = 1; foreach ($assigneeList as $list) { $userinfo = Users::model()->findByAttributes(array('user_id' => $list['fwd_to'])); $str .= '<tr > <td> ' . $count++ . ' </td> <td>' . $userinfo['user_name'] . '</td> <td>' . $userinfo['user_email'] . '</td> <td>' . UserRoles::model()->getRoleName($userinfo["user_role_type"]) . '</td> <td>' . Department::model()->getDepartmentName($userinfo['user_department_id']) . '</td> <td>' . Users::model()->getUserName($list['fwd_by']) . '</td>'; if (Yii::app()->session['user_data']['user_id'] == $list['fwd_by']) { $str .= '<td><a class="removeUser" data="' . $userinfo['user_id'] . '" title="Remove assign User" href="javascript:"><i class="fa fa-times" ></i></a></td></tr>'; } else { $str .= '<td></td></tr>'; } } $str .= '</table>'; } else { $str .= '<div class = "norecord col-sm-12">No users assigned.</div>'; } return $str; }
<div class="panel-heading"> <h4 class="panel-title"> <i class="fa fa-chevron-down"></i> <a data-toggle="collapse" data-parent="#accordion" href="#account_info"><?php echo Lang::t('Account Details'); ?> </a> <?php if ($can_update || Users::isMyAccount($model->id)) { ?> <span><a class="pull-right" href="<?php echo $this->createUrl('view', array('id' => $model->id, 'action' => Users::ACTION_UPDATE_ACCOUNT)); ?> "><i class="fa fa-edit"></i> <?php echo Lang::t('Edit'); ?> </a></span> <?php } ?> </h4> </div> <div id="account_info" class="panel-collapse collapse in"> <div class="panel-body"> <div class="detail-view"> <?php $this->widget('application.components.widgets.DetailView', array('data' => $model, 'attributes' => array(array('name' => 'id'), array('label' => Lang::t('Department'), 'visible' => !empty($model->dept_id), 'value' => CHtml::link(CHtml::encode(Dept::model()->get($model->dept_id, "name")), Yii::app()->createUrl('dept/default/view', array('id' => $model->dept_id)), array()), 'type' => 'raw'), array('name' => 'status', 'value' => CHtml::tag('span', array('class' => $model->status === Users::STATUS_ACTIVE ? 'badge badge-success' : 'badge badge-danger'), $model->status), 'type' => 'raw'), array('name' => 'username'), array('name' => 'email'), array('name' => 'user_level'), array('name' => 'role_id', 'visible' => !empty($model->role_id), 'value' => UserRoles::model()->get($model->role_id, 'name')), array('name' => 'timezone'), array('name' => 'date_created', 'value' => MyYiiUtils::formatDate($model->date_created)), array('name' => 'created_by', 'value' => Users::model()->get($model->created_by, "username"), 'visible' => !empty($model->created_by)), array('name' => 'last_modified', 'value' => MyYiiUtils::formatDate($model->last_modified), 'visible' => !empty($model->last_modified)), array('name' => 'last_modified_by', 'value' => Users::model()->get($model->last_modified_by, "username"), 'visible' => !empty($model->last_modified_by)), array('name' => 'last_login', 'value' => MyYiiUtils::formatDate($model->last_login))))); ?> </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 UserRoles the loaded model * @throws CHttpException */ public function loadModel($id) { $model = UserRoles::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
echo $form->toggleButtonRow($model, 'status', $htmlOptions); ?> </div> <div class="pure-control-group"> <?php echo $form->emailFieldRow($model, 'email', $htmlOptions); ?> </div> <div class="pure-control-group"> <?php echo $form->textFieldRow($model, 'displayName', $htmlOptions); ?> </div> <div class="pure-control-group"> <?php echo $form->dropDownListrow($model, 'user_role', CHtml::listData(UserRoles::model()->findAll(), 'id', 'name'), $htmlOptions); ?> </div> <legend>Optional Information</legend> <div class="pure-control-group"> <?php echo $form->textFieldRow($model, 'firstName', $htmlOptions); ?> </div> <div class="pure-control-group"> <?php echo $form->textFieldRow($model, 'lastName', $htmlOptions); ?> </div> <div class="pure-control-group">