Ejemplo n.º 1
1
 /**
  * @return Tool\User
  * @throws \Exception
  */
 public function getUser()
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         return $user;
     }
     throw new \Exception("Webservice instantiated, but no user present");
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * this is a hack for import see: http://www.pimcore.org/issues/browse/PIMCORE-790
  * @param array
  * @return array
  */
 protected function correctClasses($classes)
 {
     // this is the new method with Ext.form.MultiSelect
     /**
      * @extjs6
      * @todo this need to be refactored when extjs3 support is removed
      */
     if (is_string($classes) && !empty($classes) || \Pimcore\Tool\Admin::isExtJS6() && is_array($classes)) {
         if (!\Pimcore\Tool\Admin::isExtJS6()) {
             $classParts = explode(",", $classes);
         } else {
             $classParts = $classes;
         }
         $classes = array();
         foreach ($classParts as $class) {
             if (is_array($class)) {
                 $classes[] = $class;
             } else {
                 if ($class) {
                     $classes[] = array("classes" => $class);
                 }
             }
         }
     }
     // this was the legacy method with Ext.SuperField
     if (is_array($classes) && array_key_exists("classes", $classes)) {
         $classes = array($classes);
     }
     if (!is_array($classes)) {
         $classes = array();
     }
     return $classes;
 }
Ejemplo n.º 4
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $maintenance = false;
     $file = \Pimcore\Tool\Admin::getMaintenanceModeFile();
     if (is_file($file)) {
         $conf = (include $file);
         if (isset($conf["sessionId"])) {
             if ($conf["sessionId"] != $_COOKIE["pimcore_admin_sid"]) {
                 $maintenance = true;
             }
         } else {
             @unlink($file);
         }
     }
     // do not activate the maintenance for the server itself
     // this is to avoid problems with monitoring agents
     $serverIps = ["127.0.0.1"];
     if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) {
         header("HTTP/1.1 503 Service Temporarily Unavailable", 503);
         $file = PIMCORE_PATH . "/static/html/maintenance.html";
         $customFile = PIMCORE_CUSTOM_CONFIGURATION_DIRECTORY . "/maintenance.html";
         if (file_exists($customFile)) {
             $file = $customFile;
         }
         echo file_get_contents($file);
         exit;
     }
 }
Ejemplo n.º 5
0
 public function saveAction()
 {
     try {
         if ($this->getParam("id")) {
             $link = Document\Hardlink::getById($this->getParam("id"));
             $this->setValuesToDocument($link);
             $link->setModificationDate(time());
             $link->setUserModification($this->getUser()->getId());
             if ($this->getParam("task") == "unpublish") {
                 $link->setPublished(false);
             }
             if ($this->getParam("task") == "publish") {
                 $link->setPublished(true);
             }
             // only save when publish or unpublish
             if ($this->getParam("task") == "publish" && $link->isAllowed("publish") || $this->getParam("task") == "unpublish" && $link->isAllowed("unpublish")) {
                 $link->save();
                 $this->_helper->json(["success" => true]);
             }
         }
     } catch (\Exception $e) {
         \Logger::log($e);
         if (\Pimcore\Tool\Admin::isExtJS6() && $e instanceof Element\ValidationException) {
             $this->_helper->json(["success" => false, "type" => "ValidationException", "message" => $e->getMessage(), "stack" => $e->getTraceAsString(), "code" => $e->getCode()]);
         }
         throw $e;
     }
     $this->_helper->json(false);
 }
Ejemplo n.º 6
0
 public static function getRecordIdForGridRequest($param)
 {
     if (!\Pimcore\Tool\Admin::isExtJS6() && is_numeric($param)) {
         return intval($param);
     } else {
         $param = json_decode($param, true);
         return $param['id'];
     }
 }
Ejemplo n.º 7
0
 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"]);
 }
Ejemplo n.º 8
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->input = $input;
     $this->output = $output;
     // use Console\Dumper for nice debug output
     $this->dumper = new Dumper($this->output);
     // skip if maintenance mode is on and the flag is not set
     if (Admin::isInMaintenanceMode() && !$input->getOption('ignore-maintenance-mode')) {
         throw new \RuntimeException('In maintenance mode - set the flag --ignore-maintenance-mode to force execution!');
     }
 }
