示例#1
0
文件: Export.php 项目: jv10/pimpon
 private static function exportObject(Object_Abstract $object, $key = null)
 {
     if ($object->getId() !== self::ROOT_ID) {
         $objectData = array();
         $objectClass = get_class($object);
         $objectData['class'] = $objectClass;
         if ($objectClass != 'Object_Folder') {
             foreach ($object->getClass()->getFieldDefinitions() as $field) {
                 $property = ucfirst($field->getName());
                 $fieldtype = $field->getFieldtype();
                 $value = $object->{'get' . $property}();
                 $objectData[$property] = PimPon_Object_Encoder::encode($value, $fieldtype);
             }
         }
         foreach (self::$includeMethods as $method) {
             if (method_exists($object, $method) === false) {
                 continue;
             }
             $property = ucfirst(substr($method, 3));
             $value = $object->{$method}();
             $objectData[$property] = PimPon_Object_Encoder_Default::encode($value);
         }
         self::writeDataOnFile($objectData);
     }
     if ($object->hasChilds() === true) {
         array_walk($object->getChilds(), 'PimPon_Object_Export::exportObject');
     }
 }
示例#2
0
文件: Item.php 项目: ngocanh/pimcore
 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Pimcore_Tool_Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object_Abstract) {
                 $indentElement = Object_Abstract::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
示例#3
0
 public function subscribeAction()
 {
     // init
     $status = array('message' => 'error', 'success' => false);
     $newsletter = new Pimcore_Tool_Newsletter('customer');
     $params = $this->getAllParams();
     //
     if ($newsletter->checkParams($params)) {
         try {
             $params["parent"] = Object_Abstract::getByPath("/newsletter/subscribers");
             $user = $newsletter->subscribe($params);
             // user and email document
             // parameters available in the email: gender, firstname, lastname, email, token, object
             // ==> see mailing framework
             $newsletter->sendConfirmationMail($user, Document::getByPath('/en/emails/newsletter-confirmation'));
             // do some other stuff with the new user
             //$user->setSomeCustomField(true);
             //$user->save();
             $status['success'] = true;
             $status['message'] = "";
         } catch (\Exception $e) {
             $status['message'] = $e->getMessage();
         }
     }
     // its a ajax request?
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->viewRenderer->setNoRender(true);
         $this->getResponse()->setHeader('Content-Type', 'application/json');
         echo Zend_Json::encode($status);
     } else {
         $this->view->status = $status;
     }
 }
示例#4
0
 /**
  * @static
  * @param  $element
  * @return string
  */
 public static function getIdPathForElement($element)
 {
     $path = "";
     if ($element instanceof Document) {
         $nid = $element->getParentId();
         $ne = Document::getById($nid);
     } else {
         if ($element instanceof Asset) {
             $nid = $element->getParentId();
             $ne = Asset::getById($nid);
         } else {
             if ($element instanceof Object_Abstract) {
                 $nid = $element->getO_parentId();
                 $ne = Object_Abstract::getById($nid);
             }
         }
     }
     if ($ne) {
         $path = self::getIdPathForElement($ne, $path);
     }
     if ($element) {
         $path = $path . "/" . $element->getId();
     }
     return $path;
 }
示例#5
0
 public function indexAction()
 {
     // check maintenance
     $maintenance_enabled = false;
     $manager = Schedule_Manager_Factory::getManager("maintenance.pid");
     $lastExecution = $manager->getLastExecution();
     if ($lastExecution) {
         if (time() - $lastExecution < 610) {
             // maintenance script should run at least every 10 minutes + a little tolerance
             $maintenance_enabled = true;
         }
     }
     $this->view->maintenance_enabled = Zend_Json::encode($maintenance_enabled);
     // configuration
     $this->view->config = Pimcore_Config::getSystemConfig();
     //mail settings
     $mailIncomplete = false;
     if ($this->view->config->email) {
         $emailSettings = $this->view->config->email->toArray();
         if ($emailSettings['method'] == "sendmail" and !empty($emailSettings['sender']['email'])) {
             $mailIncomplete = true;
         }
         if ($emailSettings['method'] == "smtp" and !empty($emailSettings['sender']['email']) and !empty($emailSettings['smtp']['host'])) {
             $mailIncomplete = true;
         }
     }
     $this->view->mail_settings_incomplete = Zend_Json::encode($mailIncomplete);
     // report configuration
     $this->view->report_config = Pimcore_Config::getReportConfig();
     // customviews config
     $cvConfig = Pimcore_Tool::getCustomViewConfig();
     $cvData = array();
     if ($cvConfig) {
         foreach ($cvConfig as $node) {
             $tmpData = $node;
             $rootNode = Object_Abstract::getByPath($tmpData["rootfolder"]);
             if ($rootNode) {
                 $tmpData["rootId"] = $rootNode->getId();
                 $tmpData["allowedClasses"] = explode(",", $tmpData["classes"]);
                 $tmpData["showroot"] = (bool) $tmpData["showroot"];
                 $cvData[] = $tmpData;
             }
         }
     }
     $this->view->customview_config = $cvData;
     // upload limit
     $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B");
     $max_post = filesize2bytes(ini_get("post_max_size") . "B");
     $memory_limit = filesize2bytes(ini_get("memory_limit") . "B");
     $upload_mb = min($max_upload, $max_post, $memory_limit);
     $this->view->upload_max_filesize = $upload_mb;
     // live connect
     $liveconnectToken = Pimcore_Liveconnect::getToken();
     $this->view->liveconnectToken = $liveconnectToken;
     // adding css minify filter because of IE issues with CkEditor and more than 31 stylesheets
     if (!PIMCORE_DEVMODE) {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800);
     }
 }
