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


PHP Admin::getCurrentUser方法代码示例

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


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

示例1: getUser

 /**
  * @return Tool\User
  * @throws \Exception
  */
 public function getUser()
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         return $user;
     }
     throw new \Exception("Webservice instantiated, but no user present");
 }
开发者ID:pawansgi92,项目名称:pimcore2,代码行数:11,代码来源:Service.php

示例2: importClassDefinitionFromJson

 /**
  * @param $class
  * @param $json
  * @return bool
  */
 public static function importClassDefinitionFromJson($class, $json, $throwException = false)
 {
     $userId = 0;
     $user = \Pimcore\Tool\Admin::getCurrentUser();
     if ($user) {
         $userId = $user->getId();
     }
     $importData = \Zend_Json::decode($json);
     // set layout-definition
     $layout = self::generateLayoutTreeFromArray($importData["layoutDefinitions"], $throwException);
     if ($layout === false) {
         return false;
     }
     $class->setLayoutDefinitions($layout);
     // set properties of class
     $class->setModificationDate(time());
     $class->setUserModification($userId);
     $class->setIcon($importData["icon"]);
     $class->setAllowInherit($importData["allowInherit"]);
     $class->setAllowVariants($importData["allowVariants"]);
     $class->setShowVariants($importData["showVariants"]);
     $class->setParentClass($importData["parentClass"]);
     $class->setUseTraits($importData["useTraits"]);
     $class->setPreviewUrl($importData["previewUrl"]);
     $class->setPropertyVisibility($importData["propertyVisibility"]);
     $class->save();
     return true;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:33,代码来源:Service.php

示例3: checkUserPermission

 private function checkUserPermission($permission)
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         if ($user->isAllowed($permission)) {
             return;
         }
     }
     $this->getResponse()->setHttpResponseCode(403);
     $this->encoder->encode(["success" => false, "msg" => "not allowed"]);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:10,代码来源:RestController.php

示例4: getByKeyLocalized

 /**
  * @param $id
  * @param bool $create
  * @param bool $returnIdIfEmpty
  * @param null $language
  * @return array
  * @throws \Exception
  * @throws \Zend_Exception
  */
 public static function getByKeyLocalized($id, $create = false, $returnIdIfEmpty = false, $language = null)
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         $language = $user->getLanguage();
     } elseif ($user = Tool\Authentication::authenticateSession()) {
         $language = $user->getLanguage();
     } elseif (\Zend_Registry::isRegistered("Zend_Locale")) {
         $language = (string) \Zend_Registry::get("Zend_Locale");
     }
     if (!in_array($language, Tool\Admin::getLanguages())) {
         $config = \Pimcore\Config::getSystemConfig();
         $language = $config->general->language;
     }
     return self::getByKey($id, $create, $returnIdIfEmpty)->getTranslation($language);
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:24,代码来源:Admin.php

示例5: init

 public function init()
 {
     parent::init();
     $pimUser = false;
     if (\Pimcore\Tool::isFrontentRequestByAdmin()) {
         $pimUser = \Pimcore\Tool\Admin::getCurrentUser();
         if ($pimUser) {
             //echo "IS ADMIN";
         }
     }
     $identity = \Zend_Auth::getInstance()->getIdentity();
     if (!$identity && !$pimUser or $this->getParam('oid') != $identity['oid']) {
         $this->redirect("/");
     } else {
         // login ok
     }
 }
开发者ID:putzflorian,项目名称:Pimcore-Frontend-Login,代码行数:17,代码来源:Useraware.php

示例6: move

 /**
  * Moves a file/directory
  *
  * @param string $sourcePath
  * @param string $destinationPath
  * @return void
  */
 public function move($sourcePath, $destinationPath)
 {
     $nameParts = explode("/", $sourcePath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             $asset = null;
             if ($asset = Asset::getByPath("/" . $destinationPath)) {
                 // If we got here, this means the destination exists, and needs to be overwritten
                 $sourceAsset = Asset::getByPath("/" . $sourcePath);
                 $asset->setData($sourceAsset->getData());
                 $sourceAsset->delete();
             }
             // see: Asset\WebDAV\File::delete() why this is necessary
             $log = Asset\WebDAV\Service::getDeleteLog();
             if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
                 $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
                 if ($asset) {
                     $sourceAsset = Asset::getByPath("/" . $sourcePath);
                     $asset->setData($sourceAsset->getData());
                     $sourceAsset->delete();
                 }
             }
             if (!$asset) {
                 $asset = Asset::getByPath("/" . $sourcePath);
             }
             $asset->setFilename(basename($destinationPath));
         } else {
             $asset = Asset::getByPath("/" . $sourcePath);
             $parent = Asset::getByPath("/" . dirname($destinationPath));
             $asset->setPath($parent->getFullPath() . "/");
             $asset->setParentId($parent->getId());
         }
         $user = \Pimcore\Tool\Admin::getCurrentUser();
         $asset->setUserModification($user->getId());
         $asset->save();
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:51,代码来源:Tree.php

