public function saveAction() { $success = false; if ($this->_getParam("id")) { $asset = Asset::getById($this->_getParam("id")); $asset->getPermissionsForUser($this->getUser()); if ($asset->isAllowed("publish")) { // properties if ($this->_getParam("properties")) { $properties = array(); $propertiesData = Zend_Json::decode($this->_getParam("properties")); if (is_array($propertiesData)) { foreach ($propertiesData as $propertyName => $propertyData) { $value = $propertyData["data"]; try { $property = new Property(); $property->setType($propertyData["type"]); $property->setName($propertyName); $property->setCtype("asset"); $property->setDataFromEditmode($value); $property->setInheritable($propertyData["inheritable"]); $properties[$propertyName] = $property; } catch (Exception $e) { Logger::err("Can't add " . $propertyName . " to asset " . $asset->getFullPath()); } } $asset->setProperties($properties); } } // permissions if ($this->_getParam("permissions")) { $permissions = array(); $permissionsData = Zend_Json::decode($this->_getParam("permissions")); if (is_array($permissionsData)) { foreach ($permissionsData as $permissionData) { $permission = new Asset_Permissions(); $permission->setValues($permissionData); $permissions[] = $permission; } } $asset->setPermissions($permissions); } // scheduled tasks if ($this->_getParam("scheduler")) { $tasks = array(); $tasksData = Zend_Json::decode($this->_getParam("scheduler")); if (!empty($tasksData)) { foreach ($tasksData as $taskData) { $taskData["date"] = strtotime($taskData["date"] . " " . $taskData["time"]); $task = new Schedule_Task($taskData); $tasks[] = $task; } } $asset->setScheduledTasks($tasks); } if ($this->_getParam("data")) { $asset->setData($this->_getParam("data")); } $asset->setUserModification($this->getUser()->getId()); try { $asset->save(); $asset->getData(); $success = true; } catch (Exception $e) { $this->_helper->json(array("success" => false, "message" => $e->getMessage())); } } else { Logger::debug("prevented save asset because of missing permissions "); } $this->_helper->json(array("success" => $success)); } $this->_helper->json(false); }