示例#6
0
 /**
  * Loads a list of entries for the specicifies parameters, returns an array of Search_Backend_Data
  *
  * @return array
  */
 public function load()
 {
     $entries = array();
     $data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $entryData) {
         if ($entryData['maintype'] == 'document') {
             $element = Document::getById($entryData['id']);
         } else {
             if ($entryData['maintype'] == 'asset') {
                 $element = Asset::getById($entryData['id']);
             } else {
                 if ($entryData['maintype'] == 'object') {
                     $element = Object_Abstract::getById($entryData['id']);
                 } else {
                     Logger::err("unknown maintype ");
                 }
             }
         }
         if ($element) {
             $entry = new Search_Backend_Data();
             $entry->setId(new Search_Backend_Data_Id($element));
             $entry->setFullPath($entryData['fullpath']);
             $entry->setType($entryData['type']);
             $entry->setSubtype($entryData['subtype']);
             $entry->setUserOwner($entryData['userowner']);
             $entry->setUserModification($entryData['usermodification']);
             $entry->setCreationDate($entryData['creationdate']);
             $entry->setModificationDate($entryData['modificationdate']);
             $entry->setPublished($entryData['published'] === 0 ? false : true);
             $entries[] = $entry;
         }
     }
     $this->model->setEntries($entries);
     return $entries;
 }
示例#7
0
 /**
  * @return void
  */
 public function delete()
 {
     if ($this->getO_Id() == 1) {
         throw new Exception("root-node cannot be deleted");
     }
     parent::delete();
 }
示例#8
0
文件: Admin.php 项目: ngocanh/pimcore
 public function init()
 {
     parent::init();
     // set language
     try {
         $locale = Zend_Registry::get("Zend_Locale");
         $this->setLanguage($locale->getLanguage());
     } catch (Exception $e) {
         if ($this->_getParam("language")) {
             $this->setLanguage($this->_getParam("language"));
         } else {
             $config = Pimcore_Config::getSystemConfig();
             $this->setLanguage($config->general->language);
         }
     }
     try {
         Zend_Registry::get("pimcore_admin_initialized");
         $this->setUser(Zend_Registry::get("pimcore_admin_user"));
     } catch (Exception $e) {
         // general definitions
         Document::setHideUnpublished(false);
         Object_Abstract::setHideUnpublished(false);
         Object_Abstract::setGetInheritedValues(false);
         Pimcore::setAdminMode();
         // init translations
         self::initTranslations($this);
         // init zend action helpers
         Zend_Controller_Action_HelperBroker::addPrefix('Pimcore_Controller_Action_Helper');
         // authenticate user, first try to authenticate with session information
         $user = Pimcore_Tool_Authentication::authenticateSession();
         if ($user instanceof User) {
             $this->setUser($user);
             if ($this->getUser()->getLanguage()) {
                 $this->setLanguage($this->getUser()->getLanguage());
             }
         } else {
             // try to authenticate with digest, but this is only allowed for WebDAV
             if ($this->_getParam("module") == "admin" && $this->_getParam("controller") == "asset" && $this->_getParam("action") == "webdav") {
                 $user = Pimcore_Tool_Authentication::authenticateDigest();
                 if ($user instanceof User) {
                     $this->setUser($user);
                     return;
                 }
             }
         }
         // send a auth header for the client (is covered by the ajax object in javascript)
         if (!$this->getUser() instanceof User) {
             $this->getResponse()->setHeader("X-Pimcore-Auth", "required");
         }
         // redirect to the login-page if the user isn't authenticated
         if (!$this->getUser() instanceof User && !($this->_getParam("module") == "admin" && $this->_getParam("controller") == "login")) {
             $this->_redirect("/admin/login");
             $this->getResponse()->sendResponse();
             exit;
         }
         Zend_Registry::set("pimcore_admin_user", $this->getUser());
         Zend_Registry::set("pimcore_admin_initialized", true);
     }
 }
