/** * Handles request from the client * @todo Clean up usage of $param and $_GET * @global Array $_CORELANG Core language data * @param Array $params Client parameters * @return type */ public function set($params) { global $_CORELANG; // Global access check if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) { throw new \Exception($_CORELANG['TXT_CORE_CM_USAGE_DENIED']); } $newPage = false; $reload = false; $pg = \Env::get('pageguard'); $dataPost = !empty($params['post']) ? $params['post'] : array(); $pageArray = !empty($dataPost['page']) ? $dataPost['page'] : array(); // Only set in the editing mode. $pageId = !empty($pageArray['id']) ? intval($pageArray['id']) : (!empty($dataPost['pageId']) ? intval($dataPost['pageId']) : 0); $nodeId = !empty($pageArray['node']) ? intval($pageArray['node']) : (!empty($dataPost['nodeId']) ? intval($dataPost['nodeId']) : 0); $lang = !empty($pageArray['lang']) ? contrexx_input2raw($pageArray['lang']) : (!empty($dataPost['lang']) ? contrexx_input2raw($dataPost['lang']) : \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId())); $action = !empty($dataPost['action']) ? contrexx_input2raw($dataPost['action']) : ''; $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager(); $cacheManager->deleteSingleFile($pageId); if (!empty($pageArray)) { if (!empty($pageArray['target']) && !empty($pageArray['target_protocol'])) { $pageArray['target'] = $pageArray['target_protocol'] . $pageArray['target']; } elseif (empty($pageArray['target']) && !empty($pageArray['target_protocol'])) { $pageArray['target'] = ''; } $validatedPageArray = $this->validatePageArray($pageArray); } // UPDATE if (!empty($pageId)) { // If we got a page id, the page already exists and can be updated. $page = $this->pageRepo->find($pageId, 0, null, false); $node = $page->getNode(); // TRANSLATE } else { if (!empty($nodeId) && !empty($lang)) { // We are translating the page. $node = $this->nodeRepo->find($nodeId); $page = $node->translatePage(true, \FWLanguage::getLanguageIdByCode($lang)); $page->setNodeIdShadowed($node->getId()); $page->setEditingStatus(''); $newPage = true; $reload = true; // CREATE } else { if (empty($pageId) && !empty($lang)) { if (!\Permission::checkAccess(5, 'static', true)) { throw new \Exception($_CORELANG['TXT_CORE_CM_CREATION_DENIED']); } // Create a new node/page combination. $node = new \Cx\Core\ContentManager\Model\Entity\Node(); // CREATE WITHIN if (isset($dataPost['parent_node'])) { $parentNode = $this->nodeRepo->find($dataPost['parent_node']); if (!$parentNode) { $parentNode = $this->nodeRepo->getRoot(); } $node->setParent($parentNode); $parentNode->addChildren($node); // add parent node to ID, so the node containing the new page is opened if (!isset($_COOKIE['jstree_open'])) { $_COOKIE['jstree_open'] = ''; } $openNodes = explode(',', $_COOKIE['jstree_open']); if ($openNodes == array(0 => '')) { $openNodes = array(); } if (!in_array('#node_' . $parentNode->getId(), $openNodes)) { $openNodes[] = '#node_' . $parentNode->getId(); } setcookie('jstree_open', implode(',', $openNodes)); $this->em->persist($node); $this->em->flush(); // CREATE } else { $node->setParent($this->nodeRepo->getRoot()); $this->nodeRepo->getRoot()->addChildren($node); $this->em->persist($node); $this->em->flush(); } $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setNode($node); $node->addPage($page); $page->setNodeIdShadowed($node->getId()); $page->setLang(\FWLanguage::getLanguageIdByCode($lang)); $page->setUpdatedBy(\FWUser::getFWUserObject()->objUser->getUsername()); $newPage = true; $reload = true; } else { throw new \Exception('Page cannot be created. There are too little information.'); } } } // Page access check if ($page->isBackendProtected() && !\Permission::checkAccess($page->getBackendAccessId(), 'dynamic', true)) { throw new \Cx\Core\ContentManager\Model\Entity\PageException('Not allowed to read page'); } if (!empty($pageArray)) { $page->updateFromArray($validatedPageArray); if ($newPage) { // Make sure page has an ID $this->em->persist($page); $this->em->flush(); } } if (!empty($action)) { switch ($action) { case 'activate': case 'publish': $page->setActive(true); break; case 'deactivate': $page->setActive(false); break; case 'show': $page->setDisplay(true); break; case 'hide': $page->setDisplay(false); break; case 'protect': $page->setFrontendProtection(true); break; case 'unprotect': $page->setFrontendProtection(false); break; case 'lock': $page->setBackendProtection(true); break; case 'unlock': $page->setBackendProtection(false); break; } if ($action != 'publish' && !$page->isDraft()) { $action = 'publish'; } } $page->setUpdatedAtToNow(); $page->validate(); // Permissions are only updated in the editing mode. if (!empty($pageArray)) { if ($action == 'publish') { if (\Permission::checkAccess(36, 'static', true)) { if ($page->isFrontendProtected()) { // remove all \Permission::removeAccess($page->getFrontendAccessId(), 'dynamic'); if (isset($dataPost['frontendGroups'])) { // set new $pg->setAssignedGroupIds($page, $dataPost['frontendGroups'], true); } } if ($page->isBackendProtected()) { // remove all $groupIds = $pg->getAssignedGroupIds($page, false); \Permission::removeAccess($page->getBackendAccessId(), 'dynamic'); if (isset($dataPost['backendGroups'])) { // set new $pg->setAssignedGroupIds($page, $dataPost['backendGroups'], false); } if ($page->isBackendProtected() && !\Permission::checkAccess($page->getBackendAccessId(), 'dynamic', true)) { if (!count($groupIds)) { $page->setBackendProtection(false); } else { $pg->setAssignedGroupIds($page, $groupIds, false); } } } } } } // Block associations are only updated in the editing mode. if (!empty($pageArray) && empty($dataPost['ignoreBlocks'])) { if (!isset($dataPost['pageBlocks'])) { $dataPost['pageBlocks'] = array(); } $page->setRelatedBlocks($dataPost['pageBlocks']); } $draftUpdateLog = null; $liveUpdateLog = null; $updatingDraft = false; if ($action == 'publish' && \Permission::checkAccess(78, 'static', true)) { // User w/permission clicked save&publish. we should either publish the page or submit the draft for approval. if ($page->getEditingStatus() == 'hasDraftWaiting') { $reload = true; } if ($page->getEditingStatus() != '') { $logEntries = $this->logRepo->getLogEntries($page, false); $this->em->remove($logEntries[0]); } $page->setEditingStatus(''); $this->messages[] = $_CORELANG['TXT_CORE_SAVED']; } else { // User clicked save [as draft], so let's do that. $updatingDraft = $page->getEditingStatus() != '' ? true : false; if ($action == 'publish') { // User w/o publish permission clicked save&publish. submit it as a draft. $page->setEditingStatus('hasDraftWaiting'); $this->messages[] = $_CORELANG['TXT_CORE_DRAFT_SUBMITTED']; } else { if ($page->getEditingStatus() == 'hasDraftWaiting' && \Permission::checkAccess(78, 'static', true)) { $reload = true; } $page->setEditingStatus('hasDraft'); $this->messages[] = $_CORELANG['TXT_CORE_SAVED_AS_DRAFT']; } // Gedmo-loggable generates a LogEntry (i.e. revision) on persist, so we'll have to // store the draft first, then revert the current version to what it previously was. // In the end, we'll have the current [published] version properly stored as a page // and the draft version stored as a gedmo LogEntry. $this->em->persist($page); // Gedmo hooks in on persist/flush, so we unfortunately need to flush our em in // order to get a clean set of logEntries. $this->em->flush(); $logEntries = $this->logRepo->getLogEntries($page, false); // Revert to the published version. $cachedEditingStatus = $page->getEditingStatus(); $this->logRepo->revert($page, $logEntries[1]->getVersion()); $page->setEditingStatus($cachedEditingStatus); switch ($action) { case 'activate': case 'publish': $page->setActive(true); break; case 'deactivate': $page->setActive(false); break; case 'show': $page->setDisplay(true); break; case 'hide': $page->setDisplay(false); break; case 'protect': $page->setFrontendProtection(true); break; case 'unprotect': $page->setFrontendProtection(false); break; case 'lock': $page->setBackendProtection(true); break; case 'unlock': $page->setBackendProtection(false); break; } $this->em->persist($page); // Gedmo auto-logs slightly too much data. clean up unnecessary revisions: if ($updatingDraft) { $this->em->flush(); $logEntries = $this->logRepo->getLogEntries($page); $currentLog = $logEntries[1]; $currentLogData = $currentLog->getData(); $currentLogData['editingStatus'] = $page->getEditingStatus(); $currentLog->setData($currentLogData); $this->em->persist($currentLog); $liveUpdateLog = $logEntries[2]; $this->em->remove($logEntries[2]); } } $this->em->persist($page); if (isset($dataPost['inheritFrontendAccess']) && $dataPost['inheritFrontendAccess'] == 'on' || isset($dataPost['inheritBackendAccess']) && $dataPost['inheritBackendAccess'] == 'on' || isset($dataPost['inheritSkin']) && $dataPost['inheritSkin'] == 'on' || isset($dataPost['inheritCustomContent']) && $dataPost['inheritCustomContent'] == 'on' || isset($dataPost['inheritCssName']) && $dataPost['inheritCssName'] == 'on' || isset($dataPost['inheritCssNavName']) && $dataPost['inheritCssNavName'] == 'on' || isset($dataPost['inheritCaching']) && $dataPost['inheritCaching'] == 'on') { $pageStack = $page->getChildren(); while (count($pageStack)) { $currentPage = array_pop($pageStack); foreach ($currentPage->getChildren() as $child) { array_push($pageStack, $child); } if (isset($dataPost['inheritFrontendAccess']) && $dataPost['inheritFrontendAccess'] == 'on') { $reload = true; $page->copyProtection($currentPage, true); } if (isset($dataPost['inheritBackendAccess']) && $dataPost['inheritBackendAccess'] == 'on') { $reload = true; $page->copyProtection($currentPage, false); } if (isset($dataPost['inheritSkin']) && $dataPost['inheritSkin'] == 'on') { $currentPage->setSkin($page->getSkin()); } if (isset($dataPost['inheritCustomContent']) && $dataPost['inheritCustomContent'] == 'on') { $currentPage->setCustomContent($page->getCustomContent()); } if (isset($dataPost['inheritCssName']) && $dataPost['inheritCssName'] == 'on') { $currentPage->setCssName($page->getCssName()); } if (isset($dataPost['inheritCssNavName']) && $dataPost['inheritCssNavName'] == 'on') { $currentPage->setCssNavName($page->getCssNavName()); } if (isset($dataPost['inheritCaching']) && $dataPost['inheritCaching'] == 'on') { $currentPage->setCaching($page->getCaching()); } $this->em->persist($currentPage); } } $this->em->flush(); // bug fix #2279 // could not save alias after running $this->em->clear() // Aliases are only updated in the editing mode. if (!empty($pageArray)) { // Only users with publish rights can create aliases. if (\Permission::checkAccess(115, 'static', true) && \Permission::checkAccess(78, 'static', true)) { // Aliases are updated after persist. $data = array(); $data['alias'] = $pageArray['alias']; $aliases = $page->getAliases(); $page->updateFromArray($data); if ($aliases != $page->getAliases()) { $reload = true; } } else { // Users without permission shouldn't see the aliasses anyway //$this->messages[] = $_CORELANG['TXT_CORE_ALIAS_CREATION_DENIED']; } } // this fixes log version number skipping $this->em->clear(); $logs = $this->logRepo->getLogEntries($page); $this->em->persist($logs[0]); if ($updatingDraft) { $data = $logs[1]->getData(); if (!empty($action) && $draftUpdateLog) { $data = $draftUpdateLog->getData(); } $data['editingStatus'] = 'hasDraft'; if ($action == 'publish' && !\Permission::checkAccess(78, 'static', true)) { $data['editingStatus'] = 'hasDraftWaiting'; } switch ($action) { case 'activate': $data['active'] = true; break; case 'deactivate': $data['active'] = false; break; case 'show': $data['display'] = true; break; case 'hide': $data['display'] = false; break; case 'protect': $data['protection'] = $data['protection'] | FRONTEND_PROTECTION; break; case 'unprotect': $data['protection'] = $data['protection'] & ~FRONTEND_PROTECTION; break; case 'lock': $data['protection'] = $data['protection'] | BACKEND_PROTECTION; break; case 'unlock': $data['protection'] = $data['protection'] & ~BACKEND_PROTECTION; break; } $logs[1]->setData($data); if (!empty($action) && $action != 'publish') { $data = $logs[0]->getData(); if ($liveUpdateLog) { $data = $liveUpdateLog->getData(); } switch ($action) { case 'activate': $data['active'] = true; break; case 'deactivate': $data['active'] = false; break; case 'show': $data['display'] = true; break; case 'hide': $data['display'] = false; break; case 'protect': $data['protection'] = $data['protection'] | FRONTEND_PROTECTION; break; case 'unprotect': $data['protection'] = $data['protection'] & ~FRONTEND_PROTECTION; break; case 'lock': $data['protection'] = $data['protection'] | BACKEND_PROTECTION; break; case 'unlock': $data['protection'] = $data['protection'] & ~BACKEND_PROTECTION; break; } $logs[0]->setData($data); } $this->em->persist($logs[0]); $this->em->persist($logs[1]); $this->em->flush(); } // get version // if it is a draft, don't take the last one $version = $page->getVersion()->getVersion(); if ($page->isDraft()) { $version--; } return array('reload' => $reload, 'id' => $page->getId(), 'version' => $version, 'node' => $page->getNode()->getId(), 'lang' => \FWLanguage::getLanguageCodeById($page->getLang())); }
/** * Handles any kind of database errors * * Includes updating the payments table (I guess from version 1.2.0(?), * note that this is unconfirmed) to the current structure * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Payment // Fix the Text and Zones tables first \Text::errorHandler(); Zones::errorHandler(); \Yellowpay::errorHandler(); $table_name = DBPREFIX . 'module_shop_payment'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { // Migrate all Payment names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Payment names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Payment name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Update Payments that use obsolete PSPs: // - 05, 'Internal_CreditCard' // - 06, 'Internal_Debit', // Uses 04, Internal \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=4 WHERE `processor_id` IN (5, 6)"); // - 07, 'Saferpay_Mastercard_Multipay_CAR', // - 08, 'Saferpay_Visa_Multipay_CAR', // Uses 01, Saferpay \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=1 WHERE `processor_id` IN (7, 8)"); $table_name = DBPREFIX . 'module_shop_rel_payment'; $table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
/** * Handles database errors * * Also migrates old names to the new structure * @return boolean False. Always. * @static * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Shipment static $break = false; if ($break) { die("\n Shipment::errorHandler(): Recursion detected while handling an error.<br /><br />\n This should not happen. We are very sorry for the inconvenience.<br />\n Please contact customer support: helpdesk@comvation.com"); } $break = true; //die("Shipment::errorHandler(): Disabled!<br />"); // Fix the Zones table first Zones::errorHandler(); $table_name = DBPREFIX . 'module_shop_shipper'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_shipment_cost'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'cost'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'price_free')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always! return false; }
/** * Sanitize tree. * Translates all missing parent pages in the desired language * @param int $targetLang Language ID of the branch to sanitize * @return type */ public function setupPath($targetLang) { $node = $this->getNode()->getParent(); $pages = $node->getPagesByLang(); $sourceLang = $this->getLang(); if ($targetLang == $sourceLang) { $sourceLang = \FWLanguage::getDefaultLangId(); } if (!empty($pages) && !isset($pages[$targetLang])) { $page = $pages[$sourceLang]->copyToLang($targetLang, true, true, true, true, true, false, true); $page->setDisplay(false); \Env::get('em')->persist($page); // recursion return $pages[$sourceLang]->setupPath($targetLang); } else { return; } }
/** * Parsing the related News * * @global object $objDatabase * @global type $_ARRAYLANG * * @param Object $objTpl Template Object * @param Interger $newsId News Id * @param Interger $langId Language id * @param type $blockName Block Name * @param type $limit Limit * * @return null */ public function parseRelatedNews(\Cx\Core\Html\Sigma $objTpl, $newsId = null, $langId = null, $blockName = 'related_news', $limit = 0) { global $_ARRAYLANG, $objDatabase; if (empty($newsId) || !$objTpl->blockExists($blockName)) { return; } //Getting the related news ids $relatedNewsIds = $this->getRelatedNews($newsId); $defaultLangId = \FWLanguage::getDefaultLangId(); //Getting the related news details for the given languages $relatedNewsDetails = $this->getRelatedNewsDetails($relatedNewsIds, array($langId, $defaultLangId)); if (!empty($relatedNewsDetails)) { $defaultImage = \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/News/View/Media/default_news_image.png'; $currentCount = 1; foreach ($relatedNewsIds as $relatedNewsId) { //If the limit is reached then the loop is stopped if (!empty($limit) && $currentCount > $limit) { break; } /* * Checking the related news is available in the current * acitve front-end language if not available then the default * language details are getting used * Comment/Uncomment the following line if this condition * is required */ //$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) // ? $relatedNewsDetails[$relatedNewsId][$langId] // : $relatedNewsDetails[$relatedNewsId][$defaultLangId]; /* * Checking the related news is available in the current * acitve front-end language if not available then the related * News not listed Comment/Uncomment the following * line if this condition is required */ $currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) ? $relatedNewsDetails[$relatedNewsId][$langId] : false; if (!$currentRelatedDetails) { continue; } ++$currentCount; $categories = $this->getCategoriesByNewsId($relatedNewsId); $newsUrl = empty($currentRelatedDetails['redirect']) ? empty($currentRelatedDetails['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('news', $this->findCmdById('details', array_keys($categories)), FRONTEND_LANG_ID, array('newsid' => $relatedNewsId)) : $currentRelatedDetails['redirect']; $newstitle = $currentRelatedDetails['title']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]')); $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle)); // in case that the message is a stub, // we shall just display the news title instead of a html-a-tag // with no href target if (empty($htmlLinkTitle)) { $htmlLinkTitle = contrexx_raw2xhtml($newstitle); } $imagePath = !empty($currentRelatedDetails['teaser_image_path']) ? $currentRelatedDetails['teaser_image_path'] : $defaultImage; $imageThumbPath = !empty($currentRelatedDetails['teaser_image_thumbnail_path']) ? $currentRelatedDetails['teaser_image_thumbnail_path'] : $defaultImage; $this->parseImageBlock($objTpl, $imagePath, $newstitle, $newsUrl, 'related_news_image'); $this->parseImageBlock($objTpl, $imageThumbPath, $newstitle, $newsUrl, 'related_news_image_thumb'); $author = \FWUser::getParsedUserTitle($currentRelatedDetails['author_id'], $currentRelatedDetails['author']); $publisher = \FWUser::getParsedUserTitle($currentRelatedDetails['publisher_id'], $currentRelatedDetails['publisher']); $objSubResult = $objDatabase->Execute(' SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $relatedNewsId); $objTpl->setVariable(array('NEWS_RELATED_NEWS_ID' => contrexx_raw2xhtml($relatedNewsId), 'NEWS_RELATED_NEWS_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_RELATED_NEWS_LINK' => $htmlLink, 'NEWS_RELATED_NEWS_TITLE' => contrexx_raw2xhtml($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_SHORT' => strlen($currentRelatedDetails['title']) > 35 ? substr(strip_tags($currentRelatedDetails['title']), 0, 35) . '...' : strip_tags($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_LINK' => $htmlLinkTitle, 'NEWS_RELATED_NEWS_TEXT' => $currentRelatedDetails['text'], 'NEWS_RELATED_NEWS_TEXT_SHORT' => strlen($currentRelatedDetails['text']) > 250 ? substr(strip_tags($currentRelatedDetails['text']), 0, 247) . '...' : strip_tags($currentRelatedDetails['text']), 'NEWS_RELATED_NEWS_TEASER_TEXT' => nl2br($currentRelatedDetails['teaser_text']), 'NEWS_RELATED_NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_RELATED_NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_RELATED_NEWS_CATEGORY_NAMES' => implode(', ', contrexx_raw2xhtml($categories)), 'NEWS_RELATED_NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_COUNT_COMMENTS' => $currentRelatedDetails['commentactive'] && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : '')); if (!$objSubResult->fields['countComments'] || !$this->arrSettings['news_comments_activated']) { if ($objTpl->blockExists('related_news_comments_count')) { $objTpl->hideBlock('related_news_comments_count'); } } if ($this->arrSettings['news_use_teaser_text'] != '1' && $objTpl->blockExists('news_use_teaser_text')) { $objTpl->hideBlock('news_use_teaser_text'); } $objTpl->parse($blockName); } if ($objTpl->blockExists('related_news_block')) { $objTpl->setVariable('TXT_NEWS_RELATED_NEWS', $_ARRAYLANG['TXT_NEWS_RELATED_NEWS']); $objTpl->touchBlock('related_news_block'); } } }
/** * Select the prefered locale version of a message * @param array Array containing all localized versions of a message with its language code as index * @param string Preferend Language code * @return mixed Either the prefered message as string or NULL if $messages is empty */ private function getMessageInPreferedLanguage($messages, $langCode) { // check if a message is available if (empty($messages)) { return new Message(); } // return message in selected (=> current interface) language if (isset($messages[$langCode])) { return $messages[$langCode]; } // return message in default language if (isset($messages[\FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId())])) { return $messages[\FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId())]; } // return message in what ever language it is available reset($messages); return current($messages); }
/** * Do something after resolving is done * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page) { // TODO: Deactivated license check for now. Implement new behavior. return true; global $plainCmd, $objDatabase, $_CORELANG, $_LANGID, $section; $license = \Cx\Core_Modules\License\License::getCached(\Env::get('config'), $objDatabase); switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: if (!$license->isInLegalComponents('fulllanguage') && $_LANGID != \FWLanguage::getDefaultLangId()) { $_LANGID = \FWLanguage::getDefaultLangId(); \Env::get('Resolver')->redirectToCorrectLanguageDir(); } if (!empty($section) && !$license->isInLegalFrontendComponents($section)) { if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } else { //page not found, redirect to error page. \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error')); exit; } } break; case \Cx\Core\Core\Controller\Cx::MODE_BACKEND: // check if the requested module is active: if (!in_array($plainCmd, array('Login', 'noaccess', ''))) { $query = ' SELECT modules.is_licensed FROM ' . DBPREFIX . 'modules AS modules, ' . DBPREFIX . 'backend_areas AS areas WHERE areas.module_id = modules.id AND ( areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '&%" OR areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '" ) '; $res = $objDatabase->Execute($query); if (!$res->fields['is_licensed']) { $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home'; } } // If logged in if (\Env::get('cx')->getUser()->objUser->login(true)) { $license->check(); if ($license->getState() == \Cx\Core_Modules\License\License::LICENSE_NOK) { $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home'; $license->save($objDatabase); } $lc = \Cx\Core_Modules\License\LicenseCommunicator::getInstance(\Env::get('config')); $lc->addJsUpdateCode($_CORELANG, $license, $plainCmd == 'License'); } break; default: break; } }
/** * Add / Edit of the Event * * @param integer $eventId Event id * * @return null */ function modifyEvent($eventId) { global $objDatabase, $_ARRAYLANG, $_CORELANG, $_LANGID; $this->_objTpl->loadTemplateFile('module_calendar_modify_event.html'); \JS::registerJS("modules/{$this->moduleName}/View/Script/jquery.pagination.js"); \ContrexxJavascript::getInstance()->setVariable(array('language_id' => \FWLanguage::getDefaultLangId(), 'active_lang' => implode(',', \FWLanguage::getIdArray())), 'calendar'); $this->getSettings(); $this->getFrontendLanguages(); if (isset($_POST['submitModifyEvent']) || isset($_POST['save_and_publish'])) { $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(); if ($objEvent->save($_POST)) { $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_SUCCESSFULLY_SAVED']; if (isset($_POST['save_and_publish'])) { \Permission::checkAccess(180, 'static'); if ($objEvent->confirm()) { // do nothing } else { $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_EDITED']; } } $this->showOverview(); return; } else { $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_SAVED']; } if ($this->arrSettings['rssFeedStatus'] == 1) { $objFeedEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager(time(), null, null, null, true); $objFeed = new \Cx\Modules\Calendar\Controller\CalendarFeed($objFeedEventManager); $objFeed->creatFeed(); } } $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true); $objCategoryManager->getCategoryList(); $objFormManager = new \Cx\Modules\Calendar\Controller\CalendarFormManager(true); $objFormManager->getFormList(); $objMail = new \Cx\Modules\Calendar\Controller\CalendarMail(); $objMail->getTemplateList(); $copy = isset($_REQUEST['copy']) && !empty($_REQUEST['copy']); $this->_pageTitle = $copy || empty($eventId) ? $_ARRAYLANG['TXT_CALENDAR_INSERT_EVENT'] : $_ARRAYLANG['TXT_CALENDAR_EVENT'] . " " . $_ARRAYLANG['TXT_CALENDAR_EDIT']; if ($eventId != 0) { $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId); $objEvent->getData(); } //parse weekdays $arrWeekdays = array("1000000" => $_ARRAYLANG['TXT_CALENDAR_DAYS_MONDAY'], "0100000" => $_ARRAYLANG['TXT_CALENDAR_DAYS_TUESDAY'], "0010000" => $_ARRAYLANG['TXT_CALENDAR_DAYS_WEDNESDAY'], "0001000" => $_ARRAYLANG['TXT_CALENDAR_DAYS_THURSDAY'], "0000100" => $_ARRAYLANG['TXT_CALENDAR_DAYS_FRIDAY'], "0000010" => $_ARRAYLANG['TXT_CALENDAR_DAYS_SATURDAY'], "0000001" => $_ARRAYLANG['TXT_CALENDAR_DAYS_SUNDAY']); foreach ($arrWeekdays as $value => $name) { $selectedWeekday = $value == $objEvent->seriesData['seriesPatternWeekday'] ? 'selected="selected"' : ''; $weekdays .= '<option value="' . $value . '" ' . $selectedWeekday . '>' . $name . '</option>'; } //parse count $arrCount = array(1 => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_FIRST'], 2 => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_SECOND'], 3 => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_THIRD'], 4 => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_FOURTH'], 5 => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_LAST']); foreach ($arrCount as $value => $name) { $selectedCount = $value == $objEvent->seriesData['seriesPatternCount'] ? 'selected="selected"' : ''; $count .= '<option value="' . $value . '" ' . $selectedCount . '>' . $name . '</option>'; } if ($eventId) { $startDate = $objEvent->startDate; $endDate = $objEvent->endDate; } else { $startDate = new \DateTime(); $startMin = (int) $startDate->format('i'); // Adjust the time to next half hour if (!in_array($startMin, array(0, 30))) { $minAdj = 60 - $startMin > 30 ? 30 - $startMin : 60 - $startMin; $startDate->setTime($startDate->format('H'), $startDate->format('i') + $minAdj, 00); } $endDate = clone $startDate; $endDate->modify("+30 mins"); } $eventStartDate = $this->format2userDateTime($startDate); $eventEndDate = $this->format2userDateTime($endDate); //parse globals $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_TITLE' => $this->_pageTitle, 'TXT_' . $this->moduleLangVar . '_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT'], 'TXT_' . $this->moduleLangVar . '_SAVE' => $_ARRAYLANG['TXT_CALENDAR_SAVE'], 'TXT_' . $this->moduleLangVar . '_DELETE' => $_ARRAYLANG['TXT_CALENDAR_DELETE'], 'TXT_' . $this->moduleLangVar . '_CANCEL' => $_CORELANG['TXT_CANCEL'], 'TXT_' . $this->moduleLangVar . '_EXPAND' => $_ARRAYLANG['TXT_CALENDAR_EXPAND'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], 'TXT_' . $this->moduleLangVar . '_EVENT_DETAILS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DETAILS'], 'TXT_' . $this->moduleLangVar . '_EVENT_INVITE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_INVITE'], 'TXT_' . $this->moduleLangVar . '_EVENT_SERIES' => $_ARRAYLANG['TXT_CALENDAR_EVENT_SERIES'], 'TXT_' . $this->moduleLangVar . '_EVENT_SERIES_TYPE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_SERIES_TYPE'], 'TXT_' . $this->moduleLangVar . '_EVENT_SERIES_PATTERN' => $_ARRAYLANG['TXT_CALENDAR_EVENT_SERIES_PATTERN'], 'TXT_' . $this->moduleLangVar . '_EVENT_SERIES_EXCEPTIONS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_SERIES_EXCEPTIONS'], 'TXT_' . $this->moduleLangVar . '_EVENT_PUBLICATE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PUBLICATE'], 'TXT_' . $this->moduleLangVar . '_YES' => $_ARRAYLANG['TXT_CALENDAR_YES'], 'TXT_' . $this->moduleLangVar . '_NEXT' => $_ARRAYLANG['TXT_CALENDAR_NEXT'], 'TXT_' . $this->moduleLangVar . '_BACK' => $_ARRAYLANG['TXT_CALENDAR_STEP_BACK'], 'TXT_' . $this->moduleLangVar . '_EVENT_PRIORITY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PRIORITY'], 'TXT_' . $this->moduleLangVar . '_EVENT_START' => $_ARRAYLANG['TXT_CALENDAR_EVENT_START'], 'TXT_' . $this->moduleLangVar . '_EVENT_END' => $_ARRAYLANG['TXT_CALENDAR_EVENT_END'], 'TXT_' . $this->moduleLangVar . '_EVENT_ACCESS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS'], 'TXT_' . $this->moduleLangVar . '_EVENT_WHOLE_DAY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_WHOLE_DAY'], 'TXT_' . $this->moduleLangVar . '_BROWSE' => $_ARRAYLANG['TXT_CALENDAR_BROWSE'], 'TXT_' . $this->moduleLangVar . '_ACTIVATE' => $_ARRAYLANG['TXT_CALENDAR_ACTIVATE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PRICE' => $_ARRAYLANG['TXT_CALENDAR_PRICE'], 'TXT_' . $this->moduleLangVar . '_EVENT_LINK' => $_ARRAYLANG['TXT_CALENDAR_EVENT_LINK'], 'TXT_' . $this->moduleLangVar . '_EVENT_PICTURE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PICTURE'], 'TXT_' . $this->moduleLangVar . '_EVENT_ATTACHMENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ATTACHMENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CATEGORY'], 'TXT_' . $this->moduleLangVar . '_COMMUNITY_GROUPS' => $_ARRAYLANG['TXT_CALENDAR_COMMUNITY_GROUPS'], 'TXT_' . $this->moduleLangVar . '_PLEASE_CHECK_INPUT' => $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHECK_INPUT'], 'TXT_' . $this->moduleLangVar . '_EVENT_MORE_INVITATIONS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_MORE_INVITATIONS'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_REGISTRATION'], 'TXT_' . $this->moduleLangVar . '_EVENT_NUM_SUBSCRIBER' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NUM_SUBSCRIBER'], 'TXT_' . $this->moduleLangVar . '_EVENT_NOTIFICATION_TO' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NOTIFICATION_TO'], 'TXT_' . $this->moduleLangVar . '_EVENT_EMAIL_TEMPLATE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_EMAIL_TEMPLATE'], 'TXT_' . $this->moduleLangVar . '_EVENT_TICKET_SALES' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TICKET_SALES'], 'TXT_' . $this->moduleLangVar . '_EVENT_NUM_SEATING' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NUM_SEATING'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_DURANCE' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_DURANCE'], 'TXT_' . $this->moduleLangVar . '_SERIES_ACTIVATE' => $_ARRAYLANG['TXT_CALENDAR_SERIES_ACTIVATE'], 'TXT_' . $this->moduleLangVar . '_SERIES' => $_ARRAYLANG['TXT_CALENDAR_SERIES'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_DAILY' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_DAILY'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_WEEKLY'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_MONTHLY'], 'TXT_' . $this->moduleLangVar . '_DAYS' => $_ARRAYLANG['TXT_CALENDAR_DAYS'], 'TXT_' . $this->moduleLangVar . '_DAYS_DAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_DAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_MONDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_MONDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_TUESDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_TUESDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_WEDNESDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_WEDNESDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_THURSDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_THURSDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_FRIDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_FRIDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_SATURDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_SATURDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_SUNDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_SUNDAY'], 'TXT_' . $this->moduleLangVar . '_DAYS_WORKDAY' => $_ARRAYLANG['TXT_CALENDAR_DAYS_WORKDAY'], 'TXT_' . $this->moduleLangVar . '_AT' => $_ARRAYLANG['TXT_CALENDAR_AT'], 'TXT_' . $this->moduleLangVar . '_EVERY_1' => $_ARRAYLANG['TXT_CALENDAR_EVERY_1'], 'TXT_' . $this->moduleLangVar . '_ALL' => $_ARRAYLANG['TXT_CALENDAR_ALL'], 'TXT_' . $this->moduleLangVar . '_EVERY_2' => $_ARRAYLANG['TXT_CALENDAR_EVERY_2'], 'TXT_' . $this->moduleLangVar . '_WEEKS' => $_ARRAYLANG['TXT_CALENDAR_WEEKS'], 'TXT_' . $this->moduleLangVar . '_MONTHS' => $_ARRAYLANG['TXT_CALENDAR_MONTHS'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_BEGINS' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_BEGINS'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_NO_ENDDATE' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_NO_ENDDATE'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_ENDS_AFTER' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_ENDS_AFTER'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_APPONTMENTS' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_APPONTMENTS'], 'TXT_' . $this->moduleLangVar . '_SERIES_PATTERN_ENDS' => $_ARRAYLANG['TXT_CALENDAR_SERIES_PATTERN_ENDS'], 'TXT_' . $this->moduleLangVar . '_EVENT_SEND_INVITATION' => $objEvent->invitationSent == 0 ? $_ARRAYLANG['TXT_CALENDAR_EVENT_SEND_INVITATION'] : $_ARRAYLANG['TXT_CALENDAR_EVENT_SEND_AGAIN_INVITATION'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_EVENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION_FORM' => $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_FORM'], 'TXT_' . $this->moduleLangVar . '_EVENT_MORE_INVITATIONS_INFO' => $_ARRAYLANG['TXT_CALENDAR_EVENT_MORE_INVITATIONS_INFO'], 'TXT_' . $this->moduleLangVar . '_REGISTRATIONS_SUBSCRIBER_INFO' => $_ARRAYLANG['TXT_CALENDAR_REGISTRATIONS_SUBSCRIBER_INFO'], 'TXT_' . $this->moduleLangVar . '_EVENT_NOTIFICATION_TO_INFO' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NOTIFICATION_TO_INFO'], 'TXT_' . $this->moduleLangVar . '_EVENT_EMAIL_TEMPLATE_INFO' => $_ARRAYLANG['TXT_CALENDAR_EVENT_EMAIL_TEMPLATE_INFO'], 'TXT_' . $this->moduleLangVar . '_EVENT_NUM_SEATING_INFO' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NUM_SEATING_INFO'], 'TXT_' . $this->moduleLangVar . '_SHOW_START_DATE' => $_ARRAYLANG['TXT_CALENDAR_SHOW_START_DATE'], 'TXT_' . $this->moduleLangVar . '_SHOW_END_DATE' => $_ARRAYLANG['TXT_CALENDAR_SHOW_END_DATE'], 'TXT_' . $this->moduleLangVar . '_SHOW_TIME_TYPE' => $_ARRAYLANG['TXT_CALENDAR_SHOW_TIME_TYPE'], 'TXT_' . $this->moduleLangVar . '_SHOW_START_TIME' => $_ARRAYLANG['TXT_CALENDAR_SHOW_START_TIME'], 'TXT_' . $this->moduleLangVar . '_SHOW_END_TIME' => $_ARRAYLANG['TXT_CALENDAR_SHOW_END_TIME'], 'TXT_' . $this->moduleLangVar . '_LIST' => $_ARRAYLANG['TXT_CALENDAR_LIST'], 'TXT_' . $this->moduleLangVar . '_DETAIL' => $_ARRAYLANG['TXT_CALENDAR_DETAIL'], 'TXT_' . $this->moduleLangVar . '_BASIC_DATA' => $_ARRAYLANG['TXT_CALENDAR_BASIC_DATA'], 'TXT_' . $this->moduleLangVar . '_LANGUAGE' => $_ARRAYLANG['TXT_CALENDAR_LANG'], 'TXT_' . $this->moduleLangVar . '_ADDITIONAL_OPTIONS' => $_ARRAYLANG['TXT_CALENDAR_ADDITIONAL_OPTIONS'], 'TXT_' . $this->moduleLangVar . '_EVENT_LOCATION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_LOCATION'], 'TXT_' . $this->moduleLangVar . '_EVENT_ALL_DAY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ALL_DAY'], 'TXT_' . $this->moduleLangVar . '_EVENT_NAME' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NAME'], 'TXT_' . $this->moduleLangVar . '_EVENT_HOST' => $_ARRAYLANG['TXT_CALENDAR_EVENT_HOST'], 'TXT_' . $this->moduleLangVar . '_EVENT_EMAIL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_EMAIL'], 'TXT_' . $this->moduleLangVar . '_SELECT_EXCEPTION_DATE_INFO' => $_ARRAYLANG['TXT_CALENDAR_SELECT_EXCEPTION_DATE_INFO'], 'TXT_' . $this->moduleLangVar . '_OK' => $_ARRAYLANG['TXT_CALENDAR_OK'], 'TXT_' . $this->moduleLangVar . '_CANCEL' => $_ARRAYLANG['TXT_CALENDAR_CANCEL'], 'TXT_' . $this->moduleLangVar . '_MANAGE' => $_ARRAYLANG['TXT_CALENDAR_MANAGE'], 'TXT_' . $this->moduleLangVar . '_EVENT_SHOW_IN' => $_ARRAYLANG['TXT_CALENDAR_EVENT_SHOW_IN'], 'TXT_' . $this->moduleLangVar . '_EVENT_TITLE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TITLE'], 'TXT_' . $this->moduleLangVar . '_EVENT_TEASER' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TEASER'], 'TXT_' . $this->moduleLangVar . '_EVENT_PLACE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PLACE'], 'TXT_' . $this->moduleLangVar . '_EVENT_STREET' => $_ARRAYLANG['TXT_CALENDAR_EVENT_STREET'], 'TXT_' . $this->moduleLangVar . '_EVENT_ZIP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ZIP'], 'TXT_' . $this->moduleLangVar . '_EVENT_CITY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_CITY'], 'TXT_' . $this->moduleLangVar . '_EVENT_COUNTRY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_COUNTRY'], 'TXT_' . $this->moduleLangVar . '_EVENT_WEBSITE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_WEBSITE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PHONE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PHONE'], 'TXT_' . $this->moduleLangVar . '_EVENT_MAP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_MAP'], 'TXT_' . $this->moduleLangVar . '_EVENT_USE_GOOGLEMAPS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_USE_GOOGLEMAPS'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_DEFAULT' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_DEFAULT'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_FROM_MEDIADIR' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_FROM_MEDIADIR'], 'TXT_' . $this->moduleLangVar . '_PREV' => $_ARRAYLANG['TXT_CALENDAR_PREV'], 'TXT_' . $this->moduleLangVar . '_NEXT' => $_ARRAYLANG['TXT_CALENDAR_NEXT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DETAIL_VIEW' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DETAIL_VIEW'], 'TXT_' . $this->moduleLangVar . '_EVENT_DETAIL_VIEW_LABEL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DETAIL_VIEW_LABEL'], 'TXT_' . $this->moduleLangVar . '_EVENT_TREAT_AS_INDEPENDENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TREAT_AS_INDEPENDENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION_NONE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_REGISTRATION_NONE'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION_INTERNAL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_REGISTRATION_INTERNAL'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION_EXTERNAL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_REGISTRATION_EXTERNAL'], 'TXT_' . $this->moduleLangVar . '_EVENT_REGISTRATION_FULL_BOOKED' => $_ARRAYLANG['TXT_CALENDAR_EVENT_REGISTRATION_FULL_BOOKED'], 'TXT_' . $this->moduleLangVar . '_MORE' => $_ARRAYLANG['TXT_CALENDAR_MORE'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], $this->moduleLangVar . '_EVENT_REDIRECT_BROWSE_BUTTON' => self::showMediaBrowserButton('eventRedirect', 'sitestructure'), $this->moduleLangVar . '_EVENT_PICTURE_BROWSE_BUTTON' => self::showMediaBrowserButton('eventPicture'), $this->moduleLangVar . '_EVENT_ATTACHMENT_BROWSE_BUTTON' => self::showMediaBrowserButton('eventAttachment'), $this->moduleLangVar . '_PLACE_MAP_SOURCE_BROWSE_BUTTON' => self::showMediaBrowserButton('inputPlaceMap'), $this->moduleLangVar . '_EVENT_ID' => $eventId, $this->moduleLangVar . '_EVENT_DEFAULT_LANG_ID' => $_LANGID, $this->moduleLangVar . '_EVENT_DATE_FORMAT' => $this->getDateFormat(1), $this->moduleLangVar . '_EVENT_CURRENCY' => $this->arrSettings['paymentCurrency'], $this->moduleLangVar . '_EVENT_CATEGORIES' => $objCategoryManager->getCategoryDropdown(intval($objEvent->catId), 2), $this->moduleLangVar . '_EVENT_SERIES_PATTERN_MONTHLY_COUNT' => $count, $this->moduleLangVar . '_EVENT_SERIES_PATTERN_MONTHLY_WEEKDAY' => $weekdays, $this->moduleLangVar . '_EVENT_REGISTRATION_FORMS' => $objFormManager->getFormDorpdown(intval($objEvent->registrationForm)), $this->moduleLangVar . '_EVENT_SHOW_DETAIL_VIEW' => $eventId != 0 ? $objEvent->showDetailView == 1 ? 'checked="checked"' : '' : 'checked="checked"', $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $eventId != 0 ? $objEvent->type == 0 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $eventId != 0 ? $objEvent->type == 1 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_START_DATE' => $eventStartDate, $this->moduleLangVar . '_EVENT_END_DATE' => $eventEndDate, $this->moduleLangVar . '_EVENT_PRICE' => $eventId != 0 ? $objEvent->price : '', $this->moduleLangVar . '_EVENT_LINK' => $eventId != 0 ? $objEvent->link : '', $this->moduleLangVar . '_EVENT_PICTURE' => $eventId != 0 ? $objEvent->pic : '', $this->moduleLangVar . '_EVENT_ATTACHMENT' => $eventId != 0 ? $objEvent->attach : '', $this->moduleLangVar . '_EVENT_MORE_INVITATIONS' => $eventId != 0 ? $objEvent->invitedMails : '', $this->moduleLangVar . '_EVENT_NUM_SUBSCRIBER' => $eventId != 0 ? $objEvent->numSubscriber : '', $this->moduleLangVar . '_EVENT_NOTIFICATION_TO' => $eventId != 0 ? $objEvent->notificationTo : '', $this->moduleLangVar . '_EVENT_TICKET_SALES' => $eventId != 0 ? $objEvent->ticketSales ? 'checked="checked"' : '' : '', $this->moduleLangVar . '_EVENT_NUM_SEATING' => $eventId != 0 ? $objEvent->numSeating : '', $this->moduleLangVar . '_EVENT_ALL_DAY' => $eventId != 0 && $objEvent->all_day ? 'checked="checked"' : '', $this->moduleLangVar . '_HIDE_ON_SINGLE_LANG' => count($this->arrFrontendLanguages) == 1 ? "display: none;" : "", $this->moduleLangVar . '_LOCATION_TYPE' => $this->arrSettings['placeData'] == 3 ? $eventId != 0 ? $objEvent->locationType : 1 : $this->arrSettings['placeData'], $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MANUAL' => $eventId != 0 ? $objEvent->locationType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->locationType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_PLACE' => $eventId != 0 ? $objEvent->place : '', $this->moduleLangVar . '_EVENT_STREET' => $eventId != 0 ? $objEvent->place_street : '', $this->moduleLangVar . '_EVENT_ZIP' => $eventId != 0 ? $objEvent->place_zip : '', $this->moduleLangVar . '_EVENT_CITY' => $eventId != 0 ? $objEvent->place_city : '', $this->moduleLangVar . '_EVENT_COUNTRY' => $eventId != 0 ? $objEvent->place_country : '', $this->moduleLangVar . '_EVENT_PLACE_WEBSITE' => $eventId != 0 ? $objEvent->place_website : '', $this->moduleLangVar . '_EVENT_PLACE_LINK' => $eventId != 0 ? $objEvent->place_link : '', $this->moduleLangVar . '_EVENT_PLACE_PHONE' => $eventId != 0 ? $objEvent->place_phone : '', $this->moduleLangVar . '_PLACE_MAP_SOURCE' => $eventId != 0 ? $objEvent->place_map : '', $this->moduleLangVar . '_EVENT_MAP' => $objEvent->google == 1 ? 'checked="checked"' : '', $this->moduleLangVar . '_EVENT_HOST_TYPE' => $this->arrSettings['placeDataHost'] == 3 ? $eventId != 0 ? $objEvent->hostType : 1 : $this->arrSettings['placeDataHost'], $this->moduleLangVar . '_EVENT_HOST' => $eventId != 0 ? $objEvent->org_name : '', $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $eventId != 0 ? $objEvent->org_street : '', $this->moduleLangVar . '_EVENT_HOST_ZIP' => $eventId != 0 ? $objEvent->org_zip : '', $this->moduleLangVar . '_EVENT_HOST_CITY' => $eventId != 0 ? $objEvent->org_city : '', $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $eventId != 0 ? $objEvent->org_country : '', $this->moduleLangVar . '_EVENT_HOST_WEBSITE' => $eventId != 0 ? $objEvent->org_website : '', $this->moduleLangVar . '_EVENT_HOST_LINK' => $eventId != 0 ? $objEvent->org_link : '', $this->moduleLangVar . '_EVENT_HOST_PHONE' => $eventId != 0 ? $objEvent->org_phone : '', $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $eventId != 0 ? $objEvent->org_email : '', $this->moduleLangVar . '_EVENT_HOST_TYPE_MANUAL' => $eventId != 0 ? $objEvent->hostType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_HOST_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->hostType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_COPY' => $copy ? 1 : 0, $this->moduleLangVar . '_EVENT_REGISTRATION_NONE_SELECTED' => !empty($eventId) ? $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_NONE ? 'selected="selected"' : '' : 'selected="selected"', $this->moduleLangVar . '_EVENT_REGISTRATION_INTERNAL_SELECTED' => !empty($eventId) && $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL ? 'selected="selected"' : '', $this->moduleLangVar . '_EVENT_REGISTRATION_EXTERNAL_SELECTED' => !empty($eventId) && $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL ? 'selected="selected"' : '', $this->moduleLangVar . '_EVENT_REGISTRATION_EXTERNAL_LINK' => !empty($eventId) ? $objEvent->registrationExternalLink : '', $this->moduleLangVar . '_EVENT_REGISTRATION_EXTERNAL_FULL_BOOKED' => !empty($eventId) ? $objEvent->registrationExternalFullyBooked ? 'checked="checked"' : '' : '')); // parse invitation E-mail template foreach ($this->arrFrontendLanguages as $language) { $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_INVITATION_EMAIL_LANG' => \Html::getLanguageIcon($language['id'], 'active', 'javascript:void()'), $this->moduleLangVar . '_EVENT_INVITATION_EMAIL_LANG_ID' => (int) $language['id'], $this->moduleLangVar . '_EVENT_INVITATION_EMAIL_TEMPLATE' => $objMail->getTemplateDropdown(intval($objEvent->invitationTemplate[$language['id']]), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_INVITATION, $language['id']))); $this->_objTpl->parse('invitation_email_template'); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_REGISTRATION_EMAIL_LANG' => \Html::getLanguageIcon($language['id'], 'active', 'javascript:void()'), $this->moduleLangVar . '_EVENT_REGISTRATION_EMAIL_LANG_ID' => (int) $language['id'], $this->moduleLangVar . '_EVENT_REGISTRATION_EMAIL_TEMPLATE' => $objMail->getTemplateDropdown(intval($objEvent->emailTemplate[$language['id']]), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_CONFIRM_REG, $language['id']))); $this->_objTpl->parse('registration_email_template'); } //parse access for ($i = 0; $i < 2; $i++) { $selectedAccess = $eventId == 0 && $i == 0 ? 'selected="selected"' : $objEvent->access == $i ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ACCESS' => $i, $this->moduleLangVar . '_EVENT_ACCESS_SELECT' => $selectedAccess, $this->moduleLangVar . '_EVENT_ACCESS_NAME' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS_' . $i])); $this->_objTpl->parse('eventAccess'); } //parse priority for ($i = 1; $i <= 5; $i++) { $selectedPriority = $eventId == 0 && $i == 3 ? 'selected="selected"' : $objEvent->priority == $i ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PRIORITY' => $i, $this->moduleLangVar . '_EVENT_PRIORITY_SELECT' => $selectedPriority, $this->moduleLangVar . '_EVENT_PRIORITY_NAME' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PRIORITY_' . $i])); $this->_objTpl->parse('eventPriority'); } //parse timetypes if ($eventId != 0) { // list view $showStartDateList = $objEvent->showStartDateList; $showEndDateList = $objEvent->showEndDateList; $showStartTimeList = $objEvent->showStartTimeList; $showEndTimeList = $objEvent->showEndTimeList; $showTimeTypeList = $objEvent->showTimeTypeList; // detail view $showStartDateDetail = $objEvent->showStartDateDetail; $showEndDateDetail = $objEvent->showEndDateDetail; $showStartTimeDetail = $objEvent->showStartTimeDetail; $showEndTimeDetail = $objEvent->showEndTimeDetail; $showTimeTypeDetail = $objEvent->showTimeTypeDetail; } else { // list view $showStartDateList = $this->arrSettings['showStartDateList'] == 1; $showEndDateList = $this->arrSettings['showEndDateList'] == 1; $showStartTimeList = $this->arrSettings['showStartTimeList'] == 1; $showEndTimeList = $this->arrSettings['showEndTimeList'] == 1; // check if start- or endtime is selected in settings to set type "show time" by default if (!$_POST['showTimeTypeList'] && ($showStartTimeList == 1 || $showEndTimeList == 1)) { $showTimeTypeList = 1; } else { $showTimeTypeList = $_POST['showTimeTypeList']; } // detail view $showStartDateDetail = $this->arrSettings['showStartDateDetail'] == 1; $showEndDateDetail = $this->arrSettings['showEndDateDetail'] == 1; $showStartTimeDetail = $this->arrSettings['showStartTimeDetail'] == 1; $showEndTimeDetail = $this->arrSettings['showEndTimeDetail'] == 1; // check if start- or endtime is selected in settings to set type "show time" by default if (!$_POST['showTimeTypeDetail'] && ($showStartTimeDetail == 1 || $showEndTimeDetail == 1)) { $showTimeTypeDetail = 1; } else { $showTimeTypeDetail = $_POST['showTimeTypeDetail']; } } //time type dropdown for list $c = 0; $arrListOptions = array($_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_NOTHING'], $_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_TIME'], $_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_FULLTIME']); $strTimeTypeListDropdown = '<select id="showTimeTypeList" name="showTimeTypeList" onchange="showTimeListSelection();" >'; foreach ($arrListOptions as $key => $option) { $c == $showTimeTypeList ? $selected = 'selected="selected"' : ($selected = ''); $strTimeTypeListDropdown .= '<option value="' . $c . '" ' . $selected . ' >' . $arrListOptions[$c] . '</option>'; $c++; } $strTimeTypeListDropdown .= '</select>'; //time type dropdown for detail $c = 0; $arrDetailOptions = array($_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_NOTHING'], $_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_TIME'], $_ARRAYLANG['TXT_CALENDAR_TIME_TYPE_FULLTIME']); $strTimeTypeDetailDropdown = '<select id="showTimeTypeDetail" name="showTimeTypeDetail" onchange="showTimeDetailSelection();" >'; foreach ($arrDetailOptions as $key => $option) { $c == $showTimeTypeDetail ? $selected = 'selected="selected"' : ($selected = ''); $strTimeTypeDetailDropdown .= '<option value="' . $c . '" ' . $selected . ' >' . $arrDetailOptions[$c] . '</option>'; $c++; } $strTimeTypeDetailDropdown .= '</select>'; //time type placeholders $this->_objTpl->setVariable(array($this->moduleLangVar . '_USE_CUSTOM_DATE_DISPLAY' => $objEvent->useCustomDateDisplay ? 'checked="checked"' : '', $this->moduleLangVar . '_START_DATE_CHECKED_LIST' => $showStartDateList ? 'checked="checked"' : '', $this->moduleLangVar . '_START_DATE_VALUE_LIST' => 1, $this->moduleLangVar . '_END_DATE_CHECKED_LIST' => $showEndDateList ? 'checked="checked"' : '', $this->moduleLangVar . '_END_DATE_VALUE_LIST' => 1, $this->moduleLangVar . '_SHOW_TIME_TYPE_DROPDOWN_LIST' => $strTimeTypeListDropdown, $this->moduleLangVar . '_START_TIME_CHECKED_LIST' => $showStartTimeList ? 'checked="checked"' : '', $this->moduleLangVar . '_START_TIME_VALUE_LIST' => 1, $this->moduleLangVar . '_END_TIME_CHECKED_LIST' => $showEndTimeList ? 'checked="checked"' : '', $this->moduleLangVar . '_END_TIME_VALUE_LIST' => 1, $this->moduleLangVar . '_START_DATE_CHECKED_DETAIL' => $showStartDateDetail ? 'checked="checked"' : '', $this->moduleLangVar . '_START_DATE_VALUE_DETAIL' => 1, $this->moduleLangVar . '_END_DATE_CHECKED_DETAIL' => $showEndDateDetail ? 'checked="checked"' : '', $this->moduleLangVar . '_END_DATE_VALUE_DETAIL' => 1, $this->moduleLangVar . '_SHOW_TIME_TYPE_DROPDOWN_DETAIL' => $strTimeTypeDetailDropdown, $this->moduleLangVar . '_START_TIME_CHECKED_DETAIL' => $showStartTimeDetail ? 'checked="checked"' : '', $this->moduleLangVar . '_START_TIME_VALUE_DETAIL' => 1, $this->moduleLangVar . '_END_TIME_CHECKED_DETAIL' => $showEndTimeDetail ? 'checked="checked"' : '', $this->moduleLangVar . '_END_TIME_VALUE_DETAIL' => 1)); //parse series $lastExeptionId = 4; $seriesStatus = $objEvent->seriesStatus == 1 ? 'checked="checked"' : ''; $seriesIndependent = empty($eventId) || $objEvent->independentSeries == 1 ? 'checked="checked"' : ''; $seriesPatternDailyDays = 1; $seriesPatternWeeklyWeeks = 1; $seriesPatternMonthlyDay = 1; $seriesPatternMonthl1 = 1; $seriesPatternMonthl2 = 1; $seriesPatternEndsEvents = 5; if ($eventId != 0 && $objEvent->seriesStatus == 1) { $seriesPatternDaily = $objEvent->seriesData['seriesType'] == 1 ? 'selected="selected"' : ''; $seriesPatternWeekly = $objEvent->seriesData['seriesType'] == 2 ? 'selected="selected"' : ''; $seriesPatternMonthly = $objEvent->seriesData['seriesType'] == 3 ? 'selected="selected"' : ''; //daily if ($objEvent->seriesData['seriesType'] == 1) { $seriesPatternDaily1 = $objEvent->seriesData['seriesPatternType'] == 1 ? 'checked="checked"' : ''; $seriesPatternDaily2 = $objEvent->seriesData['seriesPatternType'] == 2 ? 'checked="checked"' : ''; $seriesPatternDailyDays = $objEvent->seriesData['seriesPatternType'] == 1 ? $objEvent->seriesData['seriesPatternDay'] : 1; } //weekly if ($objEvent->seriesData['seriesType'] == 2) { $seriesPatternWeeklyWeeks = $objEvent->seriesData['seriesPatternWeek']; $seriesPatternWeeklyMon = substr($objEvent->seriesData['seriesPatternWeekday'], 0, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklyTue = substr($objEvent->seriesData['seriesPatternWeekday'], 1, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklyWed = substr($objEvent->seriesData['seriesPatternWeekday'], 2, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklyThu = substr($objEvent->seriesData['seriesPatternWeekday'], 3, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklyFri = substr($objEvent->seriesData['seriesPatternWeekday'], 4, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklySat = substr($objEvent->seriesData['seriesPatternWeekday'], 5, 1) == 1 ? 'checked="checked"' : ''; $seriesPatternWeeklySun = substr($objEvent->seriesData['seriesPatternWeekday'], 6, 1) == 1 ? 'checked="checked"' : ''; } //monthly if ($objEvent->seriesData['seriesType'] == 3) { $seriesPatternMonthly1 = $objEvent->seriesData['seriesPatternType'] == 1 ? 'checked="checked"' : ''; $seriesPatternMonthly2 = $objEvent->seriesData['seriesPatternType'] == 2 ? 'checked="checked"' : ''; if ($objEvent->seriesData['seriesPatternType'] == 1) { $seriesPatternMonthlyDay = $objEvent->seriesData['seriesPatternDay']; $seriesPatternMonthl1 = $objEvent->seriesData['seriesPatternMonth']; } if ($objEvent->seriesData['seriesPatternType'] == 2) { $seriesPatternMonthl2 = $objEvent->seriesData['seriesPatternMonth']; } } //douration $seriesPatternDourance1 = $objEvent->seriesData['seriesPatternDouranceType'] == 1 ? 'checked="checked"' : ''; $seriesPatternDourance2 = $objEvent->seriesData['seriesPatternDouranceType'] == 2 ? 'checked="checked"' : ''; $seriesPatternDourance3 = $objEvent->seriesData['seriesPatternDouranceType'] == 3 ? 'checked="checked"' : ''; $seriesPatternEndsEvents = $objEvent->seriesData['seriesPatternDouranceType'] == 2 ? $objEvent->seriesData['seriesPatternEnd'] : 5; $seriesPatternEndsDate = $objEvent->seriesData['seriesPatternDouranceType'] == 3 ? $this->format2userDate($objEvent->seriesData['seriesPatternEndDate']) : ''; foreach ($objEvent->seriesData['seriesPatternExceptions'] as $key => $seriesExceptionDate) { if ($seriesExceptionDate != null) { $this->_objTpl->setVariable(array($this->moduleLangVar . '_SERIES_EXEPTION_DATE' => $this->format2userDate($seriesExceptionDate))); $this->_objTpl->parse('eventExeptions'); } } } else { $seriesPatternDaily = 'checked="checked"'; $seriesPatternDaily1 = 'checked="checked"'; $seriesPatternMonthly1 = 'checked="checked"'; $seriesPatternDourance1 = 'checked="checked"'; $this->_objTpl->hideBlock('eventExeptions'); } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_SERIES_STATUS' => $seriesStatus, $this->moduleLangVar . '_EVENT_SERIES_INDEPENDENT' => $seriesIndependent, $this->moduleLangVar . '_SERIES_PATTERN_DAILY' => $seriesPatternDaily, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY' => $seriesPatternWeekly, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY' => $seriesPatternMonthly, $this->moduleLangVar . '_SERIES_PATTERN_DAILY_1' => $seriesPatternDaily1, $this->moduleLangVar . '_SERIES_PATTERN_DAILY_2' => $seriesPatternDaily2, $this->moduleLangVar . '_SERIES_PATTERN_DAILY_DAYS' => $seriesPatternDailyDays, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY_1' => $seriesPatternMonthly1, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY_DAY' => $seriesPatternMonthlyDay, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY_MONTH_1' => $seriesPatternMonthl1, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY_MONTH_2' => $seriesPatternMonthl2, $this->moduleLangVar . '_SERIES_PATTERN_MONTHLY_2' => $seriesPatternMonthly2, $this->moduleLangVar . '_SERIES_PATTERN_DOURANCE_1' => $seriesPatternDourance1, $this->moduleLangVar . '_SERIES_PATTERN_DOURANCE_2' => $seriesPatternDourance2, $this->moduleLangVar . '_SERIES_PATTERN_DOURANCE_3' => $seriesPatternDourance3, $this->moduleLangVar . '_SERIES_PATTERN_ENDS_EVENTS' => $seriesPatternEndsEvents, $this->moduleLangVar . '_SERIES_PATTERN_ENDS_DATE' => $seriesPatternEndsDate, $this->moduleLangVar . '_SERIES_PATTERN_ENDS_INPUT_ID' => $seriesPatternEndsInputId, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_WEEKS' => $seriesPatternWeeklyWeeks, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_MONDAY' => $seriesPatternWeeklyMon, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_TUESDAY' => $seriesPatternWeeklyTue, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_WEDNESDAY' => $seriesPatternWeeklyWed, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_THURSDAY' => $seriesPatternWeeklyThu, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_FRIDAY' => $seriesPatternWeeklyFri, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_SATURDAY' => $seriesPatternWeeklySat, $this->moduleLangVar . '_SERIES_PATTERN_WEEKLY_SUNDAY' => $seriesPatternWeeklySun)); //parse publicate $objHostManager = new \Cx\Modules\Calendar\Controller\CalendarHostManager(null, true); $objHostManager->getHostList(); foreach ($objHostManager->hostList as $key => $objHost) { if (in_array($objHost->id, $objEvent->relatedHosts)) { $selectetHosts .= '<option value="' . $objHost->id . '">' . $objHost->title . '</option>'; } else { $deselectetHosts .= '<option value="' . $objHost->id . '">' . $objHost->title . '</option>'; } } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_DESELECTED_HOSTS' => $deselectetHosts, $this->moduleLangVar . '_EVENT_SELECTED_HOSTS' => $selectetHosts)); if ($this->arrSettings['publicationStatus'] == 1 && !empty($objHostManager->hostList)) { $onsubmitPublications = "selectAll(document.formModifyEvent.elements['selectedHosts[]']);"; $this->_objTpl->touchBlock('eventPublicateMenu'); $this->_objTpl->touchBlock('eventPublicateTab'); } else { $onsubmitPublications = ""; $this->_objTpl->hideBlock('eventPublicateMenu'); $this->_objTpl->hideBlock('eventPublicateTab'); } //parse ivited groups $this->getCommunityGroups(); foreach ($this->arrCommunityGroups as $key => $arrGroup) { if (in_array($arrGroup['id'], $objEvent->invitedGroups)) { $selectedGroups .= '<option value="' . $arrGroup['id'] . '">' . htmlentities($arrGroup['name'], ENT_QUOTES, CONTREXX_CHARSET) . '</option>'; } else { $deselectedGroups .= '<option value="' . $arrGroup['id'] . '">' . htmlentities($arrGroup['name'], ENT_QUOTES, CONTREXX_CHARSET) . '</option>'; } } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_DESELECTED_GROUPS' => $deselectedGroups, $this->moduleLangVar . '_EVENT_SELECTED_GROUPS' => $selectedGroups, $this->moduleLangVar . '_EVENT_ONSUBMIT_PUBLICATIONS' => $onsubmitPublications)); $forcedLanguage = null; if (isset($_GET['langId']) && in_array(contrexx_input2raw($_GET['langId']), \FWLanguage::getIdArray())) { $forcedLanguage = contrexx_input2raw($_GET['langId']); } //parse placeSelect if ((int) $this->arrSettings['placeData'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->place_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventPlaceSelect'); if ((int) $this->arrSettings['placeData'] == 2) { $this->_objTpl->hideBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->touchBlock('eventPlaceTypeRadio'); } } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceSelect'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } //parse placeHostSelect if ((int) $this->arrSettings['placeDataHost'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataHostForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->host_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventHostSelect'); if ((int) $this->arrSettings['placeDataHost'] == 2) { $this->_objTpl->hideBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->touchBlock('eventHostTypeRadio'); } } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostSelect'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } $multiLingualFields = array('place', 'place_city', 'place_country', 'org_name', 'org_city', 'org_country'); $isOneActiveLanguage = count($this->arrFrontendLanguages) == 1; foreach ($multiLingualFields as $inputField) { if ($isOneActiveLanguage) { $this->_objTpl->hideBlock('calendar_event_' . $inputField . '_expand'); } else { $this->_objTpl->touchBlock('calendar_event_' . $inputField . '_expand'); } } foreach ($this->arrFrontendLanguages as $key => $arrLang) { //parse globals $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_EVENT_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_EVENT_LANG_ID' => $arrLang['id'], 'TXT_' . $this->moduleLangVar . '_EVENT_LANG_NAME' => $arrLang['name'])); //parse "show in" checkboxes $arrShowIn = explode(",", $objEvent->showIn); $langChecked = false; if ($eventId != 0) { $langChecked = in_array($arrLang['id'], $arrShowIn); if ($forcedLanguage && !$langChecked) { $langChecked = $forcedLanguage == $arrLang['id']; } } else { $langChecked = $arrLang['is_default'] == 'true'; } if ($langChecked) { $langChecked = 'checked="checked"'; } else { $langChecked = ''; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LANG_CHECKED' => $langChecked)); $this->_objTpl->parse('eventShowIn'); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $arrLang['is_default'] == 'true' ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TITLE' => !empty($objEvent->arrData['title'][$arrLang['id']]) ? $objEvent->arrData['title'][$arrLang['id']] : $objEvent->title, $this->moduleLangVar . '_EVENT_TEASER' => !empty($objEvent->arrData['teaser'][$arrLang['id']]) ? $objEvent->arrData['teaser'][$arrLang['id']] : $objEvent->teaser)); //parse eventTabMenuDescTab $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_CLASS' => $defaultLang ? 'active' : '')); $this->_objTpl->parse('eventTabMenuDescTab'); //parse eventDescTab $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_EVENT_DESCRIPTION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DESCRIPTION'], 'TXT_' . $this->moduleLangVar . '_EVENT_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], $this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $arrLang['is_default'] == 'true' ? 'block' : 'none', $this->moduleLangVar . '_EVENT_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('description[' . $arrLang['id'] . ']', !empty($objEvent->arrData['description'][$arrLang['id']]) ? contrexx_raw2xhtml($objEvent->arrData['description'][$arrLang['id']]) : contrexx_raw2xhtml($objEvent->description), 'full'), $this->moduleLangVar . '_EVENT_REDIRECT' => !empty($objEvent->arrData['redirect'][$arrLang['id']]) ? $objEvent->arrData['redirect'][$arrLang['id']] : $objEvent->arrData['redirect'][$_LANGID], $this->moduleLangVar . '_EVENT_TYPE_EVENT_DISPLAY' => $objEvent->type == 0 ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT_DISPLAY' => $objEvent->type == 1 ? 'block' : 'none', $this->moduleLangVar . '_ONSUBMIT_PUBLICATION' => $onsubmitPublications)); $this->_objTpl->parse('eventDescTab'); //parse eventLingualFields foreach ($multiLingualFields as $inputField) { $this->_objTpl->setVariable($this->moduleLangVar . '_EVENT_' . strtoupper($inputField) . '_DEFAULT', $eventId != 0 ? $objEvent->{$inputField} : ''); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_VALUE' => !empty($objEvent->arrData[$inputField][$arrLang['id']]) ? $objEvent->arrData[$inputField][$arrLang['id']] : ($eventId != 0 ? $objEvent->{$inputField} : ''))); $this->_objTpl->parse('calendar_event_' . $inputField); } } if (isset($_GET['confirm']) && $_GET['confirm']) { $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_SAVE_PUBLISH' => "<input type='submit' name='save_and_publish' value='{$_ARRAYLANG['TXT_CALENDAR_SAVE_AND_PUBLISH']}'>", $this->moduleLangVar . '_EVENT_DELETE' => "<input type='button' name='delete' value='{$_ARRAYLANG['TXT_CALENDAR_DELETE']}' onClick='if (confirm(\"{$_ARRAYLANG['TXT_CALENDAR_CONFIRM_DELETE_DATA']}\\n{$_ARRAYLANG['TXT_CALENDAR_ACTION_IS_IRREVERSIBLE']}\")) { window.location.href = \"index.php?cmd={$this->moduleName}&delete={$eventId}&" . \Cx\Core\Csrf\Controller\Csrf::param() . "\"} return false;'>")); } \Cx\Core\Core\Controller\Cx::instanciate()->getComponent('Cache')->deleteComponentFiles('Calendar'); }
/** * Modify Dir * * @access private * @global array * @global ADONewConnection * @global FWLanguage */ function _editDir($copy = false) { global $_ARRAYLANG, $objDatabase; $dirid = !empty($_GET['id']) ? intval($_GET['id']) : 0; if (isset($this->directories[$dirid])) { $displayMode = $this->directories[$dirid]['displaymode']; $name = $this->directories[$dirid]['name']; $description = $this->directories[$dirid]['description']; $sort = $this->directories[$dirid]['sort']; $lang = $this->directories[$dirid]['lang']; $pic1 = $this->directories[$dirid]['pic1']; $pic2 = $this->directories[$dirid]['pic2']; } else { $dirid = 0; $displayMode = 0; $name = ''; $description = ''; $sort = 0; $lang = \FWLanguage::getDefaultLangId(); $pic1 = ''; $pic2 = ''; } $this->_objTpl->loadTemplateFile('module_memberdir_modifyDir.html'); $this->pageTitle = $dirid > 0 ? $copy ? $_ARRAYLANG['TXT_MEMBERDIR_COPY_DIR'] : $_ARRAYLANG['TXT_EDIT_DIR'] : $_ARRAYLANG['TXT_NEW_DIR']; $this->_objTpl->setVariable(array('TXT_PIC_UPLOAD' => $_ARRAYLANG['TXT_PIC_UPLOAD'], 'TXT_TITLE' => $dirid > 0 ? $copy ? $_ARRAYLANG['TXT_MEMBERDIR_COPY_DIR'] : $_ARRAYLANG['TXT_EDIT_DIR'] : $_ARRAYLANG['TXT_NEW_DIR'], 'TXT_ACTIVE' => $_ARRAYLANG['TXT_ACTIVE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_TYPE' => $_ARRAYLANG['TXT_ROW_TYPE'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_FIELDS' => $_ARRAYLANG['TXT_FIELDS'], 'TXT_DIR_NAME' => $_ARRAYLANG['TXT_MEMBERDIR_NAME'], 'TXT_MORE_ROW' => $_ARRAYLANG['TXT_MORE_ROW'], 'TXT_ONE_ROW' => $_ARRAYLANG['TXT_ONE_ROW'], 'TXT_DESCRIPTION' => $_ARRAYLANG['TXT_DESCRIPTION'], 'TXT_PARENT_DIR' => $_ARRAYLANG['TXT_PARENT_DIR'], 'TXT_SORT' => $_ARRAYLANG['TXT_SORT'], 'TXT_MEMBERDIR_USER_DEFINED' => $_ARRAYLANG['TXT_MEMBERDIR_USER_DEFINED'], 'TXT_DISPLAY_MODE_BOTH' => $_ARRAYLANG['TXT_DISPLAY_MODE_BOTH'], 'TXT_DISPLAY_MODE_DIR_ONLY' => $_ARRAYLANG['TXT_DISPLAY_MODE_DIR_ONLY'], 'TXT_DISPLAY_MODE_ENTRIES_ONLY' => $_ARRAYLANG['TXT_DISPLAY_MODE_ENTRIES_ONLY'], 'TXT_DISPLAY_MODE' => $_ARRAYLANG['TXT_DISPLAY_MODE'], 'TXT_MEMBERDIR_LANGUAGE' => $_ARRAYLANG['TXT_MEMBERDIR_LANGUAGE'])); $this->_objTpl->setVariable(array('MODE_' . $displayMode . '_CHECKED' => 'checked="checked"', 'PARENT_DIRLIST' => $this->_getDirectoryMenu('name="parentdir" size="1" style="width:300px;"', $dirid), 'MEMBERDIR_ACTION' => $dirid ? '?cmd=MemberDir&act=save' . ($copy ? 'Copy' : 'Edited') . 'Dir&id=' . $dirid : '?cmd=MemberDir&act=saveNewDir', 'MEMBERDIR_DIR_NAME' => htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET), 'MEMBERDIR_DESCRIPTION' => htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET), 'MEMBERDIR_SELECTED_SORT' => $sort, 'MEMBERDIR_LANGUAGE_MENU' => $this->_getLanguageMenu('name="memberdirLangId" size="1" style="width:300px;"', $lang), 'MEMBERDIR_FIELD_PIC_1' => $pic1 ? 'checked="checked"' : '', 'MEMBERDIR_FIELD_PIC_2' => $pic2 ? 'checked="checked"' : '')); if ($dirid) { $query = 'SELECT `field`, `dirid`, `name`, `active` FROM `' . DBPREFIX . 'module_memberdir_name` WHERE `dirid` = ' . $dirid; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { while (!$objResult->EOF) { $this->_objTpl->setVariable(array('MEMBERDIR_FIELD_ACTIVE_' . $objResult->fields['field'] => $objResult->fields['active'] == '1' ? 'checked="checked"' : '', 'MEMBERDIR_FIELD_NAME_' . $objResult->fields['field'] => htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET))); $objResult->MoveNext(); } } else { $this->statusMessage = $_ARRAYLANG['TXT_DATABASE_READ_ERROR']; } } else { $arrFieldNames = explode(';', $_ARRAYLANG['TXT_FIELD_DEFAULT_NAMES']); foreach ($arrFieldNames as $fieldId => $fieldName) { $this->_objTpl->setVariable(array('MEMBERDIR_FIELD_NAME_' . ($fieldId + 1) => $fieldName, 'MEMBERDIR_FIELD_ACTIVE_' . ($fieldId + 1) => 'checked="checked"')); } } }
/** * Tries to fix database problems * * Also migrates text fields to the new structure. * Note that no VAT classes are added here (yet), so neither the old * nor the new table exists to begin with, the new structure will be * created with no records. * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Vat $table_name = DBPREFIX . 'module_shop_vat'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00', 'renamefrom' => 'percent')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name, 'class')) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'class')) { // Migrate all Vat classes to the Text table first \Text::deleteByKey('Shop', self::TEXT_CLASS); $query = "\n SELECT `id`, `class`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { $id = $objResult->fields['id']; $class = $objResult->fields['class']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CLASS, $class)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate VAT class '{$class}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
/** * Creates a translated page in this node * * Does not flush EntityManager. * * @param boolean $activate whether the new page should be activated * @param int $targetLang target language id * @returns \Cx\Core\ContentManager\Model\Entity\Page the copy */ public function translatePage($activate, $targetLang) { $type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK; $fallback_language = \FWLanguage::getFallbackLanguageIdById($targetLang); $defaultLang = \FWLanguage::getDefaultLangId(); // copy the corresponding language version (if there is one) if ($fallback_language && $this->getPage($fallback_language)) { $pageToTranslate = $this->getPage($fallback_language); // find best page to copy if no corresponding language version is present } else { if ($this->getPage($defaultLang)) { $pageToTranslate = $this->getPage($defaultLang); } else { $pages = $this->getPages(); $pageToTranslate = $pages[0]; } if (!$fallback_language) { $type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_CONTENT; } } // copy page following redirects $page = $pageToTranslate->copyToLang($targetLang, true, true, true, true, true, false, true); $page->setActive($activate); $page->setType($type); $pageToTranslate->setupPath($targetLang); return $page; }
/** * Tries to recreate the database table(s) for the class * * Should be called whenever there's a problem with the database table. * @return boolean False. Always. */ static function errorHandler() { $table_name = DBPREFIX . 'core_country'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'alpha2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'alpha3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'is_active')); \Cx\Lib\UpdateUtil::table($table_name, $table_structure); if (\Cx\Lib\UpdateUtil::table_empty($table_name)) { \Text::deleteByKey('core', self::TEXT_NAME); // Copy the Countries from the Shop module if possible if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . "module_shop_countries")) { $query = "\n SELECT `countries_id`, `countries_name`,\n `countries_iso_code_2`, `countries_iso_code_3`,\n `activation_status`\n FROM " . DBPREFIX . "module_shop_countries"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to to query Country names", $query); } $default_lang_id = \FWLanguage::getDefaultLangId(); while (!$objResult->EOF) { $id = $objResult->fields['countries_id']; $name = $objResult->fields['countries_name']; $alpha2 = $objResult->fields['countries_iso_code_2']; $alpha3 = $objResult->fields['countries_iso_code_3']; $active = $objResult->fields['activation_status']; $ord = 0; if ($id == 14) { // fixing missing name $name = 'Österreich'; } if (!self::store($alpha2, $alpha3, $default_lang_id, $name, $ord, $active, $id)) { throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate Country '{$name}'"); } $objResult->MoveNext(); } \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_countries'); } } // USE FOR NEW INSTALLATIONS ONLY! // These records will lead to inconsistencies with Country references in // other tables otherwise. if (\Cx\Lib\UpdateUtil::table_empty($table_name)) { // Add new Country records if available if (file_exists(ASCMS_CORE_PATH . '/countries_iso_3166-2.php') && (include_once ASCMS_CORE_PATH . '/countries_iso_3166-2.php')) { //DBG::log("Country::errorHandler(): Included ISO file"); $arrCountries = null; $ord = 0; foreach ($arrCountries as $country_id => $arrCountry) { $name = $arrCountry[0]; $alpha2 = $arrCountry[1]; $alpha3 = $arrCountry[2]; // Not currently in use: // $numeric = $arrCountry[3]; // $iso_full = $arrCountry[4]; // English (language ID 2) only! if (!self::store($alpha2, $alpha3, 2, $name, ++$ord, true, $country_id)) { throw new \Cx\Lib\Update_DatabaseException("Failed to to add Country '{$name}' from ISO file"); } //DBG::log("Country::errorHandler(): Added Country ID $country_id: '$name'"); } } } //DBG::activate(DBG_ADODB); // Add more languages from the countries_languages.php file, // if present $arrCountries = array(); // $arrCountries is redefined in the file if (file_exists(ASCMS_CORE_PATH . '/countries_languages.php') && (include_once ASCMS_CORE_PATH . '/countries_languages.php')) { foreach ($arrCountries as $alpha2 => $arrLanguage) { //DBG::log("errorHandler: Looking for Alpha-2 $alpha2"); $country_id = self::getIdByAlpha2($alpha2); if (!$country_id) { // TODO: Fail or not? continue; } foreach ($arrLanguage as $lang_id => $name) { if (!\Text::replace($country_id, $lang_id, 'core', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to to update Country '{$name}' from languages file"); } //DBG::log("Country::errorHandler(): Added Country ID $country_id: language ID $lang_id"); } } } \Cx\Core\Setting\Controller\Setting::init('core', 'country'); \Cx\Core\Setting\Controller\Setting::add('numof_countries_per_page_backend', 30, 101); // More to come... // Always! return false; }
/** * Return link to the profile of a user */ function GetProfileURL($code, $email, $type = self::USER_TYPE_NEWSLETTER) { global $_ARRAYLANG, $_CONFIG; if ($type == self::USER_TYPE_CORE) { // recipients that will receive the newsletter through the selection of their user group don't have a profile return ''; } $profileURI = '?section=Newsletter&cmd=profile&code=' . $code . '&mail=' . urlencode($email); $uri = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter(\FWLanguage::getDefaultLangId(), 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . $profileURI; return '<a href="' . $uri . '">' . $_ARRAYLANG['TXT_EDIT_PROFILE'] . '</a>'; }
/** * Handles any kind of database error * @throws Cx\Lib\Update_DatabaseException * @return boolean False. Always. */ static function errorHandler() { // ShopCategory // Fix the Text and Settings table first \Text::errorHandler(); ShopSettings::errorHandler(); $default_lang_id = \FWLanguage::getDefaultLangId(); $table_name = DBPREFIX . 'module_shop_categories'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'catid'), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'parentid'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'catsorting'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'catstatus'), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'default' => '')); $table_index = array('flags' => array('fields' => 'flags', 'type' => 'FULLTEXT')); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'catname')) { // Migrate all ShopCategory names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); \Text::deleteByKey('Shop', self::TEXT_DESCRIPTION); $query = "\n SELECT `catid`, `catname`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query ShopCategory names"); } while (!$objResult->EOF) { $id = $objResult->fields['catid']; $name = $objResult->fields['catname']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate ShopCategory name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
public function resolve() { // $this->resolveAlias() also sets $this->page $aliaspage = $this->resolveAlias(); if ($aliaspage != null) { $this->lang = $aliaspage->getTargetLangId(); $aliaspage = clone $aliaspage; $aliaspage->setVirtual(true); } else { $this->lang = \Env::get('init')->getFallbackFrontendLangId(); //try to find the language in the url $extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir()); $activeLanguages = \FWLanguage::getActiveFrontendLanguages(); if (!$extractedLanguage) { $this->redirectToCorrectLanguageDir(); } if (!in_array($extractedLanguage, array_keys($activeLanguages))) { $this->lang = \FWLanguage::getDefaultLangId(); $this->redirectToCorrectLanguageDir(); } //only set langid according to url if the user has not explicitly requested a language change. if (!isset($_REQUEST['setLang'])) { $this->lang = $extractedLanguage; //the user wants to change the language, but we're still inside the wrong language directory. } else { if ($this->lang != $extractedLanguage) { $this->redirectToCorrectLanguageDir(); } } } // used for LinkGenerator define('FRONTEND_LANG_ID', $this->lang); // used to load template file \Env::get('init')->setFrontendLangId($this->lang); global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection; $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : ''; $history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0; // Initialize page meta $page = null; $pageAccessId = 0; $page_protected = $pageId = $themesPages = $page_template = null; // If standalone is set, then we will not have to initialize/load any content page related stuff $isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false'; // Regular page request if ($isRegularPageRequest) { // TODO: history (empty($history) ? ) if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) { $sessionObj = \cmsSession::getInstance(); } $this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray()); try { $this->resolvePage(); $page = $this->getPage(); // TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ? // only set $section and $command if the requested page is an application $command = $this->getCmd(); $section = $this->getSection(); } catch (\Cx\Core\Routing\ResolverException $e) { try { $this->legacyResolve($url, $section, $command); $page = $this->getPage(); $command = $this->getCmd(); $section = $this->getSection(); } catch (\Cx\Core\Routing\ResolverException $e) { // legacy resolving also failed. // provoke a 404 $page = null; } } if (!$page || !$page->isActive()) { //fallback for inexistant error page if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } else { //page not found, redirect to error page. \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error')); exit; } } // TODO: question: what do we need this for? I think there is no need for this (had been added in r15026) //legacy: re-populate cmd and section into $_GET $_GET['cmd'] = $command; $_GET['section'] = $section; // END of TODO question //check whether the page is active $now = new \DateTime('now'); $start = $page->getStart(); $end = $page->getEnd(); $pageId = $page->getId(); //access: frontend access id for default requests $pageAccessId = $page->getFrontendAccessId(); //revert the page if a history param has been given if ($history) { //access: backend access id for history requests $pageAccessId = $page->getBackendAccessId(); $logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry'); try { $logRepo->revert($page, $history); } catch (\Gedmo\Exception\UnexpectedValueException $e) { } $logRepo->revert($page, $history); } /* //404 for inactive pages if(($start > $now && $start != null) || ($now > $end && $end != null)) { if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404'); exit; }*/ \Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels()); $themesPages = \Env::get('init')->getTemplates($page); //replace the {NODE_<ID>_<LANG>}- placeholders \LinkGenerator::parseTemplate($themesPages); //TODO: analyze those, take action. //$page_protected = $objResult->fields['protected']; $page_protected = $page->isFrontendProtected(); //$page_access_id = $objResult->fields['frontend_access_id']; $page_template = $themesPages['content']; // Authentification for protected pages // This is only done for regular page requests ($isRegularPageRequest == TRUE) $this->checkPageFrontendProtection($page, $history); //TODO: history } // TODO: refactor system to be able to remove this backward compatibility // Backwards compatibility for code pre Contrexx 3.0 (update) $_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command; $_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section; // the system should directly use $this->url->getParamArray() instead of using the super globals $qsArr = $this->url->getParamArray(); foreach ($qsArr as $qsParam => $qsArgument) { $_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument; } // To clone any module, use an optional integer cmd suffix. // E.g.: "shop2", "gallery5", etc. // Mind that you *MUST* copy all necessary database tables, and fix any // references to your module (section and cmd parameters, database tables) // using the MODULE_INDEX constant in the right place both in your code // *AND* templates! // See the Shop module for an example. $arrMatch = array(); if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) { // The plain section/module name, used below $plainSection = $arrMatch[1]; } else { $plainSection = $section; } // The module index. // An empty or 1 (one) index represents the same (default) module, // values 2 (two) and larger represent distinct instances. $moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2]; define('MODULE_INDEX', $moduleIndex); // Start page or default page for no section if ($section == 'Home') { if (!\Env::get('init')->hasCustomContent()) { $page_template = $themesPages['home']; } else { $page_template = $themesPages['content']; } } // this is the case for standalone and backend requests if (!$this->page) { return null; } $this->page = clone $this->page; $this->page->setVirtual(); // check for further URL parts to resolve if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->page->getPath() != '/' . $this->url->getSuggestedTargetPath()) { // does this work for fallback(/aliases)? $additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath())); $componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule())); if ($componentController) { $parts = explode('/', substr($additionalPath, 1)); $componentController->resolve($parts, $this->page); } } return $this->page; }
/** * Returns the type of the page as string. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page * @return string $type */ public function getTypeByPage($page) { global $_CORELANG; switch ($page->getType()) { case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT: $criteria = array('nodeIdShadowed' => $page->getTargetNodeId(), 'lang' => $page->getLang()); $targetPage = $this->findOneBy($criteria); $targetTitle = $targetPage ? $targetPage->getTitle() : $page->getTarget(); $type = $_CORELANG['TXT_CORE_CM_TYPE_REDIRECT'] . ': '; $type .= $targetTitle; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION: $type = $_CORELANG['TXT_CORE_CM_TYPE_APPLICATION'] . ': '; $type .= $page->getModule(); $type .= $page->getCmd() != '' ? ' | ' . $page->getCmd() : ''; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK: $fallbackLangId = \FWLanguage::getFallbackLanguageIdById($page->getLang()); if ($fallbackLangId == 0) { $fallbackLangId = \FWLanguage::getDefaultLangId(); } $type = $_CORELANG['TXT_CORE_CM_TYPE_FALLBACK'] . ' '; $type .= \FWLanguage::getLanguageCodeById($fallbackLangId); break; default: $type = $_CORELANG['TXT_CORE_CM_TYPE_CONTENT']; } return $type; }
/** * Tries to fix any database problems * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { //die("Discount::errorHandler(): Disabled!<br />"); // Discount \Text::errorHandler(); $table_name = DBPREFIX . 'module_shop_article_group'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true)); $table_index = array(); //\DBG::activate(DBG_DB); if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_ARTICLE); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query article group names", $query); } while (!$objResult->EOF) { $group_id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_ARTICLE, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate article group names"); } $objResult->MoveNext(); } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } $table_name = DBPREFIX . 'module_shop_customer_group'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true)); $table_index = array(); if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_CUSTOMER); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query customer group names", $query); } while (!$objResult->EOF) { $group_id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_CUSTOMER, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate customer group names"); } $objResult->MoveNext(); } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } $table_name = DBPREFIX . 'module_shop_rel_discount_group'; $table_structure = array('customer_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'article_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'rate' => array('type' => 'decimal(9,2)', 'notnull' => true, 'default' => '0.00')); $table_index = array(); if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } $table_name = DBPREFIX . 'module_shop_discountgroup_count_name'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true)); $table_index = array(); if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_COUNT); \Text::deleteByKey('Shop', self::TEXT_UNIT_GROUP_COUNT); $query = "\n SELECT `id`, `name`, `unit`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query count group names", $query); } while (!$objResult->EOF) { $group_id = $objResult->fields['id']; $name = $objResult->fields['name']; $unit = $objResult->fields['unit']; if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_COUNT, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group names"); } if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_UNIT_GROUP_COUNT, $unit)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group units"); } $objResult->MoveNext(); } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); } $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate'; $table_structure = array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
public function migrateAliases() { try { if (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_alias_source')) { return true; } $objResult = \Cx\Lib\UpdateUtil::sql(' SELECT `s`.`url` AS `slug`, `t`.`type`, `t`.`url` AS `target` FROM `' . DBPREFIX . 'module_alias_source` AS `s` INNER JOIN `' . DBPREFIX . 'module_alias_target` AS `t` ON `s`.`target_id` = `t`.`id` '); } catch (\Cx\Lib\UpdateException $e) { \Cx\Lib\UpdateUtil::DefaultActionHandler($e); return false; } $arrAliases = array(); if ($objResult !== false) { while (!$objResult->EOF) { $arrAliases[$objResult->fields['target']][$objResult->fields['slug']] = $objResult->fields['type']; $objResult->MoveNext(); } } foreach ($arrAliases as $target => $arrSlugs) { foreach ($arrSlugs as $slug => $type) { $pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); if ($type === 'local') { $aliasPage = $pageRepo->findOneBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => 'legacy_page_' . $target), true); if ($aliasPage) { $targetPage = $pageRepo->getTargetPage($aliasPage); if ($targetPage) { $objAliasLib = new \aliasLib($targetPage->getLang()); $objAliasLib->_saveAlias($slug, $aliasPage->getTarget(), true); } } } else { $objAliasLib = new \aliasLib(\FWLanguage::getDefaultLangId()); $objAliasLib->_saveAlias($slug, $target, false); } } } return true; }
/** * Log in the current user with the object given * @param mixed $objUser the user to be logged in */ function loginUser($objUser) { global $objInit; $_SESSION->cmsSessionUserUpdate($objUser->getId()); $objUser->registerSuccessfulLogin(); unset($_SESSION['auth']['loginLastAuthFailed']); // Store frontend lang_id in cookie if (empty($_COOKIE['langId'])) { // TODO: Seems that this method returns zero at first when the Users' language is set to "default"! $langId = $objUser->getFrontendLanguage(); // Temporary fix: if (empty($langId)) { $langId = FWLanguage::getDefaultLangId(); } if ($objInit->arrLang[$langId]['frontend']) { setcookie("langId", $langId, time() + 3600 * 24 * 30, ASCMS_PATH_OFFSET . '/'); } } }
/** * Update the news locales * while activate/deactivate a language in the Administrative -> Language * * @param array $eventArgs Arguments for the event * * @return boolean */ protected function languageStatusUpdate(array $eventArgs) { global $objDatabase; if (empty($eventArgs[0])) { return; } $defaultLangId = \FWLanguage::getDefaultLangId(); foreach ($eventArgs[0]['langData'] as $args) { $langId = isset($args['langId']) ? $args['langId'] : 0; $langStatus = isset($args['status']) ? $args['status'] : 0; if (empty($langId) || !isset($args['status']) || !$langStatus && !$eventArgs[0]['langRemovalStatus']) { continue; } //Update the news locale $newsQuery = $langStatus ? 'INSERT IGNORE INTO `' . DBPREFIX . 'module_news_locale` ( `news_id`, `lang_id`, `is_active`, `title`, `text`, `teaser_text` ) SELECT `news_id`, ' . $langId . ', 0, `title`, `text`, `teaser_text` FROM `' . DBPREFIX . 'module_news_locale` WHERE lang_id = ' . $defaultLangId : 'DELETE FROM `' . DBPREFIX . 'module_news_locale` WHERE lang_id = ' . $langId; $objDatabase->Execute($newsQuery); //Update the news category locale $catQuery = $langStatus ? 'INSERT IGNORE INTO `' . DBPREFIX . 'module_news_categories_locale` ( `category_id`, `lang_id`, `name` ) SELECT `category_id`, ' . $langId . ', `name` FROM `' . DBPREFIX . 'module_news_categories_locale` WHERE lang_id = ' . $defaultLangId : 'DELETE FROM `' . DBPREFIX . 'module_news_categories_locale` WHERE lang_id = ' . $langId; $objDatabase->Execute($catQuery); } }
/** * Handles database errors * * Also migrates old Currency names to the Text class, * and inserts default Currencyes if necessary * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { global $objDatabase; // Currency \Text::errorHandler(); $table_name = DBPREFIX . 'module_shop_currencies'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'increment' => array('type' => 'DECIMAL(6,5)', 'unsigned' => true, 'notnull' => true, 'default' => '0.01'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'), 'default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'is_default')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { // Migrate all Currency names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `code`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Currency names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Currency name '{$name}'"); } $objResult->MoveNext(); } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); return false; } // If the table did not exist, insert defaults $arrCurrencies = array('Schweizer Franken' => array('CHF', 'sFr.', 1.0, '0.05', 1, 1, 1), 'Euro' => array('EUR', html_entity_decode("€"), 1.18, '0.01', 2, 1, 0), 'United States Dollars' => array('USD', '$', 0.88, '0.01', 3, 1, 0)); // There is no previous version of this table! \Cx\Lib\UpdateUtil::table($table_name, $table_structure); // And there aren't even records to migrate, so foreach ($arrCurrencies as $name => $arrCurrency) { $query = "\n INSERT INTO `contrexx_module_shop_currencies` (\n `code`, `symbol`, `rate`, `increment`,\n `ord`, `active`, `default`\n ) VALUES (\n '" . join("','", $arrCurrency) . "'\n )"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to insert default Currencies"); } $id = $objDatabase->Insert_ID(); if (!\Text::replace($id, FRONTEND_LANG_ID, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Text for default Currency name '{$name}'"); } } // Always return false; }
/** * Add or edit the news types * @global ADONewConnection * @global array * @param string $pageContent */ function manageTypes() { global $objDatabase, $_ARRAYLANG; $this->_objTpl->loadTemplateFile('module_news_type.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_TYPES_MANAGER']; $this->_objTpl->setVariable(array('TXT_ADD_NEW_TYPE' => $_ARRAYLANG['TXT_ADD_NEW_TYPE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_ADD' => $_ARRAYLANG['TXT_ADD'], 'TXT_TYPE_LIST' => $_ARRAYLANG['TXT_TYPE_LIST'], 'TXT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_ACTION' => $_ARRAYLANG['TXT_ACTION'], 'TXT_ACCEPT_CHANGES' => $_ARRAYLANG['TXT_ACCEPT_CHANGES'], 'TXT_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_CONFIRM_DELETE_DATA'], 'TXT_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACTION_IS_IRREVERSIBLE'], 'TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK' => $_ARRAYLANG['TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK'])); $this->_objTpl->setGlobalVariable(array('TXT_DELETE' => $_ARRAYLANG['TXT_DELETE'], 'TXT_NEWS_EXTENDED' => $_ARRAYLANG['TXT_NEWS_EXTENDED'])); // Add a new type if (isset($_POST['addType']) && $_POST['addType'] == true) { $typeName = contrexx_input2db(trim($_POST['newTypeName'])); if (empty($typeName)) { $this->strErrMessage = $_ARRAYLANG['TXT_NEWS_TYPE_ADD_ERROR_EMPTY']; } else { $status = true; if ($objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_news_types () VALUES ()") === false) { $status = false; } else { $typeId = $objDatabase->Insert_ID(); if ($objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_news_types_locale\n (lang_id, type_id, name)\n SELECT id, '{$typeId}', '{$typeName}' FROM " . DBPREFIX . "languages") === false) { $status = false; } } if ($status) { $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_ADDED_SUCCESSFUL']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; } } } // Modify a new type if (isset($_POST['modType']) && $_POST['modType'] == true) { if ($this->storeTypesLocales($_POST['newsTypeName'])) { $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; } } $objResult = $objDatabase->Execute("SELECT type_id\n FROM " . DBPREFIX . "module_news_types_locale\n GROUP BY type_id\n ORDER BY type_id asc"); $arrLanguages = \FWLanguage::getLanguageArray(); $typeLangData = $this->getTypesLangData(); $i = 0; if ($objResult !== false) { while (!$objResult->EOF) { $cssStyle = $i++ % 2 == 0 ? 'row2' : 'row1'; foreach ($arrLanguages as $langId => $arrLanguage) { $this->_objTpl->setVariable(array('NEWS_TYPE_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name']), 'NEWS_TYPE_NAME_VALUE' => contrexx_raw2xhtml($typeLangData[$objResult->fields['type_id']][$langId]), 'NEWS_TYPE_LANG_ID' => $langId, 'NEWS_TYPE_ID' => $objResult->fields['type_id'])); $this->_objTpl->parse('type_name_list'); } $this->_objTpl->setVariable(array('NEWS_ROWCLASS' => $cssStyle, 'NEWS_TYPE_ID' => $objResult->fields['type_id'], 'NEWS_TYPE_NAME' => contrexx_raw2xhtml($typeLangData[$objResult->fields['type_id']][\FWLanguage::getDefaultLangId()]))); $this->_objTpl->parse('newsRow'); $objResult->MoveNext(); } } }
/** * Handles database errors * * Also migrates old ProductAttribute to new Attribute structures, * including Text records. * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Attribute $default_lang_id = \FWLanguage::getDefaultLangId(); $table_name_old = DBPREFIX . 'module_shop_products_attributes_name'; $table_name_new = DBPREFIX . 'module_shop_attribute'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type')); $table_index = array(); if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name_old}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'"); } $objResult->MoveNext(); } } } //DBG::activate(DBG_ADODB); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table"); } } $table_name_old = DBPREFIX . 'module_shop_products_attributes_value'; $table_name_new = DBPREFIX . 'module_shop_option'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00')); $table_index = array(); if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME); $query = "\n SELECT `id`, `value`\n FROM `{$table_name_old}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['value']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table"); } } $table_name_old = DBPREFIX . 'module_shop_products_attributes'; $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}"); } } // Always return false; }
/** * @param Sigma $template */ public function preFinalize(Sigma $template) { if (count($this->mediaBrowserInstances) == 0) { return; } global $_ARRAYLANG; /** * @var $init \InitCMS */ $init = \Env::get('init'); $init->loadLanguageData('MediaBrowser'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $thumbnailsTemplate = new Sigma(); $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html'); $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE'])); foreach ($this->cx->getMediaSourceManager()->getThumbnailGenerator()->getThumbnails() as $thumbnail) { $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size'])); $thumbnailsTemplate->parse('thumbnails'); } \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('languages', \FWLanguage::getActiveFrontendLanguages(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('language', \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId()), 'mediabrowser'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/MediaBrowser/View/Script/MediaBrowser.js'); }
/** * Add / Edit Event * * @param integer $eventId Event id * * @return null */ function modifyEvent($eventId = null) { global $_ARRAYLANG, $_CORELANG, $_LANGID; \JS::activate('cx'); \JS::activate('jqueryui'); \JS::registerJS('modules/Calendar/View/Script/Frontend.js'); $this->getFrontendLanguages(); $this->getSettings(); $this->_objTpl->setTemplate($this->pageContent, true, true); $showFrom = true; $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(); $isEventLoaded = false; if (isset($_POST['submitFormModifyEvent'])) { $arrData = array(); $arrData = $_POST; $arrData['access'] = 0; $arrData['priority'] = 3; if ($objEvent->save($arrData)) { $showFrom = false; $this->_objTpl->hideBlock('calendarEventModifyForm'); $this->_objTpl->touchBlock('calendarEventOkMessage'); // refresh event data after save $objEvent->get($eventId); $objEvent->getData(); $isEventLoaded = true; $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager(); $objMailManager->sendMail($objEvent, \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_NOTFY_NEW_APP); } else { $this->_objTpl->touchBlock('calendarEventErrMessage'); } } if ($eventId && !$isEventLoaded) { $objEvent->get($eventId); $objEvent->getData(); } $dateFormat = $this->getDateFormat(1); $locationType = $this->arrSettings['placeData'] == 3 ? $eventId != 0 ? $objEvent->locationType : 1 : $this->arrSettings['placeData']; $hostType = $this->arrSettings['placeDataHost'] == 3 ? $eventId != 0 ? $objEvent->hostType : 1 : $this->arrSettings['placeDataHost']; \ContrexxJavascript::getInstance()->setVariable(array('language_id' => \FWLanguage::getDefaultLangId(), 'active_lang' => implode(',', \FWLanguage::getIdArray())), 'calendar'); $javascript = <<<EOF <script language="JavaScript" type="text/javascript"> var defaultLang = cx.variables.get('language_id', 'calendar'); var activeLang = [cx.variables.get('active_lang', 'calendar')]; cx.ready(function() { var options = { dateFormat: '{$dateFormat}', timeFormat: 'hh:mm', showSecond: false, onSelect: function(dateText, inst){ var startDate = cx.jQuery( ".startDate" ).datetimepicker("getDate"); var endDate = cx.jQuery( ".endDate" ).datetimepicker("getDate"); if ( cx.jQuery( this )[0].id == 'startDate' ) { var prevStartDate = cx.jQuery( ".startDate" ).data('prevDate'); if (cx.jQuery(".all_day").is(':checked')) { prevStartDate.setHours(0, 0, 0); startDate.setHours(0, 0, 0); endDate.setHours(0, 0, 0); } if (prevStartDate.getTime() != startDate.getTime()) { var timeDiff = Math.abs(endDate.getTime() - prevStartDate.getTime()); endDate = new Date(startDate.getTime() + timeDiff); cx.jQuery( ".endDate" ).datetimepicker('setDate', endDate); } } else if (startDate.getTime() > endDate.getTime()) { endDate = new Date(startDate.getTime() + (30*60*1000)); cx.jQuery(".endDate").datetimepicker('setDate', endDate); } cx.jQuery( ".startDate" ).data('prevDate', cx.jQuery(".startDate").datetimepicker("getDate")); cx.jQuery( ".endDate" ).data('prevDate', cx.jQuery(".endDate").datetimepicker("getDate")); cx.jQuery( this ).datetimepicker('refresh'); } }; cx.jQuery('input[name=startDate]') .datetimepicker(options) .data('prevDate', cx.jQuery(".startDate").datetimepicker("getDate")); cx.jQuery('input[name=endDate]') .datetimepicker(options) .data('prevDate', cx.jQuery(".endDate").datetimepicker("getDate")); if ( \$J(".all_day").is(':checked') ) { modifyEvent._handleAllDayEvent( \$J(".all_day") ); } showOrHidePlaceFields('{$locationType}', 'place'); showOrHidePlaceFields('{$hostType}', 'host'); }); </script> EOF; if ($showFrom) { try { $javascript .= <<<UPLOADER {$this->getUploaderCode(self::PICTURE_FIELD_KEY, 'pictureUpload')} {$this->getUploaderCode(self::MAP_FIELD_KEY, 'mapUpload')} {$this->getUploaderCode(self::ATTACHMENT_FIELD_KEY, 'attachmentUpload', 'uploadFinished', false)} UPLOADER; } catch (Exception $e) { \DBG::msg("Error in initializing uploader"); } } $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_EVENT_LANG_ID' => $_LANGID, $this->moduleLangVar . '_JAVASCRIPT' => $javascript)); $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true); $objCategoryManager->getCategoryList(); if ($eventId) { $startDate = $objEvent->startDate; $endDate = $objEvent->endDate; } else { $startDate = new \DateTime(); $endDate = new \DateTime(); } $eventStartDate = $this->format2userDateTime($startDate); $eventEndDate = $this->format2userDateTime($endDate); $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DETAILS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DETAILS'], 'TXT_' . $this->moduleLangVar . '_SAVE' => $_ARRAYLANG['TXT_CALENDAR_SAVE'], 'TXT_' . $this->moduleLangVar . '_EVENT_START' => $_ARRAYLANG['TXT_CALENDAR_START'], 'TXT_' . $this->moduleLangVar . '_EVENT_END' => $_ARRAYLANG['TXT_CALENDAR_END'], 'TXT_' . $this->moduleLangVar . '_EVENT_TITLE' => $_ARRAYLANG['TXT_CALENDAR_TITLE'], 'TXT_' . $this->moduleLangVar . '_EXPAND' => $_ARRAYLANG['TXT_CALENDAR_EXPAND'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PLACE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PLACE'], 'TXT_' . $this->moduleLangVar . '_EVENT_STREET' => $_ARRAYLANG['TXT_CALENDAR_EVENT_STREET'], 'TXT_' . $this->moduleLangVar . '_EVENT_ZIP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ZIP'], 'TXT_' . $this->moduleLangVar . '_EVENT_CITY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_CITY'], 'TXT_' . $this->moduleLangVar . '_EVENT_COUNTRY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_COUNTRY'], 'TXT_' . $this->moduleLangVar . '_EVENT_WEBSITE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_WEBSITE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PHONE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PHONE'], 'TXT_' . $this->moduleLangVar . '_EVENT_MAP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_MAP'], 'TXT_' . $this->moduleLangVar . '_EVENT_USE_GOOGLEMAPS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_USE_GOOGLEMAPS'], 'TXT_' . $this->moduleLangVar . '_EVENT_LINK' => $_ARRAYLANG['TXT_CALENDAR_EVENT_LINK'], 'TXT_' . $this->moduleLangVar . '_EVENT_EMAIL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_EMAIL'], 'TXT_' . $this->moduleLangVar . '_EVENT_PICTURE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PICTURE'], 'TXT_' . $this->moduleLangVar . '_EVENT_ATTACHMENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ATTACHMENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CAT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DESCRIPTION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DESCRIPTION'], 'TXT_' . $this->moduleLangVar . '_PLEASE_CHECK_INPUT' => $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHECK_INPUT'], 'TXT_' . $this->moduleLangVar . '_EVENT_HOST' => $_ARRAYLANG['TXT_CALENDAR_EVENT_HOST'], 'TXT_' . $this->moduleLangVar . '_EVENT_NAME' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NAME'], 'TXT_' . $this->moduleLangVar . '_EVENT_ALL_DAY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ALL_DAY'], 'TXT_' . $this->moduleLangVar . '_LANGUAGE' => $_ARRAYLANG['TXT_CALENDAR_LANG'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_EVENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DESCRIPTION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DESCRIPTION'], 'TXT_' . $this->moduleLangVar . '_EVENT_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_DEFAULT' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_DEFAULT'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_FROM_MEDIADIR' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_FROM_MEDIADIR'], 'TXT_' . $this->moduleLangVar . '_PREV' => $_ARRAYLANG['TXT_CALENDAR_PREV'], 'TXT_' . $this->moduleLangVar . '_NEXT' => $_ARRAYLANG['TXT_CALENDAR_NEXT'], 'TXT_' . $this->moduleLangVar . '_MORE' => $_ARRAYLANG['TXT_CALENDAR_MORE'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $eventId != 0 ? $objEvent->type == 0 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $eventId != 0 ? $objEvent->type == 1 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_START_DATE' => $eventStartDate, $this->moduleLangVar . '_EVENT_END_DATE' => $eventEndDate, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_PICTURE_THUMB' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '.thumb" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach, $this->moduleLangVar . '_EVENT_CATEGORIES' => $objCategoryManager->getCategoryDropdown(intval($objEvent->catId), 2), $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_STREET' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_PLACE_WEBSITE' => $objEvent->place_website, $this->moduleLangVar . '_EVENT_PLACE_MAP' => $objEvent->place_map, $this->moduleLangVar . '_EVENT_PLACE_LINK' => $objEvent->place_link, $this->moduleLangVar . '_EVENT_PLACE_PHONE' => $objEvent->place_phone, $this->moduleLangVar . '_EVENT_MAP' => $objEvent->google == 1 ? 'checked="checked"' : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_WEBSITE' => $objEvent->org_website, $this->moduleLangVar . '_EVENT_HOST_LINK' => $objEvent->org_link, $this->moduleLangVar . '_EVENT_HOST_PHONE' => $objEvent->org_phone, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email, $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MANUAL' => $eventId != 0 ? $objEvent->locationType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->locationType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_HOST_TYPE_MANUAL' => $eventId != 0 ? $objEvent->hostType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_HOST_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->hostType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_ID' => $eventId, $this->moduleLangVar . '_EVENT_ALL_DAY' => $eventId != 0 && $objEvent->all_day ? 'checked="checked"' : '', $this->moduleLangVar . '_HIDE_ON_SINGLE_LANG' => count($this->arrFrontendLanguages) == 1 ? "display: none;" : "")); $multiLingualFields = array('place', 'place_city', 'place_country', 'org_name', 'org_city', 'org_country'); $isOneActiveLanguage = count($this->arrFrontendLanguages) == 1; foreach ($multiLingualFields as $inputField) { if ($isOneActiveLanguage) { $this->_objTpl->hideBlock('calendar_event_' . $inputField . '_expand'); } else { $this->_objTpl->touchBlock('calendar_event_' . $inputField . '_expand'); } } foreach ($this->arrFrontendLanguages as $arrLang) { //parse globals $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_EVENT_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_EVENT_LANG_ID' => $arrLang['id'], 'TXT_' . $this->moduleLangVar . '_EVENT_LANG_NAME' => $arrLang['name'])); //parse "show in" checkboxes $arrShowIn = explode(",", $objEvent->showIn); $langChecked = false; if ($eventId != 0) { $langChecked = in_array($arrLang['id'], $arrShowIn) ? true : false; } else { $langChecked = $arrLang['is_default'] == 'true'; } //parse eventTabMenuDescTab $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $langChecked ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TAB_CLASS' => '')); $this->_objTpl->parse('eventTabMenuDescTab'); //parse eventDescTab $eventTitle = !empty($objEvent->arrData['title'][$arrLang['id']]) ? $objEvent->arrData['title'][$arrLang['id']] : (!empty($objEvent->arrData['redirect'][$_LANGID]) ? $objEvent->arrData['redirect'][$_LANGID] : ''); $eventDescription = !empty($objEvent->arrData['description'][$arrLang['id']]) ? $objEvent->arrData['description'][$arrLang['id']] : ''; $eventRedirect = !empty($objEvent->arrData['redirect'][$arrLang['id']]) ? $objEvent->arrData['redirect'][$arrLang['id']] : (!empty($objEvent->arrData['redirect'][$_LANGID]) ? $objEvent->arrData['redirect'][$_LANGID] : ''); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $langChecked ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TITLE' => contrexx_raw2xhtml($eventTitle), $this->moduleLangVar . '_EVENT_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg("description[{$arrLang['id']}]", contrexx_raw2xhtml($eventDescription), $eventId != 0 ? 'small' : 'bbcode'), $this->moduleLangVar . '_EVENT_REDIRECT' => contrexx_raw2xhtml($eventRedirect), $this->moduleLangVar . '_EVENT_TYPE_EVENT_DISPLAY' => $objEvent->type == 0 ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT_DISPLAY' => $objEvent->type == 1 ? 'block' : 'none')); $this->_objTpl->parse('eventDescTab'); //parse eventLingualFields foreach ($multiLingualFields as $inputField) { $this->_objTpl->setVariable($this->moduleLangVar . '_EVENT_' . strtoupper($inputField) . '_DEFAULT', $eventId != 0 ? $objEvent->{$inputField} : ''); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_VALUE' => !empty($objEvent->arrData[$inputField][$arrLang['id']]) ? $objEvent->arrData[$inputField][$arrLang['id']] : ($eventId != 0 ? $objEvent->{$inputField} : ''))); $this->_objTpl->parse('calendar_event_' . $inputField); } $langChecked = $langChecked ? 'checked="checked"' : ''; $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LANG_CHECKED' => $langChecked)); $this->_objTpl->parse('eventShowIn'); } //parse placeSelect if ((int) $this->arrSettings['placeData'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->place_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventPlaceSelect'); if ((int) $this->arrSettings['placeData'] == 2) { $this->_objTpl->hideBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->touchBlock('eventPlaceTypeRadio'); } } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceSelect'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } //parse placeHostSelect if ((int) $this->arrSettings['placeDataHost'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataHostForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->host_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventHostSelect'); if ((int) $this->arrSettings['placeDataHost'] == 2) { $this->_objTpl->hideBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->touchBlock('eventHostTypeRadio'); } } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostSelect'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } }
public function setNames($arrNames) { $this->arrName = array(); foreach ($arrNames as $langId => $name) { $this->arrName[intval($langId)] = $name; } // add text for inactive languages too $defaultLangId = \FWLanguage::getDefaultLangId(); foreach (\FWLanguage::getLanguageArray() as $langId => $langInfo) { if (!isset($arrNames[$langId])) { $this->arrName[$langId] = $this->arrName[$defaultLangId]; } } $this->arrAttributes[$this->id]['names'] = $this->arrName; }
/** * Handles database errors * * Also migrates text fields to the new structure * @return boolean False. Always. * @static * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Product // Fix the Text, Discount, and Manufacturer tables first \Text::errorHandler(); // Discount::errorHandler(); // Called by Customer::errorHandler(); Manufacturer::errorHandler(); $table_name = DBPREFIX . 'module_shop_products'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discount_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'is_special_offer'), 'stock' => array('type' => 'INT(10)', 'default' => '10'), 'stock_visible' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'stock_visibility'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'date_start' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'startdate'), 'date_end' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'enddate'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'category_id' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'catid'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'manufacturer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'manufacturer'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'usergroup_ids' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_order'), 'distribution' => array('type' => 'VARCHAR(16)', 'default' => '', 'renamefrom' => 'handler'), 'picture' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'flags' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'minimum_order_quantity' => array('type' => 'INT(10)', 'unsigned' => false, 'default' => '0')); $table_index = array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT')); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); \Text::deleteByKey('Shop', self::TEXT_SHORT); \Text::deleteByKey('Shop', self::TEXT_LONG); \Text::deleteByKey('Shop', self::TEXT_CODE); \Text::deleteByKey('Shop', self::TEXT_URI); \Text::deleteByKey('Shop', self::TEXT_KEYS); $query = "\n SELECT `id`, `title`, `shortdesc`, `description`,\n `product_id`, `external_link`, `keywords`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Product strings", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['title']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product name '{$name}'"); } $short = $objResult->fields['shortdesc']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_SHORT, $short)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product short '{$short}'"); } $long = $objResult->fields['description']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_LONG, $long)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product long '{$long}'"); } $code = $objResult->fields['product_id']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CODE, $code)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product code '{$code}'"); } $uri = $objResult->fields['external_link']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product uri '{$uri}'"); } $keys = $objResult->fields['keywords']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_KEYS, $keys)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product keys '{$keys}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Also fix Customer and some related tables Customer::errorHandler(); // Always return false; }
/** * Handles database errors * * Also migrates old Shop Customers to the User accounts and adds * all new settings * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Customer $table_name_old = DBPREFIX . "module_shop_customers"; // If the old Customer table is missing, the migration has completed // successfully already if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { return false; } // Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables // are ready first! //DBG::log("Customer::errorHandler(): Adding settings"); ShopSettings::errorHandler(); // \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler(); Order::errorHandler(); Discount::errorHandler(); \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); $objUser = \FWUser::getFWUserObject()->objUser; // Create new User_Profile_Attributes $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop'); if (!$index_notes) { //DBG::log("Customer::errorHandler(): Adding notes attribute..."); // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); //DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true)); $objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes')); $objProfileAttribute->setType('text'); $objProfileAttribute->setMultiline(true); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); //DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); //DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId()); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting"); } //DBG::log("Customer::errorHandler(): Stored notes attribute ID setting"); } $index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop'); if (!$index_group) { // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); $objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe')); $objProfileAttribute->setType('text'); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting"); } } // For the migration, a temporary flag is needed in the orders table // in order to prevent mixing up old and new customer_id values. $table_order_name = DBPREFIX . "module_shop_orders"; if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) { $query = "\n ALTER TABLE `{$table_order_name}`\n ADD `migrated` TINYINT(1) unsigned NOT NULL default 0"; \Cx\Lib\UpdateUtil::sql($query); } // Create missing UserGroups for customers and resellers $objGroup = null; $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); if ($group_id_customer) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Endkunden'); $objGroup->setName('Shop Endkunden'); $objGroup->setType('frontend'); } //DBG::log("Group: ".var_export($objGroup, true)); if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId()); \Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_customer')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for customers"); } $group_id_customer = $objGroup->getId(); $objGroup = null; $group_id_reseller = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); if ($group_id_reseller) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_reseller); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Wiederverkäufer')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Wiederverkäufer'); $objGroup->setName('Shop Wiederverkäufer'); $objGroup->setType('frontend'); } if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for resellers"); } //DBG::log("Customer::errorHandler(): Made reseller usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for resellers"); } \Cx\Core\Setting\Controller\Setting::set('usergroup_id_reseller', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_reseller')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for resellers"); } $group_id_reseller = $objGroup->getId(); $default_lang_id = \FWLanguage::getDefaultLangId(); $query = "\n SELECT `customer`.`customerid`,\n `customer`.`prefix`, `customer`.`firstname`,\n `customer`.`lastname`,\n `customer`.`company`, `customer`.`address`,\n `customer`.`city`, `customer`.`zip`,\n `customer`.`country_id`,\n `customer`.`phone`, `customer`.`fax`,\n `customer`.`email`,\n `customer`.`username`, `customer`.`password`,\n `customer`.`company_note`,\n `customer`.`is_reseller`,\n `customer`.`customer_status`, `customer`.`register_date`,\n `customer`.`group_id`\n FROM `{$table_name_old}` AS `customer`\n ORDER BY `customer`.`customerid` ASC"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { $old_customer_id = $objResult->fields['customerid']; if (empty($objResult->fields['email'])) { $objResult->fields['email'] = $objResult->fields['username']; } $email = $objResult->fields['email']; $objUser = \FWUser::getFWUserObject()->objUser->getUsers(array('email' => array(0 => $email))); // TODO: See whether a User with that username (but different e-mail address) exists! $objUser_name = \FWUser::getFWUserObject()->objUser->getUsers(array('username' => array(0 => $objResult->fields['username']))); if ($objUser && $objUser_name) { $objUser = $objUser_name; } $objCustomer = null; if ($objUser) { $objCustomer = self::getById($objUser->getId()); } if (!$objCustomer) { $lang_id = Order::getLanguageIdByCustomerId($old_customer_id); $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id); if (!$lang_id) { $lang_id = $default_lang_id; } $objCustomer = new Customer(); if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_female'); } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_male'); // } else { // Other "genders", like "family", "thing", or "it" won't be matched // and are left on "gender_unknown". //DBG::log("*** Prefix {$objResult->fields['prefix']}, UNKNOWN GENDER!"); } //DBG::log("Prefix {$objResult->fields['prefix']}, made gender ".$objCustomer->gender()); $objCustomer->company($objResult->fields['company']); $objCustomer->firstname($objResult->fields['firstname']); $objCustomer->lastname($objResult->fields['lastname']); $objCustomer->address($objResult->fields['address']); $objCustomer->city($objResult->fields['city']); $objCustomer->zip($objResult->fields['zip']); $objCustomer->country_id($objResult->fields['country_id']); $objCustomer->phone($objResult->fields['phone']); $objCustomer->fax($objResult->fields['fax']); $objCustomer->email($objResult->fields['email']); $objCustomer->companynote($objResult->fields['company_note']); $objCustomer->active($objResult->fields['customer_status']); // Handled by a UserGroup now, see below //$objCustomer->setResellerStatus($objResult->fields['is_reseller']); $objCustomer->register_date($objResult->fields['register_date']); $objCustomer->group_id($objResult->fields['group_id']); // NOTE: Mind that the User class has been modified to accept e-mail addresses // as usernames! $objCustomer->username($objResult->fields['username']); // Copy the md5 hash of the password! $objCustomer->password = $objResult->fields['password']; $objCustomer->setFrontendLanguage($lang_id); } if ($objResult->fields['is_reseller']) { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_reseller)); //DBG::log("Customer::errorHandler(): Added reseller: ".$objCustomer->id()); } else { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_customer)); //DBG::log("Customer::errorHandler(): Added customer: ".$objCustomer->id()); } if (!$objCustomer->store()) { //DBG::log(var_export($objCustomer, true)); throw new \Cx\Lib\Update_DatabaseException("Failed to migrate existing Customer ID " . $old_customer_id . " to Users (Messages: " . join(', ', $objCustomer->error_msg) . ")"); } // Update the Orders table with the new Customer ID. // Note that we use the ambiguous old customer ID that may // coincide with a new User ID, so to prevent inconsistencies, // migrated Orders are marked as such. $query = "\n UPDATE `{$table_order_name}`\n SET `customer_id`=" . $objCustomer->id() . ",\n `migrated`=1\n WHERE `customer_id`={$old_customer_id}\n AND `migrated`=0"; \Cx\Lib\UpdateUtil::sql($query); // Drop migrated $query = "\n DELETE FROM `{$table_name_old}`\n WHERE `customerid`={$old_customer_id}"; \Cx\Lib\UpdateUtil::sql($query); $objResult->MoveNext(); if (!checkMemoryLimit() || !checkTimeoutLimit()) { return false; } } // Remove the flag, it's no longer needed. // (You could also verify that all records have been migrated by // querying them with "[...] WHERE `migrated`=0", which *MUST* result // in an empty recordset. This is left as an exercise for the reader.) $query = "\n ALTER TABLE `{$table_order_name}`\n DROP `migrated`"; \Cx\Lib\UpdateUtil::sql($query); \Cx\Lib\UpdateUtil::drop_table($table_name_old); //DBG::log("Updated Customer table and related stuff"); // Always return false; }
/** * get the email template lang id for sending mail * * @param Array $availableEmailTemp available email template ids * @param String $email recipient email id * * @return Integer */ function getEmailTempLang($availableEmailTemp = array(), $email = '') { $objFWUser = \FWUser::getFWUserObject(); if (empty($email)) { return false; } $defaultLangId = \FWLanguage::getDefaultLangId(); /** * This IF clause fixes #1799, but there has to be a better solution for this! */ if (!$objFWUser->objUser) { return false; } $objUsers = $objFWUser->objUser->getUsers($filter = array('email' => addslashes($email))); if ($objUsers) { $availableLangId = ''; switch (true) { case $objUsers->getBackendLanguage() && in_array($objUsers->getBackendLanguage(), $availableEmailTemp): $availableLangId = $objUsers->getBackendLanguage(); break; case $objUsers->getFrontendLanguage() && in_array($objUsers->getFrontendLanguage(), $availableEmailTemp): $availableLangId = $objUsers->getFrontendLanguage(); break; case $defaultLangId && in_array($defaultLangId, $availableEmailTemp): $availableLangId = $defaultLangId; break; default: $availableLangId = $availableEmailTemp[0]; break; } return $availableLangId; } else { switch (true) { case $defaultLangId && in_array($defaultLangId, $availableEmailTemp): $availableLangId = $defaultLangId; break; default: $availableLangId = $availableEmailTemp[0]; break; } return $availableLangId; } return false; }
public function copy($arguments) { global $_CORELANG; // Global access check if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) { throw new ContentManagerException($_CORELANG['TXT_CORE_CM_USAGE_DENIED']); } if (!\Permission::checkAccess(53, 'static', true)) { throw new ContentManagerException($_CORELANG['TXT_CORE_CM_COPY_DENIED']); } $node = $this->nodeRepo->find($arguments['get']['id']); if (!$node) { throw new ContentManagerException($_CORELANG['TXT_CORE_CM_COPY_FAILED']); } // this is necessary to get the position of the original node $sortedLevel = array(); foreach ($node->getParent()->getChildren() as $levelNode) { $sortedLevel[$levelNode->getLft()] = $levelNode; } ksort($sortedLevel); $position = 0; foreach ($sortedLevel as $sortedNode) { $position++; if ($sortedNode == $node) { break; } } $this->em->getConnection()->beginTransaction(); try { // copy the node recursively and persist changes $newNode = $node->copy(true); $this->em->flush(); // rename page foreach ($newNode->getPages() as $page) { $title = $page->getTitle() . ' (' . $_CORELANG['TXT_CORE_CM_COPY_OF_PAGE'] . ')'; $i = 1; while ($this->titleExists($node->getParent(), $page->getLang(), $title)) { $i++; if ($page->getLang() == \FWLanguage::getDefaultLangId()) { $position++; } $title = $page->getTitle() . ' (' . sprintf($_CORELANG['TXT_CORE_CM_COPY_N_OF_PAGE'], $i) . ')'; } $page->setTitle($title); $this->em->persist($page); } // move the node to correct position $this->nodeRepo->moveUp($newNode, true); $this->nodeRepo->moveDown($newNode, $position, true); $this->em->persist($newNode); $this->em->flush(); $this->em->getConnection()->commit(); $this->clearCache(); } catch (\Exception $e) { $this->em->getConnection()->rollback(); throw $e; } }