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


PHP rex::getUser方法代码示例

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


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

示例1: execute

 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('user has no permission for this operation!');
     }
     $type = rex_get('type', 'string');
     switch ($type) {
         case 'articles':
             $prefix = 'art\\_%';
             $defaultFields = [['translate:online_from', 'art_online_from', '1', '', '10', ''], ['translate:online_to', 'art_online_to', '2', '', '10', ''], ['translate:description', 'art_description', '3', '', '2', '']];
             break;
         case 'media':
             $prefix = 'med\\_%';
             $defaultFields = [['translate:pool_file_description', 'med_description', '1', '', '2', ''], ['translate:pool_file_copyright', 'med_copyright', '2', '', '1', '']];
             break;
         default:
             throw new rex_api_exception(sprintf('metainfo type "%s" does not have default field.', $type));
     }
     $existing = rex_sql::factory()->getArray('SELECT name FROM ' . rex::getTable('metainfo_field') . ' WHERE name LIKE ?', [$prefix]);
     $existing = array_column($existing, 'name', 'name');
     foreach ($defaultFields as $field) {
         if (!isset($existing[$field[1]])) {
             $return = call_user_func_array('rex_metainfo_add_field', $field);
             if (is_string($return)) {
                 throw new rex_api_exception($return);
             }
         }
     }
     return new rex_api_result(true, rex_i18n::msg('minfo_default_fields_created'));
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:30,代码来源:api_default_fields.php

示例2: getWidget

 public static function getWidget($id, $name, $value, array $args = [])
 {
     $art_name = '';
     $art = rex_article::get($value);
     $category = 0;
     // Falls ein Artikel vorausgewählt ist, dessen Namen anzeigen und beim öffnen der Linkmap dessen Kategorie anzeigen
     if ($art instanceof rex_article) {
         $art_name = $art->getName();
         $category = $art->getCategoryId();
     }
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if ($category || isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&category_id=' . $category;
     }
     $class = ' rex-disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $class = '';
         $open_func = 'openLinkMap(\'REX_LINK_' . $id . '\', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLink(' . $id . ');';
     }
     $e = [];
     $e['field'] = '<input class="form-control" type="text" name="REX_LINK_NAME[' . $id . ']" value="' . htmlspecialchars($art_name) . '" id="REX_LINK_' . $id . '_NAME" readonly="readonly" /><input type="hidden" name="' . $name . '" id="REX_LINK_' . $id . '" value="' . $value . '" />';
     $e['functionButtons'] = '
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"><i class="rex-icon rex-icon-open-linkmap"></i></a>
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget.php');
     return $media;
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:32,代码来源:var_link.php

示例3: _getNavigation

 /**
  * @param rex_be_page[] $blockPages
  *
  * @return array
  */
 private function _getNavigation(array $blockPages)
 {
     $navigation = [];
     foreach ($blockPages as $page) {
         if ($page->isHidden() || !$page->checkPermission(rex::getUser())) {
             continue;
         }
         $n = [];
         $n['linkClasses'] = [];
         $n['itemClasses'] = [];
         $n['linkAttr'] = [];
         $n['itemAttr'] = [];
         $n['itemClasses'][] = $page->getItemAttr('class');
         $n['linkClasses'][] = $page->getItemAttr('class');
         foreach ($page->getItemAttr(null) as $name => $value) {
             $n['itemAttr'][$name] = trim($value);
         }
         foreach ($page->getLinkAttr(null) as $name => $value) {
             $n['linkAttr'][$name] = trim($value);
         }
         $n['href'] = str_replace('&', '&amp;', $page->getHref());
         $n['title'] = $page->getTitle();
         $n['active'] = $page->isActive();
         $subpages = $page->getSubpages();
         if (is_array($subpages) && !empty($subpages)) {
             $n['children'] = $this->_getNavigation($subpages);
         }
         $navigation[] = $n;
     }
     return $navigation;
 }
开发者ID:skerbis,项目名称:redaxo,代码行数:36,代码来源:navigation.php

示例4: wildcardFormControlElement

 public static function wildcardFormControlElement(\rex_extension_point $ep)
 {
     if (!\rex::getUser()->getComplexPerm('clang')->hasAll()) {
         $subject = $ep->getSubject();
         unset($subject['delete']);
         $ep->setSubject($subject);
     }
 }