示例#9
0
 public function setAction()
 {
     $owner = $_POST['user'];
     $activities = $_POST['activities'];
     $object = $_POST['object'];
     $isValid = Website_P1GlobalFunction::checkValidation($_POST, array('user', 'activities', 'object'));
     if (count($isValid) > 0) {
         $arrayReturn = array("status" => "failed", "message" => "field not found", "data" => $isValid);
         $json_plans = $this->_helper->json($arrayReturn);
         Website_P1GlobalFunction::sendResponse($json_plans);
         exit;
     }
     $ownerId = Object_Abstract::getById($owner);
     $activitiesId = Object_Abstract::getById($activities);
     $key = str_replace(' ', '_', strtolower($ownerId->Name)) . "-" . str_replace(' ', '_', strtolower($activitiesId->Name) . "-" . rand());
     $now = date("Y-m-d,H-i");
     $getDateTime = new Pimcore_Date($now);
     if ($ownerId->o_className == "Customer") {
         $getId = Object_Abstract::getByPath('/log/customers');
         //get folder id
         $setLog = new Object\LogCustomers();
         $setLog->setCustomers($ownerId);
         $setLog->setActivities($activitiesId);
         $setLog->setObjectContent($object);
         $setLog->setDatetime($getDateTime);
         $setLog->setO_parentId($getId->o_id);
         $setLog->setKey($key);
         $setLog->setPublished(1);
         $setLog->save();
         $status = "Success";
         $message = "Success";
         $data = "Add Customer log Success";
     } else {
         if ($ownerId->o_className == "Agen") {
             $getId = Object_Abstract::getByPath('/log/agen');
             //get folder id
             $setLog = new Object\LogAgents();
             $setLog->setAgen($ownerId);
             $setLog->setActivities($activitiesId);
             $setLog->setObjectContent($object);
             $setLog->setDatetime($getDateTime);
             $setLog->setO_parentId($getId->o_id);
             $setLog->setKey($key);
             $setLog->setPublished(1);
             $setLog->save();
             $status = "Success";
             $message = "Success";
             $data = "Add Agen log Success";
         } else {
             $status = "Field";
             $message = "Log id not found";
             $data = "Null";
         }
     }
     $arrayReturn = array("status" => $status, "message" => $message, "data" => $data);
     $json_log = $this->_helper->json($arrayReturn);
     Website_P1GlobalFunction::sendResponse($json_log);
 }
示例#10
0
 public function productDetailAction()
 {
     $key = $this->_getParam('text');
     $id = $this->_getParam('id');
     $entries = Object_Abstract::getById($id);
     $data = $entries;
     $this->view->product = $data;
     $this->enableLayout();
     $this->view->layout()->setLayout("layout_mobile");
 }
示例#11
0
 /**
  * Preview entry in pimcore admin.
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function previewAction()
 {
     $id = (int) $this->_getParam('o_id');
     $entry = Object_Abstract::getById($id);
     /* @var $entry Blog_Entry */
     if (null == $entry) {
         throw new Zend_Controller_Action_Exception("No entry with ID '{$id}'", 404);
     }
     return $this->_forward('show', null, null, array('key' => $entry->getUrlPath()));
 }
