示例#1
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;
     }
 }
示例#2
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);
     }
 }
示例#3
0
 /**
  * Takes data from editmode and convert it to internal objects
  *
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     // IMPORTANT: if you use this method be sure that the type of the property is already set
     if ($this->type == "document") {
         $this->data = Document::getByPath($data);
     } else {
         if ($this->type == "asset") {
             $this->data = Asset::getByPath($data);
         } else {
             if ($this->type == "object") {
                 $this->data = Object_Abstract::getByPath($data);
             } else {
                 if ($this->type == "date") {
                     $this->data = new Zend_Date($data);
                 } else {
                     if ($this->type == "bool") {
                         $this->data = false;
                         if (!empty($data)) {
                             $this->data = true;
                         }
                     } else {
                         // plain text
                         $this->data = $data;
                     }
                 }
             }
         }
     }
 }
示例#4
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();
 }
示例#5
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);
 }
示例#6
0
 public function addAction()
 {
     $id_customer = $_POST['id_customer'];
     $id_product = $_POST['id_product'];
     $description = $_POST['description'];
     $rate = $_POST['rate'];
     // $data;
     $namekey = str_replace(' ', '_', $id_customer) . "_" . strtotime(date("YmdHis"));
     $getCustomerObj = Object_Abstract::getById($id_customer);
     $getProductObj = Object_Abstract::getById($id_product);
     $return_array = array();
     // if($id_customer == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Customer ID is required';
     //     $return_array['data']       = '';
     // }
     // else if($id_product == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Product ID is required';
     //     $return_array['data']       = '';
     // }
     // else if($description == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Description is required';
     //     $return_array['data']       = '';
     // }
     // else if($rate == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Rate is required';
     //     $return_array['data']       = '';
     // }
     $getPath = Object_Abstract::getByPath('/review');
     $addreview = array();
     $addreview = new Object_Review();
     $addreview->setcustomer($getCustomerObj);
     $addreview->setproduct($getProductObj);
     $addreview->setdescription($description);
     $addreview->setrating($rate);
     $addreview->setKey(strtolower($namekey));
     $addreview->setO_parentId($getPath->o_id);
     $addreview->setIndex(0);
     $addreview->setPublished(0);
     $addreview->save();
     $return_array['status'] = 'success';
     $return_array['message'] = 'Thank you for your review & rating';
     // $return_array['data']       = $addreview;
     $json_review = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_review);
     $this->sendResponse($json_review);
 }
示例#7
0
文件: Import.php 项目: jv10/pimpon
 private function objectSave(&$object)
 {
     try {
         $object->save();
     } catch (Exception $ex) {
         if ($this->getAllowReplace() === true && self::isDuplicateException($ex) === true) {
             $objectHinder = Object_Abstract::getByPath($object->getFullPath());
             $objectHinder->delete();
             $object->save();
         } else {
             self::l($ex->getMessage());
             throw $ex;
         }
     }
 }
 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);
 }
示例#9
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;
 }
示例#10
0
 public function correctPath()
 {
     // set path
     if ($this->getId() != 1) {
         // not for the root node
         $parent = Object_Abstract::getById($this->getParentId());
         if ($parent) {
             $this->setPath(str_replace("//", "/", $parent->getFullPath() . "/"));
         } else {
             // parent document doesn't exist anymore, so delete this document
             //$this->delete();
             // parent document doesn't exist anymore, set the parent to to root
             $this->setO_parentId(1);
             $this->setO_path("/");
         }
     }
     if (Object_Service::pathExists($this->getFullPath())) {
         $duplicate = Object_Abstract::getByPath($this->getFullPath());
         if ($duplicate instanceof Object_Abstract and $duplicate->getId() != $this->getId()) {
             throw new Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot create object");
         }
     }
 }
$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);
示例#12
0
 public function addAction()
 {
     $valid = true;
     $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'];
     $passport = $_POST['passport'];
     $postcode = $_POST['postcode'];
     $city = $_POST['city'];
     $state = $_POST['state'];
     $country = $_POST['country'];
     $mobile = $_POST['mobile'];
     $gender = $_POST['gender'];
     $dob = $_POST['dob'];
     $dateofbirth = strtotime($dob);
     $date_ob = new Pimcore_Date($dateofbirth);
     $namekey = str_replace(' ', '_', $name) . "_" . strtotime(date("YmdHis"));
     $getRaceObj = Object_Abstract::getById($race);
     $getNationalityObj = Object_Abstract::getById($nationality);
     $getCountryObj = Object_Abstract::getById($country);
     $return_array = array();
     // $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;
     // }
     // 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) {
         $addregister = array();
         $addregister = new Object_Customer();
         $addregister->setusername($username);
         $addregister->setpassword($password);
         $addregister->setname($name);
         $addregister->setaddress($address);
         $addregister->setemailAddress($email);
         $addregister->setdeliveryAddress($delivery_address);
         $addregister->setmailingAddress($mailing_address);
         $addregister->setrace($getRaceObj);
         $addregister->setnationality($getNationalityObj);
         $addregister->setpassportNo($passport);
         $addregister->setPostcode($postcode);
         $addregister->setcity($city);
         $addregister->setstate($state);
         $addregister->setcountry($getCountryObj);
         $addregister->setmobileNo($mobile);
         $addregister->setgender($gender);
         $addregister->setdob($date_ob);
         $getPath = Object_Abstract::getByPath('/customers');
         $addregister->setKey(strtolower($namekey));
         $addregister->setO_parentId($getPath->o_id);
         $addregister->setIndex(0);
         $addregister->setPublished(1);
         $addregister->save();
         $return_array['status'] = 'success';
         $return_array['message'] = 'Thank you for your registration';
         $return_array['data'] = $addregister;
     }
     $json_customer = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_customer);
     $this->sendResponse($json_customer);
 }
示例#13
0
 /**
  * @param string $key
  * @return Blog_Entry
  */
 public function getEntry($key)
 {
     return Object_Abstract::getByPath('/blog/entries/' . $key);
 }