示例7: createActionNote

 /**
  * Creates a note for an action with a transition
  * @param Element\AbstractElement $element
  * @param string $type
  * @param string $title
  * @param string $description
  * @param array $noteData
  * @return Element\Note $note
  */
 public static function createActionNote($element, $type, $title, $description, $noteData, $user = null)
 {
     //prepare some vars for creating the note
     if (!$user) {
         $user = \Pimcore\Tool\Admin::getCurrentUser();
     }
     $note = new Element\Note();
     $note->setElement($element);
     $note->setDate(time());
     $note->setType($type);
     $note->setTitle($title);
     $note->setDescription($description);
     $note->setUser($user->getId());
     if (is_array($noteData)) {
         foreach ($noteData as $row) {
             $note->addData($row['key'], $row['type'], $row['value']);
         }
     }
     $note->save();
     return $note;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:30,代码来源:Service.php

示例8: adminElementGetPreSendData

 /**
  * Fired before information is sent back to the admin UI about an element
  * @param \Zend_EventManager_Event $e
  * @throws \Exception
  */
 public static function adminElementGetPreSendData($e)
 {
     $element = self::extractElementFromEvent($e);
     $returnValueContainer = $e->getParam('returnValueContainer');
     $data = $returnValueContainer->getData();
     //create a new namespace for WorkflowManagement
     //set some defaults
     $data['workflowManagement'] = ['hasWorkflowManagement' => false];
     if (Workflow\Manager::elementCanAction($element)) {
         $data['workflowManagement']['hasWorkflowManagement'] = true;
         //see if we can change the layout
         $currentUser = Admin::getCurrentUser();
         $manager = Workflow\Manager\Factory::getManager($element, $currentUser);
         $data['workflowManagement']['workflowName'] = $manager->getWorkflow()->getName();
         //get the state and status
         $state = $manager->getElementState();
         $data['workflowManagement']['state'] = $manager->getWorkflow()->getStateConfig($state);
         $status = $manager->getElementStatus();
         $data['workflowManagement']['status'] = $manager->getWorkflow()->getStatusConfig($status);
         if ($element instanceof ConcreteObject) {
             $workflowLayoutId = $manager->getObjectLayout();
             //check for !is_null here as we might want to specify 0 in the workflow config
             if (!is_null($workflowLayoutId)) {
                 //load the new layout into the object container
                 $validLayouts = Object\Service::getValidLayouts($element);
                 //check that the layout id is valid before trying to load
                 if (!empty($validLayouts)) {
                     //todo check user permissions again
                     if ($validLayouts && $validLayouts[$workflowLayoutId]) {
                         $customLayout = ClassDefinition\CustomLayout::getById($workflowLayoutId);
                         $customLayoutDefinition = $customLayout->getLayoutDefinitions();
                         Object\Service::enrichLayoutDefinition($customLayoutDefinition, $e->getParam('object'));
                         $data["layout"] = $customLayoutDefinition;
                     }
                 }
             }
         }
     }
     $returnValueContainer->setData($data);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:45,代码来源:EventHandler.php

示例9: foreach

</head>

<body>

<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

        <div class="navbar-header">
            <a href="#" class="navbar-brand dropdown-toggle"><span class="glyphicon glyphicon-shopping-cart"></span> Online-Shop Back Office</span></a>
        </div>

        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <?php 
$user = \Pimcore\Tool\Admin::getCurrentUser();
$currentAction = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
$currentController = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
$arrActions = [];
if ($user->isAllowed('plugin_onlineshop_back-office_order')) {
    $arrActions['order'][] = 'list';
}
foreach ($arrActions as $controller => $actions) {
    foreach ($actions as $action) {
        ?>
                    <li class="<?php 
        echo $currentController == 'admin-' . $controller && $currentAction == $action ? 'active' : '';
        ?>
">
                        <a href="<?php 
        echo $this->url(['action' => $action, 'controller' => 'admin-' . $controller, 'module' => 'OnlineShop'], null, true);
开发者ID:ascertain,项目名称:NGshop,代码行数:31,代码来源:back-office.php

示例10: getFromWebserviceImport

 /**
  * @param mixed $value
  * @param null $object
  * @param null $idMapper
  * @return mixed|null|Object\Localizedfield
  * @throws \Exception
  */
 public function getFromWebserviceImport($value, $object = null, $idMapper = null)
 {
     if (is_array($value)) {
         $validLanguages = Tool::getValidLanguages();
         if (!$idMapper || !$idMapper->ignoreMappingFailures()) {
             foreach ($value as $v) {
                 if (!in_array($v->language, $validLanguages)) {
                     throw new \Exception("Invalid language in localized fields");
                 }
             }
         }
         $localizedFields = $object->getLocalizedFields();
         if (!$localizedFields) {
             $localizedFields = new Object\Localizedfield();
         }
         if ($object instanceof Object\Concrete) {
             $localizedFields->setObject($object);
         }
         $user = Tool\Admin::getCurrentUser();
         $languagesAllowed = null;
         if ($user && !$user->isAdmin()) {
             $languagesAllowed = Object\Service::getLanguagePermissions($object, $user, "lEdit");
             if ($languagesAllowed) {
                 $languagesAllowed = array_keys($languagesAllowed);
             }
         }
         foreach ($value as $field) {
             if ($field instanceof \stdClass) {
                 $field = Tool\Cast::castToClass("\\Pimcore\\Model\\Webservice\\Data\\Object\\Element", $field);
             }
             if ($idMapper && $idMapper->ignoreMappingFailures()) {
                 if (!in_array($field->language, $validLanguages)) {
                     continue;
                 }
             }
             if ($languagesAllowed && !in_array($field->language, $languagesAllowed)) {
                 //TODO needs to be discussed. Maybe it is better to throw an exception instead of ignoring
                 //the language
                 continue;
             }
             if (!$field instanceof Model\Webservice\Data\Object\Element) {
                 throw new \Exception("Invalid import data in field [ {$field->name} ] for language [ {$field->language} ] in localized fields [ " . $this->getName() . " ]");
             }
             $fd = $this->getFielddefinition($field->name);
             if (!$fd instanceof Object\ClassDefinition\Data) {
                 if ($idMapper && $idMapper->ignoreMappingFailures()) {
                     continue;
                 }
                 throw new \Exception("Unknown field [ {$field->name} ] for language [ {$field->language} ] in localized fields [ " . $this->getName() . " ] ");
             } else {
                 if ($fd->getFieldtype() != $field->type) {
                     throw new \Exception("Type mismatch for field [ {$field->name} ] for language [ {$field->language} ] in localized fields [ " . $this->getName() . " ]. Should be [ " . $fd->getFieldtype() . " ], but is [ " . $field->type . " ] ");
                 }
             }
             $localizedFields->setLocalizedValue($field->name, $this->getFielddefinition($field->name)->getFromWebserviceImport($field->value, $object, $idMapper), $field->language);
         }
         return $localizedFields;
     } else {
         if (!empty($value)) {
             throw new \Exception("Invalid data in localized fields");
         } else {
             return null;
         }
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:72,代码来源:Localizedfields.php

示例11: fieldcollectionListAction

 public function fieldcollectionListAction()
 {
     $user = \Pimcore\Tool\Admin::getCurrentUser();
     $currentLayoutId = $this->getParam("layoutId");
     $list = new Object\Fieldcollection\Definition\Listing();
     $list = $list->load();
     if ($this->hasParam("allowedTypes")) {
         $filteredList = [];
         $allowedTypes = explode(",", $this->getParam("allowedTypes"));
         /** @var $type Object\Fieldcollection\Definition */
         foreach ($list as $type) {
             if (in_array($type->getKey(), $allowedTypes)) {
                 $filteredList[] = $type;
                 // mainly for objects-meta data-type
                 $layoutDefinitions = $type->getLayoutDefinitions();
                 Object\Service::enrichLayoutDefinition($layoutDefinitions, null);
                 if ($currentLayoutId == -1 && $user->isAdmin()) {
                     Object\Service::createSuperLayout($layoutDefinitions);
                 }
             }
         }
         $list = $filteredList;
     }
     $this->_helper->json(["fieldcollections" => $list]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:25,代码来源:ClassController.php

示例12:

?>
,
        google_webmastertools_enabled: <?php 
echo \Zend_Json::encode((bool) \Pimcore\Google\Webmastertools::isConfigured());
?>
,
        customviews: <?php 
echo \Zend_Json::encode($this->customview_config);
?>
,
        language: '<?php 
echo $this->language;
?>
',
        websiteLanguages: <?php 
echo \Zend_Json::encode(explode(",", \Pimcore\Tool\Admin::reorderWebsiteLanguages(\Pimcore\Tool\Admin::getCurrentUser(), $this->config->general->validLanguages)));
?>
,
        google_translate_api_key: "<?php 
echo $this->config->services->translate->apikey;
?>
",
        google_maps_api_key: "<?php 
echo $googleMapsApiKey;
?>
",
        showCloseConfirmation: true,
        debug_admin_translations: <?php 
echo \Zend_Json::encode((bool) $this->config->general->debug_admin_translations);
?>
,
开发者ID:tododo,项目名称:pimcore,代码行数:31,代码来源:index6.php

示例13: getRuntimePerspective

 /** Gets the active perspective for the current user
  * @return array
  */
 public static function getRuntimePerspective()
 {
     $currentUser = Tool\Admin::getCurrentUser();
     $currentConfigName = $currentUser->getActivePerspective() ? $currentUser->getActivePerspective() : $currentUser->getFirstAllowedPerspective();
     $config = self::getPerspectivesConfig()->toArray();
     $result = [];
     if ($config[$currentConfigName]) {
         $result = $config[$currentConfigName];
     } else {
         $availablePerspectives = self::getAvailablePerspectives($currentUser);
         if ($availablePerspectives) {
             $currentPerspective = reset($availablePerspectives);
             $currentConfigName = $currentPerspective["name"];
             if ($currentConfigName && $config[$currentConfigName]) {
                 $result = $config[$currentConfigName];
             }
         }
     }
     if ($result && $currentConfigName != $currentUser->getActivePerspective()) {
         $currentUser->setActivePerspective($currentConfigName);
         $currentUser->save();
     }
     $result["elementTree"] = self::getRuntimeElementTreeConfig($currentConfigName);
     return $result;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:28,代码来源:Config.php

示例14: getCustomLayoutDefinitionForGridColumnConfig

 /**  Determines the custom layout definition (if necessary) for the given class
  * @param ClassDefinition $class
  * @param int $objectId
  * @return array layout
  */
 public static function getCustomLayoutDefinitionForGridColumnConfig(ClassDefinition $class, $objectId)
 {
     $layoutDefinitions = $class->getLayoutDefinitions();
     $result = array("layoutDefinition" => $layoutDefinitions);
     if (!$objectId) {
         return $result;
     }
     $user = AdminTool::getCurrentUser();
     if ($user->isAdmin()) {
         return $result;
     }
     $mergedFieldDefinition = self::getCustomGridFieldDefinitions($class->getId(), $objectId);
     if (is_array($mergedFieldDefinition)) {
         if ($mergedFieldDefinition["localizedfields"]) {
             $childs = $mergedFieldDefinition["localizedfields"]->getFieldDefinitions();
             if (is_array($childs)) {
                 foreach ($childs as $locKey => $locValue) {
                     $mergedFieldDefinition[$locKey] = $locValue;
                 }
             }
         }
         self::doFilterCustomGridFieldDefinitions($layoutDefinitions, $mergedFieldDefinition);
         $result["layoutDefinition"] = $layoutDefinitions;
         $result["fieldDefinition"] = $mergedFieldDefinition;
     }
     return $result;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:32,代码来源:Service.php

示例15: put

 /**
  * @param resource $data
  * @throws DAV\Exception\Forbidden
  * @throws \Exception
  */
 function put($data)
 {
     if ($this->asset->isAllowed("publish")) {
         // read from resource -> default for SabreDAV
         $tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/asset-dav-tmp-file-" . uniqid();
         file_put_contents($tmpFile, $data);
         $file = fopen($tmpFile, "r+");
         $user = AdminTool::getCurrentUser();
         $this->asset->setUserModification($user->getId());
         $this->asset->setStream($file);
         $this->asset->save();
         fclose($file);
         unlink($tmpFile);
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:22,代码来源:File.php


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