开发者ID:VIEWSION,项目名称:redaxo_sprog,代码行数:8,代码来源:Extension.php

示例5: testGetUser

 public function testGetUser()
 {
     // there is no user, when tests are run from CLI
     if (PHP_SAPI === 'cli') {
         return;
     }
     $this->assertNotNull(rex::getUser(), 'user is not null');
     $this->assertInstanceOf('rex_user', rex::getUser(), 'returns a user of correct class');
 }
开发者ID:staabm,项目名称:redaxo,代码行数:9,代码来源:rex_test.php

示例6: getWidget

 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '';
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;rex_file_category=' . $category;
     }
     foreach ($args as $aname => $avalue) {
         $open_params .= '&amp;args[' . $aname . ']=' . urlencode($avalue);
     }
     $wdgtClass = ' rex-js-widget-medialist';
     if (isset($args['preview']) && $args['preview']) {
         $wdgtClass .= ' rex-js-widget-preview';
         if (rex_addon::get('media_manager')->isAvailable()) {
             $wdgtClass .= ' rex-js-widget-preview-media-manager';
         }
     }
     $options = '';
     $medialistarray = explode(',', $value);
     if (is_array($medialistarray)) {
         foreach ($medialistarray as $file) {
             if ($file != '') {
                 $options .= '<option value="' . $file . '">' . $file . '</option>';
             }
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $add_func = '';
     $delete_func = '';
     $view_func = '';
     if (rex::getUser()->getComplexPerm('media')->hasMediaPerm()) {
         $disabled = '';
         $open_func = 'openREXMedialist(' . $id . ',\'' . $open_params . '\');';
         $add_func = 'addREXMedialist(' . $id . ',\'' . $open_params . '\');';
         $delete_func = 'deleteREXMedialist(' . $id . ');';
         $view_func = 'viewREXMedialist(' . $id . ',\'' . $open_params . '\');';
     }
     $e = [];
     $e['before'] = '<div class="rex-js-widget' . $wdgtClass . '">';
     $e['field'] = '<select class="form-control" name="REX_MEDIALIST_SELECT[' . $id . ']" id="REX_MEDIALIST_SELECT_' . $id . '" size="8">' . $options . '</select><input type="hidden" name="' . $name . '" id="REX_MEDIALIST_' . $id . '" value="' . $value . '" />';
     $e['moveButtons'] = '
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_medialist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_medialist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_medialist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_medialist_move_bottom') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
     $e['functionButtons'] = '
             <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_media_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-mediapool"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $add_func . 'return false;" title="' . rex_i18n::msg('var_media_new') . '"' . $disabled . '><i class="rex-icon rex-icon-add-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_media_remove') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $view_func . 'return false;" title="' . rex_i18n::msg('var_media_view') . '"' . $disabled . '><i class="rex-icon rex-icon-view-media"></i></a>';
     $e['after'] = '<div class="rex-js-media-preview"></div></div>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget_list.php');
     return $media;
 }
开发者ID:skerbis,项目名称:redaxo,代码行数:56,代码来源:var_medialist.php