Ejemplo n.º 9
0
 /**
  * @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);
 }
Ejemplo n.º 10
0
 public function updateAction()
 {
     $report = CustomReport\Config::getByName($this->getParam("name"));
     $data = \Zend_Json::decode($this->getParam("configuration"));
     if (\Pimcore\Tool\Admin::isExtJS6() && !is_array($data["yAxis"])) {
         $data["yAxis"] = strlen($data["yAxis"]) ? [$data["yAxis"]] : [];
     }
     foreach ($data as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($report, $setter)) {
             $report->{$setter}($value);
         }
     }
     $report->save();
     $this->_helper->json(["success" => true]);
 }
 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
     }
 }
Ejemplo n.º 12
0
 /**
  * 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);
     }
 }
Ejemplo n.º 13
0
 /**
  * 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;
 }
Ejemplo n.º 14
0
 /**
  * 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);
 }
Ejemplo n.º 15
0
 /**
  * this is a hack for import see: http://www.pimcore.org/issues/browse/PIMCORE-790
  * @param array
  * @return array
  */
 protected function correctClasses($classes)
 {
     // this is the new method with Ext.form.MultiSelect
     if (is_string($classes) && !empty($classes) || \Pimcore\Tool\Admin::isExtJS5() && is_array($classes)) {
         if (!\Pimcore\Tool\Admin::isExtJS5()) {
             $classParts = explode(",", $classes);
         } else {
             $classParts = $classes;
         }
         $classes = array();
         foreach ($classParts as $class) {
             $classes[] = array("classes" => $class);
         }
     }
     // this was the legacy method with Ext.SuperField
     if (is_array($classes) && array_key_exists("classes", $classes)) {
         $classes = array($classes);
     }
     if (!is_array($classes)) {
         $classes = array();
     }
     return $classes;
 }
Ejemplo n.º 16
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $maintenance = false;
     $file = \Pimcore\Tool\Admin::getMaintenanceModeFile();
     if (is_file($file)) {
         $conf = new \Zend_Config_Xml($file);
         if ($conf->sessionId) {
             if ($conf->sessionId != $_COOKIE["pimcore_admin_sid"]) {
                 $maintenance = true;
             }
         } else {
             @unlink($file);
         }
     }
     // do not activate the maintenance for the server itself
     // this is to avoid problems with monitoring agents
     $serverIps = array("127.0.0.1");
     if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) {
         header("HTTP/1.1 503 Service Temporarily Unavailable", 503);
         echo file_get_contents(PIMCORE_PATH . "/static/html/maintenance.html");
         exit;
     }
 }
Ejemplo n.º 17
0
 /**
  * Constructor.
  *
  * @param string $name The name of the application
  * @param string $version The version of the application
  *
  * @api
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     parent::__construct('Pimcore CLI', Version::getVersion());
     // init default autoload namespaces
     $this->initDefaultAutoloadNamespaces();
     // allow to register commands here (e.g. through plugins)
     \Pimcore::getEventManager()->trigger('system.console.init', $this);
     $dispatcher = new EventDispatcher();
     $this->setDispatcher($dispatcher);
     $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
         if ($event->getInput()->getOption("maintenance-mode")) {
             // enable maintenance mode if requested
             $maintenanceModeId = 'cache-warming-dummy-session-id';
             $event->getOutput()->writeln('Activating maintenance mode with ID <comment>' . $maintenanceModeId . '</comment> ...');
             Admin::activateMaintenanceMode($maintenanceModeId);
         }
     });
     $dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) {
         if ($event->getInput()->getOption("maintenance-mode")) {
             $event->getOutput()->writeln('Deactivating maintenance mode...');
             Admin::deactivateMaintenanceMode();
         }
     });
 }
Ejemplo n.º 18
0
 /**
  * @param array
  * @return void $assetTypes
  */
 public function setAssetTypes($assetTypes)
 {
     // this is the new method with Ext.form.MultiSelect
     if (is_string($assetTypes) && !empty($assetTypes) || \Pimcore\Tool\Admin::isExtJS6() && is_array($assetTypes)) {
         if (!\Pimcore\Tool\Admin::isExtJS6()) {
             $parts = explode(",", $assetTypes);
         } else {
             $parts = $assetTypes;
         }
         $assetTypes = array();
         foreach ($parts as $type) {
             $assetTypes[] = array("assetTypes" => $type);
         }
     }
     $this->assetTypes = $assetTypes;
     return $this;
 }
