/** * Sets the user's and the database timezone * @param \Cx\Core\Routing\Url $request Request URL */ public function preResolve(\Cx\Core\Routing\Url $request) { $databaseTimezoneString = $this->cx->getDb()->getDb()->getTimezone(); $this->databaseTimezone = new \DateTimeZone($databaseTimezoneString); $internalTimezoneString = \Cx\Core\Setting\Controller\Setting::getValue('timezone', 'Config'); $this->internalTimezone = new \DateTimeZone($internalTimezoneString); $this->userTimezone = \FWUser::getFWUserObject()->objUser->getTimezone(); }
/** * Do something before content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_CONFIG, $cl, $lang, $objInit, $dataBlocks, $lang, $dataBlocks, $themesPages, $page_template; // Initialize counter and track search engine robot \Cx\Core\Setting\Controller\Setting::init('Config', 'component', 'Yaml'); if (\Cx\Core\Setting\Controller\Setting::getValue('dataUseModule') && $cl->loadFile(ASCMS_MODULE_PATH . '/Data/Controller/DataBlocks.class.php')) { $lang = $objInit->loadLanguageData('Data'); $dataBlocks = new \Cx\Modules\Data\Controller\DataBlocks($lang); \Env::get('cx')->getPage()->setContent($dataBlocks->replace(\Env::get('cx')->getPage()->getContent())); $themesPages = $dataBlocks->replace($themesPages); $page_template = $dataBlocks->replace($page_template); } }
/** * Constructor for PHP5 * * @param int $lang */ function __construct() { global $objInit; \Cx\Core\Setting\Controller\Setting::init('Config', 'component', 'Yaml'); if (\Cx\Core\Setting\Controller\Setting::getValue('dataUseModule')) { $this->active = true; } else { return; } $this->_arrSettings = $this->createSettingsArray(); $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_THEMES_PATH); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); $this->langVars = $objInit->loadLanguageData('Data'); }
/** * Do something after content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // Show the Shop navbar in the Shop, or on every page if configured to do so if (!Shop::isInitialized()) { \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (\Cx\Core\Setting\Controller\Setting::getValue('shopnavbar_on_all_pages', 'Shop')) { Shop::init(); Shop::setNavbar(); } } break; } }
/** * Gets all the providers from the setting db. * * @static * @return array the providers and their data */ public static function getProviders() { \Cx\Core\Setting\Controller\Setting::init('Access', 'sociallogin'); $settingProviders = json_decode(\Cx\Core\Setting\Controller\Setting::getValue('providers', 'Access')); foreach ($settingProviders as $providerName => $providerData) { $class = self::getClassByProvider($providerName); if ($class != null) { $oauthProvider = new $class(); $oauthProvider->setApplicationData($providerData->settings); $oauthProvider->setActive(isset($providerData->active) ? $providerData->active : false); self::$providers[$providerName] = $oauthProvider; } } return self::$providers; }
/** * postInit * * @param \Cx\Core\Core\Controller\Cx $cx * * @return null */ public function postInit(\Cx\Core\Core\Controller\Cx $cx) { $componentController = $this->getComponent('MultiSite'); if (!$componentController) { return; } \Cx\Core\Setting\Controller\Setting::init('MultiSite', 'config', 'FileSystem'); if (\Cx\Core\Setting\Controller\Setting::getValue('mode', 'MultiSite') != \Cx\Core_Modules\MultiSite\Controller\ComponentController::MODE_WEBSITE) { return; } $updateFile = $cx->getWebsiteTempPath() . '/Update/' . \Cx\Core_Modules\Update\Model\Repository\DeltaRepository::PENDING_DB_UPDATES_YML; if (!file_exists($updateFile)) { return; } $componentController->setCustomerPanelDomainAsMainDomain(); $updateController = $this->getController('Update'); $updateController->applyDelta(); }
/** * FeedBack Form * * @global array $_ARRAYLANG */ public function showFeedBackForm() { global $_ARRAYLANG; $objUser = \FWUser::getFWUserObject(); //feed back types $feedBackTypes = array($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_SELECT_FEEDBACK'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_BUG_REPORT'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_FEATURE_REQUEST'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_HAVE_QUESTION']); \Cx\Core\Setting\Controller\Setting::init('Support', 'setup', 'Yaml'); $faqUrl = \Cx\Core\Setting\Controller\Setting::getValue('faqUrl', 'Support'); $recipientMailAddress = \Cx\Core\Setting\Controller\Setting::getValue('recipientMailAddress', 'Support'); $faqLink = '<a target="_blank" title="click to FAQ page" href=' . $faqUrl . '>' . $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_FAQ'] . '</a>'; //Get License information $license = \Env::get('cx')->getLicense(); $licenseName = $license->getEditionName(); $licenseValid = date(ASCMS_DATE_FORMAT_DATE, $license->getValidToDate()); $licenseVersion = $license->getVersion()->getNumber(); //get the input datas $feedBackType = isset($_POST['feedBackType']) ? contrexx_input2raw($_POST['feedBackType']) : ''; $feedBackSubject = isset($_POST['feedBackSubject']) ? contrexx_input2raw($_POST['feedBackSubject']) : ''; $feedBackComment = isset($_POST['feedBackComment']) ? contrexx_input2raw($_POST['feedBackComment']) : ''; $customerName = isset($_POST['customerName']) ? contrexx_input2raw($_POST['customerName']) : ''; $customerEmailId = isset($_POST['customerEmailId']) ? contrexx_input2raw($_POST['customerEmailId']) : ''; $feedBackUrl = isset($_POST['feedBackUrl']) ? contrexx_input2raw($_POST['feedBackUrl']) : ''; if (isset($_POST['sendAndSave'])) { if (!empty($feedBackSubject) && !empty($feedBackComment)) { //get the hostname domain $domainRepo = new \Cx\Core\Net\Model\Repository\DomainRepository(); $domain = $domainRepo->findOneBy(array('id' => 0)); $arrFields = array('name' => contrexx_raw2xhtml($customerName), 'fromEmail' => contrexx_raw2xhtml($customerEmailId), 'feedBackType' => $feedBackType != 0 ? contrexx_raw2xhtml($feedBackTypes[$feedBackType]) : '', 'url' => $faqUrl, 'comments' => contrexx_raw2xhtml($feedBackComment), 'subject' => contrexx_raw2xhtml($feedBackSubject), 'firstName' => $objUser->objUser->getProfileAttribute('firstname'), 'lastName' => $objUser->objUser->getProfileAttribute('lastname'), 'phone' => !$objUser->objUser->getProfileAttribute('phone_office') ? $objUser->objUser->getProfileAttribute('phone_mobile') : $objUser->objUser->getProfileAttribute('phone_office'), 'company' => $objUser->objUser->getProfileAttribute('company'), 'toEmail' => $recipientMailAddress, 'licenseName' => $licenseName, 'licenseValid' => $licenseValid, 'licenseVersion' => $licenseVersion, 'domainName' => $domain ? $domain->getName() : ''); //send the feedBack mail $this->sendMail($arrFields) ? \Message::ok($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_EMAIL_SEND_SUCESSFULLY']) : \Message::error($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_EMAIL_SEND_FAILED']); } else { \Message::error($_ARRAYLANG['TXT_SUPPORT_ERROR_MSG_FIELDS_EMPTY']); $this->template->setVariable(array('TXT_SUPPORT_ERROR_CLASS_SUBJECT' => !empty($feedBackSubject) ? "" : "errBoxStyle", 'TXT_SUPPORT_ERROR_CLASS_COMMENT' => !empty($feedBackComment) ? "" : "errBoxStyle", 'SUPPORT_FEEDBACK_SUBJECT' => contrexx_raw2xhtml($feedBackSubject), 'SUPPORT_FEEDBACK_COMMENT' => contrexx_raw2xhtml($feedBackComment))); } } //show FeedBack Types foreach ($feedBackTypes as $key => $feedbackType) { $this->template->setVariable(array('SUPPORT_FEEDBACK_TYPES' => $feedbackType, 'SUPPORT_FEEDBACK_SELECTED_TYPE' => !empty($feedBackType) && $feedBackType == $key ? 'selected' : '', 'SUPPORT_FEEDBACK_ID' => $key)); $this->template->parse('showFeedBackTypes'); } $this->template->setVariable(array('SUPPORT_FEEDBACK_FAQ' => $faqLink, 'SUPPORT_FEEDBACK_CUSTOMER_NAME' => $objUser->objUser->getUsername(), 'SUPPORT_FEEDBACK_CUSTOMER_EMAIL' => $objUser->objUser->getEmail())); $this->template->setVariable(array('TXT_SUPPORT_FEEDBACK' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK'], 'TXT_SUPPORT_FEEDBACK_SUBJECT' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_SUBJECT'], 'TXT_SUPPORT_FEEDBACK_COMMENTS' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_COMMENTS'])); }
/** * Do something before content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $knowledgeInterface, $page_template, $themesPages; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // get knowledge content \Cx\Core\Setting\Controller\Setting::init('Config', 'component', 'Yaml'); if (MODULE_INDEX < 2 && \Cx\Core\Setting\Controller\Setting::getValue('useKnowledgePlaceholders', 'Config')) { $knowledgeInterface = new KnowledgeInterface(); if (preg_match('/{KNOWLEDGE_[A-Za-z0-9_]+}/i', \Env::get('cx')->getPage()->getContent())) { $knowledgeInterface->parse(\Env::get('cx')->getPage()->getContent()); } if (preg_match('/{KNOWLEDGE_[A-Za-z0-9_]+}/i', $page_template)) { $knowledgeInterface->parse($page_template); } if (preg_match('/{KNOWLEDGE_[A-Za-z0-9_]+}/i', $themesPages['index'])) { $knowledgeInterface->parse($themesPages['index']); } } break; } }
public static function processRequest($token, $arrOrder) { global $_CONFIG; if (empty($token)) { return array('status' => 'error', 'message' => 'invalid token'); } $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0; $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_private_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_private_key', 'Shop'); if ($token) { try { $request = new Paymill\Request($apiKey); $transaction = new Paymill\Models\Request\Transaction(); $transaction->setAmount($arrOrder['amount'])->setCurrency($arrOrder['currency'])->setToken($token)->setDescription($arrOrder['note'])->setSource('contrexx_' . $_CONFIG['coreCmsVersion']); DBG::log("Transactoin created with token:" . $token); $response = $request->create($transaction); $paymentId = $response->getId(); DBG::log("Payment ID" . $paymentId); return array('status' => 'success', 'payment_id' => $paymentId); } catch (\Paymill\Services\PaymillException $e) { //Do something with the error informations below return array('status' => 'error', 'response_code' => $e->getResponseCode(), 'status_code' => $e->getStatusCode(), 'message' => $e->getErrorMessage()); } } }
/** * gets default port from settings */ function getDefaultPort() { $mode = $this->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND ? 'Backend' : 'Frontend'; \Cx\Core\Setting\Controller\Setting::init('Config', null, 'Yaml', null, \Cx\Core\Setting\Controller\Setting::NOT_POPULATE); $protocol = strtoupper($this->getProtocol()); $port = \Cx\Core\Setting\Controller\Setting::getValue('port' . $mode . $protocol, 'Config'); return $port; }
/** * Sets up the Payment settings view * @param \Cx\Core\Html\Sigma $objTemplate The optional Template, * by reference * @return boolean True on success, * false otherwise */ static function view_settings(&$objTemplate = null) { if (!$objTemplate) { $objTemplate = new \Cx\Core\Html\Sigma(); $objTemplate->loadTemplateFile('module_shop_settings_payment.html'); } else { $objTemplate->addBlockfile('SHOP_SETTINGS_FILE', 'settings_block', 'module_shop_settings_payment.html'); } $i = 0; foreach (Payment::getArray() as $payment_id => $arrPayment) { $zone_id = Zones::getZoneIdByPaymentId($payment_id); $objTemplate->setVariable(array('SHOP_PAYMENT_STYLE' => 'row' . (++$i % 2 + 1), 'SHOP_PAYMENT_ID' => $arrPayment['id'], 'SHOP_PAYMENT_NAME' => $arrPayment['name'], 'SHOP_PAYMENT_HANDLER_MENUOPTIONS' => PaymentProcessing::getMenuoptions($arrPayment['processor_id']), 'SHOP_PAYMENT_COST' => $arrPayment['fee'], 'SHOP_PAYMENT_COST_FREE_SUM' => $arrPayment['free_from'], 'SHOP_ZONE_SELECTION' => Zones::getMenu($zone_id, "zone_id[{$payment_id}]"), 'SHOP_PAYMENT_STATUS' => intval($arrPayment['active']) ? \Html::ATTRIBUTE_CHECKED : '')); $objTemplate->parse('shopPayment'); } $objTemplate->setVariable(array('SHOP_PAYMENT_HANDLER_MENUOPTIONS_NEW' => PaymentProcessing::getMenuoptions(-1), 'SHOP_ZONE_SELECTION_NEW' => Zones::getMenu(0, 'zone_id_new'))); // Payment Service Providers $objTemplate->setVariable(array('SHOP_PAYMILL_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('paymill_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PAYMILL_TEST_SELECTED' => \Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop') == 0 ? \Html::ATTRIBUTE_SELECTED : '', 'SHOP_PAYMILL_LIVE_SELECTED' => \Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop') == 1 ? \Html::ATTRIBUTE_SELECTED : '', 'SHOP_PAYMILL_TEST_PRIVATE_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_test_private_key', 'Shop')), 'SHOP_PAYMILL_TEST_PUBLIC_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_test_public_key', 'Shop')), 'SHOP_PAYMILL_LIVE_PRIVATE_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_live_private_key', 'Shop')), 'SHOP_PAYMILL_LIVE_PUBLIC_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_live_public_key', 'Shop')), 'SHOP_PAYMILL_PRIVATE_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_private_key', 'Shop')), 'SHOP_PAYMILL_PUBLIC_KEY' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paymill_public_key', 'Shop')), 'SHOP_SAFERPAY_ID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop'), 'SHOP_SAFERPAY_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_SAFERPAY_TEST_ID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_use_test_account', 'Shop'), 'SHOP_SAFERPAY_TEST_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_use_test_account', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_SAFERPAY_FINALIZE_PAYMENT' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_finalize_payment', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_SAFERPAY_WINDOW_MENUOPTIONS' => \Saferpay::getWindowMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('saferpay_window_option', 'Shop')), 'SHOP_PAYREXX_INSTANCE_NAME' => \Cx\Core\Setting\Controller\Setting::getValue('payrexx_instance_name', 'Shop'), 'SHOP_PAYREXX_API_SECRET' => \Cx\Core\Setting\Controller\Setting::getValue('payrexx_api_secret', 'Shop'), 'SHOP_PAYREXX_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('payrexx_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_YELLOWPAY_SHOP_ID' => \Cx\Core\Setting\Controller\Setting::getValue('postfinance_shop_id', 'Shop'), 'SHOP_YELLOWPAY_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('postfinance_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_YELLOWPAY_HASH_SIGNATURE_IN' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_in', 'Shop')), 'SHOP_YELLOWPAY_HASH_SIGNATURE_OUT' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_out', 'Shop')), 'SHOP_YELLOWPAY_AUTHORIZATION_TYPE_OPTIONS' => \Yellowpay::getAuthorizationMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('postfinance_authorization_type', 'Shop')), 'SHOP_YELLOWPAY_USE_TESTSERVER_CHECKED' => \Cx\Core\Setting\Controller\Setting::getValue('postfinance_use_testserver', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_POSTFINANCE_MOBILE_WEBUSER' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_webuser', 'Shop')), 'SHOP_POSTFINANCE_MOBILE_SIGN' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_sign', 'Shop')), 'SHOP_POSTFINANCE_MOBILE_IJUSTWANTTOTEST_CHECKED' => \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_ijustwanttotest', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_POSTFINANCE_MOBILE_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_status', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_DATATRANS_AUTHORIZATION_TYPE_OPTIONS' => \Datatrans::getReqtypeMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('datatrans_request_type', 'Shop')), 'SHOP_DATATRANS_MERCHANT_ID' => \Cx\Core\Setting\Controller\Setting::getValue('datatrans_merchant_id', 'Shop'), 'SHOP_DATATRANS_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('datatrans_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_DATATRANS_USE_TESTSERVER_YES_CHECKED' => \Cx\Core\Setting\Controller\Setting::getValue('datatrans_use_testserver', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_DATATRANS_USE_TESTSERVER_NO_CHECKED' => \Cx\Core\Setting\Controller\Setting::getValue('datatrans_use_testserver', 'Shop') ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_PAYPAL_EMAIL' => contrexx_raw2xhtml(\Cx\Core\Setting\Controller\Setting::getValue('paypal_account_email', 'Shop')), 'SHOP_PAYPAL_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('paypal_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PAYPAL_DEFAULT_CURRENCY_MENUOPTIONS' => \PayPal::getAcceptedCurrencyCodeMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('paypal_default_currency', 'Shop')), 'SHOP_PAYMENT_LSV_STATUS' => \Cx\Core\Setting\Controller\Setting::getValue('payment_lsv_active', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PAYMENT_DEFAULT_CURRENCY' => Currency::getDefaultCurrencySymbol(), 'SHOP_CURRENCY_CODE' => Currency::getCurrencyCodeById(Currency::getDefaultCurrencyId()))); return true; }
config.protectedSource.push(/<span[^>]*><\/span>/g); config.protectedSource.push(/<a[^>]*><\/a>/g); config.tabSpaces = 4; config.baseHref = '<?php echo $cx->getRequest()->getUrl()->getProtocol() . '://' . $mainDomain . $cx->getWebsiteOffsetPath(); ?> /'; config.templates_files = [ '<?php echo $defaultTemplateFilePath; ?> ' ]; config.templates_replaceContent = <?php echo \Cx\Core\Setting\Controller\Setting::getValue('replaceActualContents', 'Wysiwyg') ? 'true' : 'false'; ?> ; config.toolbar_Full = config.toolbar_Small = [ ['Source','-','NewPage','Templates'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], ['NumberedList','BulletedList','-','Outdent','Indent', 'Blockquote'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','HorizontalRule','SpecialChar'], ['Format'], ['TextColor','BGColor'], ['ShowBlocks'],
/** * Return the global setting * * @return string * @throws DatabaseError * @global $objDatabase * @return mixed */ protected function getGlobalSetting() { //return the global setting('useKnowledgePlaceholders') value \Cx\Core\Setting\Controller\Setting::init('Config', 'component', 'Yaml'); return \Cx\Core\Setting\Controller\Setting::getValue('useKnowledgePlaceholders', 'Config'); }
private function saveSettings() { global $objDatabase; /** * save mailtemplates */ foreach ($_POST["filesharingMail"] as $lang => $inputs) { $objMailTemplate = $objDatabase->Execute("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . intval($lang)); $content = str_replace(array('{', '}'), array('[[', ']]'), contrexx_input2db($inputs["content"])); if ($objMailTemplate === false or $objMailTemplate->RecordCount() == 0) { $objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_filesharing_mail_template (`subject`, `content`, `lang_id`) VALUES ('" . contrexx_input2db($inputs["subject"]) . "', '" . contrexx_raw2db($content) . "', '" . contrexx_raw2db($lang) . "')"); } else { $objDatabase->Execute("UPDATE " . DBPREFIX . "module_filesharing_mail_template SET `subject` = '" . contrexx_input2db($inputs["subject"]) . "', `content` = '" . contrexx_raw2db($content) . "' WHERE `lang_id` = '" . contrexx_raw2db($lang) . "'"); } } /** * save permissions */ \Cx\Core\Setting\Controller\Setting::init('FileSharing', 'config'); $oldFilesharingSetting = \Cx\Core\Setting\Controller\Setting::getValue('permission', 'FileSharing'); $newFilesharingSetting = $_POST['filesharingSettingsPermission']; if (!is_numeric($newFilesharingSetting)) { if (is_numeric($oldFilesharingSetting)) { // remove AccessId \Permission::removeAccess($oldFilesharingSetting, 'dynamic'); } } else { $accessGroups = ''; if (isset($_POST['filesharing_access_associated_groups'])) { $accessGroups = $_POST['filesharing_access_associated_groups']; } // get groups \Permission::removeAccess($oldFilesharingSetting, 'dynamic'); if (isset($_POST['filesharing_access_associated_groups'])) { $accessGroups = $_POST['filesharing_access_associated_groups']; } // add AccessID $newFilesharingSetting = \Permission::createNewDynamicAccessId(); // save AccessID if (count($accessGroups)) { \Permission::setAccess($newFilesharingSetting, 'dynamic', $accessGroups); } } // save new setting \Cx\Core\Setting\Controller\Setting::set('permission', $newFilesharingSetting); \Cx\Core\Setting\Controller\Setting::updateAll(); }
/** * parse the upload form * * @access private */ private function getForm() { global $_ARRAYLANG; \Cx\Core\Setting\Controller\Setting::init('FileSharing', 'config'); $permissionNeeded = \Cx\Core\Setting\Controller\Setting::getValue('permission', 'FileSharing'); if (!$permissionNeeded) { \Cx\Core\Setting\Controller\Setting::add('permission', 'off'); $permissionNeeded = \Cx\Core\Setting\Controller\Setting::getValue('permission', 'FileSharing'); } if ($permissionNeeded == 'off' || is_numeric($permissionNeeded) && !\Permission::checkAccess($permissionNeeded, 'dynamic')) { $this->objTemplate->setVariable('FILESHARING_NO_ACCESS', $_ARRAYLANG['TXT_FILESHARING_NO_ACCESS']); if ($this->objTemplate->parse('no_access')) { $this->objTemplate->parse('no_access'); } if ($this->objTemplate->blockExists('upload_form')) { $this->objTemplate->hideBlock('upload_form'); } if ($this->objTemplate->blockExists('uploaded')) { $this->objTemplate->hideBlock('uploaded'); } } else { // parse the upload form // init uploader $uploadId = $this->initUploader(); // set form parameters $formAction = clone \Env::get("Resolver")->getUrl(); $formAction->setParam("uploadId", $uploadId); $formAction->setParam("check", false); $formAction->setParam("hash", false); $this->objTemplate->setVariable(array("FORM_ACTION" => $formAction, "FORM_METHOD" => "POST", "FILESHARING_EMAIL" => $_ARRAYLANG["TXT_EMAIL"], "FILESHARING_EMAIL_INFO" => $_ARRAYLANG["TXT_FILESHARING_EMAIL_INFO"], "FILESHARING_SUBJECT" => $_ARRAYLANG["TXT_FILESHARING_SUBJECT"], "FILESHARING_SUBJECT_INFO" => $_ARRAYLANG["TXT_FILESHARING_SUBJECT_INFO"], "FILESHARING_MESSAGE" => $_ARRAYLANG["TXT_FILESHARING_MESSAGE"], "FILESHARING_MESSAGE_INFO" => $_ARRAYLANG["TXT_FILESHARING_MESSAGE_INFO"], "FILESHARING_EXPIRATION" => $_ARRAYLANG["TXT_FILESHARING_EXPIRATION"], "FILESHARING_SEND" => $_ARRAYLANG["TXT_FILESHARING_SEND"], "FILESHARING_MORE" => $_ARRAYLANG["TXT_FILESHARING_MORE"], "FILESHARING_ERROR_FILE_NOT_FOUND" => $_ARRAYLANG["TXT_FILESHARING_ERROR_FILE_NOT_FOUND"], "FILESHARING_ERROR_NO_FILES_UPLOADED" => $_ARRAYLANG["TXT_FILESHARING_ERROR_NO_FILES_UPLOADED"], 'TXT_FILESHARING_EXPLANATION' => $_ARRAYLANG['TXT_FILESHARING_EXPLANATION'], 'TXT_FILESHARING_I_AGREE' => $_ARRAYLANG['TXT_FILESHARING_I_AGREE'], 'TXT_FILESHARING_TERMS_OF_SERVICE' => $_ARRAYLANG['TXT_FILESHARING_TERMS_OF_SERVICE'], 'TXT_FILESHARING_I_ACCEPT' => $_ARRAYLANG['TXT_FILESHARING_I_ACCEPT'], 'TXT_FILESHARING_FILES' => $_ARRAYLANG['TXT_FILESHARING_FILES'])); if ($this->objTemplate->blockExists('upload_form')) { $this->objTemplate->touchBlock("upload_form"); } if ($this->objTemplate->blockExists('uploaded')) { $this->objTemplate->hideBlock("uploaded"); } } }
public function showFtp() { global $_ARRAYLANG, $objTemplate, $_CONFIG; $this->strPageTitle = $_ARRAYLANG['TXT_SETTINGS_FTP']; $objTemplate->addBlockfile('ADMIN_CONTENT', 'settings_ftp', 'settings_ftp.html'); //get the ftp server name $domainRepo = \Env::get('em')->getRepository('Cx\\Core\\Net\\Model\\Entity\\Domain'); $objDomain = $domainRepo->findOneBy(array('id' => 0)); //get the ftp user name \Cx\Core\Setting\Controller\Setting::init('MultiSite', 'website', 'FileSystem'); $ftpUserName = \Cx\Core\Setting\Controller\Setting::getValue('websiteFtpUser', 'MultiSite'); if (empty($ftpUserName)) { throw new \Exception('FTP Failed to load: Website Ftp User is empty'); } $objTemplate->setVariable(array('FTP_SERVER_NAME' => 'ftp://' . $objDomain->getName(), 'FTP_USER_NAME' => $ftpUserName)); $objTemplate->setVariable(array('TXT_SETTINGS_FTP' => $_ARRAYLANG['TXT_SETTINGS_FTP'], 'TXT_SETTINGS_FTP_SERVER' => $_ARRAYLANG['TXT_SETTINGS_FTP_SERVER'], 'TXT_SETTINGS_FTP_USER' => $_ARRAYLANG['TXT_SETTINGS_FTP_USER'], 'TXT_SETTINGS_FTP_PASSWORD' => $_ARRAYLANG['TXT_SETTINGS_FTP_PASSWORD'], 'TXT_SETTINGS_RESET_PASSWORD' => $_ARRAYLANG['TXT_SETTINGS_RESET_PASSWORD'])); }
/** * Show the general setting options * * @global array $_ARRAYLANG */ public function showDefault() { global $_ARRAYLANG; \Cx\Core\Setting\Controller\Setting::init('LinkManager', 'config'); //get post values $settings = isset($_POST['setting']) ? $_POST['setting'] : array(); if (isset($_POST['save'])) { $includeFromSave = array('entriesPerPage'); foreach ($settings as $settingName => $settingValue) { if (in_array($settingName, $includeFromSave)) { \Cx\Core\Setting\Controller\Setting::set($settingName, $settingValue); \Cx\Core\Setting\Controller\Setting::update($settingName); \Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']); } } } //get the settings values from DB $this->template->setVariable(array($this->moduleNameLang . '_ENTRIES_PER_PAGE' => \Cx\Core\Setting\Controller\Setting::getValue('entriesPerPage', 'LinkManager'))); }
/** * Adding Crm Contact and link it with crm company if possible * * @param Array $arrFormData form data's * @param int $userAccountId * @param int $frontendLanguage * @global <object> $objDatabase * @global int $_LANGID * */ function setContactPersonProfile($arrFormData = array(), $userAccountId = 0, $frontendLanguage) { global $objDatabase, $_LANGID; $this->contact = new \Cx\Modules\Crm\Model\Entity\CrmContact(); if (!empty($userAccountId)) { $userExists = $objDatabase->Execute("SELECT id FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE user_account = {$userAccountId}"); if ($userExists && $userExists->RecordCount()) { $id = (int) $userExists->fields['id']; $this->contact->load($id); $this->contact->customerName = !empty($arrFormData['firstname'][0]) ? contrexx_input2raw($arrFormData['firstname'][0]) : ''; $this->contact->family_name = !empty($arrFormData['lastname'][0]) ? contrexx_input2raw($arrFormData['lastname'][0]) : ''; $this->contact->contact_language = !empty($frontendLanguage) ? (int) $frontendLanguage : $_LANGID; $this->contact->contact_gender = !empty($arrFormData['gender'][0]) ? $arrFormData['gender'][0] == 'gender_female' ? 1 : ($arrFormData['gender'][0] == 'gender_male' ? 2 : '') : ''; $this->contact->contactType = 2; $this->contact->datasource = 2; $this->contact->account_id = $userAccountId; //set profile picture if (!empty($arrFormData['picture'][0])) { $picture = $arrFormData['picture'][0]; $cx = \Cx\Core\Core\Controller\Cx::instanciate(); if (!file_exists($cx->getWebsiteImagesCrmProfilePath() . '/' . $picture)) { $file = $cx->getWebsiteImagesAccessProfilePath() . '/'; $newFile = $cx->getWebsiteImagesCrmProfilePath() . '/'; if (copy($file . $picture, $newFile . $picture)) { if ($this->createThumbnailOfPicture($picture)) { $this->contact->profile_picture = $picture; } } } } else { $this->contact->profile_picture = 'profile_person_big.png'; } // save current setting values, so we can switch back to them after we got our used settings out of database $prevSection = \Cx\Core\Setting\Controller\Setting::getCurrentSection(); $prevGroup = \Cx\Core\Setting\Controller\Setting::getCurrentGroup(); $prevEngine = \Cx\Core\Setting\Controller\Setting::getCurrentEngine(); \Cx\Core\Setting\Controller\Setting::init('Crm', 'config'); if ($arrFormData["company"][0] != "") { $crmCompany = new \Cx\Modules\Crm\Model\Entity\CrmContact(); if ($this->contact->contact_customer != 0) { $crmCompany->load($this->contact->contact_customer); } $crmCompany->customerName = $arrFormData["company"][0]; $crmCompany->contactType = 1; $customerType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_type', 'Crm')][0]; if ($customerType !== false) { $crmCompany->customerType = $customerType; } $companySize = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_company_size', 'Crm')][0]; if ($companySize !== false) { $crmCompany->companySize = $companySize; } $industryType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_industry_type', 'Crm')][0]; if ($industryType !== false) { $crmCompany->industryType = $industryType; } if (isset($arrFormData["phone_office"])) { $crmCompany->phone = $arrFormData["phone_office"]; } // store/update the company profile $crmCompany->save(); // setting & storing the primary email address must be done after // the company has been saved for the case where the company is // being added as a new object without having an ID yet if (empty($crmCompany->email)) { $crmCompany->email = $this->contact->email; $crmCompany->storeEMail(); } $this->contact->contact_customer = $crmCompany->id; } if ($this->contact->save()) { // insert website if (!empty($arrFormData['website'][0])) { $webExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $fields = array('url' => $arrFormData['website'][0], 'url_profile' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id); if ($webExists) { $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}"; } else { $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)); } $db = $objDatabase->Execute($query); } //insert address if (!empty($arrFormData['address'][0]) || !empty($arrFormData['city'][0]) || !empty($arrFormData['zip'][0]) || !empty($arrFormData['country'][0])) { $addressExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $country = \Cx\Core\Country\Controller\Country::getById($arrFormData['country'][0]); if ($addressExists && $addressExists->RecordCount()) { $query = "UPDATE `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n address = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n city = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n zip = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n country = '" . $country['name'] . "',\n Address_Type = '2'\n WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"; } else { $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n address = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n city = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n state = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n zip = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n country = '" . $country['name'] . "',\n Address_Type = '2',\n is_primary = '1',\n contact_id = '{$this->contact->id}'"; } $objDatabase->Execute($query); } // insert Phone $contactPhone = array(); if (!empty($arrFormData['phone_office'][0])) { $phoneExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $fields = array('phone' => $arrFormData['phone_office'][0], 'phone_type' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id); if ($phoneExists && $phoneExists->RecordCount()) { $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}"; } else { $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true)); } $objDatabase->Execute($query); } } \Cx\Core\Setting\Controller\Setting::init($prevSection, $prevGroup, $prevEngine); } } }
/** * Show the last run's crawler result * * @global array $_ARRAYLANG */ public function showCrawlerResult() { global $_ARRAYLANG; \JS::activate('cx'); $objCx = \ContrexxJavascript::getInstance(); $objCx->setVariable(array('updateSuccessMsg' => $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_UPDATE_SUCCESS_MSG'], 'loadingLabel' => $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_LABEL_LOADING']), 'LinkManager'); if (isset($_POST['checkAgain'])) { $this->recheckSelectedLinks(); } //show crawler results //get parameters $pos = isset($_GET['pos']) ? $_GET['pos'] : 0; //set the settings value from DB \Cx\Core\Setting\Controller\Setting::init('LinkManager', 'config'); $pageLimit = \Cx\Core\Setting\Controller\Setting::getValue('entriesPerPage', 'LinkManager'); $parameter = './index.php?cmd=' . $this->moduleName . '&act=crawlerResult'; $this->template->setVariable('ENTRIES_PAGING', \Paging::get($parameter, $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_LINKS'], $this->linkRepository->brokenLinkCount(), $pageLimit, true, $pos, 'pos')); $brokenLinks = $this->linkRepository->getBrokenLinks($pos, $pageLimit); $i = 1; $objUser = new \Cx\Core_Modules\LinkManager\Controller\User(); if ($brokenLinks && $brokenLinks->count() > 0) { foreach ($brokenLinks as $brokenLink) { $this->template->setVariable(array($this->moduleNameLang . '_BROKEN_LINK_ID' => contrexx_raw2xhtml($brokenLink->getId()), $this->moduleNameLang . '_BROKEN_LINK_IMAGE' => $brokenLink->getBrokenLinkText() == $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NO_IMAGE'] ? 'brokenImage' : 'brokenLinkImage', $this->moduleNameLang . '_BROKEN_LINK_TEXT' => $brokenLink->getBrokenLinkText(), $this->moduleNameLang . '_BROKEN_LINK_URL' => contrexx_raw2xhtml($brokenLink->getRequestedPath()), $this->moduleNameLang . '_BROKEN_LINK_REFERER' => contrexx_raw2xhtml($brokenLink->getLeadPath()) . '&pos=' . $pos . '&csrf=' . \Cx\Core\Csrf\Controller\Csrf::code(), $this->moduleNameLang . '_BROKEN_LINK_MODULE_NAME' => contrexx_raw2xhtml($brokenLink->getModuleName()), $this->moduleNameLang . '_BROKEN_LINK_ENTRY_TITLE' => contrexx_raw2xhtml($brokenLink->getEntryTitle()), $this->moduleNameLang . '_BROKEN_LINK_STATUS_CODE' => $brokenLink->getLinkStatusCode() == 0 ? $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NON_EXISTING_DOMAIN'] : contrexx_raw2xhtml($brokenLink->getLinkStatusCode()), $this->moduleNameLang . '_BROKEN_LINK_STATUS' => $brokenLink->getLinkStatus() ? $brokenLink->getLinkStatus() : 0, $this->moduleNameLang . '_BROKEN_LINK_STATUS_CHECKED' => $brokenLink->getLinkStatus() ? 'checked' : '', $this->moduleNameLang . '_BROKEN_LINK_DETECTED' => \Cx\Core_Modules\LinkManager\Controller\DateTime::formattedDateAndTime($brokenLink->getDetectedTime()), $this->moduleNameLang . '_BROKEN_LINK_UPDATED_BY' => $brokenLink->getUpdatedBy() ? contrexx_raw2xhtml($objUser->getUpdatedUserName($brokenLink->getUpdatedBy(), 0)) : '', $this->moduleNameLang . '_CRAWLER_BROKEN_LINK' => $brokenLink->getLinkRecheck() && $brokenLink->getLinkStatus() ? 'brokenLink' : '', $this->moduleNameLang . '_CRAWLER_RUN_ROW' => 'row' . (++$i % 2 + 1))); $this->template->parse($this->moduleName . 'CrawlerResultList'); } $this->template->hideBlock('LinkManagerNoCrawlerResultFound'); } else { $this->template->touchBlock('LinkManagerNoCrawlerResultFound'); } }
/** * Returns an array of values to be substituted * * Contains the following keys and values: * 'SHOP_COMPANY' => The company name (from the settings) * 'SHOP_HOMEPAGE' => The shop starting page URL * Used primarily for all MailTemplates. * Indexed by placeholder names. * @return array The substitution array */ static function getSubstitutionArray() { return array('SHOP_COMPANY' => \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop'), 'SHOP_HOMEPAGE' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '', FRONTEND_LANG_ID)->toString()); }
function listInputfields($objTpl, $intView, $intEntryId) { global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID, $objInit; usort($this->arrInputfields, array(__CLASS__, "sortInputfields")); switch ($intView) { case 1: //Settings View $objTpl->addBlockfile($this->moduleLangVar . '_SETTINGS_INPUTFIELDS_CONTENT', 'settings_inputfields_content', 'module_' . $this->moduleNameLC . '_settings_inputfields.html'); $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName); $arrShow = array(1 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACK_N_FRONTEND'], 2 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_FRONTEND'], 3 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACKEND']); $i = 0; $intLastId = 0; foreach ($this->arrInputfields as $key => $arrInputfield) { $strMustfield = $arrInputfield['required'] == 1 ? 'checked="checked"' : ''; $strExpSearch = $arrInputfield['search'] == 1 ? 'checked="checked"' : ''; if ($arrInputfield['id'] > $intLastId) { $intLastId = $arrInputfield['id']; } $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_SETTINGS_INPUTFIELD_LASTID' => $intLastId)); if ($arrInputfield['id'] != 1 && $arrInputfield['id'] != 2) { $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_FORM_ID' => $this->intFormId, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_TYPE' => $this->buildDropdownmenu($this->getInputfieldTypes(), $arrInputfield['type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_VERIFICATION' => $this->buildDropdownmenu($this->getInputfieldVerifications(), $arrInputfield['verification']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_SHOW' => $this->buildDropdownmenu($arrShow, $arrInputfield['show_in']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_CONTEXT' => $this->buildDropdownmenu($this->getInputContexts(), $arrInputfield['context_type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_MUSTFIELD' => $strMustfield, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_EXP_SEARCH' => $strExpSearch, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME_MASTER' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE_MASTER' => contrexx_raw2xhtml($arrInputfield['default_value'][0]), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO_MASTER' => $arrInputfield['info'][0])); //fieldname foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_NAME_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME' => $arrInputfield['name'][$arrLang['id']])); $objTpl->parse($this->moduleNameLC . 'InputfieldNameList'); } //default values foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE' => contrexx_raw2xhtml($arrInputfield['default_value'][$arrLang['id']]))); $objTpl->parse($this->moduleNameLC . 'InputfieldDefaultvalueList'); } //infotext foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_INFO_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO' => $arrInputfield['info'][$arrLang['id']])); $objTpl->parse($this->moduleNameLC . 'InputfieldInfoList'); } //language names foreach ($this->arrFrontendLanguages as $key => $arrLang) { if ($key + 1 == count($this->arrFrontendLanguages)) { $minimize = "<a id=\"inputfieldMinimize_" . $arrInputfield['id'] . "\" href=\"javascript:ExpandMinimizeInputfields('inputfieldName', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldDefaultvalue', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldLanguages', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldInfo', '" . $arrInputfield['id'] . "');\">« " . $_ARRAYLANG['TXT_MEDIADIR_MINIMIZE'] . "</a>"; } else { $minimize = ""; } $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_MINIMIZE' => $minimize)); $objTpl->parse($this->moduleNameLC . 'InputfieldLanguagesList'); } if ($arrInputfield['exp_search'] == 0) { $objTpl->hideBlock($this->moduleNameLC . 'InputfieldAdvancedSearch'); } else { $objTpl->touchBlock($this->moduleNameLC . 'InputfieldAdvancedSearch'); } $objTpl->parse($this->moduleNameLC . 'Inputfield'); } else { if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) { $objTpl->setVariable(array($this->moduleLangVar . '_SETTINGS_SELECTOR_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_SELECTOR_NAME' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_SELECTOR_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_SELECTOR_EXP_SEARCH' => $strExpSearch)); $objTpl->parse($this->moduleNameLC . 'Selector'); } } $i++; $objTpl->parse($this->moduleNameLC . 'InputfieldList'); } $objTpl->parse('settings_inputfields_content'); break; case 2: //modify (add/edit) View $objAddStep = new MediaDirectoryAddStep($this->moduleName); $i = 0; $isFileInputFound = false; foreach ($this->arrInputfields as $key => $arrInputfield) { $strInputfield = null; if ($arrInputfield['required'] == 1) { $strRequiered = '<font color="#ff0000"> *</font>'; } else { $strRequiered = null; } if (!empty($arrInputfield['type'])) { if (!$isFileInputFound && in_array($arrInputfield['type_name'], array('image', 'file', 'downloads'))) { $isFileInputFound = true; } $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); switch ($strType) { case 'add_step': $objAddStep->addNewStep(empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID]); $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId, $objAddStep); break; case 'field_group': //to do break; default: if ($arrInputfield['show_in'] == 1) { $bolGetInputfield = true; } else { if ($objInit->mode == 'backend' && $arrInputfield['show_in'] == 3) { $bolGetInputfield = true; } else { if ($objInit->mode == 'frontend' && $arrInputfield['show_in'] == 2) { $bolGetInputfield = true; } else { $bolGetInputfield = false; } } } if ($bolGetInputfield) { $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId); } else { $strInputfield = null; } break; } if ($strInputfield != null) { $this->makeJavascriptInputfieldArray($arrInputfield['id'], $this->moduleNameLC . "Inputfield[" . $arrInputfield['id'] . "]", $arrInputfield['required'], $arrInputfield['regex'], $strType); $this->strJavascriptInputfieldCheck[$strType] = $objInputfield->getJavascriptCheck(); $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = $objInputfield->getFormOnSubmit($arrInputfield['id']); } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } else { $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName); /*if($objInit->mode == 'backend') { $strStyle = 'style="overflow: auto; border: 1px solid #0A50A1; background-color: #ffffff; width: 298px; height: 200px; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"'; } else { $strStyle = 'style="overflow: auto; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"'; }*/ if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) { if ($arrInputfield['id'] == 2) { $objLevel = new MediaDirectoryLevel(null, null, 1, $this->moduleName); $arrSelectorOptions = $objLevel->listLevels($objTpl, 4, null, null, $intEntryId); $strSelectedOptionsName = "selectedLevels"; $strNotSelectedOptionsName = "deselectedLevels"; } else { $objCategory = new MediaDirectoryCategory(null, null, 1, $this->moduleName); $arrSelectorOptions = $objCategory->listCategories($objTpl, 4, null, null, $intEntryId); $strSelectedOptionsName = "selectedCategories"; $strNotSelectedOptionsName = "deselectedCategories"; } $strInputfield .= '<div class="mediadirSelector container-fluid"><div class="row"><div class="col-md-offset-3">'; $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorLeft"><div class="row"><select id="' . $strNotSelectedOptionsName . '" name="' . $strNotSelectedOptionsName . '[]" size="12" multiple="multiple">'; $strInputfield .= $arrSelectorOptions['not_selected']; $strInputfield .= '</select></div></div>'; $strInputfield .= '<div class="mediadirSelectorCenter col-md-2 col-sm-12 col-xs-12">'; $strInputfield .= '<input class="btn btn-default" value=" >> " name="addElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],addElement,removeElement);" type="button">'; $strInputfield .= '<br />'; $strInputfield .= '<input class="btn btn-default" value=" << " name="removeElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],removeElement,addElement);" type="button">'; $strInputfield .= '</div>'; $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorRight"><div class="row"><select id="' . $strSelectedOptionsName . '" name="' . $strSelectedOptionsName . '[]" size="12" multiple="multiple">'; $strInputfield .= $arrSelectorOptions['selected']; $strInputfield .= '</select></div></div>'; $strInputfield .= '</div></div></div>'; $this->makeJavascriptInputfieldArray($arrInputfield['id'], $strSelectedOptionsName, 1, 1, "selector"); $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = "selectAll(document.entryModfyForm.elements['" . $strSelectedOptionsName . "[]']); "; } } if ($arrInputfield['type_name'] == 'add_step' && $objInit->mode != 'backend') { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP' => $strInputfield)); $objTpl->parse($this->moduleNameLC . 'InputfieldAddStep'); } else { if ($strInputfield != null) { if ($arrInputfield['type_name'] == 'title') { $strStartTitle = '<h2>'; $strEndTitle = '</h2>'; } else { $strStartTitle = ''; $strEndTitle = ''; } $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME' => $strStartTitle . (empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID] . $strRequiered) . $strEndTitle, $this->moduleLangVar . '_INPUTFIELD_FIELD' => $strInputfield, $this->moduleLangVar . '_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2')); if ($arrInputfield['type_name'] != 'add_step') { $i++; $objTpl->parse($this->moduleNameLC . 'InputfieldList'); } } } if ($objInit->mode != 'backend') { $objTpl->parse($this->moduleNameLC . 'InputfieldElement'); } } if ($isFileInputFound && $objInit->mode != 'backend') { // init uploader to upload images $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback($this->moduleNameLC . 'UploaderCallback'); $uploader->setOptions(array('id' => $this->moduleNameLC . 'ImageUploader', 'style' => 'display:none', 'data-upload-limit' => 1)); $objTpl->setVariable(array($this->moduleLangVar . '_UPLOADER_ID' => $uploader->getId(), $this->moduleLangVar . '_UPLOADER_CODE' => $uploader->getXHtml())); } if (!empty($objAddStep->arrSteps) && $objInit->mode != 'backend') { $objAddStep->getStepNavigation($objTpl); $objTpl->parse($this->moduleNameLC . 'EntryAddStepNavigation'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP_TERMINATOR' => "</div>")); } break; case 3: //frontend View foreach ($this->arrInputfields as $key => $arrInputfield) { $intInputfieldId = intval($arrInputfield['id']); $intInputfieldType = intval($arrInputfield['type']); if (($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId) || $objTpl->blockExists($this->moduleNameLC . '_inputfields')) && ($intInputfieldType != 16 && $intInputfieldType != 17)) { if (!empty($arrInputfield['type'])) { $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); if (intval($arrInputfield['type_multi_lang']) == 1) { $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, $this->arrTranslationStatus); } else { $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, null); } if (!empty($arrInputfieldContent)) { if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[([A-Z][A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } foreach ($arrInputfieldContent as $strPlaceHolder => $strContent) { $objTpl->setVariable(array(strtoupper($strPlaceHolder) => $strContent)); } if ($objTpl->blockExists($this->moduleNameLC . '_inputfields')) { $objTpl->parse($this->moduleNameLC . '_inputfields'); } else { if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) { $objTpl->parse($this->moduleNameLC . '_inputfield_' . $intInputfieldId); } } } else { if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) { $objTpl->hideBlock($this->moduleNameLC . '_inputfield_' . $intInputfieldId); } } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } } $objTpl->clearVariables(); } break; case 4: //Exp Search View $strInputfields = ''; foreach ($this->arrInputfields as $key => $arrInputfield) { if ($this->checkFieldTypeIsExpSeach($arrInputfield['type'])) { if (!empty($arrInputfield['type'])) { $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $strInputfield = $objInputfield->getInputfield(2, $arrInputfield); if ($strInputfield != null) { $strInputfields .= '<p><label>' . $arrInputfield['name'][0] . '</label>' . $strInputfield . '</p>'; } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } } } return $strInputfields; break; } }
/** * Check in the payment processor after the payment is complete. * @return mixed For external payment methods: * The integer order ID, if known, upon success * For internal payment methods: * Boolean true, in order to make these skip the order * status update, as this has already been done. * If the order ID is unknown or upon failure: * Boolean false */ static function checkIn() { //DBG::log("PaymentProcessing::checkIn(): Entered"); //DBG::log("POST: ".var_export($_POST, true)); //DBG::log("GET: ".var_export($_GET, true)); $result = NULL; if (isset($_GET['result'])) { $result = abs(intval($_GET['result'])); if ($result == 0 || $result == 2) { return false; } } if (empty($_REQUEST['handler'])) { return false; } switch ($_REQUEST['handler']) { case 'paymill_cc': case 'paymill_elv': case 'paymill_iban': $arrShopOrder = array('order_id' => $_SESSION['shop']['order_id'], 'amount' => intval(bcmul($_SESSION['shop']['grand_total_price'], 100, 0)), 'currency' => Currency::getActiveCurrencyCode(), 'note' => $_SESSION['shop']['note']); $response = \PaymillHandler::processRequest($_REQUEST['paymillToken'], $arrShopOrder); \DBG::log(var_export($response, true)); if ($response['status'] === 'success') { return true; } else { \DBG::log("PaymentProcessing::checkIn(): WARNING: paymill: Payment verification failed; errors: " . var_export($response, true)); return false; } case 'saferpay': $arrShopOrder = array('ACCOUNTID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop')); $id = \Saferpay::payConfirm(); if (\Cx\Core\Setting\Controller\Setting::getValue('saferpay_finalize_payment', 'Shop')) { $arrShopOrder['ID'] = $id; $id = \Saferpay::payComplete($arrShopOrder); } //DBG::log("Transaction: ".var_export($transaction, true)); return (bool) $id; case 'paypal': if (empty($_POST['custom'])) { //DBG::log("PaymentProcessing::checkIn(): No custom parameter, returning NULL"); return NULL; } $order_id = \PayPal::getOrderId(); // if (!$order_id) { // $order_id = (isset($_SESSION['shop']['order_id']) // ? $_SESSION['shop']['order_id'] // : (isset ($_SESSION['shop']['order_id_checkin']) // ? $_SESSION['shop']['order_id_checkin'] // : NULL)); // } $order = Order::getById($order_id); $amount = $currency_id = $customer_email = NULL; if ($order) { $amount = $order->sum(); $currency_id = $order->currency_id(); $customer_id = $order->customer_id(); $customer = Customer::getById($customer_id); if ($customer) { $customer_email = $customer->email(); } } $currency_code = Currency::getCodeById($currency_id); return \PayPal::ipnCheck($amount, $currency_code, $order_id, $customer_email, \Cx\Core\Setting\Controller\Setting::getValue('paypal_account_email', 'Shop')); case 'yellowpay': $passphrase = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_out', 'Shop'); return \Yellowpay::checkIn($passphrase); // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } case 'payrexx': return \PayrexxProcessor::checkIn(); // Added 20100222 -- Reto Kohli // Added 20100222 -- Reto Kohli case 'mobilesolutions': // A return value of null means: Do not change the order status if (empty($_POST['state'])) { return null; } $result = \PostfinanceMobile::validateSign(); if ($result) { //DBG::log("PaymentProcessing::checkIn(): mobilesolutions: Payment verification successful!"); } else { DBG::log("PaymentProcessing::checkIn(): WARNING: mobilesolutions: Payment verification failed; errors: " . var_export(\PostfinanceMobile::getErrors(), true)); } return $result; // Added 20081117 -- Reto Kohli // Added 20081117 -- Reto Kohli case 'datatrans': return \Datatrans::validateReturn() && \Datatrans::getPaymentResult() == 1; // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. case 'internal': case 'internal_creditcard': case 'internal_debit': case 'internal_lsv': return true; // Dummy payment. // Dummy payment. case 'dummy': $result = ''; if (isset($_REQUEST['result'])) { $result = $_REQUEST['result']; } // Returns the order ID on success, false otherwise return \Dummy::commit($result); default: break; } // Anything else is wrong. return false; }
/** * Fixes database errors. * * Also migrates settings from the old Shop settings table to \Cx\Core\Setting. * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { global $_CONFIGURATION; // ShopSettings \Cx\Core\Setting\Controller\Setting::errorHandler(); \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); $table_name = DBPREFIX . 'module_shop_config'; $i = 0; if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { // Migrate all entries using the \Cx\Core\Setting\Controller\Setting class $query = "\n SELECT `name`, `value`, `status`\n FROM " . DBPREFIX . "module_shop_config\n ORDER BY `id` ASC"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException('Failed to query old Shop settings', $query); } while (!$objResult->EOF) { $name = $objResult->fields['name']; $value = $objResult->fields['value']; $status = $objResult->fields['status']; $name_status = null; switch ($name) { // OBSOLETE case 'tax_default_id': case 'tax_enabled': case 'tax_included': case 'tax_number': // Ignore, do not migrate! $name = null; break; // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\]) // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\]) case 'confirmation_emails': $name = 'email_confirmation'; break; case 'country_id': case 'datatrans_merchant_id': case 'datatrans_request_type': break; case 'datatrans_status': $name = 'datatrans_active'; break; case 'datatrans_use_testserver': case 'email': case 'fax': case 'orderitems_amount_max': case 'paypal_default_currency': case 'postfinance_mobile_ijustwanttotest': case 'postfinance_mobile_sign': case 'postfinance_mobile_status': case 'postfinance_mobile_webuser': case 'product_sorting': case 'saferpay_finalize_payment': case 'saferpay_window_option': break; case 'shop_address': case 'shop_company': case 'shop_show_products_default': case 'shop_thumbnail_max_height': case 'shop_thumbnail_max_width': case 'shop_thumbnail_quality': case 'shop_weight_enable': $name = preg_replace('/^shop_/', '', $name); break; case 'telephone': case 'vat_default_id': case 'vat_enabled_foreign_customer': case 'vat_enabled_foreign_reseller': case 'vat_enabled_home_customer': case 'vat_enabled_home_reseller': case 'vat_included_foreign_customer': case 'vat_included_foreign_reseller': case 'vat_included_home_customer': case 'vat_included_home_reseller': case 'vat_number': case 'vat_other_id': break; case 'yellowpay_accepted_payment_methods': case 'yellowpay_authorization_type': case 'yellowpay_hash_seed': case 'yellowpay_hash_signature_in': case 'yellowpay_hash_signature_out': case 'yellowpay_use_testserver': $name = preg_replace('/^yellowpay(.*)$/', 'postfinance$1', $name); break; case 'yellowpay_id': // Obsolete $name = null; break; // VALUE & STATUS // VALUE & STATUS case 'paypal_account_email': $name_status = 'paypal_active'; break; case 'saferpay_id': $name_status = 'saferpay_active'; break; case 'yellowpay_shop_id': $name = 'postfinance_shop_id'; $name_status = 'postfinance_active'; break; // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\]) // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\]) case 'payment_lsv_status': $name_status = 'payment_lsv_active'; $name = null; break; case 'saferpay_use_test_account': $name_status = $name; $name = null; break; } if ($name) { if (\Cx\Core\Setting\Controller\Setting::getValue($name, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name, $value, ++$i)) { throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for '{$name}'"); } } if ($name_status) { if (\Cx\Core\Setting\Controller\Setting::getValue($name_status, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name_status, $status, ++$i)) { throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for status '{$name_status}'"); } } $objResult->MoveNext(); } } \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); // Try adding any that just *might* be missing for *any* reason \Cx\Core\Setting\Controller\Setting::add('email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('email_confirmation', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('company', 'Comvation AG', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('address', 'Burgstrasse 20', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('country_id', 204, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('telephone', '+4133 2266000', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('fax', '+4133 2266001', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_number', '12345678', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_included_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_included_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_default_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('vat_other_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('weight_enable', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('show_products_default', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('product_sorting', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '0:TXT_SHOP_PRODUCT_SORTING_ALPHABETIC,' . '1:TXT_SHOP_PRODUCT_SORTING_INDIVIDUAL,' . '2:TXT_SHOP_PRODUCT_SORTING_PRODUCTCODE', 'config'); \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_width', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_height', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('thumbnail_quality', 90, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('saferpay_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('saferpay_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('saferpay_use_test_account', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('saferpay_finalize_payment', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('saferpay_window_option', 2, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('paypal_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('paypal_account_email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('paypal_default_currency', 'CHF', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); // Also see Yellowpay.class \Cx\Core\Setting\Controller\Setting::add('payrexx_instance_name', 'Instanz Name', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT); \Cx\Core\Setting\Controller\Setting::add('payrexx_api_secret', 'API Secret', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT); \Cx\Core\Setting\Controller\Setting::add('payrexx_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1'); \Cx\Core\Setting\Controller\Setting::add('postfinance_shop_id', 'Ihr Kontoname', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT); \Cx\Core\Setting\Controller\Setting::add('postfinance_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1'); \Cx\Core\Setting\Controller\Setting::add('postfinance_authorization_type', 'SAL', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, 'RES:Reservation,SAL:Verkauf'); // OBSOLETE // As it appears that in_array(0, $array) is true for each non-empty // $array, indices for the entries must be numbered starting at 1. // $arrPayments = array(); // foreach (self::$arrKnownPaymentMethod as $index => $name) { // $arrPayments[$index] = $name; // } // \Cx\Core\Setting\Controller\Setting::add('postfinance_accepted_payment_methods', '', ++$i, // \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOXGROUP, // \Cx\Core\Setting\Controller\Setting::joinValues($arrPayments)); \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_in', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT); \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_out', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT); \Cx\Core\Setting\Controller\Setting::add('postfinance_use_testserver', '1', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1'); \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_webuser', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_sign', 'geheimer_schlüssel', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_ijustwanttotest', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_status', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('datatrans_merchant_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('datatrans_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('datatrans_request_type', 'CAA', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('datatrans_use_testserver', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('payment_lsv_active', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); // New for V3.0 // Disable jsCart by default. $useJsCart = '0'; // Activate it in case it was activated in config/configuration.php if (isset($_CONFIGURATION['custom']['shopJsCart']) && $_CONFIGURATION['custom']['shopJsCart']) { $useJsCart = '1'; } \Cx\Core\Setting\Controller\Setting::add('use_js_cart', $useJsCart, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX); // Disable shopnavbar on other pages by default. $shopnavbar = '0'; // Activate it in case it was activated in config/configuration.php if (isset($_CONFIGURATION['custom']['shopnavbar']) && $_CONFIGURATION['custom']['shopnavbar']) { $shopnavbar = '1'; } \Cx\Core\Setting\Controller\Setting::add('shopnavbar_on_all_pages', $shopnavbar, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX); // New for v3.1.0 \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_min', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); // New for v2.2(?) \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_max', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); // New for v2.3 \Cx\Core\Setting\Controller\Setting::add('register', ShopLibrary::REGISTER_MANDATORY, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, \Cx\Core\Setting\Controller\Setting::joinValues(array(ShopLibrary::REGISTER_MANDATORY, ShopLibrary::REGISTER_OPTIONAL, ShopLibrary::REGISTER_NONE)), 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_products_per_page_frontend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('history_maximum_age_days', 730, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_frontend', 10, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_customers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_manufacturers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_mailtemplate_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('numof_coupon_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('usergroup_id_customer', 0, 341, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('usergroup_id_reseller', 0, 342, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_customer_group_id', 0, 351, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_notes', 0, 352, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config'); \Cx\Core\Setting\Controller\Setting::add('num_categories_per_row', 4, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config'); // Note that the Settings *MUST* be reinited after adding new entries! // Add more new/missing settings here \Cx\Lib\UpdateUtil::drop_table($table_name); // Always return false; }
/** * Change Subscription State to Terminate. * * @throws WebsiteException */ public function terminate() { global $_ARRAYLANG; if ($this->externalSubscriptionId) { \Cx\Core\Setting\Controller\Setting::init('MultiSite', '', 'FileSystem'); $instanceName = \Cx\Core\Setting\Controller\Setting::getValue('payrexxAccount', 'MultiSite'); $apiSecret = \Cx\Core\Setting\Controller\Setting::getValue('payrexxApiSecret', 'MultiSite'); if (empty($instanceName) || empty($apiSecret)) { return; } $payrexx = new \Payrexx\Payrexx($instanceName, $apiSecret); $subscription = new \Payrexx\Models\Request\Subscription(); $subscription->setId($this->externalSubscriptionId); try { $response = $payrexx->cancel($subscription); if (isset($response['status']) && $response['status'] != 'success' || isset($response['data']['status']) && $response['data']['status'] != 'cancelled') { throw new SubscriptionException($_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PAYREXX_CANCEL_FAILED']); } } catch (\Payrexx\PayrexxException $e) { throw new SubscriptionException($e->getMessage()); } } //set state terminated. $this->setState(self::STATE_TERMINATED); //Set current date/time $this->setTerminationDate(new \DateTime()); //Trigger the model event terminated on the subscription's product entity. \Env::get('cx')->getEvents()->triggerEvent('model/terminated', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em')))); }
/** * Create a new Order * * @param integer $productId productId * @param object $objUser \User object * @param string $transactionReference transactionReference * @param array $subscriptionOptions subscriptionOptions * * @return boolean * @throws OrderRepositoryException */ public function createOrder($productId, \Cx\Modules\Crm\Model\Entity\Currency $currency, \User $objUser, $transactionReference, $subscriptionOptions = array()) { if (\FWValidator::isEmpty($productId) || \FWValidator::isEmpty($subscriptionOptions) || \FWValidator::isEmpty($transactionReference) || \FWValidator::isEmpty($currency)) { return; } $contactId = $objUser->getCrmUserId(); if (\FWValidator::isEmpty($contactId)) { return; } try { $order = new \Cx\Modules\Order\Model\Entity\Order(); $order->setContactId($contactId); $order->setCurrency($currency); $productRepository = \Env::get('em')->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Product'); $product = $productRepository->findOneBy(array('id' => $productId)); //create subscription $subscription = $order->createSubscription($product, $subscriptionOptions); // set discount price for first payment period of subscription if (!empty($subscriptionOptions['oneTimeSalePrice'])) { $subscription->setPaymentAmount($subscriptionOptions['oneTimeSalePrice']); } $order->billSubscriptions(); $invoices = $order->getInvoices(); if (!empty($invoices)) { \DBG::msg(__METHOD__ . ": order has invoices"); $paymentRepo = \Env::get('em')->getRepository('\\Cx\\Modules\\Order\\Model\\Entity\\Payment'); foreach ($invoices as $invoice) { if (!$invoice->getPaid()) { \DBG::msg(__METHOD__ . ": lookup payment with transaction-reference {$transactionReference} and amount " . $invoice->getAmount()); $payment = $paymentRepo->findOneByCriteria(array('amount' => $invoice->getAmount(), 'transactionReference' => $transactionReference, 'invoice' => null)); if ($payment) { \DBG::msg(__METHOD__ . ": payment found"); //set subscription-id to Subscription::$externalSubscriptionId if ($subscription) { \DBG::msg(__METHOD__ . ": trying to link to new subscription to the external subscription ID"); $referenceArry = explode('|', $payment->getTransactionReference()); if (isset($referenceArry[4]) && !empty($referenceArry[4])) { $subscription->setExternalSubscriptionId($referenceArry[4]); } } $transactionData = $payment->getTransactionData(); if (!\FWValidator::isEmpty($transactionData) && isset($transactionData['contact']) && isset($transactionData['contact']['id'])) { \DBG::msg(__METHOD__ . ": set externalPaymentCustomerIdProfileAttributeId of user to " . $transactionData['contact']['id']); $objUser->setProfile(array(\Cx\Core\Setting\Controller\Setting::getValue('externalPaymentCustomerIdProfileAttributeId', 'MultiSite') => array(0 => $transactionData['contact']['id'])), true); if (!$objUser->store()) { \DBG::msg('Order::createOrder() Updating user failed: ' . $objUser->getErrorMsg()); } } $invoice->addPayment($payment); $payment->setInvoice($invoice); \Env::get('em')->persist($invoice); \Env::get('em')->persist($payment); break; } } } } \Env::get('em')->persist($order); \Env::get('em')->flush(); return $order; } catch (\Exception $e) { throw new OrderRepositoryException($e->getMessage()); } }
/** * Generates a new dynamic access-ID * * @return mixed Returns the newly created dynamic access-ID or FALSE on failure. */ public static function createNewDynamicAccessId() { \Cx\Core\Setting\Controller\Setting::init('Config', 'core', 'Yaml'); if (!\Cx\Core\Setting\Controller\Setting::isDefined('lastAccessId')) { $newAccessId = 1; \Cx\Core\Setting\Controller\Setting::add('lastAccessId', $newAccessId, 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, '', 'core'); } else { $newAccessId = \Cx\Core\Setting\Controller\Setting::getValue('lastAccessId', 'Config') + 1; \Cx\Core\Setting\Controller\Setting::set('lastAccessId', $newAccessId); if (!\Cx\Core\Setting\Controller\Setting::update('lastAccessId')) { return false; } } // verify that the update was successful \Cx\Core\Setting\Controller\Setting::init('Config', 'core', 'Yaml'); if (\Cx\Core\Setting\Controller\Setting::getValue('lastAccessId', 'Config') != $newAccessId) { return false; } return $newAccessId; }
/** * Processes the Order * * Verifies all data, updates and stores it in the database, and * initializes payment * @return boolean True on successs, false otherwise */ static function process() { global $objDatabase, $_ARRAYLANG; // FOR TESTING ONLY (repeatedly process/store the order, also disable self::destroyCart()) //$_SESSION['shop']['order_id'] = NULL; // Verify that the order hasn't yet been saved // (and has thus not yet been confirmed) if (isset($_SESSION['shop']['order_id'])) { return \Message::error($_ARRAYLANG['TXT_ORDER_ALREADY_PLACED']); } // No more confirmation self::$objTemplate->hideBlock('shopConfirm'); // Store the customer, register the order $customer_ip = $_SERVER['REMOTE_ADDR']; $customer_host = substr(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 0, 100); $customer_browser = substr(getenv('HTTP_USER_AGENT'), 0, 100); $new_customer = false; //\DBG::log("Shop::process(): E-Mail: ".$_SESSION['shop']['email']); if (self::$objCustomer) { //\DBG::log("Shop::process(): Existing User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']); } else { // Registered Customers are required to be logged in! self::$objCustomer = Customer::getRegisteredByEmail($_SESSION['shop']['email']); if (self::$objCustomer) { \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_REGISTERED_EMAIL']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'confirm'))); } // Unregistered Customers are stored as well, as their information is needed // nevertheless. Their active status, however, is set to false. self::$objCustomer = Customer::getUnregisteredByEmail($_SESSION['shop']['email']); if (!self::$objCustomer) { self::$objCustomer = new Customer(); // Currently, the e-mail address is set as the user name $_SESSION['shop']['username'] = $_SESSION['shop']['email']; //\DBG::log("Shop::process(): New User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']); self::$objCustomer->username($_SESSION['shop']['username']); self::$objCustomer->email($_SESSION['shop']['email']); // Note that the password is unset when the Customer chooses // to order without registration. The generated one // defaults to length 8, fulfilling the requirements for // complex passwords. And it's kept absolutely secret. $password = empty($_SESSION['shop']['password']) ? \User::make_password() : $_SESSION['shop']['password']; //\DBG::log("Password: $password (session: {$_SESSION['shop']['password']})"); if (!self::$objCustomer->password($password)) { \Message::error($_ARRAYLANG['TXT_INVALID_PASSWORD']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account')); } self::$objCustomer->active(empty($_SESSION['shop']['dont_register'])); $new_customer = true; } } // Update the Customer object from the session array // (whether new or not -- it may have been edited) self::$objCustomer->gender($_SESSION['shop']['gender']); self::$objCustomer->firstname($_SESSION['shop']['firstname']); self::$objCustomer->lastname($_SESSION['shop']['lastname']); self::$objCustomer->company($_SESSION['shop']['company']); self::$objCustomer->address($_SESSION['shop']['address']); self::$objCustomer->city($_SESSION['shop']['city']); self::$objCustomer->zip($_SESSION['shop']['zip']); self::$objCustomer->country_id($_SESSION['shop']['countryId']); self::$objCustomer->phone($_SESSION['shop']['phone']); self::$objCustomer->fax($_SESSION['shop']['fax']); $arrGroups = self::$objCustomer->getAssociatedGroupIds(); $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); if (empty($usergroup_id)) { //\DBG::log("Shop::process(): ERROR: Missing reseller group"); \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } if (!in_array($usergroup_id, $arrGroups)) { //\DBG::log("Shop::process(): Customer is not in Reseller group (ID $usergroup_id)"); // Not a reseller. See if she's a final customer $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); if (empty($usergroup_id)) { //\DBG::log("Shop::process(): ERROR: Missing final customer group"); \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } if (!in_array($usergroup_id, $arrGroups)) { //\DBG::log("Shop::process(): Customer is not in final customer group (ID $usergroup_id), either"); // Neither one, add to the final customer group (default) $arrGroups[] = $usergroup_id; self::$objCustomer->setGroups($arrGroups); //\DBG::log("Shop::process(): Added Customer to final customer group (ID $usergroup_id): ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } else { //\DBG::log("Shop::process(): Customer is a final customer (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } } else { //\DBG::log("Shop::process(): Customer is a Reseller (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } // Insert or update the customer //\DBG::log("Shop::process(): Storing Customer: ".var_export(self::$objCustomer, true)); if (!self::$objCustomer->store()) { return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']); } // Authenticate new Customer if ($new_customer) { // Fails for "unregistered" Customers! if (self::$objCustomer->auth($_SESSION['shop']['username'], $_SESSION['shop']['password'], false, true)) { if (!self::_authenticate()) { return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']); } } } //die(); // Clear the ship-to country if there is no shipping if (!Cart::needs_shipment()) { $_SESSION['shop']['countryId2'] = 0; } $shipper_id = empty($_SESSION['shop']['shipperId']) ? null : $_SESSION['shop']['shipperId']; $payment_id = empty($_SESSION['shop']['paymentId']) ? null : $_SESSION['shop']['paymentId']; $objOrder = new Order(); $objOrder->customer_id(self::$objCustomer->id()); $objOrder->billing_gender($_SESSION['shop']['gender']); $objOrder->billing_firstname($_SESSION['shop']['firstname']); $objOrder->billing_lastname($_SESSION['shop']['lastname']); $objOrder->billing_company($_SESSION['shop']['company']); $objOrder->billing_address($_SESSION['shop']['address']); $objOrder->billing_city($_SESSION['shop']['city']); $objOrder->billing_zip($_SESSION['shop']['zip']); $objOrder->billing_country_id($_SESSION['shop']['countryId']); $objOrder->billing_phone($_SESSION['shop']['phone']); $objOrder->billing_fax($_SESSION['shop']['fax']); $objOrder->billing_email($_SESSION['shop']['email']); $objOrder->currency_id($_SESSION['shop']['currencyId']); $objOrder->sum($_SESSION['shop']['grand_total_price']); $objOrder->date_time(date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME)); $objOrder->status(0); $objOrder->company($_SESSION['shop']['company2']); $objOrder->gender($_SESSION['shop']['gender2']); $objOrder->firstname($_SESSION['shop']['firstname2']); $objOrder->lastname($_SESSION['shop']['lastname2']); $objOrder->address($_SESSION['shop']['address2']); $objOrder->city($_SESSION['shop']['city2']); $objOrder->zip($_SESSION['shop']['zip2']); $objOrder->country_id($_SESSION['shop']['countryId2']); $objOrder->phone($_SESSION['shop']['phone2']); $objOrder->vat_amount($_SESSION['shop']['vat_price']); $objOrder->shipment_amount($_SESSION['shop']['shipment_price']); $objOrder->shipment_id($shipper_id); $objOrder->payment_id($payment_id); $objOrder->payment_amount($_SESSION['shop']['payment_price']); $objOrder->ip($customer_ip); $objOrder->host($customer_host); $objOrder->lang_id(FRONTEND_LANG_ID); $objOrder->browser($customer_browser); $objOrder->note($_SESSION['shop']['note']); if (!$objOrder->insert()) { // $order_id is unset! return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_STORING']); } $order_id = $objOrder->id(); $_SESSION['shop']['order_id'] = $order_id; // The products will be tested one by one below. // If any single one of them requires delivery, this // flag will be set to true. // This is used to determine the order status at the // end of the shopping process. $_SESSION['shop']['isDelivery'] = false; // Try to redeem the Coupon, if any $coupon_code = isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : null; //\DBG::log("Cart::update(): Coupon Code: $coupon_code"); $items_total = 0; // Suppress Coupon messages (see Coupon::available()) \Message::save(); foreach (Cart::get_products_array() as $arrProduct) { $objProduct = Product::getById($arrProduct['id']); if (!$objProduct) { unset($_SESSION['shop']['order_id']); return \Message::error($_ARRAYLANG['TXT_ERROR_LOOKING_UP_ORDER']); } $product_id = $arrProduct['id']; $name = $objProduct->name(); $priceOptions = !empty($arrProduct['optionPrice']) ? $arrProduct['optionPrice'] : 0; $quantity = $arrProduct['quantity']; $price = $objProduct->get_custom_price(self::$objCustomer, $priceOptions, $quantity); $item_total = $price * $quantity; $items_total += $item_total; $productVatId = $objProduct->vat_id(); $vat_rate = $productVatId && Vat::getRate($productVatId) ? Vat::getRate($productVatId) : '0.00'; // Test the distribution method for delivery $productDistribution = $objProduct->distribution(); if ($productDistribution == 'delivery') { $_SESSION['shop']['isDelivery'] = true; } $weight = $productDistribution == 'delivery' ? $objProduct->weight() : 0; // grams if ($weight == '') { $weight = 0; } // Add to order items table $result = $objOrder->insertItem($order_id, $product_id, $name, $price, $quantity, $vat_rate, $weight, $arrProduct['options']); if (!$result) { unset($_SESSION['shop']['order_id']); // TODO: Verify error message set by Order::insertItem() return false; } // Store the Product Coupon, if applicable. // Note that it is not redeemed yet (uses=0)! if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $item_total, self::$objCustomer->id(), $product_id, $payment_id); if ($objCoupon) { //\DBG::log("Shop::process(): Got Coupon for Product ID $product_id: ".var_export($objCoupon, true)); if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $price * $quantity, 0)) { // TODO: Do something if the Coupon does not work \DBG::log("Shop::process(): ERROR: Failed to store Coupon for Product ID {$product_id}"); } $coupon_code = null; } } } // foreach product in cart // Store the Global Coupon, if applicable. // Note that it is not redeemed yet (uses=0)! //\DBG::log("Shop::process(): Looking for global Coupon $coupon_code"); if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $items_total, self::$objCustomer->id(), null, $payment_id); if ($objCoupon) { //\DBG::log("Shop::process(): Got global Coupon: ".var_export($objCoupon, true)); if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $items_total, 0)) { \DBG::log("Shop::process(): ERROR: Failed to store global Coupon"); } } } \Message::restore(); $processor_id = Payment::getProperty($_SESSION['shop']['paymentId'], 'processor_id'); $processor_name = PaymentProcessing::getPaymentProcessorName($processor_id); // other payment methods PaymentProcessing::initProcessor($processor_id); // TODO: These arguments are no longer valid. Set them up later? // Currency::getActiveCurrencyCode(), // FWLanguage::getLanguageParameter(FRONTEND_LANG_ID, 'lang')); // if the processor is Internal_LSV, and there is account information, // store the information. if ($processor_name == 'internal_lsv') { if (!self::lsv_complete()) { // Missing mandatory data; return to payment unset($_SESSION['shop']['order_id']); \Message::error($_ARRAYLANG['TXT_ERROR_ACCOUNT_INFORMATION_NOT_AVAILABLE']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } $query = "\n INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv (\n order_id, holder, bank, blz\n ) VALUES (\n {$order_id},\n '" . contrexx_raw2db($_SESSION['shop']['account_holder']) . "',\n '" . contrexx_raw2db($_SESSION['shop']['account_bank']) . "',\n '" . contrexx_raw2db($_SESSION['shop']['account_blz']) . "'\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { // Return to payment unset($_SESSION['shop']['order_id']); \Message::error($_ARRAYLANG['TXT_ERROR_INSERTING_ACCOUNT_INFORMATION']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } } $_SESSION['shop']['order_id_checkin'] = $order_id; $strProcessorType = PaymentProcessing::getCurrentPaymentProcessorType(); // Test whether the selected payment method can be // considered an instant or deferred one. // This is used to set the order status at the end // of the shopping process. // TODO: Invert this flag, as it may no longer be present after paying // online using one of the external payment methods! Ensure that it is set // instead when paying "deferred". $_SESSION['shop']['isInstantPayment'] = false; if ($strProcessorType == 'external') { // For the sake of simplicity, all external payment // methods are considered to be 'instant'. // All currently implemented internal methods require // further action from the merchant, and thus are // considered to be 'deferred'. $_SESSION['shop']['isInstantPayment'] = true; } // Send the Customer login separately, as the password possibly // won't be available later if (!empty($_SESSION['shop']['password'])) { self::sendLogin(self::$objCustomer->email(), $_SESSION['shop']['password']); } // Show payment processing page. // Note that some internal payments are redirected away // from this page in checkOut(): // 'internal', 'internal_lsv' self::$objTemplate->setVariable('SHOP_PAYMENT_PROCESSING', PaymentProcessing::checkOut()); // Clear the order ID. // The order may be resubmitted and the payment retried. unset($_SESSION['shop']['order_id']); // Custom. // Enable if Discount class is customized and in use. //self::showCustomerDiscount(Cart::get_price()); return true; }
/** * settings for mail tempalte design * * @global <type> $objDatabase * @global <type> $_ARRAYLANG * @return true */ function mailTemplates() { global $_CORELANG, $_ARRAYLANG; $_REQUEST['active_tab'] = 1; if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'mailtemplate_edit') { $_REQUEST['active_tab'] = 2; } \Cx\Core\MailTemplate\Controller\MailTemplate::deleteTemplate('Crm'); // If there is anything to be stored, and if that fails, return to // the edit view in order to save the posted form content $result_store = \Cx\Core\MailTemplate\Controller\MailTemplate::storeFromPost('Crm'); if ($result_store === false) { $_REQUEST['active_tab'] = 2; } $objTemplate = null; $result &= \Cx\Core\Setting\Controller\Setting::show_external($objTemplate, $_CORELANG['TXT_CORE_MAILTEMPLATES'], \Cx\Core\MailTemplate\Controller\MailTemplate::overview('Crm', 'config', \Cx\Core\Setting\Controller\Setting::getValue('numof_mailtemplate_per_page_backend', 'Crm'))->get()); $result &= \Cx\Core\Setting\Controller\Setting::show_external($objTemplate, empty($_REQUEST['key']) ? $_CORELANG['TXT_CORE_MAILTEMPLATE_ADD'] : $_CORELANG['TXT_CORE_MAILTEMPLATE_EDIT'], \Cx\Core\MailTemplate\Controller\MailTemplate::edit('Crm')->get()); $result &= \Cx\Core\Setting\Controller\Setting::show_external($objTemplate, $_ARRAYLANG['TXT_CRM_PLACEHOLDERS'], $this->getCrmModulePlaceHolders()); $this->_objTpl->addBlock('CRM_MAIL_SETTINGS_FILE', 'settings_block', $objTemplate->get()); $this->_objTpl->touchBlock('settings_block'); }
/** * Searches the content and returns an array that is built as needed by the search module. * * @param string $searchTerm * * @return array */ public function searchResultsForSearchModule($searchTerm) { $em = \Env::get('cx')->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); // only list results in case the associated page of the module is active $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION)); //If page is not exists or page is inactive then return empty result if (!$page || !$page->isActive()) { return array(); } //get the config site values \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml'); $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config'); $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config'); //get the config otherConfigurations value \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml'); $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config'); $hasPageAccess = true; $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible(); if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) { $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true); } //If the page is invisible and frontend access is denied then return empty result if ($isNotVisible || !$hasPageAccess) { return array(); } //get the media directory entry by the search term $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName); $entries->getEntries(null, null, null, $searchTerm); //if no entries found then return empty result if (empty($entries->arrEntries)) { return array(); } $results = array(); $formEntries = array(); $defaultEntries = null; $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName); $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']); foreach ($entries->arrEntries as $entry) { $pageUrlResult = null; $entryForm = $objForm->arrForms[$entry['entryFormId']]; //Get the entry's link url //check the entry's form detail view exists if not, //check the entry's form overview exists if not, //check the default overview exists if not, dont show the corresponding entry in entry switch (true) { case $entries->checkPageCmd('detail' . $entry['entryFormId']): $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId'])); break; case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']): case $entries->checkPageCmd(''): if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) { $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']); } if (!$pageCmdExists && !isset($defaultEntries)) { $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $defaultEntries->getEntries(); } //get entry's form overview / default page paging position $entriesPerPage = $numOfEntries; if ($pageCmdExists) { $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries; } $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : ''; $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries); $entryPos = array_search($entry['entryId'], $entryKeys); $position = floor($entryPos / $entriesPerPage); $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage)); break; default: break; } //If page url is empty then dont show it in the result if (!$pageUrlResult) { continue; } //Get the search results title and content from the form context field 'title' and 'content' $title = current($entry['entryFields']); $content = ''; $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName); $inputFields = $objInputfields->getInputfields(); foreach ($inputFields as $arrInputfield) { $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : ''; if (!in_array($contextType, array('title', 'content'))) { continue; } $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : ''; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null; $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus); if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } } catch (\Exception $e) { \DBG::log($e->getMessage()); continue; } $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE']; if (empty($inputFieldValue)) { continue; } if ($contextType == 'title') { $title = $inputFieldValue; } elseif ($contextType == 'content') { $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength); } } $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString()); } return $results; }
/** * Returns all domains and ports this instance of cloudrexx can be reached at * @return array List of domains and ports (array(array(0=>{domain}, 1=>{port}))) */ protected function getDomainsAndPorts() { $domainsAndPorts = array(); $domainRepo = new \Cx\Core\Net\Model\Repository\DomainRepository(); $domains = $domainRepo->findAll(); foreach (array('http', 'https') as $protocol) { foreach ($domains as $domain) { $domainsAndPorts[] = array($domain->getName(), \Cx\Core\Setting\Controller\Setting::getValue('portFrontend' . strtoupper($protocol), 'Config')); } } return $domainsAndPorts; $requestDomain = $_CONFIG['domainUrl']; $domainOffset = ASCMS_PATH_OFFSET; $request = "BAN {$domainOffset} HTTP/1.0\r\n"; $request .= "Host: {$requestDomain}\r\n"; $request .= "User-Agent: Cloudrexx Varnish Cache Clear\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($varnishSocket, $request); fclose($varnishSocket); }