示例#14
0
文件: Href.php 项目: ngocanh/pimcore
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $values = explode(":", $importValue);
     if (count($values) == 2) {
         $type = $values[0];
         $path = $values[1];
         $value = Element_Service::getElementByPath($type, $path);
     } else {
         //fallback for old export files
         if ($el = Asset::getByPath($importValue)) {
             $value = $el;
         } else {
             if ($el = Document::getByPath($importValue)) {
                 $value = $el;
             } else {
                 if ($el = Object_Abstract::getByPath($importValue)) {
                     $value = $el;
                 }
             }
         }
     }
     return $value;
 }
示例#15
0
 /**
  * @static
  * @param  string $type
  * @param  string $path
  * @return Element_Interface
  */
 public static function getElementByPath($type, $path)
 {
     if ($type == "asset") {
         $element = Asset::getByPath($path);
     } else {
         if ($type == "object") {
             $element = Object_Abstract::getByPath($path);
         } else {
             if ($type == "document") {
                 $element = Document::getByPath($path);
             }
         }
     }
     return $element;
 }
示例#16
0
 /**
  * Returns a uniqe key for the document in the $target-Path (recursive)
  * @param Element_Interface $element
  */
 protected function getSaveCopyName($element, $key, $path)
 {
     if ($element instanceof Object_Abstract) {
         $equal = Object_Abstract::getByPath($path . "/" . $key);
     } else {
         if ($element instanceof Document) {
             $equal = Document::getByPath($path . "/" . $key);
         } else {
             if ($element instanceof Asset) {
                 $equal = Asset::getByPath($path . "/" . $key);
             }
         }
     }
     if ($equal) {
         $key .= "_WScopy";
         return $this->getSaveCopyName($element, $key, $path);
     }
     return $key;
 }
 public function copyAction()
 {
     $success = false;
     $message = "";
     $sourceId = intval($this->_getParam("sourceId"));
     $source = Object_Abstract::getById($sourceId);
     $session = new Zend_Session_Namespace("pimcore_copy");
     $targetId = intval($this->_getParam("targetId"));
     if ($this->_getParam("targetParentId")) {
         $sourceParent = Object_Abstract::getById($this->_getParam("sourceParentId"));
         // this is because the key can get the prefix "_copy" if the target does already exists
         if ($session->{$this->_getParam("transactionId")}["parentId"]) {
             $targetParent = Object_Abstract::getById($session->{$this->_getParam("transactionId")}["parentId"]);
         } else {
             $targetParent = Object_Abstract::getById($this->_getParam("targetParentId"));
         }
         $targetPath = preg_replace("@^" . $sourceParent->getFullPath() . "@", $targetParent . "/", $source->getPath());
         $target = Object_Abstract::getByPath($targetPath);
     } else {
         $target = Object_Abstract::getById($targetId);
     }
     if ($target->isAllowed("create")) {
         $source = Object_Abstract::getById($sourceId);
         if ($source != null) {
             try {
                 if ($this->_getParam("type") == "child") {
                     $newObject = $this->_objectService->copyAsChild($target, $source);
                     // this is because the key can get the prefix "_copy" if the target does already exists
                     if ($this->_getParam("saveParentId")) {
                         $session->{$this->_getParam("transactionId")}["parentId"] = $newObject->getId();
                     }
                 } else {
                     if ($this->_getParam("type") == "replace") {
                         $this->_objectService->copyContents($target, $source);
                     }
                 }
                 $success = true;
             } catch (Exception $e) {
                 Logger::err($e);
                 $success = false;
                 $message = $e->getMessage() . " in object " . $source->getFullPath() . " [id: " . $source->getId() . "]";
             }
         } else {
             Logger::error("could not execute copy/paste, source object with id [ {$sourceId} ] not found");
             $this->_helper->json(array("success" => false, "message" => "source object not found"));
         }
     } else {
         Logger::error("could not execute copy/paste because of missing permissions on target [ " . $targetId . " ]");
         $this->_helper->json(array("error" => false, "message" => "missing_permission"));
     }
     $this->_helper->json(array("success" => $success, "message" => $message));
 }