示例7: prepareQuery

 private static function prepareQuery($qry)
 {
     // rex::getUser() gibts im Setup nicht
     $user = rex::getUser() ? rex::getUser()->getValue('login') : '';
     $qry = str_replace('%USER%', $user, $qry);
     $qry = str_replace('%TIME%', time(), $qry);
     $qry = str_replace('%TABLE_PREFIX%', rex::getTablePrefix(), $qry);
     $qry = str_replace('%TEMP_PREFIX%', rex::getTempPrefix(), $qry);
     return $qry;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:10,代码来源:util.php

示例8: addCatOption

 protected function addCatOption(rex_media_category $mediacat)
 {
     if (!$this->check_perms || $this->check_perms && rex::getUser()->getComplexPerm('media')->hasCategoryPerm($mediacat->getId())) {
         $mid = $mediacat->getId();
         $mname = $mediacat->getName() . ' [' . $mid . ']';
         $this->addOption($mname, $mid, $mid, $mediacat->getParentId());
         $childs = $mediacat->getChildren();
         if (is_array($childs)) {
             foreach ($childs as $child) {
                 $this->addCatOption($child);
             }
         }
     }
 }
开发者ID:staabm,项目名称:redaxo,代码行数:14,代码来源:media_category_select.php

示例9: setUp

 public function setUp()
 {
     if (rex::getUser()) {
         $this->skipped = true;
         $this->markTestSkipped('The rex_backend_login class can not be tested when test suite is running in redaxo backend.');
     }
     $adduser = rex_sql::factory();
     $adduser->setTable(rex::getTablePrefix() . 'user');
     $adduser->setValue('name', 'test user');
     $adduser->setValue('login', $this->login);
     $adduser->setValue('password', rex_login::passwordHash($this->password));
     $adduser->setValue('status', '1');
     $adduser->setValue('login_tries', '0');
     $adduser->setValue('cookiekey', $this->cookiekey);
     $adduser->insert();
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:16,代码来源:backend_login_test.php

示例10: execute

 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $addonkey = rex_request('addonkey', 'string');
     try {
         rex_install_webservice::delete(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)));
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return new rex_api_result(true, rex_i18n::msg('install_info_addon_deleted', $addonkey));
 }
开发者ID:staabm,项目名称:redaxo,代码行数:16,代码来源:api_package_delete.php

