当前位置: 首页>>代码示例>>PHP>>正文


PHP UserRights类代码示例

本文整理汇总了PHP中UserRights的典型用法代码示例。如果您正苦于以下问题:PHP UserRights类的具体用法?PHP UserRights怎么用?PHP UserRights使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UserRights类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     //zisti, ci uzivatel ma pravo menit dane udaje
     $rights = new UserRights(CDatabaza::getInstance());
     if (!$rights->approved("EDIT_ENUMS")) {
         $this->disable();
         return;
     }
     $this->enable();
     //inicializuje premenne
     $this->initialize();
     //nastavi spustitelne funkcie a prislusne formulare triedy
     $this->setFunction("add_topic", "add_topic");
     $this->setForm("add_topic", "Pridaj rubriku", "add_topic", "add_topic_form");
     $this->setFunction("edit_topic", "edit_topic");
     $this->setForm("edit_topic", "Uprav rubriku", "edit_topic", "edit_topic_form");
     $this->setFunction("remove_topic", "remove_topic");
     $this->setForm("remove_topic", "Odstráň rubriku", "remove_topic", "remove_topic_form");
     $this->setFunction("add_theme", "add_theme");
     $this->setForm("add_theme", "Pridaj tému", "add_theme", "add_theme_form");
     $this->setFunction("edit_theme", "edit_theme");
     $this->setForm("edit_theme", "Uprav tému", "edit_theme", "edit_theme_form");
     $this->setFunction("remove_theme", "remove_theme");
     $this->setForm("remove_theme", "Odstráň tému", "remove_theme", "remove_theme_form");
 }
开发者ID:estrom85,项目名称:sample-codes,代码行数:25,代码来源:Topics.php

示例2: __construct

 public function __construct()
 {
     if (!isset($_SESSION['user'])) {
         return;
     }
     $user = $_SESSION['user'];
     $hasInfo = true;
     //ziska informacie z databazy
     $data = CDatabaza::getInstance();
     $data->connect();
     $rights = new UserRights($data);
     //ziska uzivatelske prava
     if (mysqli_num_rows($data->query("SELECT * FROM Uzivatel_info WHERE uzivatel_id={$user}")) == 0) {
         $hasInfo = false;
     }
     $data->close();
     //prida polia hlavneho menu na zaklade uzivatelskych prav
     $this->addItem("Domov", ProgramManager::getId("Intro"));
     if ($hasInfo) {
         $this->addItem("Môj profil", ProgramManager::getId("User_info"));
     }
     if ($rights->approved('EDIT_USERS')) {
         $this->addItem("Užívatelia", ProgramManager::getId("Users"));
     }
     if ($rights->approved('EDIT_ENUMS')) {
         $this->addItem("Rubriky", ProgramManager::getId("Topics"));
     }
     $this->addItem("Články", ProgramManager::getId("Article_list"));
     //$this->addItem("Príspevky", 0);
     //$this->addItem("Nastavenia", 0);
     //$this->addItem("Odhlásiť","?id=".ProgramManager::getId("Login")."&func=logout",0);
     $this->displayed = true;
 }
开发者ID:estrom85,项目名称:sample-codes,代码行数:33,代码来源:Menu.php