示例#18
0
 public static function setLog()
 {
     $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();
     } 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();
         } else {
             echo "ERROR";
         }
     }
 }
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         if ($el = Object_Abstract::getByPath($element)) {
             $metaObject = new Object_Data_ObjectMetadata($this->getName(), $this->getColumnKeys(), $el);
             $value[] = $metaObject;
         }
     }
     return $value;
 }
示例#20
0
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         if ($el = Object_Abstract::getByPath($element)) {
             $value[] = $el;
         }
     }
     return $value;
 }
示例#21
0
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         $tokens = explode(":", $element);
         if (count($tokens) == 2) {
             $type = $tokens[0];
             $path = $tokens[1];
             $value[] = Element_Service::getElementByPath($type, $path);
         } else {
             //fallback for old export files
             if ($el = Asset::getByPath($element)) {
                 $value[] = $el;
             } else {
                 if ($el = Document::getByPath($element)) {
                     $value[] = $el;
                 } else {
                     if ($el = Object_Abstract::getByPath($element)) {
                         $value[] = $el;
                     }
                 }
             }
         }
     }
     return $value;
 }
 public function createuserAction()
 {
     // $errorMsg = "";
     error_reporting(1);
     $password = rand(8, 12);
     $content = $_POST['data'];
     $requestedData = json_decode($content);
     if ($this->checkExists($requestedData)) {
         if ($this->authenicateUserAPIKey($requestedData->auth)) {
             if (empty($requestedData->NRIC_PP) || !isset($requestedData->NRIC_PP) && $this->checkExists($requestedData->NRIC_PP)) {
                 $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                 echo json_encode($json);
                 exit;
             } else {
                 if (empty($requestedData->IDType) || !isset($requestedData->IDType) && $this->checkExists($requestedData->IDType)) {
                     $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                     echo json_encode($json);
                     exit;
                 } else {
                     if (empty($requestedData->Username) || !isset($requestedData->Username) && $this->checkExists($requestedData->Username)) {
                         $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                         echo json_encode($json);
                         exit;
                     } else {
                         if (empty($requestedData->Fullname) || !isset($requestedData->Fullname) && $this->checkExists($requestedData->Fullname)) {
                             $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                             echo json_encode($json);
                             exit;
                         }
                     }
                 }
             }
             //                else if (!preg_match($email_reg, $requestedData->Username)) {
             //                    $json = array('code' => "REG003-202", 'ErrorMsg' => "Please check all fields are provided correct.");
             //                    echo json_encode($json);
             //                    exit;
             //                }
             //                else if (!preg_match($email_reg, $requestedData->Username)) {
             //                    $json = array('code' => "REG003-202", 'ErrorMsg' => "Please check all fields are provided correct.");
             //                    echo json_encode($json);
             //                    exit;
             //                }
             $addregister = array();
             $addregister = new Object_Customer();
             $namekey = str_replace(' ', '_', $requestedData->Fullname) . "_" . strtotime(date("YmdHis"));
             $addregister->setUsername($requestedData->Username);
             $addregister->setNRIC_PP($requestedData->NRIC_PP);
             $addregister->setPassword(md5($password));
             $addregister->setFullname($requestedData->Fullname);
             if (strtoupper($requestedData->IDType) != "PASSPORT") {
                 $addregister->setnationality("Malaysia");
                 $getNationalityObj = Object_Abstract::getById("Malaysia");
             }
             $getPath = Object_Abstract::getByPath('/customers');
             $addregister->setKey(strtolower($namekey));
             $addregister->setO_parentId($getPath->o_id);
             $addregister->setIndex(0);
             $addregister->setPublished(1);
             $response = $addregister->save();
             if ($this->checkExists($response)) {
                 $json = array('code' => "REG003-200", 'status' => "Success");
                 echo json_encode($json);
                 //   $this->sendemail($password, $requestedData->Username);
                 exit;
             } else {
                 $json = array('code' => "REG003-206", 'status' => "Unable to connect to server");
                 echo json_encode($json);
                 exit;
             }
         } else {
             $json = array('code' => "REG003-201", 'ErrorMsg' => "Invalid authentication");
             echo json_encode($json);
             exit;
         }
     } else {
         $json = array('code' => "REG003-203", 'status' => "failure", 'ErrorMsg' => "Json format is incorrect.");
         echo json_encode($json);
         exit;
     }
 }
 public function importProcessAction()
 {
     $success = true;
     $type = $this->_getParam("type");
     $parentId = $this->_getParam("parentId");
     $job = $this->_getParam("job");
     $id = $this->_getParam("id");
     $mappingRaw = Zend_Json::decode($this->_getParam("mapping"));
     $class = Object_Class::getById($this->_getParam("classId"));
     $skipFirstRow = $this->_getParam("skipHeadRow") == "true";
     $fields = $class->getFieldDefinitions();
     $file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
     if ($type == "csv") {
         // determine type
         $dialect = Pimcore_Tool_Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
         $count = 0;
         if (($handle = fopen($file, "r")) !== false) {
             $data = fgetcsv($handle, 1000, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
         }
         if ($skipFirstRow && $job == 1) {
             //read the next row, we need to skip the head row
             $data = fgetcsv($handle, 1000, $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];
             }
         }
     }
     // create new object
     $className = "Object_" . ucfirst($this->_getParam("className"));
     $parent = Object_Abstract::getById($this->_getParam("parentId"));
     $parent->getPermissionsForUser($this->getUser());
     $objectKey = "object_" . $job;
     if ($this->_getParam("filename") == "id") {
         $objectKey = null;
     } else {
         if ($this->_getParam("filename") != "default") {
             $objectKey = Pimcore_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_Abstract::getByPath($intendedPath);
             if (!$object instanceof Object_Concrete) {
                 //create new object
                 $object = new $className();
             } else {
                 if (object instanceof Object_Concrete and $object->getO_className() !== $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_Abstract::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 ($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));
 }