示例11: execute

 public function execute()
 {
     // check if a new category was folded
     $category_id = rex_request('toggle_category_id', 'int', -1);
     $category_id = rex_category::get($category_id) ? $category_id : -1;
     /**
      * @var rex_user
      */
     $user = rex::getUser();
     if (!$user->getComplexPerm('structure')->hasCategoryPerm($category_id)) {
         throw new rex_api_exception('user has no permission for this category!');
     }
     $context = rex_context::fromGet();
     $categoryTree = new rex_sitemap_category_tree($context);
     $tree = $categoryTree->getTree($category_id);
     $result = new rex_api_result(true);
     return $result;
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:18,代码来源:api_sitemap.php

示例12: getWidget

 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;category_id=' . $category;
     }
     $options = '';
     $linklistarray = explode(',', $value);
     if (is_array($linklistarray)) {
         foreach ($linklistarray as $link) {
             if ($link != '') {
                 if ($article = rex_article::get($link)) {
                     $options .= '<option value="' . $link . '">' . htmlspecialchars($article->getName()) . '</option>';
                 }
             }
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $disabled = '';
         $open_func = 'openREXLinklist(' . $id . ', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLinklist(' . $id . ');';
     }
     $e = [];
     $e['field'] = '
             <select class="form-control" name="REX_LINKLIST_SELECT[' . $id . ']" id="REX_LINKLIST_SELECT_' . $id . '" size="10">
                 ' . $options . '
             </select>
             <input type="hidden" name="' . $name . '" id="REX_LINKLIST_' . $id . '" value="' . $value . '" />';
     $e['moveButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_linklist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_linklist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_linklist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_linklist_move_bottom') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
     $e['functionButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-linkmap"></i></a>
                 <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $link = $fragment->parse('core/form/widget_list.php');
     return $link;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:44,代码来源:var_linklist.php

示例13: getWidget

 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '';
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;rex_file_category=' . $category;
     }
     foreach ($args as $aname => $avalue) {
         $open_params .= '&amp;args[' . urlencode($aname) . ']=' . urlencode($avalue);
     }
     $wdgtClass = ' rex-js-widget-media';
     if (isset($args['preview']) && $args['preview']) {
         $wdgtClass .= ' rex-js-widget-preview';
         if (rex_addon::get('media_manager')->isAvailable()) {
             $wdgtClass .= ' rex-js-widget-preview-media-manager';
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $add_func = '';
     $delete_func = '';
     $view_func = '';
     if (rex::getUser()->getComplexPerm('media')->hasMediaPerm()) {
         $disabled = '';
         $open_func = 'openREXMedia(' . $id . ',\'' . $open_params . '\');';
         $add_func = 'addREXMedia(' . $id . ',\'' . $open_params . '\');';
         $delete_func = 'deleteREXMedia(' . $id . ');';
         $view_func = 'viewREXMedia(' . $id . ',\'' . $open_params . '\');';
     }
     $e = [];
     $e['before'] = '<div class="rex-js-widget' . $wdgtClass . '">';
     $e['field'] = '<input class="form-control" type="text" name="' . $name . '" value="' . $value . '" id="REX_MEDIA_' . $id . '" readonly />';
     $e['functionButtons'] = '
             <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_media_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-mediapool"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $add_func . 'return false;" title="' . rex_i18n::msg('var_media_new') . '"' . $disabled . '><i class="rex-icon rex-icon-add-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_media_remove') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $view_func . 'return false;" title="' . rex_i18n::msg('var_media_view') . '"' . $disabled . '><i class="rex-icon rex-icon-view-media"></i></a>';
     $e['after'] = '<div class="rex-js-media-preview"></div></div>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget.php');
     return $media;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:42,代码来源:var_media.php

示例14: execute

 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $addonkey = rex_request('addonkey', 'string');
     $upload = rex_request('upload', [['upload_file', 'bool'], ['oldversion', 'string'], ['redaxo', 'array[string]'], ['description', 'string'], ['status', 'int'], ['replace_assets', 'bool'], ['ignore_tests', 'bool']]);
     $file = [];
     $archive = null;
     $file['version'] = $upload['upload_file'] ? rex_addon::get($addonkey)->getVersion() : $upload['oldversion'];
     $file['redaxo_versions'] = $upload['redaxo'];
     $file['description'] = $upload['description'];
     $file['status'] = $upload['status'];
     try {
         if ($upload['upload_file']) {
             $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip');
             $exclude = [];
             if ($upload['replace_assets']) {
                 $exclude[] = 'assets';
             }
             if ($upload['ignore_tests']) {
                 $exclude[] = 'tests';
             }
             rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
             if ($upload['replace_assets']) {
                 rex_install_archive::copyDirToArchive(rex_url::addonAssets($addonkey), $archive, $addonkey . '/assets');
             }
             $file['checksum'] = md5_file($archive);
         }
         rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), ['file' => $file], $archive);
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     if ($archive) {
         rex_file::delete($archive);
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return new rex_api_result(true, rex_i18n::msg('install_info_addon_uploaded', $addonkey));
 }
开发者ID:staabm,项目名称:redaxo,代码行数:41,代码来源:api_package_upload.php

示例15: execute

 public function execute()
 {
     $article_id = rex_request('article_id', 'int');
     $clang = rex_request('clang', 'int');
     $slice_id = rex_request('slice_id', 'int');
     $direction = rex_request('direction', 'string');
     $ooArt = rex_article::get($article_id, $clang);
     if (!$ooArt instanceof rex_article) {
         throw new rex_api_exception('Unable to find article with id "' . $article_id . '" and clang "' . $clang . '"!');
     }
     $category_id = $ooArt->getCategoryId();
     /**
      * @var rex_user
      */
     $user = rex::getUser();
     // check permissions
     if (!$user->hasPerm('moveSlice[]')) {
         throw new rex_api_exception(rex_i18n::msg('no_rights_to_this_function'));
     }
     if (!$user->getComplexPerm('structure')->hasCategoryPerm($category_id)) {
         throw new rex_api_exception(rex_i18n::msg('no_rights_to_this_function'));
     }
     // modul und rechte vorhanden ?
     $CM = rex_sql::factory();
     $CM->setQuery('select * from ' . rex::getTablePrefix() . 'article_slice left join ' . rex::getTablePrefix() . 'module on ' . rex::getTablePrefix() . 'article_slice.module_id=' . rex::getTablePrefix() . 'module.id where ' . rex::getTablePrefix() . "article_slice.id='{$slice_id}' and clang_id={$clang}");
     if ($CM->getRows() != 1) {
         throw new rex_api_exception(rex_i18n::msg('module_not_found'));
     } else {
         $module_id = (int) $CM->getValue(rex::getTablePrefix() . 'article_slice.module_id');
         // ----- RECHTE AM MODUL ?
         if ($user->getComplexPerm('modules')->hasPerm($module_id)) {
             $message = rex_content_service::moveSlice($slice_id, $clang, $direction);
         } else {
             throw new rex_api_exception(rex_i18n::msg('no_rights_to_this_function'));
         }
     }
     $result = new rex_api_result(true, $message);
     return $result;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:39,代码来源:api_content.php


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