示例#1
0
 /**
  * finds all objects which hold a reference to a specific user
  *
  * @static
  * @param  integer $userId
  * @return Concrete[]
  */
 public static function getObjectsReferencingUser($userId)
 {
     $userObjects = array();
     $classesList = new ClassDefinition\Listing();
     $classesList->setOrderKey("name");
     $classesList->setOrder("asc");
     $classes = $classesList->load();
     $classesToCheck = array();
     if (is_array($classes)) {
         foreach ($classes as $class) {
             $fieldDefinitions = $class->getFieldDefinitions();
             $dataKeys = array();
             if (is_array($fieldDefinitions)) {
                 foreach ($fieldDefinitions as $tag) {
                     if ($tag instanceof ClassDefinition\Data\User) {
                         $dataKeys[] = $tag->getName();
                     }
                 }
             }
             if (is_array($dataKeys) and count($dataKeys) > 0) {
                 $classesToCheck[$class->getName()] = $dataKeys;
             }
         }
     }
     foreach ($classesToCheck as $classname => $fields) {
         $listName = "\\Pimcore\\Model\\Object\\" . ucfirst($classname) . "\\Listing";
         $list = new $listName();
         $conditionParts = array();
         foreach ($fields as $field) {
             $conditionParts[] = $field . "='" . $userId . "'";
         }
         $list->setCondition(implode(" AND ", $conditionParts));
         $objects = $list->load();
         $userObjects = array_merge($userObjects, $objects);
     }
     return $userObjects;
 }
示例#2
0
 /**
  * See http://www.pimcore.org/issues/browse/PIMCORE-2358
  * Add option to export/import all class definitions/brick definitions etc. at once
  */
 public function bulkExportAction()
 {
     $result = [];
     $this->removeViewRenderer();
     $fieldCollections = new Object\Fieldcollection\Definition\Listing();
     $fieldCollections = $fieldCollections->load();
     foreach ($fieldCollections as $fieldCollection) {
         $key = $fieldCollection->key;
         $fieldCollectionJson = json_decode(Object\ClassDefinition\Service::generateFieldCollectionJson($fieldCollection));
         $fieldCollectionJson->key = $key;
         $result["fieldcollection"][] = $fieldCollectionJson;
     }
     $classes = new Object\ClassDefinition\Listing();
     $classes->setOrder("ASC");
     $classes->setOrderKey("id");
     $classes = $classes->load();
     foreach ($classes as $class) {
         $data = Model\Webservice\Data\Mapper::map($class, "\\Pimcore\\Model\\Webservice\\Data\\ClassDefinition\\Out", "out");
         unset($data->fieldDefinitions);
         $result["class"][] = $data;
     }
     $objectBricks = new Object\Objectbrick\Definition\Listing();
     $objectBricks = $objectBricks->load();
     foreach ($objectBricks as $objectBrick) {
         $key = $objectBrick->key;
         $objectBrickJson = json_decode(Object\ClassDefinition\Service::generateObjectBrickJson($objectBrick));
         $objectBrickJson->key = $key;
         $result["objectbrick"][] = $objectBrickJson;
     }
     $customLayouts = new Object\ClassDefinition\CustomLayout\Listing();
     $customLayouts = $customLayouts->load();
     foreach ($customLayouts as $customLayout) {
         /** @var  $customLayout Object\ClassDefinition\CustomLayout */
         $classId = $customLayout->getClassId();
         $class = Object\ClassDefinition::getById($classId);
         $customLayout->className = $class->getName();
         $result["customlayout"][] = $customLayout;
     }
     header("Content-type: application/json");
     header("Content-Disposition: attachment; filename=\"bulk_export.json\"");
     $result = json_encode($result);
     echo $result;
 }