示例#12
0
 /**
  * legacy - not required anymore
  *
  *
  * @return void
  */
 protected function cleanUp()
 {
     try {
         $class = Object_Class::getByName("unittest");
         if ($class instanceof Object_Class) {
             $class->delete();
         }
     } catch (Exception $e) {
     }
     try {
         $objectRoot = Object_Abstract::getById(1);
         if ($objectRoot and $objectRoot->hasChilds()) {
             $childs = $objectRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $assetRoot = Asset::getById(1);
         if ($assetRoot and $assetRoot->hasChilds()) {
             $childs = $assetRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $documentRoot = Asset::getById(1);
         if ($documentRoot and $documentRoot->hasChilds()) {
             $childs = $documentRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $userList = new User_List();
         $userList->setCondition("id > 1");
         $users = $userList->load();
         if (is_array($users) and count($users) > 0) {
             foreach ($users as $user) {
                 $user->delete();
             }
         }
     } catch (Exception $e) {
     }
 }
示例#13
0
 protected function getCondition()
 {
     if ($cond = $this->model->getCondition()) {
         if (Object_Abstract::doHideUnpublished() && !$this->model->getUnpublished()) {
             return " WHERE (" . $cond . ") AND o_published = 1";
         }
         return " WHERE " . $cond . " ";
     } else {
         if (Object_Abstract::doHideUnpublished() && !$this->model->getUnpublished()) {
             return " WHERE o_published = 1";
         }
     }
     return "";
 }
 public function setAction()
 {
     $ipAddress = $_POST['ipaddress'];
     $array = array();
     $arrays = array();
     $http_user_agent = $_SERVER['HTTP_USER_AGENT'];
     //get user agent information
     $getBrowser = $this->getBrowser($http_user_agent);
     $getOS = $this->getOS($http_user_agent);
     $key = $ipAddress . "_" . rand();
     $now = date("Y-m-d,H-i");
     $date = date("Y-m-d");
     $date = strtotime($date);
     $date = strtotime("+7 day", $date);
     $getStartDate = new Pimcore_Date($now);
     $getExpiredDate = new Pimcore_Date($date);
     $is_exist = $this->checkVaalidate($ipAddress);
     //check is exsisting ip or new
     if ($is_exist["status"] != "failed") {
         $this->putAction();
         $this->getAction();
     } else {
         $getId = Object_Abstract::getByPath('/session/');
         //get folder id
         $setSession = new Object\Sessions();
         $setSession->setCreatedAt($getStartDate);
         $setSession->setExpiredAt($getExpiredDate);
         $setSession->setMessage('setNew');
         $setSession->setStatus('Active');
         $setSession->setOs($getOS);
         $setSession->setBrowser($getBrowser);
         $setSession->setIpAddress($ipAddress);
         $setSession->setO_parentId($getId->o_id);
         $setSession->setKey($key);
         $setSession->setPublished(1);
         $setSession->save();
         //$startDate = date("d/m/Y",strtotime(new Pimcore_Date($session->date_tglBuat)));
         //$endDate= date("d/m/Y",strtotime(new Pimcore_Date($session->date_tglLahir)));
         $array['status'] = "success";
         $array['message'] = "success";
         $array['ip_address'] = $ip_address;
         //get active ip from user
         $array['browser'] = $getBrowser;
         $array['os'] = $getOS;
     }
     $json_session = $this->_helper->json($array);
     Website_P1GlobalFunction::sendResponse($json_session);
 }
示例#15
0
 /**
  * Loads a list of objects for the specicifies parameters, returns an array of Object_Abstract elements
  *
  * @return array 
  */
 public function load()
 {
     $objects = array();
     try {
         $objectsData = $this->db->fetchAll("SELECT DISTINCT " . $this->getTableName() . ".o_id AS o_id,o_type FROM `" . $this->getTableName() . "`" . $this->getJoins() . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     } catch (Exception $e) {
         return $this->exceptionHandler($e);
     }
     foreach ($objectsData as $objectData) {
         if ($object = Object_Abstract::getById($objectData["o_id"])) {
             $objects[] = Object_Abstract::getById($objectData["o_id"]);
         }
     }
     $this->model->setObjects($objects);
     return $objects;
 }
示例#16
0
 public function __construct($element)
 {
     parent::__construct($element);
     if ($element instanceof Object_Product) {
         $backup = Object_Abstract::doGetInheritedValues($element);
         Object_Abstract::setGetInheritedValues(true);
         if ($element->getParent() instanceof Object_Product) {
             $this->elementIcon = '/pimcore/static/img/icon/tag_green.png';
             $this->elementIconClass = null;
         } else {
             $this->elementIcon = '/pimcore/static/img/icon/tag_blue.png';
             $this->elementIconClass = null;
         }
         Object_Abstract::setGetInheritedValues($backup);
     }
 }
示例#17
0
 public function exportAction()
 {
     try {
         $objectId = $this->getParam("objectId");
         $object = Object_Abstract::getById($objectId);
         $exportFile = PimPon_Object_Export::doExport($object);
         ob_end_clean();
         header("Content-type: application/json");
         header("Content-Disposition: attachment; filename=\"pimponexport.objects." . $object->getKey() . ".json\"");
         echo file_get_contents($exportFile);
         exit;
     } catch (Exception $ex) {
         Logger::err($ex->getMessage());
         $this->_helper->json(array("success" => false, "data" => 'error'), false);
     }
     $this->getResponse()->setHeader("Content-Type", "text/html");
 }
示例#18
0
 /**
  * Get the data for the object from database for the given id
  * @param integer $id
  * @return void
  */
 public function getById($id)
 {
     $data = $this->db->fetchRow("SELECT * FROM notes WHERE id = ?", $id);
     if (!$data["id"]) {
         throw new Exception("Note item with id " . $id . " not found");
     }
     $this->assignVariablesToModel($data);
     // get key-value data
     $keyValues = $this->db->fetchAll("SELECT * FROM notes_data WHERE id = ?", $id);
     $preparedData = array();
     foreach ($keyValues as $keyValue) {
         $data = $keyValue["data"];
         $type = $keyValue["type"];
         $name = $keyValue["name"];
         if ($type == "document") {
             if ($data) {
                 $data = Document::getById($data);
             }
         } else {
             if ($type == "asset") {
                 if ($data) {
                     $data = Asset::getById($data);
                 }
             } else {
                 if ($type == "object") {
                     if ($data) {
                         $data = Object_Abstract::getById($data);
                     }
                 } else {
                     if ($type == "date") {
                         if ($data > 0) {
                             $data = new Zend_Date($data);
                         }
                     } else {
                         if ($type == "bool") {
                             $data = (bool) $data;
                         }
                     }
                 }
             }
         }
         $preparedData[$name] = array("data" => $data, "type" => $type);
     }
     $this->model->setData($preparedData);
 }
示例#19
0
 /**
  * @static
  * @return mixed|Zend_Config
  */
 public static function getWebsiteConfig()
 {
     try {
         $config = Zend_Registry::get("pimcore_config_website");
     } catch (Exception $e) {
         $cacheKey = "website_config";
         if (!($config = Pimcore_Model_Cache::load($cacheKey))) {
             $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
             $settingsArray = array();
             if (is_file($websiteSettingFile)) {
                 $rawConfig = new Zend_Config_Xml($websiteSettingFile);
                 $arrayData = $rawConfig->toArray();
                 foreach ($arrayData as $key => $value) {
                     $s = null;
                     if ($value["type"] == "document") {
                         $s = Document::getByPath($value["data"]);
                     } else {
                         if ($value["type"] == "asset") {
                             $s = Asset::getByPath($value["data"]);
                         } else {
                             if ($value["type"] == "object") {
                                 $s = Object_Abstract::getByPath($value["data"]);
                             } else {
                                 if ($value["type"] == "bool") {
                                     $s = (bool) $value["data"];
                                 } else {
                                     if ($value["type"] == "text") {
                                         $s = (string) $value["data"];
                                     }
                                 }
                             }
                         }
                     }
                     if ($s) {
                         $settingsArray[$key] = $s;
                     }
                 }
             }
             $config = new Zend_Config($settingsArray, true);
             Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
示例#20
0
 public function getNavigationPath()
 {
     $topLevel = $this;
     $categories = array();
     $root = Object_Abstract::getById(47);
     //Pimcore_Config::getWebsiteConfig()->shopCategoriesFolder;
     while ($topLevel && $topLevel->getId() != $root->getId()) {
         $categories[] = $topLevel;
         $topLevel = $topLevel->getParent();
     }
     $categories = array_reverse($categories);
     $path = '';
     foreach ($categories as $category) {
         $path .= Website_Tool_Text::toUrl($category->getText()) . '/';
     }
     $path = substr($path, 0, strlen($path) - 1);
     return $path;
 }
 public function endpointAction()
 {
     // disable wsdl cache
     if (PIMCORE_DEVMODE) {
         ini_set("soap.wsdl_cache_enabled", "0");
     }
     // create classmappings
     $classMap = Webservice_Tool::createClassMappings();
     //        p_r($classMap); die();
     // create wsdl
     // @TODO create a cache here
     $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array("object[]" => "Zend_Soap_Wsdl_Strategy_AnyType"), "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex");
     $autodiscover = new Zend_Soap_AutoDiscover($strategy);
     $autodiscover->setClass('Webservice_Service');
     $wsdl = $autodiscover->toXml();
     //TODO: do we really want to normalize class names since we had to introduce request and response objects anyway?
     $wsdl = str_replace("Webservice_Data_", "", $wsdl);
     // normalize classnames
     $wsdlFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/wsdl.xml";
     file_put_contents($wsdlFile, $wsdl);
     chmod($wsdlFile, 0766);
     // let's go
     if (isset($_GET["wsdl"])) {
         header("Content-Type: text/xml; charset=utf8");
         echo $wsdl;
     } else {
         Pimcore::setAdminMode();
         Document::setHideUnpublished(false);
         Object_Abstract::setHideUnpublished(false);
         Object_Abstract::setGetInheritedValues(false);
         try {
             $server = new Zend_Soap_Server($wsdlFile, array("cache_wsdl" => false, "soap_version" => SOAP_1_2, "classmap" => $classMap));
             $server->registerFaultException("Exception");
             $server->setClass("Webservice_Service");
             $server->handle();
         } catch (Exception $e) {
             Logger::log("Soap request failed");
             Logger::log($e);
             throw $e;
         }
     }
     exit;
 }
示例#22
0
 public function init()
 {
     parent::init();
     // enable layout only if its a normal request
     if ($this->getRequest()->isXmlHttpRequest() === false) {
         $this->enableLayout();
         $this->setLayout('back-office');
     }
     // sprache setzen
     $language = $this->getUser() ? $this->getUser()->getLanguage() : 'en';
     Zend_Registry::set("Zend_Locale", new Zend_Locale($language));
     $this->language = $language;
     $this->view->language = $language;
     $this->initTranslation();
     // enable inherited values
     Object_Abstract::setGetInheritedValues(true);
     Object_Localizedfield::setGetFallbackValues(true);
     // init
     $this->orderManager = OnlineShop_Framework_Factory::getInstance()->getOrderManager();
 }
示例#23
0
 /**
  * @param int $targetId
  */
 public function setTargetId($targetId)
 {
     $this->targetId = $targetId;
     try {
         if ($this->type == "object") {
             $this->target = Object_Abstract::getById($targetId);
         } else {
             if ($this->type == "asset") {
                 $this->target = Asset::getById($targetId);
             } else {
                 if ($this->type == "document") {
                     $this->target = Document::getById($targetId);
                 } else {
                     Logger::log(get_class($this) . ": could not set resource - unknown type[" . $this->type . "]");
                 }
             }
         }
     } catch (Exception $e) {
         Logger::log(get_class($this) . ": Error setting resource");
     }
 }
示例#24
0
文件: Import.php 项目: jv10/pimpon
 private function reassignReferences()
 {
     foreach ($this->bindReferencesCollection as $objectPath => $propertiesCollection) {
         $objectId = $this->objectMap[$objectPath];
         $object = Object_Abstract::getById($objectId);
         foreach ($propertiesCollection as $property => $referencesCollection) {
             $value = null;
             foreach ($referencesCollection as $reference) {
                 $referenceInstance = $this->getReferenceInstance($reference);
                 if ($reference->type === PimPon_Object_Encoder_Href::TYPE) {
                     $value = $referenceInstance;
                 } else {
                     if ($reference->type === PimPon_Object_Encoder_Collection::TYPE) {
                         $value[] = $referenceInstance;
                     }
                 }
             }
             $object->{'set' . ucfirst($property)}($value);
             $object->save();
         }
     }
 }
示例#25
0
 public function commentsAction()
 {
     if ($this->_getParam('xaction') == "destroy") {
         $id = $this->_getParam("comments");
         $id = str_replace('"', '', $id);
         RatingsComments_Plugin::deleteComment($id);
         $results["success"] = true;
         $results["comments"] = "";
     } else {
         $id = $this->_getParam("objectid");
         $type = $this->_getParam("type");
         if ($type == "object") {
             $target = Object_Abstract::getById($id);
         } else {
             if ($type == "page" || $type == "snippet") {
                 $target = Document::getById($id);
             } else {
                 //try asset
                 $target = Asset::getById($id);
             }
         }
         $comments = RatingsComments_Plugin::getComments($target);
         $results = array();
         if (is_array($comments)) {
             foreach ($comments as $comment) {
                 $shorttext = $comment->getComment();
                 if (strlen($shorttext) > 50) {
                     $shorttext = substr($shorttext, 0, 50) . "...";
                 }
                 $results["comments"][] = array("c_id" => $comment->getId(), "c_shorttext" => $shorttext, "c_text" => $comment->getComment(), "c_rating" => $comment->getRating(), "c_user" => $comment->getName(), "c_created" => $comment->getDate());
             }
         }
         if (!isset($results["comments"])) {
             $results["comments"] = "";
         }
     }
     echo Zend_Json::encode($results);
     $this->removeViewRenderer();
 }
示例#26
0
 private function getDataEntry($report)
 {
     $importDate = new Zend_Date($report->getImportDate());
     $importDate = $importDate->get(Zend_Date::DATETIME_MEDIUM);
     $product = Object_Abstract::getById($report->getProductId());
     if (!empty($product)) {
         $product = $product->getFullPath();
     }
     $processedDate = "";
     if ($report->getProcessedDate()) {
         $processedDate = new Zend_Date($report->getProcessedDate());
         $processedDate = $processedDate->get(Zend_Date::DATETIME_MEDIUM);
     }
     $user = User::getById($report->getUserId());
     if (!empty($user)) {
         $user = $user->getUsername();
     } else {
         $user = "";
     }
     $data = array('id' => $report->getId(), 'importDate' => $importDate, 'action' => $report->getAction(), 'type' => $report->getType(), 'productid' => $report->getProductId(), 'productpath' => $product, 'state' => $report->getState(), 'processedDate' => $processedDate, 'user' => $user);
     return $data;
 }
示例#27
0
 public function portletModifiedObjectsAction()
 {
     $list = Object_Abstract::getList(array("limit" => 10, "order" => "DESC", "orderKey" => "o_modificationDate", "condition" => "o_userModification = '" . $this->getUser()->getId() . "'"));
     $response = array();
     $response["objects"] = array();
     foreach ($list as $object) {
         $response["objects"][] = array("id" => $object->getId(), "type" => $object->getType(), "path" => $object->getFullPath(), "date" => $object->getModificationDate());
     }
     $this->_helper->json($response);
 }
$data = array();
foreach ($arrayData as $key => $value) {
    $setting = new WebsiteSetting();
    $setting->setName($key);
    $type = $value["type"];
    $setting->setType($type);
    $data = $value["data"];
    if ($type == "bool") {
        $data = (bool) $data;
    } else {
        if ($type == "document") {
            $data = Document::getByPath($value["data"]);
        } else {
            if ($type == "asset") {
                $data = Asset::getByPath($value["data"]);
            } else {
                if ($type == "object") {
                    $data = Object_Abstract::getByPath($value["data"]);
                }
            }
        }
    }
    if ($data instanceof Element_Interface) {
        $data = $data->getId();
    }
    $setting->setData($data);
    $siteId = $value["siteId"] > 0 ? (int) $value["siteId"] : null;
    $setting->setSiteId($siteId);
    $setting->save();
}
@rename($configFile, $configFileNew);
示例#29
0
 public function editAction()
 {
     $valid = true;
     $id_customer = $_POST['id_customer'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $name = $_POST['name'];
     $address = $_POST['address'];
     $email = $_POST['email'];
     $delivery_address = $_POST['delivery_address'];
     $mailing_address = $_POST['mailing_address'];
     $race = $_POST['race'];
     $nationality = $_POST['nationality'];
     $getRaceObj = Object_Abstract::getById($race);
     $getNationalityObj = Object_Abstract::getById($nationality);
     $return_array = array();
     $data;
     $cekuser = new Object\Customer\Listing();
     $cekuser->setCondition("username = '******'");
     if ($cekuser->Count() >= 1) {
         $return_array['status'] = 'failed';
         $return_array['message'] = 'username is already used';
         $return_array['data'] = '';
         $valid = false;
     } else {
         if ($id_customer == "") {
             $return_array['status'] = 'failed';
             $return_array['message'] = 'ID Customer is required';
             $return_array['data'] = '';
             $valid = false;
         } else {
             if ($username == "") {
                 $return_array['status'] = 'failed';
                 $return_array['message'] = 'Username is required';
                 $return_array['data'] = '';
                 $valid = false;
             } else {
                 if ($password == "") {
                     $return_array['status'] = 'failed';
                     $return_array['message'] = 'Password is required';
                     $return_array['data'] = '';
                     $valid = false;
                 } else {
                     if ($name == "") {
                         $return_array['status'] = 'failed';
                         $return_array['message'] = 'Name is required';
                         $return_array['data'] = '';
                         $valid = false;
                     } else {
                         if ($address == "") {
                             $return_array['status'] = 'failed';
                             $return_array['message'] = 'Address is required';
                             $return_array['data'] = '';
                             $valid = false;
                         } else {
                             if ($email == "") {
                                 $return_array['status'] = 'failed';
                                 $return_array['message'] = 'Email is required';
                                 $return_array['data'] = '';
                                 $valid = false;
                             } else {
                                 if ($delivery_address == "") {
                                     $return_array['status'] = 'failed';
                                     $return_array['message'] = 'Delivery Address is required';
                                     $return_array['data'] = '';
                                     $valid = false;
                                 } else {
                                     if ($mailing_address == "") {
                                         $return_array['status'] = 'failed';
                                         $return_array['message'] = 'Mailing Address is required';
                                         $return_array['data'] = '';
                                         $valid = false;
                                     } else {
                                         if ($race == "") {
                                             $return_array['status'] = 'failed';
                                             $return_array['message'] = 'Race is required';
                                             $return_array['data'] = '';
                                             $valid = false;
                                         } else {
                                             if ($nationality == "") {
                                                 $return_array['status'] = 'failed';
                                                 $return_array['message'] = 'Nationality is required';
                                                 $return_array['data'] = '';
                                                 $valid = false;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($valid) {
         $customer = Object_Customer::getById($id_customer);
         $customer->setusername($username);
         $customer->setpassword($password);
         $customer->setname($name);
         $customer->setaddress($address);
         $customer->setemailAddress($email);
         $customer->setdeliveryAddress($delivery_address);
         $customer->setmailingAddress($mailing_address);
         $customer->setrace($getRaceObj);
         $customer->setnationality($getNationalityObj);
         $customer->save();
         $return_array['status'] = 'success';
         $return_array['message'] = 'Success';
         $return_array['data'] = $customer;
     }
     $json_customer = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_customer);
     $this->sendResponse($json_customer);
 }
示例#30
0
 public function testObjectConcrete()
 {
     $client = $this->getSoapClient();
     //get an object list with 3 elements
     $condition = "o_type='object'";
     $generalCondition = $this->getListCondition();
     if (!empty($generalCondition)) {
         if (!empty($condition)) {
             $condition .= " AND " . $generalCondition;
         } else {
             $condition = $generalCondition;
         }
     }
     $order = "";
     $orderKey = "";
     $offset = 0;
     $limit = 3;
     $groupBy = "";
     $wsDocument = $client->getObjectList($condition, $order, $orderKey, $offset, $limit, $groupBy);
     $this->assertTrue(is_array($wsDocument) and $wsDocument[0] instanceof Webservice_Data_Object_List_Item);
     //take first element and fetch object
     $id = $wsDocument[0]->id;
     $this->assertTrue(is_numeric($id));
     $wsDocument = $client->getObjectConcreteById($id);
     $this->assertTrue($wsDocument instanceof Webservice_Data_Object_Concrete_Out);
     $className = "Object_" . ucfirst($wsDocument->className);
     $this->assertTrue(class_exists($className));
     $object = new $className();
     $wsDocument->reverseMap($object);
     //some checks to see if we got a valid object
     $this->assertTrue($object->getCreationDate() > 0);
     $this->assertTrue(strlen($object->getPath()) > 0);
     //copy the object retrieved from ws
     $new = clone $object;
     $new->id = null;
     $new->setKey($object->getKey() . "_phpUnitTestCopy");
     $new->setResource(null);
     //send new object back via ws
     $apiObject = Webservice_Data_Mapper::map($new, "Webservice_Data_Object_Concrete_In", "in");
     $id = $client->createObjectConcrete($apiObject);
     $this->assertTrue($id > 0);
     $wsDocument = $client->getObjectConcreteById($id);
     $this->assertTrue($wsDocument instanceof Webservice_Data_Object_Concrete_Out);
     $refetchObject = new $className();
     $wsDocument->reverseMap($refetchObject);
     //make sure we deal with 2 different objects
     $this->assertTrue($id == $refetchObject->getId());
     $this->assertTrue($id != $object->getId());
     //compare original object, and the one we mangled back and forth through the web service
     $localObject = Object_Abstract::getById($object->getId());
     //remove childs, this can not be set through WS
     $localObject->setChilds(null);
     $this->assertTrue(Test_Tool::objectsAreEqual($localObject, $refetchObject, true));
     //update object
     $refetchObject->setProperty("updateTest", "text", "a update test");
     $refetchObject->setInput("my updated test");
     $apiObject = Webservice_Data_Mapper::map($refetchObject, "Webservice_Data_Object_Concrete_In", "in");
     //        Logger::err(print_r($apiObject,true));
     $success = $client->updateObjectConcrete($apiObject);
     Logger::err($client->getLastRequest());
     $this->assertTrue($success);
     $id = $refetchObject->getId();
     Test_Tool::resetRegistry();
     $localObject = Object_Abstract::getById($id);
     $localObject->setChilds(null);
     $this->assertTrue(Test_Tool::objectsAreEqual($localObject, $refetchObject, true));
     //delete our test copy
     $success = $client->deleteObject($refetchObject->getId());
     $this->assertTrue($success);
 }