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


PHP Object_Abstract::GetById方法代码示例

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


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

示例1: getTreePermissionsAction

 public function getTreePermissionsAction()
 {
     $this->removeViewRenderer();
     $user = User::getById($this->_getParam("user"));
     if ($this->_getParam("xaction") == "update") {
         $data = json_decode($this->_getParam("data"));
         if (!empty($data->id)) {
             $nodes[] = $data;
         } else {
             $nodes = $data;
         }
         //loop through store nodes  = objects to edit
         if (is_array($nodes)) {
             foreach ($nodes as $node) {
                 $object = Object_Abstract::GetById($node->id);
                 $parent = Object_Abstract::getById($object->getParentId());
                 $objectPermission = $object->getPermissionsForUser($user);
                 if ($objectPermission instanceof Object_Permissions) {
                     $found = true;
                     if (!$node->permissionSet) {
                         //reset permission by deleting it
                         if ($objectPermission->getCid() == $object->getId()) {
                             $objectPermission->delete();
                             $permissions = $object->getPermissions();
                         }
                         break;
                     } else {
                         if ($objectPermission->getCid() != $object->getId() or $objectPermission->getUser()->getId() != $user->getId()) {
                             //we got a parent's permission create new permission
                             //or we got a usergroup permission, create a new permission for specific user
                             $objectPermission = new Object_Permissions();
                             $objectPermission->setUser($user);
                             $objectPermission->setUserId($user->getId());
                             $objectPermission->setUsername($user->getUsername());
                             $objectPermission->setCid($object->getId());
                             $objectPermission->setCpath($object->getFullPath());
                         }
                         //update object_permission
                         $permissionNames = $objectPermission->getValidPermissionKeys();
                         foreach ($permissionNames as $name) {
                             //check if parent allows list
                             if ($parent) {
                                 $parent->getPermissionsForUser($user);
                                 $parentList = $parent->isAllowed("list");
                             } else {
                                 $parentList = true;
                             }
                             $setterName = "set" . ucfirst($name);
                             if (isset($node->{$name}) and $node->{$name} and $parentList) {
                                 $objectPermission->{$setterName}(true);
                             } else {
                                 if (isset($node->{$name})) {
                                     $objectPermission->{$setterName}(false);
                                     //if no list permission set all to false
                                     if ($name == "list") {
                                         foreach ($permissionNames as $n) {
                                             $setterName = "set" . ucfirst($n);
                                             $objectPermission->{$setterName}(false);
                                         }
                                         break;
                                     }
                                 }
                             }
                         }
                         $objectPermission->save();
                         if ($node->evictChildrenPermissions) {
                             $successorList = new Object_List();
                             $successorList->setOrderKey("o_key");
                             $successorList->setOrder("asc");
                             if ($object->getParentId() < 1) {
                                 $successorList->setCondition("o_parentId > 0");
                             } else {
                                 $successorList->setCondition("o_path like '" . $object->getFullPath() . "/%'");
                             }
                             $successors = $successorList->load();
                             foreach ($successors as $successor) {
                                 $permission = $successor->getPermissionsForUser($user);
                                 if ($permission->getId() > 0 and $permission->getCid() == $successor->getId()) {
                                     $permission->delete();
                                 }
                             }
                         }
                     }
                 }
             }
             $this->_helper->json(array("success" => true));
         }
     } else {
         if ($this->_getParam("xaction") == "destroy") {
             //ignore
         } else {
             //read
             if ($user instanceof User) {
                 $userPermissionsNamespace = new Zend_Session_Namespace('objectUserPermissions');
                 if (!isset($userPermissionsNamespace->expandedNodes) or $userPermissionsNamespace->currentUser != $user->getId()) {
                     $userPermissionsNamespace->currentUser = $user->getId();
                     $userPermissionsNamespace->expandedNodes = array();
                 }
                 if (is_numeric($this->_getParam("anode")) and $this->_getParam("anode") > 0) {
                     $node = $this->_getParam("anode");
//.........这里部分代码省略.........
开发者ID:ngocanh,项目名称:pimcore,代码行数:101,代码来源:ObjectController.php


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