示例3: actionRights

 public function actionRights()
 {
     $Users = User::model()->findAllByAttributes(['company_id' => Yii::app()->getUser()->getProfile()->company_id]);
     if (isset($_POST['save'])) {
         foreach ($Users as $User) {
             UserRights::model()->deleteAllByAttributes(['user_id' => $User->id]);
         }
         if (!empty($_POST['rights'])) {
             foreach ($_POST['rights'] as $userId => $rights) {
                 $User = User::model()->findByPK($userId);
                 if ($User->company_id != Yii::app()->getUser()->getProfile()->company_id) {
                     break;
                 }
                 //TODO переработать обновление
                 foreach ($rights as $right => $status) {
                     $UserRights = new UserRights();
                     $UserRights->user_id = $User->id;
                     $UserRights->right = $right;
                     $UserRights->save();
                 }
             }
         }
     }
     $this->render('rights', ['Users' => $Users]);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:25,代码来源:StaffController.php

示例4: IsUserAllowed

 public function IsUserAllowed()
 {
     $bRet = true;
     if (array_key_exists('profile_list', $_SESSION)) {
         $aProfiles = $_SESSION['profile_list'];
     } else {
         $oUser = UserRights::GetUserObject();
         $oSet = $oUser->Get('profile_list');
         while (($oLnkUserProfile = $oSet->Fetch()) !== null) {
             $aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
         }
         $_SESSION['profile_list'] = $aProfiles;
     }
     foreach ($this->aData['deny'] as $sDeniedProfile) {
         // If one denied profile is present, it's enough => return false
         if (in_array($sDeniedProfile, $aProfiles)) {
             return false;
         }
     }
     // If there are some "allow" profiles, then by default the result is false
     // since the user must have at least one of the profiles to be allowed
     if (count($this->aData['allow']) > 0) {
         $bRet = false;
     }
     foreach ($this->aData['allow'] as $sAllowProfile) {
         // If one "allow" profile is present, it's enough => return true
         if (in_array($sAllowProfile, $aProfiles)) {
             return true;
         }
     }
     return $bRet;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:32,代码来源:portaldispatcher.class.inc.php

示例5: OnMenuCreation

 public static function OnMenuCreation()
 {
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new WebPageMenuNode('ConfigEditor', utils::GetAbsoluteUrlModulesRoot() . 'itop-config/config.php', $oAdminMenu->GetIndex(), 18);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:7,代码来源:main.itop-config.php

示例6: Display

 /**
  * Get the HTML fragment corresponding to the HTML editor widget
  * @param WebPage $oP The web page used for all the output
  * @param Hash $aArgs Extra context arguments
  * @return string The HTML fragment to be inserted into the page
  */
 public function Display(WebPage $oPage, $aArgs = array())
 {
     $iId = $this->m_iId;
     $sCode = $this->m_sAttCode . $this->m_sNameSuffix;
     $sValue = $this->m_sValue;
     $sHelpText = $this->m_sHelpText;
     $sValidationField = $this->m_sValidationField;
     $sHtmlValue = "<table><tr><td><textarea class=\"htmlEditor\" title=\"{$sHelpText}\" name=\"attr_{$this->m_sFieldPrefix}{$sCode}\" rows=\"10\" cols=\"10\" id=\"{$iId}\">{$sValue}</textarea></td><td>{$sValidationField}</td></tr></table>";
     // Replace the text area with CKEditor
     // To change the default settings of the editor,
     // a) edit the file /js/ckeditor/config.js
     // b) or override some of the configuration settings, using the second parameter of ckeditor()
     $sLanguage = strtolower(trim(UserRights::GetUserLanguage()));
     $oPage->add_ready_script("\$('#{$iId}').ckeditor(function() { /* callback code */ }, { language : '{$sLanguage}' , contentsLanguage : '{$sLanguage}', extraPlugins: 'disabler' });");
     // Transform $iId into a CKEdit
     // Please read...
     // ValidateCKEditField triggers a timer... calling itself indefinitely
     // This design was the quickest way to achieve the field validation (only checking if the field is blank)
     // because the ckeditor does not fire events like "change" or "keyup", etc.
     // See http://dev.ckeditor.com/ticket/900 => won't fix
     // The most relevant solution would be to implement a plugin to CKEdit, and handle the internal events like: setData, insertHtml, insertElement, loadSnapshot, key, afterUndo, afterRedo
     // Could also be bound to 'instanceReady.ckeditor'
     $oPage->add_ready_script("\$('#{$iId}').bind('validate', function(evt, sFormId) { return ValidateCKEditField('{$iId}', '', {$this->m_sMandatory}, sFormId, '') } );\n");
     $oPage->add_ready_script("\$('#{$iId}').bind('update', function() { BlockField('cke_{$iId}', \$('#{$iId}').attr('disabled')); } );\n");
     return $sHtmlValue;
 }
开发者ID:henryavila,项目名称:itop,代码行数:32,代码来源:ui.htmleditorwidget.class.inc.php

示例7: IsUserAllowed

 public function IsUserAllowed()
 {
     if (array_key_exists('profile_list', $_SESSION)) {
         $aProfiles = $_SESSION['profile_list'];
     } else {
         $oUser = UserRights::GetUserObject();
         $oSet = $oUser->Get('profile_list');
         while (($oLnkUserProfile = $oSet->Fetch()) !== null) {
             $aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
         }
         $_SESSION['profile_list'] = $aProfiles;
     }
     foreach ($this->aData['deny'] as $sDeniedProfile) {
         // If one denied profile is present, it's enough => return false
         if (in_array($sDeniedProfile, $aProfiles)) {
             return false;
         }
     }
     foreach ($this->aData['allow'] as $sAllowProfile) {
         // if one required profile is missing, it's enough => return false
         if (!in_array($sAllowProfile, $aProfiles)) {
             return false;
         }
     }
     return true;
 }
开发者ID:henryavila,项目名称:itop,代码行数:26,代码来源:portaldispatcher.class.inc.php

示例8: IsEnabled

 public static function IsEnabled()
 {
     if (self::$m_bEnabled_Duration || self::$m_bEnabled_Memory) {
         if (self::$m_sAllowedUser == '*' || UserRights::GetUser() == trim(self::$m_sAllowedUser)) {
             return true;
         }
     }
     return false;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:9,代码来源:kpi.class.inc.php

示例9: GetHeader

 public function GetHeader()
 {
     $sData = '';
     $oSet = new DBObjectSet($this->oSearch);
     $this->aStatusInfo['status'] = 'running';
     $this->aStatusInfo['position'] = 0;
     $this->aStatusInfo['total'] = $oSet->Count();
     $aSelectedClasses = $this->oSearch->GetSelectedClasses();
     foreach ($aSelectedClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAliases = array_keys($aAuthorizedClasses);
     $aData = array();
     foreach ($this->aStatusInfo['fields'] as $sExtendedAttCode) {
         if (preg_match('/^([^\\.]+)\\.(.+)$/', $sExtendedAttCode, $aMatches)) {
             $sAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
         } else {
             $sAlias = reset($aAliases);
             $sAttCode = $sExtendedAttCode;
         }
         if (!in_array($sAlias, $aAliases)) {
             throw new Exception("Invalid alias '{$sAlias}' for the column '{$sExtendedAttCode}'. Availables aliases: '" . implode("', '", $aAliases) . "'");
         }
         $sClass = $aSelectedClasses[$sAlias];
         switch ($sAttCode) {
             case 'id':
                 if (count($aSelectedClasses) > 1) {
                     $aData[] = $sAlias . '.id';
                     //@@@
                 } else {
                     $aData[] = 'id';
                     //@@@
                 }
                 break;
             default:
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                 if (count($aSelectedClasses) > 1) {
                     $aData[] = $sAlias . '.' . $oAttDef->GetLabel();
                 } else {
                     $aData[] = $oAttDef->GetLabel();
                 }
         }
     }
     $sData .= "<table class=\"listResults\">\n";
     $sData .= "<thead>\n";
     $sData .= "<tr>\n";
     foreach ($aData as $sLabel) {
         $sData .= "<th>" . $sLabel . "</th>\n";
     }
     $sData .= "</tr>\n";
     $sData .= "</thead>\n";
     $sData .= "<tbody>\n";
     return $sData;
 }
开发者ID:henryavila,项目名称:itop,代码行数:57,代码来源:htmlbulkexport.class.inc.php

示例10: GetCurrentUserName

 public static function GetCurrentUserName()
 {
     if (UserRights::IsImpersonated()) {
         $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUserFriendlyName(), UserRights::GetUserFriendlyName());
     } else {
         $sUserString = UserRights::GetUserFriendlyName();
     }
     return $sUserString;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:9,代码来源:cmdbchange.class.inc.php

示例11: __construct

 public function __construct()
 {
     $rights = new UserRights(CDatabaza::getInstance());
     if (!$rights->approved("EDIT_USERS")) {
         $this->disable();
         return;
     }
     $this->enable();
     $this->initialize();
     $this->setFunction("add", "add_user");
     $this->setForm("add", "Pridaj užívateľa", "add_user", "add_user_form");
     $this->setFunction("edit", "edit_user");
     $this->setForm("edit", "Uprav informácie o užívateľovi", "edit_user", "edit_user_form");
     $this->setFunction("remove", "remove_user");
     $this->setForm("remove", "Vymaž užívateľa", "remove_user", "remove_user_form");
     $this->setFunction("set_rights", "set_user_rights");
     $this->setForm("set_rights", "Nastav užívateľské práva", "set_rights", "set_user_rights_form");
     $this->setFunction("reset", "reset_password");
     $this->setForm("reset", "Resetuj heslo", "remove_user", "remove_user_form");
 }
开发者ID:estrom85,项目名称:sample-codes,代码行数:20,代码来源:Users.php

示例12: checkRight

 private static function checkRight($array, $user)
 {
     if (!is_array($array)) {
         return $array == $user;
     }
     foreach ($array as $right) {
         if (UserRights::checkRight($right, $user)) {
             return true;
         }
     }
     return false;
 }
开发者ID:estrom85,项目名称:sample-codes,代码行数:12,代码来源:UserRights.php

示例13: OnMenuCreation

 public static function OnMenuCreation()
 {
     // Add the admin menus
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1, true);
         new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2);
         new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/notifications.php', $oAdminMenu->GetIndex(), 3);
         new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4);
         new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/run_query.php', $oAdminMenu->GetIndex(), 8);
         new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5, true);
         new WebPageMenuNode('ExportMenu', utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php?interactive=1', $oAdminMenu->GetIndex(), 9);
         new WebPageMenuNode('DataModelMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/schema.php', $oAdminMenu->GetIndex(), 10);
         new WebPageMenuNode('UniversalSearchMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:16,代码来源:main.itop-welcome-itil.php

示例14: OnMenuCreation

 public static function OnMenuCreation()
 {
     $oToolsMenu = new MenuGroup('DataAdministration', 70, 'Organization', UR_ACTION_MODIFY, UR_ALLOWED_YES | UR_ALLOWED_DEPENDS);
     new WebPageMenuNode('CSVImportMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/csvimport.php', $oToolsMenu->GetIndex(), 1);
     // Add the admin menus
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1);
         new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2);
         new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/notifications.php', $oAdminMenu->GetIndex(), 3);
         new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4);
         new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/run_query.php', $oAdminMenu->GetIndex(), 8);
         new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5, true);
         new WebPageMenuNode('ExportMenu', utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php', $oAdminMenu->GetIndex(), 9);
         new WebPageMenuNode('DataModelMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/schema.php', $oAdminMenu->GetIndex(), 10);
         new WebPageMenuNode('UniversalSearchMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:18,代码来源:main.itop-welcome-itil.php

示例15: IsUserAllowed

 public function IsUserAllowed()
 {
     $bRet = true;
     $aProfiles = UserRights::ListProfiles();
     foreach ($this->aData['deny'] as $sDeniedProfile) {
         // If one denied profile is present, it's enough => return false
         if (in_array($sDeniedProfile, $aProfiles)) {
             return false;
         }
     }
     // If there are some "allow" profiles, then by default the result is false
     // since the user must have at least one of the profiles to be allowed
     if (count($this->aData['allow']) > 0) {
         $bRet = false;
     }
     foreach ($this->aData['allow'] as $sAllowProfile) {
         // If one "allow" profile is present, it's enough => return true
         if (in_array($sAllowProfile, $aProfiles)) {
             return true;
         }
     }
     return $bRet;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:23,代码来源:portaldispatcher.class.inc.php


注:本文中的UserRights类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。