Ejemplo n.º 19
0
 public function gridProxyAction()
 {
     if ($this->getParam("language")) {
         $this->setLanguage($this->getParam("language"), true);
     }
     if ($this->getParam("data")) {
         if ($this->getParam("xaction") == "update") {
             try {
                 $data = \Zend_Json::decode($this->getParam("data"));
                 // save
                 $object = Object::getById($data["id"]);
                 /** @var Object\ClassDefinition $class */
                 $class = $object->getClass();
                 if (!$object->isAllowed("publish")) {
                     throw new \Exception("Permission denied. You don't have the rights to save this object.");
                 }
                 $user = Tool\Admin::getCurrentUser();
                 if (!$user->isAdmin()) {
                     $languagePermissions = $object->getPermissions("lEdit", $user);
                     $languagePermissions = explode(",", $languagePermissions["lEdit"]);
                 }
                 $objectData = array();
                 foreach ($data as $key => $value) {
                     $parts = explode("~", $key);
                     if (substr($key, 0, 1) == "~") {
                         $type = $parts[1];
                         $field = $parts[2];
                         $keyid = $parts[3];
                         $getter = "get" . ucfirst($field);
                         $setter = "set" . ucfirst($field);
                         $keyValuePairs = $object->{$getter}();
                         if (!$keyValuePairs) {
                             $keyValuePairs = new Object\Data\KeyValue();
                             $keyValuePairs->setObjectId($object->getId());
                             $keyValuePairs->setClass($object->getClass());
                         }
                         $keyValuePairs->setPropertyWithId($keyid, $value, true);
                         $object->{$setter}($keyValuePairs);
                     } elseif (count($parts) > 1) {
                         $brickType = $parts[0];
                         $brickKey = $parts[1];
                         $brickField = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                         $fieldGetter = "get" . ucfirst($brickField);
                         $brickGetter = "get" . ucfirst($brickType);
                         $valueSetter = "set" . ucfirst($brickKey);
                         $brick = $object->{$fieldGetter}()->{$brickGetter}();
                         if (empty($brick)) {
                             $classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
                             $brickSetter = "set" . ucfirst($brickType);
                             $brick = new $classname($object);
                             $object->{$fieldGetter}()->{$brickSetter}($brick);
                         }
                         $brick->{$valueSetter}($value);
                     } else {
                         if (!$user->isAdmin() && $languagePermissions) {
                             $fd = $class->getFieldDefinition($key);
                             if (!$fd) {
                                 // try to get via localized fields
                                 $localized = $class->getFieldDefinition("localizedfields");
                                 if ($localized instanceof Object\ClassDefinition\Data\Localizedfields) {
                                     $field = $localized->getFieldDefinition($key);
                                     if ($field) {
                                         $currentLocale = (string) \Zend_Registry::get("Zend_Locale");
                                         if (!in_array($currentLocale, $languagePermissions)) {
                                             continue;
                                         }
                                     }
                                 }
                             }
                         }
                         $objectData[$key] = $value;
                     }
                 }
                 $object->setValues($objectData);
                 $object->save();
                 $this->_helper->json(array("data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true));
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         }
     } else {
         // get list of objects
         $folder = Object::getById($this->getParam("folderId"));
         $class = Object\ClassDefinition::getById($this->getParam("classId"));
         $className = $class->getName();
         $colMappings = array("filename" => "o_key", "fullpath" => array("o_path", "o_key"), "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate");
         $start = 0;
         $limit = 20;
         $orderKey = "o_id";
         $order = "ASC";
         $fields = array();
         $bricks = array();
         if ($this->getParam("fields")) {
             $fields = $this->getParam("fields");
             foreach ($fields as $f) {
                 $parts = explode("~", $f);
                 $sub = substr($f, 0, 1);
                 if (substr($f, 0, 1) == "~") {
                     //                        $type = $parts[1];
                     //                        $field = $parts[2];
                     //                        $keyid = $parts[3];
                     // key value, ignore for now
                 } elseif (count($parts) > 1) {
                     $bricks[$parts[0]] = $parts[0];
                 }
             }
         }
         if ($this->getParam("limit")) {
             $limit = $this->getParam("limit");
         }
         if ($this->getParam("start")) {
             $start = $this->getParam("start");
         }
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         if ($sortingSettings['order']) {
             $order = $sortingSettings['order'];
         }
         if (strlen($sortingSettings['orderKey']) > 0) {
             $orderKey = $sortingSettings['orderKey'];
             if (!(substr($orderKey, 0, 1) == "~")) {
                 if (array_key_exists($orderKey, $colMappings)) {
                     $orderKey = $colMappings[$orderKey];
                 }
             }
         }
         $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
         $conditionFilters = array();
         if ($this->getParam("only_direct_children") == "true") {
             $conditionFilters[] = "o_parentId = " . $folder->getId();
         } else {
             $conditionFilters[] = "(o_path = '" . $folder->getFullPath() . "' OR o_path LIKE '" . str_replace("//", "/", $folder->getFullPath() . "/") . "%')";
         }
         // create filter condition
         if ($this->getParam("filter")) {
             $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
         }
         if ($this->getParam("condition")) {
             $conditionFilters[] = "(" . $this->getParam("condition") . ")";
         }
         $list = new $listClass();
         if (!empty($bricks)) {
             foreach ($bricks as $b) {
                 $list->addObjectbrick($b);
             }
         }
         $list->setCondition(implode(" AND ", $conditionFilters));
         $list->setLimit($limit);
         $list->setOffset($start);
         $list->setOrder($order);
         $list->setOrderKey($orderKey);
         if ($class->getShowVariants()) {
             $list->setObjectTypes([Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT]);
         }
         $list->load();
         $objects = array();
         foreach ($list->getObjects() as $object) {
             $o = Object\Service::gridObjectData($object, $fields);
             $objects[] = $o;
         }
         $this->_helper->json(array("data" => $objects, "success" => true, "total" => $list->getTotalCount()));
     }
 }
Ejemplo n.º 20
0
 /**
  * @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();
     }
 }
Ejemplo n.º 21
0
 /**
  * @see Model\Object\ClassDefinition\Data::getDataFromEditmode
  * @param string $data
  * @param null|Model\Object\AbstractObject $object
  * @return string
  */
 public function getDataFromEditmode($data, $object = null)
 {
     if ($data) {
         if (\Pimcore\Tool\Admin::isExtJS5()) {
             return $data;
         } else {
             return explode(",", $data);
         }
     } else {
         return null;
     }
 }
 protected function disableMaintenanceMode()
 {
     if ($this->input->getOption('maintenanceMode')) {
         $this->output->writeln('Deactivating maintenance mode...');
         Admin::deactivateMaintenanceMode();
     }
 }
Ejemplo n.º 23
0
    /**
     * @param \Zend_Controller_Request_Abstract $request
     */
    public function postDispatch(\Zend_Controller_Request_Abstract $request)
    {
        $conf = Config::getSystemConfig();
        // add scripts to editmode
        if (\Pimcore\Tool\Admin::isExtJS6()) {
            $editmodeLibraries = array("/pimcore/static6/js/pimcore/namespace.js", "/pimcore/static6/js/lib/prototype-light.js", "/pimcore/static6/js/lib/jquery.min.js", "/pimcore/static6/js/lib/ext/ext-all.js", "/pimcore/static6/js/lib/ckeditor/ckeditor.js");
            $editmodeScripts = array("/pimcore/static6/js/pimcore/functions.js", "/pimcore/static6/js/pimcore/element/tag/imagehotspotmarkereditor.js", "/pimcore/static6/js/pimcore/element/tag/imagecropper.js", "/pimcore/static6/js/pimcore/document/edit/helper.js", "/pimcore/static6/js/pimcore/document/edit/dnd.js", "/pimcore/static6/js/pimcore/document/tag.js", "/pimcore/static6/js/pimcore/document/tags/block.js", "/pimcore/static6/js/pimcore/document/tags/date.js", "/pimcore/static6/js/pimcore/document/tags/href.js", "/pimcore/static6/js/pimcore/document/tags/multihref.js", "/pimcore/static6/js/pimcore/document/tags/checkbox.js", "/pimcore/static6/js/pimcore/document/tags/image.js", "/pimcore/static6/js/pimcore/document/tags/input.js", "/pimcore/static6/js/pimcore/document/tags/link.js", "/pimcore/static6/js/pimcore/document/tags/select.js", "/pimcore/static6/js/pimcore/document/tags/snippet.js", "/pimcore/static6/js/pimcore/document/tags/textarea.js", "/pimcore/static6/js/pimcore/document/tags/numeric.js", "/pimcore/static6/js/pimcore/document/tags/wysiwyg.js", "/pimcore/static6/js/pimcore/document/tags/renderlet.js", "/pimcore/static6/js/pimcore/document/tags/table.js", "/pimcore/static6/js/pimcore/document/tags/video.js", "/pimcore/static6/js/pimcore/document/tags/multiselect.js", "/pimcore/static6/js/pimcore/document/tags/areablock.js", "/pimcore/static6/js/pimcore/document/tags/area.js", "/pimcore/static6/js/pimcore/document/tags/pdf.js", "/pimcore/static6/js/pimcore/document/edit/helper.js");
            $editmodeStylesheets = array("/pimcore/static6/css/icons.css", "/pimcore/static6/css/editmode.css?_dc=" . time());
        } else {
            $editmodeLibraries = array("/pimcore/static/js/pimcore/namespace.js", "/pimcore/static/js/lib/prototype-light.js", "/pimcore/static/js/lib/jquery.min.js", "/pimcore/static/js/lib/ext/adapter/jquery/ext-jquery-adapter-debug.js", "/pimcore/static/js/lib/ext/ext-all-debug.js", "/pimcore/static/js/lib/ext-plugins/ux/Spinner.js", "/pimcore/static/js/lib/ext-plugins/ux/SpinnerField.js", "/pimcore/static/js/lib/ext-plugins/ux/MultiSelect.js", "/pimcore/static/js/lib/ext-plugins/GridRowOrder/roworder.js", "/pimcore/static/js/lib/ckeditor/ckeditor.js", "/pimcore/static/js/pimcore/libfixes.js");
            $editmodeScripts = array("/pimcore/static/js/pimcore/functions.js", "/pimcore/static/js/pimcore/element/tag/imagehotspotmarkereditor.js", "/pimcore/static/js/pimcore/element/tag/imagecropper.js", "/pimcore/static/js/pimcore/document/edit/helper.js", "/pimcore/static/js/pimcore/document/edit/dnd.js", "/pimcore/static/js/pimcore/document/tag.js", "/pimcore/static/js/pimcore/document/tags/block.js", "/pimcore/static/js/pimcore/document/tags/date.js", "/pimcore/static/js/pimcore/document/tags/href.js", "/pimcore/static/js/pimcore/document/tags/multihref.js", "/pimcore/static/js/pimcore/document/tags/checkbox.js", "/pimcore/static/js/pimcore/document/tags/image.js", "/pimcore/static/js/pimcore/document/tags/input.js", "/pimcore/static/js/pimcore/document/tags/link.js", "/pimcore/static/js/pimcore/document/tags/select.js", "/pimcore/static/js/pimcore/document/tags/snippet.js", "/pimcore/static/js/pimcore/document/tags/textarea.js", "/pimcore/static/js/pimcore/document/tags/numeric.js", "/pimcore/static/js/pimcore/document/tags/wysiwyg.js", "/pimcore/static/js/pimcore/document/tags/renderlet.js", "/pimcore/static/js/pimcore/document/tags/table.js", "/pimcore/static/js/pimcore/document/tags/video.js", "/pimcore/static/js/pimcore/document/tags/multiselect.js", "/pimcore/static/js/pimcore/document/tags/areablock.js", "/pimcore/static/js/pimcore/document/tags/area.js", "/pimcore/static/js/pimcore/document/tags/pdf.js", "/pimcore/static/js/pimcore/document/edit/helper.js");
            $editmodeStylesheets = array("/pimcore/static/css/icons.css", "/pimcore/static/css/editmode.css?asd=" . time());
        }
        //add plugin editmode JS and CSS
        try {
            $pluginConfigs = ExtensionManager::getPluginConfigs();
            $jsPaths = array();
            $cssPaths = array();
            if (!empty($pluginConfigs)) {
                //registering plugins
                foreach ($pluginConfigs as $p) {
                    $pluginJsPaths = array();
                    if (array_key_exists("pluginDocumentEditmodeJsPaths", $p['plugin']) && is_array($p['plugin']['pluginDocumentEditmodeJsPaths']) && isset($p['plugin']['pluginDocumentEditmodeJsPaths']['path'])) {
                        if (is_array($p['plugin']['pluginDocumentEditmodeJsPaths']['path'])) {
                            $pluginJsPaths = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                        } else {
                            if ($p['plugin']['pluginDocumentEditmodeJsPaths']['path'] != null) {
                                $pluginJsPaths[] = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                            }
                        }
                    }
                    //manipulate path for frontend
                    if (is_array($pluginJsPaths) and count($pluginJsPaths) > 0) {
                        for ($i = 0; $i < count($pluginJsPaths); $i++) {
                            if (is_file(PIMCORE_PLUGINS_PATH . $pluginJsPaths[$i])) {
                                $jsPaths[] = "/plugins" . $pluginJsPaths[$i];
                            }
                        }
                    }
                    $pluginCssPaths = array();
                    if (array_key_exists("pluginDocumentEditmodeCssPaths", $p['plugin']) && is_array($p['plugin']['pluginDocumentEditmodeCssPaths']) && isset($p['plugin']['pluginDocumentEditmodeCssPaths']['path'])) {
                        if (is_array($p['plugin']['pluginDocumentEditmodeCssPaths']['path'])) {
                            $pluginCssPaths = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                        } else {
                            if ($p['plugin']['pluginDocumentEditmodeCssPaths']['path'] != null) {
                                $pluginCssPaths[] = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                            }
                        }
                    }
                    //manipulate path for frontend
                    if (is_array($pluginCssPaths) and count($pluginCssPaths) > 0) {
                        for ($i = 0; $i < count($pluginCssPaths); $i++) {
                            if (is_file(PIMCORE_PLUGINS_PATH . $pluginCssPaths[$i])) {
                                $cssPaths[] = "/plugins" . $pluginCssPaths[$i];
                            }
                        }
                    }
                }
            }
            $editmodeScripts = array_merge($editmodeScripts, $jsPaths);
            $editmodeStylesheets = array_merge($editmodeStylesheets, $cssPaths);
        } catch (\Exception $e) {
            \Logger::alert("there is a problem with the plugin configuration");
            \Logger::alert($e);
        }
        $editmodeHeadHtml = "\n\n\n<!-- pimcore editmode -->\n";
        // include stylesheets
        foreach ($editmodeStylesheets as $sheet) {
            $editmodeHeadHtml .= '<link rel="stylesheet" type="text/css" href="' . $sheet . '?_dc=' . Version::$revision . '" />';
            $editmodeHeadHtml .= "\n";
        }
        $editmodeHeadHtml .= "\n\n";
        $editmodeHeadHtml .= '<script type="text/javascript">var jQueryPreviouslyLoaded = (typeof jQuery == "undefined") ? false : true;</script>' . "\n";
        // include script libraries
        foreach ($editmodeLibraries as $script) {
            $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Version::$revision . '"></script>';
            $editmodeHeadHtml .= "\n";
        }
        // combine the pimcore scripts in non-devmode
        if ($conf->general->devmode) {
            foreach ($editmodeScripts as $script) {
                $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Version::$revision . '"></script>';
                $editmodeHeadHtml .= "\n";
            }
        } else {
            $scriptContents = "";
            foreach ($editmodeScripts as $scriptUrl) {
                $scriptContents .= file_get_contents(PIMCORE_DOCUMENT_ROOT . $scriptUrl) . "\n\n\n";
            }
            $editmodeHeadHtml .= '<script type="text/javascript" src="' . \Pimcore\Tool\Admin::getMinimizedScriptPath($scriptContents) . '?_dc=' . Version::$revision . '"></script>' . "\n";
        }
        $user = \Pimcore\Tool\Authentication::authenticateSession();
        $lang = $user->getLanguage();
        $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-system/language/' . $lang . '/?_dc=' . Version::$revision . '"></script>' . "\n";
        $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-admin/language/' . $lang . '/?_dc=' . Version::$revision . '"></script>' . "\n";
        $editmodeHeadHtml .= "\n\n";
        // set var for editable configurations which is filled by Document\Tag::admin()
        $editmodeHeadHtml .= '<script type="text/javascript">
            var editableConfigurations = new Array();
            var pimcore_document_id = ' . $request->getParam("document")->getId() . ';

            if(jQueryPreviouslyLoaded) {
                jQuery.noConflict( true );
            }
        </script>';
        $editmodeHeadHtml .= "\n\n<!-- /pimcore editmode -->\n\n\n";
        // add scripts in html header for pages in editmode
        if ($this->controller->editmode && Document\Service::isValidType($this->controller->document->getType())) {
            //ckogler
            include_once "simple_html_dom.php";
            $body = $this->getResponse()->getBody();
            $html = str_get_html($body);
            if ($html) {
                $htmlElement = $html->find("html", 0);
                $head = $html->find("head", 0);
                $bodyElement = $html->find("body", 0);
                // if there's no head and no body, create a wrapper including these elements
                // add html headers for snippets in editmode, so there is no problem with javascript
                if (!$head && !$bodyElement && !$htmlElement) {
                    $body = "<!DOCTYPE html>\n<html>\n<head></head><body>" . $body . "</body></html>";
                    $html = str_get_html($body);
                    // get them again with the updated html markup
                    $htmlElement = $html->find("html", 0);
                    $head = $html->find("head", 0);
                    $bodyElement = $html->find("body", 0);
                }
                if ($head && $bodyElement && $htmlElement) {
                    $head->innertext = $head->innertext . "\n\n" . $editmodeHeadHtml;
                    $bodyElement->onunload = "pimcoreOnUnload();";
                    if (\Pimcore\Tool\Admin::isExtJS6()) {
                        $bodyElement->innertext = $bodyElement->innertext . "\n\n" . '<script type="text/javascript" src="/pimcore/static6/js/pimcore/document/edit/startup.js?_dc=' . Version::$revision . '"></script>' . "\n\n";
                    } else {
                        $bodyElement->innertext = $bodyElement->innertext . "\n\n" . '<script type="text/javascript" src="/pimcore/static/js/pimcore/document/edit/startup.js?_dc=' . Version::$revision . '"></script>' . "\n\n";
                    }
                    $body = $html->save();
                    $this->getResponse()->setBody($body);
                } else {
                    $this->getResponse()->setBody('<div style="font-size:30px; font-family: Arial; font-weight:bold; color:red; text-align: center; margin: 40px 0">You have to define a &lt;html&gt;, &lt;head&gt;, &lt;body&gt;<br />HTML-tag in your view/layout markup!</div>');
                }
                $html->clear();
                unset($html);
            }
        }
        // IE compatibility
        //$this->getResponse()->setHeader("X-UA-Compatible", "IE=8; IE=9", true);
    }
Ejemplo n.º 24
0
 public function save()
 {
     // check if there's a valid user
     if (!$this->getUser()) {
         // try to use the logged in user
         if (\Pimcore::inAdmin()) {
             if ($user = \Pimcore\Tool\Admin::getCurrentUser()) {
                 $this->setUser($user->getId());
             }
         }
     }
     $this->getResource()->save();
 }
Ejemplo n.º 25
0
 /**  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;
 }
Ejemplo n.º 26
0
 /**
  * @param $filters
  * @param $fields
  * @param bool $ignoreSelectAndGroupBy
  * @param null $drillDownFilters
  * @param null $selectField
  * @return array
  */
 protected function getBaseQuery($filters, $fields, $ignoreSelectAndGroupBy = false, $drillDownFilters = null, $selectField = null)
 {
     $db = Resource::get();
     $condition = array("1 = 1");
     $sql = $this->buildQueryString($this->config, $ignoreSelectAndGroupBy, $drillDownFilters, $selectField);
     $data = "";
     if ($filters) {
         if (is_array($filters)) {
             foreach ($filters as $filter) {
                 if (\Pimcore\Tool\Admin::isExtJS6()) {
                     $operator = $filter['operator'];
                     switch ($operator) {
                         case 'like':
                             $condition[] = $db->quoteIdentifier($filter["property"]) . " LIKE " . $db->quote("%" . $filter["value"] . "%");
                             break;
                         case "lt":
                         case "gt":
                         case "eq":
                             $compMapping = array("lt" => "<", "gt" => ">", "eq" => "=");
                             $condition[] = $db->quoteIdentifier($filter["property"]) . " " . $compMapping[$operator] . " " . $db->quote($filter["value"]);
                             break;
                         case "=":
                             $condition[] = $db->quoteIdentifier($filter["property"]) . " = " . $db->quote((int) $filter["value"]);
                             break;
                     }
                 } else {
                     if ($filter["type"] == "string") {
                         $condition[] = $db->quoteIdentifier($filter["field"]) . " LIKE " . $db->quote("%" . $filter["value"] . "%");
                     } else {
                         if ($filter["type"] == "numeric") {
                             $compMapping = array("lt" => "<", "gt" => ">", "eq" => "=");
                             if ($compMapping[$filter["comparison"]]) {
                                 $condition[] = $db->quoteIdentifier($filter["field"]) . " " . $compMapping[$filter["comparison"]] . " " . $db->quote($filter["value"]);
                             }
                         } else {
                             if ($filter["type"] == "boolean") {
                                 $condition[] = $db->quoteIdentifier($filter["field"]) . " = " . $db->quote((int) $filter["value"]);
                             } else {
                                 if ($filter["type"] == "date") {
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!preg_match("/(ALTER|CREATE|DROP|RENAME|TRUNCATE|UPDATE|DELETE) /i", $sql, $matches)) {
         $condition = implode(" AND ", $condition);
         $total = "SELECT COUNT(*) FROM (" . $sql . ") AS somerandxyz WHERE " . $condition;
         if ($fields) {
             $data = "SELECT `" . implode("`, `", $fields) . "` FROM (" . $sql . ") AS somerandxyz WHERE " . $condition;
         } else {
             $data = "SELECT * FROM (" . $sql . ") AS somerandxyz WHERE " . $condition;
         }
     } else {
         return;
     }
     return array("data" => $data, "count" => $total);
 }
Ejemplo n.º 27
0
 /**
  * @param $instance
  * @throws \Zend_Exception
  */
 public static function initTranslations($instance)
 {
     $language = "en";
     $locale = $instance->getLanguage();
     if ($locale) {
         $locale = new \Zend_Locale($locale);
         foreach ([(string) $locale, $locale->getLanguage()] as $localeVariant) {
             if (in_array($localeVariant, AdminTool::getLanguages())) {
                 $language = $localeVariant;
                 break;
             }
         }
     }
     //add translations to registry
     $coreLanguageFile = AdminTool::getLanguageFile($language);
     $translator = new \Zend_Translate('Pimcore\\Translate\\Adapter\\Json', $coreLanguageFile, $language);
     $languageFile = AdminTool::getLanguageFile($language);
     $translator->addTranslation($languageFile, $language);
     if (\Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = \Zend_Registry::get("Zend_Locale");
         @$translator->setLocale($locale);
     }
     \Zend_Registry::set("Zend_Translate", $translator);
     if ($instance) {
         $instance->setTranslator($translator);
     }
 }
Ejemplo n.º 28
0
 public function getLanguageFlagAction()
 {
     $iconPath = Tool::getLanguageFlagFile($this->getParam("language"));
     if (Tool\Admin::isExtJS6()) {
         header("Content-Type: image/svg+xml");
     } else {
         header("Content-Type: image/png");
     }
     echo file_get_contents($iconPath);
     exit;
 }
Ejemplo n.º 29
0
 protected function getRoleTreeNodeConfig($role)
 {
     $tmpUser = ["id" => $role->getId(), "text" => $role->getName(), "elementType" => "role", "qtipCfg" => ["title" => "ID: " . $role->getId()]];
     // set type specific settings
     if ($role instanceof User\Role\Folder) {
         $tmpUser["leaf"] = false;
         $tmpUser["iconCls"] = "pimcore_icon_folder";
         $tmpUser["expanded"] = true;
         $tmpUser["allowChildren"] = true;
         if ($role->hasChilds()) {
             $tmpUser["expanded"] = false;
         } elseif (\Pimcore\Tool\Admin::isExtJS6()) {
             $tmpUser["loaded"] = true;
         }
     } else {
         $tmpUser["leaf"] = true;
         $tmpUser["iconCls"] = "pimcore_icon_roles";
         $tmpUser["allowChildren"] = false;
     }
     return $tmpUser;
 }
Ejemplo n.º 30
0
 public function importProcessAction()
 {
     $success = true;
     $parentId = $this->getParam("parentId");
     $job = $this->getParam("job");
     $id = $this->getParam("id");
     $mappingRaw = \Zend_Json::decode($this->getParam("mapping"));
     $class = Object\ClassDefinition::getById($this->getParam("classId"));
     $skipFirstRow = $this->getParam("skipHeadRow") == "true";
     $fields = $class->getFieldDefinitions();
     $file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
     // currently only csv supported
     // determine type
     $dialect = Tool\Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
     $count = 0;
     if (($handle = fopen($file, "r")) !== false) {
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     if ($skipFirstRow && $job == 1) {
         //read the next row, we need to skip the head row
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     $tmpFile = $file . "_tmp";
     $tmpHandle = fopen($tmpFile, "w+");
     while (!feof($handle)) {
         $buffer = fgets($handle);
         fwrite($tmpHandle, $buffer);
     }
     fclose($handle);
     fclose($tmpHandle);
     unlink($file);
     rename($tmpFile, $file);
     // prepare mapping
     foreach ($mappingRaw as $map) {
         if ($map[0] !== "" && $map[1] && !empty($map[2])) {
             $mapping[$map[2]] = $map[0];
         } else {
             if ($map[1] == "published (system)") {
                 $mapping["published"] = $map[0];
             } else {
                 if ($map[1] == "type (system)") {
                     $mapping["type"] = $map[0];
                 }
             }
         }
     }
     // create new object
     $className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     $className = Tool::getModelClassMapping($className);
     $parent = Object::getById($this->getParam("parentId"));
     $objectKey = "object_" . $job;
     if ($this->getParam("filename") == "id") {
         $objectKey = null;
     } else {
         if ($this->getParam("filename") != "default") {
             $objectKey = File::getValidFilename($data[$this->getParam("filename")]);
         }
     }
     $overwrite = false;
     if ($this->getParam("overwrite") == "true") {
         $overwrite = true;
     }
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getFullPath() . "/" . $objectKey;
         if ($overwrite) {
             $object = Object::getByPath($intendedPath);
             if (!$object instanceof Object\Concrete) {
                 //create new object
                 $object = new $className();
             } else {
                 if ($object instanceof Object\Concrete and !$object instanceof $className) {
                     //delete the old object it is of a different class
                     $object->delete();
                     $object = new $className();
                 } else {
                     if ($object instanceof Object\Folder) {
                         //delete the folder
                         $object->delete();
                         $object = new $className();
                     } else {
                         //use the existing object
                     }
                 }
             }
         } else {
             $counter = 1;
             while (Object::getByPath($intendedPath) != null) {
                 $objectKey .= "_" . $counter;
                 $intendedPath = $parent->getFullPath() . "/" . $objectKey;
                 $counter++;
             }
             $object = new $className();
         }
         $object->setClassId($this->getParam("classId"));
         $object->setClassName($this->getParam("className"));
         $object->setParentId($this->getParam("parentId"));
         $object->setKey($objectKey);
         $object->setCreationDate(time());
         $object->setUserOwner($this->getUser()->getId());
         $object->setUserModification($this->getUser()->getId());
         if (in_array($data[$mapping["type"]], ["object", "variant"])) {
             $object->setType($data[$mapping["type"]]);
         } else {
             $object->setType("object");
         }
         if ($data[$mapping["published"]] === "1") {
             $object->setPublished(true);
         } else {
             $object->setPublished(false);
         }
         foreach ($class->getFieldDefinitions() as $key => $field) {
             $value = $data[$mapping[$key]];
             if (array_key_exists($key, $mapping) and $value != null) {
                 // data mapping
                 $value = $field->getFromCsvImport($value);
                 if ($value !== null) {
                     $object->setValue($key, $value);
                 }
             }
         }
         try {
             $object->save();
             $this->_helper->json(array("success" => true));
         } catch (\Exception $e) {
             $this->_helper->json(array("success" => false, "message" => $object->getKey() . " - " . $e->getMessage()));
         }
     }
     $this->_helper->json(array("success" => $success));
 }