예제 #1
0
파일: Href.php 프로젝트: ngocanh/pimcore
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $values = explode(":", $importValue);
     if (count($values) == 2) {
         $type = $values[0];
         $path = $values[1];
         $value = Element_Service::getElementByPath($type, $path);
     } else {
         //fallback for old export files
         if ($el = Asset::getByPath($importValue)) {
             $value = $el;
         } else {
             if ($el = Document::getByPath($importValue)) {
                 $value = $el;
             } else {
                 if ($el = Object_Abstract::getByPath($importValue)) {
                     $value = $el;
                 }
             }
         }
     }
     return $value;
 }
예제 #2
0
 protected function getImportCopyName($intendedPath, $key, $objectId, $type)
 {
     $equalObject = Element_Service::getElementByPath($type, str_replace("//", "/", $intendedPath . "/" . $key));
     while ($equalObject and $equalObject->getId() != $objectId) {
         $key .= "_importcopy";
         $equalObject = Element_Service::getElementByPath($type, str_replace("//", "/", $intendedPath . "/" . $key));
         if (!$equalObject) {
             break;
         }
     }
     return $key;
 }
예제 #3
0
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         $tokens = explode(":", $element);
         if (count($tokens) == 2) {
             $type = $tokens[0];
             $path = $tokens[1];
             $value[] = Element_Service::getElementByPath($type, $path);
         } else {
             //fallback for old export files
             if ($el = Asset::getByPath($element)) {
                 $value[] = $el;
             } else {
                 if ($el = Document::getByPath($element)) {
                     $value[] = $el;
                 } else {
                     if ($el = Object_Abstract::getByPath($element)) {
                         $value[] = $el;
                     }
                 }
             }
         }
     }
     return $value;
 }
예제 #4
0
 public function updateAction()
 {
     $user = User_Abstract::getById(intval($this->_getParam("id")));
     if ($this->_getParam("data")) {
         $values = Zend_Json::decode($this->_getParam("data"));
         if (!empty($values["password"])) {
             $values["password"] = Pimcore_Tool_Authentication::getPasswordHash($user->getName(), $values["password"]);
         }
         if (method_exists($user, "setAllAclToFalse")) {
             $user->setAllAclToFalse();
         }
         $user->setValues($values);
         // check for permissions
         $availableUserPermissionsList = new User_Permission_Definition_List();
         $availableUserPermissions = $availableUserPermissionsList->load();
         foreach ($availableUserPermissions as $permission) {
             if ($values["permission_" . $permission->getKey()]) {
                 $user->setPermission($permission->getKey(), (bool) $values["permission_" . $permission->getKey()]);
             }
         }
         // check for workspaces
         if ($this->_getParam("workspaces")) {
             $workspaces = Zend_Json::decode($this->_getParam("workspaces"));
             foreach ($workspaces as $type => $spaces) {
                 $newWorkspaces = array();
                 foreach ($spaces as $space) {
                     $element = Element_Service::getElementByPath($type, $space["path"]);
                     if ($element) {
                         $className = "User_Workspace_" . ucfirst($type);
                         $workspace = new $className();
                         $workspace->setValues($space);
                         $workspace->setCid($element->getId());
                         $workspace->setCpath($element->getFullPath());
                         $workspace->setUserId($user->getId());
                         $newWorkspaces[] = $workspace;
                     }
                 }
                 $user->{"setWorkspaces" . ucfirst($type)}($newWorkspaces);
             }
         }
     }
     $user->save();
     $this->_helper->json(array("success" => true));
 }