コード例 #1
0
    /**
     * get all news list
     *
     * @return json result
     */
    public function getAllNews($data = array())
    {
        global $objDatabase;
        $searchTerm = isset($data['get']['term']) ? contrexx_input2raw($data['get']['term']) : '';
        $id = isset($data['get']['id']) ? contrexx_input2int($data['get']['id']) : 0;
        $langId = isset($data['get']['langId']) ? contrexx_input2int($data['get']['langId']) : 0;
        if (empty($searchTerm)) {
            $this->messages[] = '';
            //TODO Show error message
        }
        $query = '
            SELECT
                    n.`id`,
                    nl.`title`

            FROM `' . DBPREFIX . 'module_news`          AS `n`
            LEFT JOIN ' . DBPREFIX . 'module_news_locale    AS `nl`
            ON      nl.`news_id` = n.`id`
            WHERE   nl.`is_active`="1"
            AND     n.`status`="1"' . (!empty($id) ? ' AND n.`id`!="' . $id . '"' : '') . (!empty($langId) ? ' AND nl.`lang_id`="' . $langId . '"' : '') . ' AND (
                        nl.title        LIKE "%' . contrexx_raw2db($searchTerm) . '%"
                    OR  nl.teaser_text  LIKE "%' . contrexx_raw2db($searchTerm) . '%"
                )
            ORDER BY nl.`title`';
        $result = array();
        $objResult = $objDatabase->Execute($query);
        if ($objResult && $objResult->RecordCount() > 0) {
            while (!$objResult->EOF) {
                $result[$objResult->fields['id']] = $objResult->fields['title'];
                $objResult->MoveNext();
            }
        }
        return $result;
    }
コード例 #2
0
 function showEntry()
 {
     global $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     //get ids
     $intCategoryId = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
     $intLevelId = isset($_GET['lid']) ? intval($_GET['lid']) : 0;
     $intEntryId = isset($_GET['eid']) ? intval($_GET['eid']) : 0;
     // load source code if cmd value is integer
     if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) {
         $page = new \Cx\Core\ContentManager\Model\Entity\Page();
         $page->setVirtual(true);
         $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
         $page->setModule('MediaDir');
         $page->setCmd('detail');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     //get navtree
     if ($this->_objTpl->blockExists($this->moduleNameLC . 'Navtree') && ($intCategoryId != 0 || $intLevelId != 0)) {
         $this->getNavtree($intCategoryId, $intLevelId);
     }
     if ($intEntryId != 0 && $this->_objTpl->blockExists($this->moduleNameLC . 'EntryList')) {
         $objEntry = new MediaDirectoryEntry($this->moduleName);
         $objEntry->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1);
         $objEntry->listEntries($this->_objTpl, 2);
         $objEntry->updateHits($intEntryId);
         //set meta attributes
         $entries = new MediaDirectoryEntry($this->moduleName);
         $entries->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1);
         $entry = $entries->arrEntries[$intEntryId];
         $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName);
         $inputFields = $objInputfields->getInputfields();
         $titleChanged = false;
         $contentChanged = false;
         foreach ($inputFields as $arrInputfield) {
             $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : '';
             if (!in_array($contextType, array('title', 'content', 'image'))) {
                 continue;
             }
             $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : '';
             $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
             try {
                 $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                 $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null;
                 $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus);
                 switch ($contextType) {
                     case 'title':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'];
                         if ($inputfieldValue) {
                             $this->metaTitle .= ' - ' . $inputfieldValue;
                             $this->pageTitle = $inputfieldValue;
                         }
                         $titleChanged = true;
                         break;
                     case 'content':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'];
                         if ($inputfieldValue) {
                             $this->metaDescription = $inputfieldValue;
                         }
                         $contentChanged = true;
                         break;
                     case 'image':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_SRC'];
                         if ($inputfieldValue) {
                             $this->metaImage = $inputfieldValue;
                         }
                         break;
                     default:
                         break;
                 }
             } catch (\Exception $e) {
                 \DBG::log($e->getMessage());
                 continue;
             }
         }
         $firstInputfieldValue = $entries->arrEntries[$intEntryId]['entryFields'][0];
         if (!$titleChanged && $firstInputfieldValue) {
             $this->pageTitle = $firstInputfieldValue;
             $this->metaTitle = $firstInputfieldValue;
         }
         if (!$contentChanged && $firstInputfieldValue) {
             $this->metaDescription = $firstInputfieldValue;
         }
         if (empty($objEntry->arrEntries)) {
             $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryList');
             $this->_objTpl->clearVariables();
             header("Location: index.php?section=" . $this->moduleName);
             exit;
         }
     } else {
         header("Location: index.php?section=" . $this->moduleName);
         exit;
     }
 }
コード例 #3
0
 function getContent($intEntryId, $arrInputfield, $arrTranslationStatus)
 {
     global $objDatabase, $_LANGID;
     $intId = intval($arrInputfield['id']);
     $intEntryDefaultLang = $objDatabase->getOne("SELECT `lang_id` FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_entries WHERE id=" . intval($intEntryId) . " LIMIT 1");
     if ($this->arrSettings['settingsTranslationStatus'] == 1) {
         $intLangId = in_array($_LANGID, $arrTranslationStatus) ? $_LANGID : contrexx_input2int($intEntryDefaultLang);
     } else {
         $intLangId = $_LANGID;
     }
     $objResult = $objDatabase->Execute("\n            SELECT `value`\n              FROM " . DBPREFIX . "module_mediadir_rel_entry_inputfields\n             WHERE field_id={$intId}\n               AND entry_id={$intEntryId}\n               AND lang_id={$intLangId}\n             LIMIT 1 ");
     if (empty($objResult->fields['value'])) {
         $objResult = $objDatabase->Execute("\n                SELECT `value`\n                  FROM " . DBPREFIX . "module_mediadir_rel_entry_inputfields\n                 WHERE field_id={$intId}\n                   AND entry_id={$intEntryId}\n                   AND lang_id={$intEntryDefaultLang}\n                 LIMIT 1 ");
     }
     $arrValue = explode(",", $objResult->fields['value']);
     $strValue = strip_tags(htmlspecialchars($arrValue[0], ENT_QUOTES, CONTREXX_CHARSET));
     if (!empty($strValue) && $strValue != 'new_file') {
         $arrFileInfo = pathinfo($strValue);
         $strFileName = htmlspecialchars($arrFileInfo['basename'], ENT_QUOTES, CONTREXX_CHARSET);
         if (empty($arrValue[1])) {
             $strName = $strFileName;
         } else {
             $strName = strip_tags(htmlspecialchars($arrValue[1], ENT_QUOTES, CONTREXX_CHARSET));
         }
         $arrContent['TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME'] = htmlspecialchars($arrInputfield['name'][0], ENT_QUOTES, CONTREXX_CHARSET);
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = '<a href="' . urldecode($strValue) . '" alt="' . $strName . '" title="' . $strName . '" target="_blank">' . $strName . '</a>';
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_SRC'] = urldecode($strValue);
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_NAME'] = $strName;
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_FILENAME'] = $strFileName;
     } else {
         $arrContent = null;
     }
     return $arrContent;
 }
コード例 #4
0
 /**
  * Initialize the row sorting functionality
  * 
  * @param string $entityNameSpace entity namespace
  * 
  * @return boolean
  */
 protected function getSortingOption($entityNameSpace)
 {
     //If the entity namespace is empty or an array then disable the row sorting
     if (empty($entityNameSpace) && $entityNameSpace === 'array') {
         return;
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $em = $cx->getDb()->getEntityManager();
     $sortBy = isset($this->options['functions']['sortBy']) && is_array($this->options['functions']['sortBy']) ? $this->options['functions']['sortBy'] : array();
     //If the option 'sortBy' is not set in the function array
     // then disable the row sorting.
     if (empty($sortBy)) {
         return;
     }
     //If the function array has 'order' option and the order by field
     //is not equal to 'sortBy' => 'field' then disable the row sorting
     $sortField = key($this->options['functions']['sortBy']['field']);
     $orderOption = isset($this->options['functions']['order']) && is_array($this->options['functions']['order']) ? key($this->options['functions']['order']) : array();
     if (!empty($orderOption) && stripos($orderOption, $sortField) === false) {
         return;
     }
     //get the primary key name
     $entityObject = $em->getClassMetadata($entityNameSpace);
     $primaryKeyName = $entityObject->getSingleIdentifierFieldName();
     //If the 'sortBy' option does not have 'jsonadapter',
     //we need to get the component name and entity name for updating the sorting order in db
     $componentName = '';
     $entityName = '';
     if (!isset($sortBy['jsonadapter']) || isset($sortBy['jsonadapter']) && (empty($sortBy['jsonadapter']['object']) || empty($sortBy['jsonadapter']['act']))) {
         $split = explode('\\', $entityNameSpace);
         $componentName = isset($split[2]) ? $split[2] : '';
         $entityName = isset($split) ? end($split) : '';
     }
     //If 'sorting' is applied and sorting field is not equal to
     //'sortBy' => 'field' then disable the row sorting.
     $orderParamName = $entityName . 'Order';
     if (isset($_GET[$orderParamName]) && stripos($_GET[$orderParamName], $sortField) === false) {
         return;
     }
     //Get the current sorting order
     $order = isset($_GET[$orderParamName]) ? explode('/', $_GET[$orderParamName]) : '';
     $sortOrder = $sortBy['field'][$sortField] == SORT_ASC ? 'ASC' : 'DESC';
     if ($order) {
         $sortOrder = !empty($order[1]) ? $order[1] : 'ASC';
     }
     //Get the paging position value
     $pagingPosName = $entityName . 'Pos';
     $pagingPosition = isset($_GET[$pagingPosName]) ? contrexx_input2int($_GET[$pagingPosName]) : 0;
     //set the sorting parameters in the functions 'sortBy' array and
     //it should be used in the Backend::constructor
     $this->options['functions']['sortBy']['sortingKey'] = $primaryKeyName;
     $this->options['functions']['sortBy']['component'] = $componentName;
     $this->options['functions']['sortBy']['entity'] = $entityName;
     $this->options['functions']['sortBy']['sortOrder'] = $sortOrder;
     $this->options['functions']['sortBy']['pagingPosition'] = $pagingPosition;
     //Register the script Backend.js and activate the jqueryui and cx for the row sorting
     \JS::registerJS(substr($cx->getCoreFolderName() . '/Html/View/Script/Backend.js', 1));
 }
コード例 #5
0
 /**
  * Remove the file from folder widget
  *
  * @param array $params array from json request
  */
 public function removeFileFromFolderWidget($params)
 {
     \cmsSession::getInstance();
     $folderWidgetId = isset($params['get']['widget']) ? contrexx_input2int($params['get']['widget']) : 0;
     if (empty($folderWidgetId) || empty($_SESSION['MediaBrowser']['FolderWidget'][$folderWidgetId]) || $_SESSION['MediaBrowser']['FolderWidget'][$folderWidgetId]['mode'] == \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget::MODE_VIEW_ONLY) {
         return false;
     }
     $path = !empty($params['get']['file']) ? contrexx_input2raw($params['get']['file']) : null;
     if (empty($path)) {
         return false;
     }
     $folder = $_SESSION['MediaBrowser']['FolderWidget'][$folderWidgetId]['folder'];
     $localFileSystem = new \Cx\Core\MediaSource\Model\Entity\LocalFileSystem($folder);
     $file = '/' . $path;
     $objFile = new \Cx\Core\MediaSource\Model\Entity\LocalFile($file);
     $this->setMessage($localFileSystem->removeFile($objFile));
     return array();
 }
コード例 #6
0
ファイル: Calendar.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Loads the event manager
  * 
  * @return null
  */
 function loadEventManager()
 {
     $term = isset($_GET['term']) ? contrexx_input2raw($_GET['term']) : '';
     $from = isset($_GET['from']) ? contrexx_input2raw($_GET['from']) : '';
     $till = isset($_GET['till']) ? contrexx_input2raw($_GET['till']) : '';
     $catid = isset($_GET['catid']) ? contrexx_input2raw($_GET['catid']) : '';
     $cmd = isset($_GET['cmd']) ? contrexx_input2raw($_GET['cmd']) : '';
     // get startdate
     if (!empty($from)) {
         $this->startDate = $this->getDateTime($from);
     } else {
         if ($cmd == 'archive') {
             $this->startDate = null;
             $this->sortDirection = 'DESC';
         } else {
             $this->startDate = new \DateTime();
             $startDay = isset($_GET['day']) ? $_GET['day'] : $this->startDate->format('d');
             $startMonth = isset($_GET['month']) ? $_GET['month'] : $this->startDate->format('m');
             $startYear = isset($_GET['year']) ? $_GET['year'] : $this->startDate->format('Y');
             $this->startDate->setDate($startYear, $startMonth, $startDay);
             $this->startDate->setTime(0, 0, 0);
         }
     }
     // get enddate
     if (!empty($till)) {
         $this->endDate = $this->getDateTime($till);
     } else {
         if ($cmd == 'archive') {
             $this->endDate = new \DateTime();
         } else {
             $this->endDate = new \DateTime();
             $endDay = isset($_GET['endDay']) ? $_GET['endDay'] : $this->endDate->format('d');
             $endMonth = isset($_GET['endMonth']) ? $_GET['endMonth'] : $this->endDate->format('m');
             $endYear = isset($_GET['endYear']) ? $_GET['endYear'] : $this->endDate->format('Y');
             $endYear = empty($_GET['endYear']) && empty($_GET['endMonth']) ? $endYear + 10 : $endYear;
             $this->endDate->setDate($endYear, $endMonth, $endDay);
             $this->endDate->setTime(23, 59, 59);
         }
     }
     // get datepicker-time
     if ((isset($_REQUEST["yearID"]) || isset($_REQUEST["monthID"]) || isset($_REQUEST["dayID"])) && $cmd != 'boxes') {
         $this->startDate = new \DateTime();
         $year = isset($_REQUEST["yearID"]) ? (int) $_REQUEST["yearID"] : $this->startDate->format('Y');
         $month = isset($_REQUEST["monthID"]) ? (int) $_REQUEST["monthID"] : $this->startDate->format('m');
         $day = isset($_REQUEST["dayID"]) ? (int) $_REQUEST["dayID"] : $this->startDate->format('d');
         $this->startDate->setDate($year, $month, $day);
         $this->startDate->modify("first day of this month");
         $this->startDate->setTime(0, 0, 0);
         $this->endDate = clone $this->startDate;
         // add months for the list view(month view)
         if ((empty($_GET['act']) || $_GET['act'] != 'list') && empty($_REQUEST['dayID'])) {
             $this->endDate->modify("+{$this->boxCount} months");
         }
         $this->endDate->modify("last day of this month");
         $this->endDate->setTime(23, 59, 59);
     } elseif (isset($_GET["yearID"]) && isset($_GET["monthID"]) && isset($_GET["dayID"])) {
         $this->startDate = new \DateTime();
         $year = isset($_REQUEST["yearID"]) ? (int) $_REQUEST["yearID"] : $this->startDate->format('Y');
         $month = isset($_REQUEST["monthID"]) ? (int) $_REQUEST["monthID"] : $this->startDate->format('m');
         $day = isset($_REQUEST["dayID"]) ? (int) $_REQUEST["dayID"] : $this->startDate->format('d');
         $this->startDate->setDate($year, $month, $day);
         $this->startDate->setTime(0, 0, 0);
         $this->endDate = clone $this->startDate;
         $this->endDate->setTime(23, 59, 59);
     }
     // In case $_GET['cmd'] is an integer, then we shall treat it as the
     // ID of a category and switch to category-mode
     if (!empty($cmd) && (string) intval($cmd) == $cmd) {
         $catid = intval($cmd);
         $cmd == 'category';
         $this->simulateCategoryView = true;
     }
     $this->searchTerm = !empty($term) ? contrexx_raw2db($term) : null;
     $this->categoryId = !empty($catid) ? intval($catid) : null;
     if ($cmd == 'boxes' || $cmd == 'category') {
         $this->startPos = 0;
         $this->numEvents = 'n';
     } else {
         if (!isset($_GET['search']) && ($cmd != 'list' && $cmd != 'eventlist' && $cmd != 'archive')) {
             $this->startPos = 0;
             $this->numEvents = $this->arrSettings['numEntrance'];
         } else {
             $this->startPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
             $this->numEvents = $this->arrSettings['numPaging'];
         }
     }
     if ($cmd == 'detail') {
         $this->startDate = null;
         $this->numEvents = 'n';
     }
     if ($cmd == 'my_events') {
         $objFWUser = \FWUser::getFWUserObject();
         $objUser = $objFWUser->objUser;
         $this->author = intval($objUser->getId());
     } else {
         $this->author = null;
     }
     $this->objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $this->categoryId, $this->searchTerm, true, $this->needAuth, true, $this->startPos, $this->numEvents, $this->sortDirection, true, $this->author);
     if (!in_array($cmd, array('detail', 'register'))) {
         $this->objEventManager->getEventList();
     } else {
         /* if($_GET['external'] == 1 && $this->arrSettings['publicationStatus'] == 1) {
                $this->objEventManager->getExternalEvent(intval($_GET['id']), intval($_GET['date'])); 
            } else { */
         $eventId = isset($_REQUEST['id']) ? contrexx_input2int($_REQUEST['id']) : 0;
         $date = isset($_REQUEST['date']) ? contrexx_input2int($_REQUEST['date']) : 0;
         $this->objEventManager->getEvent($eventId, $date);
         /* } */
     }
 }
コード例 #7
0
ファイル: News.class.php プロジェクト: nahakiole/cloudrexx
 /**
  * Gets the list with the headlines
  *
  * @global    array
  * @global    ADONewConnection
  * @global    array
  * @return    string    parsed content
  */
 private function getHeadlines()
 {
     global $_CONFIG, $objDatabase, $_ARRAYLANG, $_LANGID;
     // load source code if cmd value is integer
     if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) {
         $page = new \Cx\Core\ContentManager\Model\Entity\Page();
         $page->setVirtual(true);
         $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
         $page->setModule('News');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $validToShowList = true;
     $newsCategories = array();
     $menuCategories = array();
     $parameters = array();
     $selectedCat = '';
     $selectedType = '';
     $selectedPublisher = '';
     $selectedAuthor = '';
     $newsfilter = '';
     $paging = '';
     $pos = 0;
     $i = 0;
     if (isset($_GET['pos'])) {
         $pos = intval($_GET['pos']);
     }
     $catFromCmd = !empty($_REQUEST['cmd']) ? explode(',', $_REQUEST['cmd']) : array();
     $catFromReq = !empty($_REQUEST['category']) ? explode(',', $_REQUEST['category']) : array();
     if (!empty($catFromCmd)) {
         $menuCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($catFromCmd));
         if ($this->_objTpl->placeholderExists('NEWS_CMD')) {
             $this->_objTpl->setVariable('NEWS_CMD', $_REQUEST['cmd']);
         }
     }
     $newsCategories = $categories = !empty($catFromReq) ? $catFromReq : (!empty($catFromCmd) ? $catFromCmd : array());
     if (count($newsCategories) == 1 && $this->categoryExists($newsCategories[0])) {
         $selectedCat = intval($newsCategories[0]);
     }
     if (empty($newsCategories)) {
         $newsCategories[] = $this->nestedSetRootId;
     }
     $newsCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($newsCategories));
     if (!empty($newsCategories)) {
         $newsfilter .= ' AND (`nc`.`category_id` IN (' . implode(',', $newsCategories) . '))';
     }
     if ($this->_objTpl->placeholderExists('NEWS_CAT_DROPDOWNMENU')) {
         $catMenu = '<select onchange="this.form.submit()" name="category">' . "\n";
         $catMenu .= '<option value="">' . $_ARRAYLANG['TXT_CATEGORY'] . '</option>' . "\n";
         $catMenu .= $this->getCategoryMenu(!empty($menuCategories) ? $menuCategories : array(), array($selectedCat)) . "\n";
         $catMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_CAT_DROPDOWNMENU', $catMenu);
     }
     //Filter by types
     if ($this->arrSettings['news_use_types'] == 1) {
         if (!empty($_REQUEST['type'])) {
             $arrTypes = explode(',', $_REQUEST['type']);
             if (!empty($arrTypes)) {
                 $newsfilter .= ' AND (`n`.`typeid` IN (' . implode(', ', contrexx_input2int($arrTypes)) . '))';
             }
             $selectedType = current($arrTypes);
         }
         if ($this->_objTpl->placeholderExists('NEWS_TYPE_DROPDOWNMENU')) {
             $typeMenu = '<select onchange="this.form.submit()" name="type">' . "\n";
             $typeMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_TYPE'] . '</option>' . "\n";
             $typeMenu .= $this->getTypeMenu($selectedType) . "\n";
             $typeMenu .= '</select>' . "\n";
             $this->_objTpl->setVariable('NEWS_TYPE_DROPDOWNMENU', $typeMenu);
         }
     }
     //Filter by publisher
     if (!empty($_REQUEST['publisher'])) {
         $parameters['filterPublisher'] = $publisher = contrexx_input2raw($_REQUEST['publisher']);
         $arrPublishers = explode(',', $publisher);
         if (!empty($arrPublishers)) {
             $newsfilter .= ' AND (`n`.`publisher_id` IN (' . implode(', ', contrexx_input2int($arrPublishers)) . '))';
         }
         $selectedPublisher = current($arrPublishers);
     }
     if ($this->_objTpl->placeholderExists('NEWS_PUBLISHER_DROPDOWNMENU')) {
         $publisherMenu = '<select onchange="window.location=\'' . \Cx\Core\Routing\Url::fromModuleAndCmd('News', intval($_REQUEST['cmd'])) . '&amp;publisher=\'+this.value" name="publisher">' . "\n";
         $publisherMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_PUBLISHER'] . '</option>' . "\n";
         $publisherMenu .= $this->getPublisherMenu($selectedPublisher, $selectedCat) . "\n";
         $publisherMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_PUBLISHER_DROPDOWNMENU', $publisherMenu);
     }
     //Filter by Author
     if (!empty($_REQUEST['author'])) {
         $parameters['filterAuthor'] = $author = contrexx_input2raw($_REQUEST['author']);
         $arrAuthors = explode(',', $author);
         if (!empty($arrAuthors)) {
             $newsfilter .= ' AND (`n`.`author_id` IN (' . implode(', ', contrexx_input2int($arrAuthors)) . '))';
         }
         $selectedAuthor = current($arrAuthors);
     }
     if ($this->_objTpl->placeholderExists('NEWS_AUTHOR_DROPDOWNMENU')) {
         $authorMenu = '<select onchange="this.form.submit()" name="author">' . "\n";
         $authorMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_AUTHOR'] . '</option>' . "\n";
         $authorMenu .= $this->getAuthorMenu($selectedAuthor) . "\n";
         $authorMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_AUTHOR_DROPDOWNMENU', $authorMenu);
     }
     //Filter by tag
     if (!empty($_REQUEST['tag'])) {
         $parameters['filterTag'] = $searchTag = contrexx_input2raw($_REQUEST['tag']);
         $searchedTag = $this->getNewsTags(null, $searchTag);
         $searchedTagId = current(array_keys($searchedTag['tagList']));
         if (!empty($searchedTag['newsIds'])) {
             $this->incrementViewingCount($searchedTagId);
             $newsfilter .= ' AND n.`id` IN (' . implode(',', $searchedTag['newsIds']) . ')';
             $this->_objTpl->setVariable(array('NEWS_FILTER_TAG_ID' => $searchedTagId, 'NEWS_FILTER_TAG_NAME' => ucfirst(current($searchedTag['tagList']))));
             if ($this->_objTpl->blockExists('tagFilterCont')) {
                 $this->_objTpl->parse('tagFilterCont');
             }
         } else {
             $validToShowList = false;
         }
     }
     $this->_objTpl->setVariable(array('TXT_PERFORM' => $_ARRAYLANG['TXT_PERFORM'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_TYPE' => $this->arrSettings['news_use_types'] == 1 ? $_ARRAYLANG['TXT_TYPE'] : '', 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_NEWS_MESSAGE']));
     $query = '  SELECT      n.id                AS newsid,
                             n.userid            AS newsuid,
                             n.date              AS newsdate,
                             n.teaser_image_path,
                             n.teaser_image_thumbnail_path,
                             n.redirect,
                             n.publisher,
                             n.publisher_id,
                             n.author,
                             n.author_id,
                             n.allow_comments AS commentactive,
                             n.enable_tags,
                             nl.title            AS newstitle,
                             nl.text NOT REGEXP \'^(<br type="_moz" />)?$\' AS newscontent,
                             nl.teaser_text
                 FROM        ' . DBPREFIX . 'module_news AS n
                 INNER JOIN  ' . DBPREFIX . 'module_news_locale AS nl ON nl.news_id = n.id
                 INNER JOIN  ' . DBPREFIX . 'module_news_rel_categories AS nc ON nc.news_id = n.id
                 WHERE       status = 1
                             AND nl.is_active=1
                             AND nl.lang_id=' . FRONTEND_LANG_ID . '
                             AND (n.startdate<=\'' . date('Y-m-d H:i:s') . '\' OR n.startdate="0000-00-00 00:00:00")
                             AND (n.enddate>=\'' . date('Y-m-d H:i:s') . '\' OR n.enddate="0000-00-00 00:00:00")
                             ' . $newsfilter . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . ' GROUP BY newsid ' . ' ORDER BY newsdate DESC';
     /***start paging ****/
     $objResult = $objDatabase->Execute($query);
     $count = $objResult->RecordCount();
     $category = '';
     if (!empty($_REQUEST['cmd'])) {
         $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['cmd']);
         $category .= '&cmd=' . $_REQUEST['cmd'];
     }
     if (!empty($_REQUEST['category'])) {
         $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['category']);
         $category .= '&category=' . $_REQUEST['category'];
     }
     $type = '';
     if (!empty($_REQUEST['type'])) {
         $parameters['filterType'] = contrexx_input2raw($_REQUEST['type']);
         $type = '&type=' . $selectedType;
     }
     if ($count > intval($_CONFIG['corePagingLimit'])) {
         $paging = getPaging($count, $pos, '&section=News' . $category . $type, $_ARRAYLANG['TXT_NEWS_MESSAGES'], true);
     }
     $this->_objTpl->setVariable('NEWS_PAGING', $paging);
     $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos);
     /*** end paging ***/
     if ($count >= 1 && $validToShowList) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['newsid'];
             $newstitle = $objResult->fields['newstitle'];
             $newsCommentActive = $objResult->fields['commentactive'];
             $arrNewsCategories = $this->getCategoriesByNewsId($newsid);
             $parameters['newsid'] = $newsid;
             $newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($arrNewsCategories), $categories)), FRONTEND_LANG_ID, $parameters) : $objResult->fields['redirect'];
             $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);
             }
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $objSubResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $objResult->fields['newsid']);
             if (empty($arrNewsCategories) && $this->_objTpl->blockExists('newsCategories')) {
                 $this->_objTpl->hideBlock('newsCategories');
             }
             $this->_objTpl->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['newsdate']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['newsdate']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['newsdate']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_CATEGORY' => implode(', ', contrexx_raw2xhtml($arrNewsCategories)), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_COUNT_COMMENTS' => contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS'])));
             if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) {
                 if ($this->_objTpl->blockExists('news_comments_count')) {
                     $this->_objTpl->hideBlock('news_comments_count');
                 }
             }
             if (!empty($image)) {
                 $this->_objTpl->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
                 if ($this->_objTpl->blockExists('news_image')) {
                     $this->_objTpl->parse('news_image');
                 }
             } else {
                 if ($this->_objTpl->blockExists('news_image')) {
                     $this->_objTpl->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             if (!empty($this->arrSettings['news_use_tags']) && !empty($objResult->fields['enable_tags'])) {
                 $this->parseNewsTags($this->_objTpl, $newsid);
             }
             $this->_objTpl->parse('newsrow');
             $i++;
             $objResult->MoveNext();
         }
         if ($this->_objTpl->blockExists('news_list')) {
             $this->_objTpl->parse('news_list');
         }
         if ($this->_objTpl->blockExists('news_menu')) {
             $this->_objTpl->parse('news_menu');
         }
         if ($this->_objTpl->blockExists('news_status_message')) {
             $this->_objTpl->hideBlock('news_status_message');
         }
     } else {
         $this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']);
         if ($this->_objTpl->blockExists('news_status_message')) {
             $this->_objTpl->parse('news_status_message');
         }
         if ($this->_objTpl->blockExists('news_menu')) {
             $this->_objTpl->parse('news_menu');
         }
         if ($this->_objTpl->blockExists('news_list')) {
             $this->_objTpl->hideBlock('news_list');
         }
     }
     return $this->_objTpl->get();
 }
コード例 #8
0
 /**
  * Get News Filter Condition Query
  * 
  * @param string $tableAlias
  * @param array  $filters
  * @param string $filterCategory category filter 
  * 
  * @return string  sql query
  */
 public function getNewsFilterQuery($tableAlias, $filters, $filterCategory)
 {
     $filterCondition = " AND {$tableAlias}.status = 1\n                    AND nl.is_active=1\n                    AND nl.lang_id=" . FRONTEND_LANG_ID . "\n                    AND ({$tableAlias}.startdate<='" . date('Y-m-d H:i:s') . "' OR {$tableAlias}.startdate=\"0000-00-00 00:00:00\")\n                    AND ({$tableAlias}.enddate>='" . date('Y-m-d H:i:s') . "' OR {$tableAlias}.enddate=\"0000-00-00 00:00:00\")" . ($this->arrSettings['news_message_protection'] == '1' && !Permission::hasAllAccess() ? ($objFWUser = FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '');
     if (!empty($filters)) {
         $additionalFilter = '';
         foreach ($filters as $field => $values) {
             $additionalFilter .= ' AND (`' . $tableAlias . '`.`' . $field . '` IN (' . implode(',', contrexx_input2int($values)) . '))';
         }
         $filterCondition .= $additionalFilter;
     }
     if (!empty($filterCategory)) {
         $filterCondition .= $filterCategory;
     }
     return $filterCondition;
 }
コード例 #9
0
ファイル: CrmTask.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * get task overview page
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 public function overview()
 {
     global $_ARRAYLANG, $objDatabase;
     \JS::registerJS('lib/javascript/jquery.tmpl.min.js');
     $objtpl = $this->_objTpl;
     $_SESSION['pageTitle'] = $_ARRAYLANG['TXT_CRM_TASK_OVERVIEW'];
     $objtpl->loadTemplateFile("module_{$this->moduleNameLC}_tasks_overview.html");
     $objtpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $msg = isset($_GET['mes']) ? base64_decode($_GET['mes']) : '';
     if ($msg) {
         switch ($msg) {
             case 'taskDeleted':
                 $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_DELETE_MESSAGE'];
                 break;
         }
     }
     $filterTaskType = isset($_GET['searchType']) ? intval($_GET['searchType']) : 0;
     $filterTaskStatus = !empty($_GET['status']) && is_array($_GET['status']) ? contrexx_input2int($_GET['status']) : array(0);
     $filterTaskTitle = isset($_GET['searchTitle']) ? contrexx_input2raw($_GET['searchTitle']) : '';
     $sortField = isset($_GET['sort_by']) && array_key_exists($_GET['sort_by'], $this->_sortFields) ? (int) $_GET['sort_by'] : 2;
     $sortOrder = isset($_GET['sort_order']) && $_GET['sort_order'] == 1 ? 1 : 0;
     $filter = array();
     $filterLink = '';
     if (!empty($filterTaskType)) {
         $filter[] = " t.task_type_id = '{$filterTaskType}'";
         $filterLink .= "&searchType={$filterTaskType}";
     }
     if (!empty($filterTaskTitle)) {
         $filter[] = " t.task_title LIKE '%{$filterTaskTitle}%' OR c.customer_name LIKE '%{$filterTaskTitle}%'";
         $filterLink .= "&searchTitle={$filterTaskTitle}";
     }
     if (!empty($filterTaskStatus)) {
         $filter[] = ' t.task_status IN (' . implode(" ,", $filterTaskStatus) . ')';
         $filterLink .= '&status[]=' . implode('&status[]=', $filterTaskStatus);
     }
     $filterCondition = !empty($filter) ? " WHERE " . implode(" AND", $filter) : '';
     $query = "SELECT tt.name,\n                               tt.icon,\n                               t.task_status,\n                               t.id AS taskId,\n                               t.task_id,\n                               t.task_title,\n                               t.task_type_id,\n                               t.added_by,\n                               t.assigned_to,\n                               c.customer_name,\n                               c.contact_familyname,\n                               t.due_date,\n                               t.description,\n                               c.id AS customer_id\n                            FROM " . DBPREFIX . "module_{$this->moduleNameLC}_task as t\n                            LEFT JOIN " . DBPREFIX . "module_{$this->moduleNameLC}_task_types as tt\n                            ON (t.task_type_id=tt.id)\n                            LEFT JOIN " . DBPREFIX . "module_{$this->moduleNameLC}_contacts as c\n                            ON (t.customer_id = c.id) {$filterCondition}";
     /* Start Paging ------------------------------------ */
     $intPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
     $intPerPage = $this->getPagingLimit();
     $strPagingSource = getPaging($this->countRecordEntries($query), $intPos, "&amp;cmd=" . $this->moduleName . "&amp;act=task{$filterLink}", false, '', $intPerPage);
     $this->_objTpl->setVariable('ENTRIES_PAGING', $strPagingSource);
     /* End Paging -------------------------------------- */
     $start = $intPos ? $intPos : 0;
     $sorto = $sortOrder ? 'DESC' : 'ASC';
     $query .= " ORDER BY {$this->_sortFields[$sortField]['column']} {$sorto} LIMIT {$start}, {$intPerPage}";
     $objResult = $objDatabase->Execute($query);
     $row = 'row2';
     $now = strtotime('now');
     if ($objResult) {
         if ($objResult->RecordCount() == 0) {
             $objtpl->setVariable(array('TXT_NO_RECORDS_FOUND' => $_ARRAYLANG['TXT_CRM_NO_RECORDS_FOUND']));
             $objtpl->touchblock('noRecords');
         } else {
             $objtpl->hideblock('noRecords');
             while (!$objResult->EOF) {
                 list($task_edit_permission, $task_delete_permission, $task_status_update_permission) = $this->getTaskPermission((int) $objResult->fields['added_by'], (int) $objResult->fields['assigned_to']);
                 if (!$task_edit_permission) {
                     $objtpl->hideblock('task_edit_block');
                 }
                 if (!$task_delete_permission) {
                     $objtpl->hideblock('task_delete_block');
                 }
                 if (!$task_status_update_permission) {
                     $objtpl->hideblock('task_status_block');
                 } else {
                     $objtpl->hideblock('task_image_block');
                 }
                 $objtpl->setVariable(array('CRM_TASK_ID' => (int) $objResult->fields['taskId'], 'CRM_TASKTITLE' => contrexx_raw2xhtml($objResult->fields['task_title']), 'CRM_TASKICON' => !empty($objResult->fields['icon']) ? \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesCrmWebPath() . '/' . contrexx_raw2xhtml($objResult->fields['icon']) . "_24X24.thumb" : '../modules/Crm/View/Media/task_default.png', 'CRM_TASKTYPE' => contrexx_raw2xhtml($objResult->fields['task_type_id']), 'CRM_CUSTOMERNAME' => contrexx_raw2xhtml($objResult->fields['customer_name'] . " " . $objResult->fields['contact_familyname']), 'CRM_DUEDATE' => contrexx_raw2xhtml(date('h:i A Y-m-d', strtotime($objResult->fields['due_date']))), 'TXT_STATUS' => (int) $objResult->fields['task_status'], 'CRM_TASK_TYPE_ACTIVE' => $objResult->fields['task_status'] == 1 ? 'led_green.gif' : 'led_red.gif', 'TXT_ROW' => $row = $row == 'row2' ? 'row1' : 'row2', 'CRM_ADDEDBY' => contrexx_raw2xhtml($this->getUserName($objResult->fields['assigned_to'])), 'CRM_TASK_CUSTOMER_ID' => (int) $objResult->fields['customer_id'], 'TXT_CRM_IMAGE_EDIT' => $_ARRAYLANG['TXT_CRM_IMAGE_EDIT'], 'TXT_CRM_IMAGE_DELETE' => $_ARRAYLANG['TXT_CRM_IMAGE_DELETE'], 'TXT_CRM_DELETE_CONFIRM' => $_ARRAYLANG['TXT_CRM_DELETE_CONFIRM'], 'CRM_TASK_EXPIRED_CLASS' => $objResult->fields['task_status'] == 1 || strtotime($objResult->fields['due_date']) > $now ? '' : 'task_expired'));
                 $objtpl->parse('showTask');
                 $objResult->MoveNext();
             }
         }
     }
     $objType = $objDatabase->Execute("SELECT id,name FROM " . DBPREFIX . "module_{$this->moduleNameLC}_task_types ORDER BY sorting");
     if ($objType) {
         while (!$objType->EOF) {
             $selected = $objType->fields['id'] == $filterTaskType ? 'selected="selected"' : '';
             $objtpl->setVariable(array('CRM_TASK_ID' => (int) $objType->fields['id'], 'TXT_TASK_NAME' => contrexx_raw2xhtml($objType->fields['name']), 'TXT_TASK_SELECTED' => $selected));
             $objtpl->parse('tastType');
             $objType->MoveNext();
         }
     }
     foreach ($this->_sortFields as $key => $value) {
         $selected = $key == $sortField ? "selected='selected'" : '';
         $objtpl->setVariable(array('CRM_FILTER_SORT_ID' => $key, 'CRM_FILTER_SORT_FIELD' => $_ARRAYLANG[$value['name']], 'CRM_FILTER_SORT_FIELD_SELECTED' => $selected));
         $objtpl->parse('sort_fields');
     }
     $sortIcons = array('../modules/Crm/View/Media/Actions-view-sort-ascending-icon.png', '../modules/Crm/View/Media/Actions-view-sort-descending-icon.png');
     $objtpl->setGlobalVariable(array('TXT_SEARCH_VALUE' => contrexx_raw2xhtml($filterTaskTitle), 'CRM_TASK_SORT_ORDER' => $sortOrder, 'CRM_TASK_SORT_ORDER_ICON' => $sortIcons[$sortOrder], 'CRM_TASK_SORT_ORDER_TITLE' => $sortOrder ? 'descending' : 'ascending', 'CRM_TASK_SORT_ORDER_ICONS' => json_encode($sortIcons), 'CRM_REDIRECT_LINK' => '&redirect=' . base64_encode("&act=task{$filterLink}&pos={$intPos}"), 'CRM_TASK_STATUS_OPEN' => !empty($filterTaskStatus) && in_array(0, $filterTaskStatus) ? 'checked="checked"' : '', 'CRM_TASK_STATUS_COMPLETED' => !empty($filterTaskStatus) && in_array(1, $filterTaskStatus) ? 'checked="checked"' : '', 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_ADD_TASK' => $_ARRAYLANG['TXT_CRM_ADD_TASK'], 'TXT_CRM_ADD_IMPORT' => $_ARRAYLANG['TXT_CRM_ADD_IMPORT'], 'TXT_CRM_ADD_EXPORT' => $_ARRAYLANG['TXT_CRM_ADD_EXPORT'], "TXT_CRM_FUNCTIONS" => $_ARRAYLANG['TXT_CRM_FUNCTIONS'], 'TXT_CRM_TASK_TYPE_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_TASK_TYPE_DESCRIPTION'], 'TXT_CRM_TASK_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE'], 'TXT_CRM_TASK_DUE_DATE' => $_ARRAYLANG['TXT_CRM_TASK_DUE_DATE'], 'TXT_CRM_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_TASK_TYPE'], 'TXT_CRM_TASK_TITLE' => $_ARRAYLANG['TXT_CRM_TASK_TITLE'], 'TXT_CRM_TASK_ID' => $_ARRAYLANG['TXT_CRM_TASK_ID'], 'TXT_CRM_TASK_STATUS' => $_ARRAYLANG['TXT_CRM_TASK_STATUS'], 'TXT_CRM_TASK' => $_ARRAYLANG['TXT_CRM_TASK'], 'TXT_CRM_SELECT_ALL' => $_ARRAYLANG['TXT_CRM_SELECT_ALL'], 'TXT_CRM_DESELECT_ALL' => $_ARRAYLANG['TXT_CRM_REMOVE_SELECTION'], 'TXT_CRM_SELECT_ACTION' => $_ARRAYLANG['TXT_CRM_SELECT_ACTION'], 'TXT_CRM_NO_OPERATION' => $_ARRAYLANG['TXT_CRM_NO_OPERATION'], 'TXT_CRM_ACTIVATESELECTED' => $_ARRAYLANG['TXT_CRM_ACTIVATESELECTED'], 'TXT_CRM_DEACTIVATESELECTED' => $_ARRAYLANG['TXT_CRM_DEACTIVATESELECTED'], 'TXT_CRM_DELETE_SELECTED' => $_ARRAYLANG['TXT_CRM_DELETE_SELECTED'], 'TXT_CRM_DELETE_CONFIRM' => $_ARRAYLANG['TXT_CRM_DELETE_CONFIRM'], 'TXT_CRM_FILTERS' => $_ARRAYLANG['TXT_CRM_FILTERS'], 'TXT_CRM_SEARCH' => $_ARRAYLANG['TXT_CRM_SEARCH'], 'TXT_CRM_ENTER_SEARCH_TERM' => $_ARRAYLANG['TXT_CRM_ENTER_SEARCH_TERM'], 'TXT_CRM_FILTER_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_FILTER_TASK_TYPE'], 'TXT_CRM_TASK_OPEN' => $_ARRAYLANG['TXT_CRM_TASK_OPEN'], 'TXT_CRM_TASK_COMPLETED' => $_ARRAYLANG['TXT_CRM_TASK_COMPLETED'], 'TXT_CRM_FILTER_SORT_BY' => $_ARRAYLANG['TXT_CRM_FILTER_SORT_BY'], 'TXT_CRM_FILTER_STATUS' => $_ARRAYLANG['TXT_CRM_FILTER_STATUS'], 'TXT_CRM_TASK_STATUS_OPEN' => $_ARRAYLANG['TXT_CRM_TASK_STATUS_OPEN'], 'TXT_CRM_TASK_STATUS_COMPLETED' => $_ARRAYLANG['TXT_CRM_TASK_STATUS_COMPLETED']));
 }
コード例 #10
0
ファイル: Country.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Returns matched array of Countries data for the given Name
  *
  * The array created is of the form
  *  array(
  *    'id'           => country ID,
  *    'name'         => country name,
  *    'alpha2'       => alpha-2 (two letter) code,
  *    'alpha3'       => alpha-3 (three letter) code,
  *    'active'       => boolean,
  *    'ord'          => ordinal value,
  *  ),
  * The Countries are returned in the current frontend language
  * as set in FRONTEND_LANG_ID, except if the optional $lang_id
  * argument is not empty.
  *
  * @param   string    $term     The search term to get countries
  * @param   integer   $lang_id  The optional language ID
  * @return  array               The Country array on success,
  *                              false otherwise
  */
 static function searchByName($term, $lang_id = null, $active = true)
 {
     global $objDatabase;
     $lang_id = contrexx_input2int($lang_id);
     if (empty($lang_id)) {
         $lang_id = FRONTEND_LANG_ID;
     }
     $arrSqlName = \Text::getSqlSnippets('`country`.`id`', $lang_id, 'core', array('name' => self::TEXT_NAME));
     $query = '
         SELECT `country`.`id`,
                `country`.`alpha2`,
                `country`.`alpha3`,
                `country`.`ord`,
                `country`.`active`, 
                ' . $arrSqlName['field'] . '
           FROM `' . DBPREFIX . 'core_country` AS `country`
               ' . $arrSqlName['join'] . '
          WHERE ' . $arrSqlName['alias']['name'] . ' LIKE "%' . contrexx_raw2db($term) . '%"';
     $countries = $objDatabase->Execute($query);
     if (!$countries) {
         return array();
     }
     $arrCountries = array();
     while (!$countries->EOF) {
         $id = $countries->fields['id'];
         $strName = $countries->fields['name'];
         if ($active && !$countries->fields['active']) {
             $countries->MoveNext();
             continue;
         }
         if ($strName === null) {
             $objText = \Text::getById($id, 'core', self::TEXT_NAME);
             if ($objText) {
                 $strName = $objText->content();
             }
         }
         $arrCountries[] = array('id' => $id, 'name' => $strName, 'ord' => $countries->fields['ord'], 'alpha2' => $countries->fields['alpha2'], 'alpha3' => $countries->fields['alpha3'], 'active' => $countries->fields['active']);
         $countries->MoveNext();
     }
     return $arrCountries;
 }
コード例 #11
0
 function settings_save_mask($arrData)
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase;
     $intMaskId = intval($arrData['maskId']);
     $strMaskTitle = contrexx_addslashes($arrData['maskTitle']);
     if (!empty($intMaskId) && $intMaskId != 0) {
         $strMaskInputfields = isset($arrData['maskInputfields']) ? contrexx_addslashes(join(',', $arrData['maskInputfields'])) : '';
         $objEditMask = $objDatabase->Execute("\n                UPDATE\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_masks\n                SET\n                    title='" . $strMaskTitle . "',\n                    fields='" . $strMaskInputfields . "'   \n                WHERE\n                    id='" . $intMaskId . "'\n                ");
         if ($objEditMask === false) {
             return false;
         }
     } else {
         $intMaskFormId = contrexx_input2int($arrData['maskForm']);
         $objAddMask = $objDatabase->Execute("\n                INSERT INTO\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_masks\n                SET\n                    title='" . $strMaskTitle . "',\n                    form_id='" . $intMaskFormId . "',\n                    active='0'\n                ");
         if ($objAddMask === false) {
             return false;
         }
     }
     return true;
 }
コード例 #12
0
 function saveForm($arrData, $intFormId = null)
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID;
     $intId = intval($intFormId);
     $strPicture = contrexx_addslashes(contrexx_strip_tags($arrData['formImage']));
     $arrName = $arrData['formName'];
     $arrDescription = $arrData['formDescription'];
     $strCmd = strtolower(contrexx_addslashes(contrexx_strip_tags($arrData['formCmd'])));
     $intUseCategory = intval($arrData['formUseCategory']);
     $intUseLevel = isset($arrData['formUseLevel']) ? contrexx_input2int($arrData['formUseLevel']) : 0;
     $intUseReadyToConfirm = isset($arrData['formUseReadyToConfirm']) ? contrexx_input2int($arrData['formUseReadyToConfirm']) : 0;
     $intEntriesPerPage = isset($arrData['formEntriesPerPage']) ? contrexx_input2int($arrData['formEntriesPerPage']) : 0;
     if (empty($intId)) {
         //insert new form
         $objInsertAttributes = $objDatabase->Execute("\n                INSERT INTO\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_forms\n                SET\n                    `order`='99',\n                    `picture`='" . $strPicture . "',\n                    `cmd`='" . $strCmd . "',\n                    `use_category`='" . $intUseCategory . "',\n                    `use_level`='" . $intUseLevel . "',\n                    `use_ready_to_confirm`='" . $intUseReadyToConfirm . "',\n                    `entries_per_page`='" . $intEntriesPerPage . "',\n                    `active`='0'\n            ");
         if ($objInsertAttributes !== false) {
             $intId = $objDatabase->Insert_ID();
             foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                 if (empty($arrName[0])) {
                     $arrName[0] = "";
                 }
                 $strName = $arrName[$arrLang['id']];
                 $strDescription = $arrDescription[$arrLang['id']];
                 if (empty($strName)) {
                     $strName = $arrName[0];
                 }
                 if (empty($strDescription)) {
                     $strDescription = $arrDescription[0];
                 }
                 $objInsertNames = $objDatabase->Execute("\n                        INSERT INTO\n                            " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_form_names\n                        SET\n                            `lang_id`='" . intval($arrLang['id']) . "',\n                            `form_id`='" . intval($intId) . "',\n                            `form_name`='" . contrexx_raw2db(contrexx_input2raw($strName)) . "',\n                            `form_description`='" . contrexx_raw2db(contrexx_input2raw($strDescription)) . "'\n                    ");
             }
             $objCreateCatSelectors = $objDatabase->Execute("\n                    INSERT INTO\n                        " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_order_rel_forms_selectors\n                    SET\n                        `selector_id`='9',\n                        `form_id`='" . intval($intId) . "',\n                        `selector_order`='0',\n                        `exp_search`='1'\n                ");
             $objCreateLevelSelectors = $objDatabase->Execute("\n                    INSERT INTO\n                        " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_order_rel_forms_selectors\n                    SET\n                        `selector_id`='10',\n                        `form_id`='" . intval($intId) . "',\n                        `selector_order`='1',\n                        `exp_search`='1'\n                ");
             //permissions
             parent::getCommunityGroups();
             foreach ($this->arrCommunityGroups as $intGroupId => $arrGroup) {
                 $objInsertPerm = $objDatabase->Execute("\n                        INSERT INTO\n                            " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_settings_perm_group_forms\n                        SET\n                            `group_id`='" . intval($intGroupId) . "',\n                            `form_id`='" . intval($intId) . "',\n                            `status_group`='1'\n                    ");
             }
             if ($objInsertNames !== false && $objCreateCatSelectors !== false && $objCreateLevelSelectors !== false) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         //update form
         $objUpdateAttributes = $objDatabase->Execute("\n                UPDATE\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_forms\n                SET\n                    `picture`='" . $strPicture . "',\n                    `cmd`='" . $strCmd . "',\n                    `use_category`='" . $intUseCategory . "',\n                    `use_level`='" . $intUseLevel . "',\n                    `use_ready_to_confirm`='" . $intUseReadyToConfirm . "',\n                    `entries_per_page`='" . $intEntriesPerPage . "'\n                WHERE\n                    `id`='" . $intId . "'\n            ");
         if ($objUpdateAttributes !== false) {
             //permissions
             $objDeletePerm = $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_settings_perm_group_forms WHERE form_id='" . $intId . "'");
             $settingsPermissionGroupForm = isset($arrData['settingsPermGroupForm'][$intId]) ? $arrData['settingsPermGroupForm'][$intId] : array();
             foreach ($settingsPermissionGroupForm as $intGroupId => $intGroupStatus) {
                 $objInsertPerm = $objDatabase->Execute("\n                        INSERT INTO\n                            " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_settings_perm_group_forms\n                        SET\n                            `group_id`='" . intval($intGroupId) . "',\n                            `form_id`='" . intval($intId) . "',\n                            `status_group`='" . intval($intGroupStatus) . "'\n                    ");
             }
             $objInsertNames = $this->updateFormLocale($arrName, $arrDescription, $intId);
             if ($objInsertNames !== false) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }
コード例 #13
0
 /**
  * Sets placeholders for the form view.
  *
  * @param object $objTpl         Template object
  * @param integer $formId        Form id
  * @param integer $intView       request mode frontend or backend
  * @param integer $arrNumSeating number of seating
  *
  * @return null
  */
 function showForm($objTpl, $formId, $intView, $ticketSales = false)
 {
     global $_ARRAYLANG, $_LANGID;
     $objForm = new \Cx\Modules\Calendar\Controller\CalendarForm(intval($formId));
     if (!empty($formId)) {
         $this->formList[$formId] = $objForm;
     }
     switch ($intView) {
         case 1:
             $this->getFrontendLanguages();
             $objTpl->setGlobalVariable(array($this->moduleLangVar . '_FORM_ID' => !empty($formId) ? $objForm->id : '', $this->moduleLangVar . '_FORM_TITLE' => !empty($formId) ? $objForm->title : ''));
             $i = 0;
             $formFields = array();
             if (!empty($formId)) {
                 $defaultLangId = $_LANGID;
                 if (!in_array($defaultLangId, \FWLanguage::getIdArray())) {
                     $defaultLangId = \FWLanguage::getDefaultLangId();
                 }
                 foreach ($objForm->inputfields as $key => $arrInputfield) {
                     $i++;
                     $fieldValue = array();
                     $defaultFieldValue = array();
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         $fieldValue[$arrLang['id']] = isset($arrInputfield['name'][$arrLang['id']]) ? $arrInputfield['name'][$arrLang['id']] : '';
                         $defaultFieldValue[$arrLang['id']] = isset($arrInputfield['default_value'][$arrLang['id']]) ? $arrInputfield['default_value'][$arrLang['id']] : '';
                     }
                     $formFields[] = array('type' => $arrInputfield['type'], 'id' => $arrInputfield['id'], 'row' => $i % 2 == 0 ? 'row2' : 'row1', 'order' => $arrInputfield['order'], 'name_master' => $fieldValue[$defaultLangId], 'default_value_master' => $defaultFieldValue[$defaultLangId], 'required' => $arrInputfield['required'], 'affiliation' => $arrInputfield['affiliation'], 'field_value' => json_encode($fieldValue), 'default_field_value' => json_encode($defaultFieldValue));
                 }
             }
             foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang']));
                 $objTpl->parse('inputfieldNameList');
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang']));
                 $objTpl->parse('inputfieldDefaultValueList');
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name']));
                 $objTpl->parse('inputfieldLanguagesList');
             }
             foreach ($this->arrInputfieldTypes as $fieldType) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)]));
                 $objTpl->parse('inputfieldTypes');
             }
             foreach ($this->arrRegistrationFields as $fieldType) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)]));
                 $objTpl->parse('inputRegfieldTypes');
             }
             /* foreach ($this->arrInputfieldAffiliations as $strAffiliation) {
                    $objTpl->setVariable(array(
                        $this->moduleLangVar.'_FORM_FIELD_TYPE'        =>  $strAffiliation,
                        'TXT_'.$this->moduleLangVar.'_FORM_FIELD_TYPE' =>  $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_AFFILIATION_'.strtoupper($strAffiliation)],
                    ));
                    $objTpl->parse('fieldAfflications');
                }*/
             $objTpl->setVariable(array($this->moduleLangVar . '_FORM_DATA' => json_encode($formFields), $this->moduleLangVar . '_FRONTEND_LANG_COUNT' => count($this->arrFrontendLanguages), $this->moduleLangVar . '_INPUTFIELD_LAST_ID' => $objForm->getLastInputfieldId(), $this->moduleLangVar . '_INPUTFIELD_LAST_ROW' => $i % 2 == 0 ? "'row2'" : "'row1'", $this->moduleLangVar . '_DISPLAY_EXPAND' => count($this->arrFrontendLanguages) > 1 ? "block" : "none"));
             break;
         case 2:
             $objFieldTemplate = new \Cx\Core\Html\Sigma('.');
             $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true);
             $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'] . '<font class="calendarRequired"> *</font>', $this->moduleLangVar . '_FIELD_INPUT' => '<select class="calendarSelect affiliateForm" name="registrationType"><option value="1" selected="selected"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option><option value="0"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option></select>', $this->moduleLangVar . '_FIELD_CLASS' => 'affiliationForm'));
             $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $objFieldTemplate->get());
             $objTpl->parse('calendarRegistrationField');
             // $selectBillingAddressStatus = false;
             foreach ($objForm->inputfields as $key => $arrInputfield) {
                 $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true);
                 $options = array();
                 $options = explode(',', $arrInputfield['default_value'][$_LANGID]);
                 $inputfield = null;
                 $hide = false;
                 $optionSelect = true;
                 $availableSeat = 0;
                 $checkSeating = false;
                 if (isset($_POST['registrationField'][$arrInputfield['id']])) {
                     $value = $_POST['registrationField'][$arrInputfield['id']];
                 } elseif (\FWUser::getFWUserObject()->objUser->login() && in_array($arrInputfield['type'], array('mail', 'firstname', 'lastname'))) {
                     $value = '';
                     switch ($arrInputfield['type']) {
                         case 'mail':
                             $value = \FWUser::getFWUserObject()->objUser->getEmail();
                             break;
                         case 'firstname':
                             $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('firstname');
                             break;
                         case 'lastname':
                             $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('lastname');
                             break;
                         default:
                             $value = $arrInputfield['default_value'][$_LANGID];
                             break;
                     }
                 } else {
                     $value = $arrInputfield['default_value'][$_LANGID];
                 }
                 $affiliationClass = 'affiliation' . ucfirst($arrInputfield['affiliation']);
                 switch ($arrInputfield['type']) {
                     case 'inputtext':
                     case 'mail':
                     case 'firstname':
                     case 'lastname':
                         $inputfield = '<input type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" /> ';
                         break;
                     case 'textarea':
                         $inputfield = '<textarea class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>';
                         break;
                     case 'seating':
                         if (!$ticketSales) {
                             $hide = true;
                         }
                         $optionSelect = false;
                         if ($this->event) {
                             $checkSeating = $this->event->registration && $this->event->numSubscriber;
                             $availableSeat = $this->event->getFreePlaces();
                         }
                     case 'select':
                     case 'salutation':
                         $inputfield = '<select class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">';
                         $selected = empty($_POST) ? 'selected="selected"' : '';
                         $inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : '';
                         foreach ($options as $key => $name) {
                             if ($checkSeating && contrexx_input2int($name) > $availableSeat) {
                                 continue;
                             }
                             $selected = $key + 1 == $value ? 'selected="selected"' : '';
                             $inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>';
                         }
                         $inputfield .= '</select>';
                         break;
                     case 'radio':
                         foreach ($options as $key => $name) {
                             $checked = $key + 1 == $value || empty($_POST) && $key == 0 ? 'checked="checked"' : '';
                             $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : '';
                             $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />';
                             $name = str_replace('[[INPUT]]', $textfield, $name);
                             $inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/>&nbsp;' . $name . '<br />';
                         }
                         break;
                     case 'checkbox':
                         foreach ($options as $key => $name) {
                             $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : '';
                             $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />';
                             $name = str_replace('[[INPUT]]', $textfield, $name);
                             $checked = in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : '';
                             $inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" />&nbsp;' . $name . '<br />';
                         }
                         break;
                     case 'agb':
                         $inputfield = '<input class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" />&nbsp;' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />';
                         break;
                         /* case 'selectBillingAddress':
                                                     if(!$selectBillingAddressStatus) {
                                                         if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') {
                                                             $selectDeviatesFromContact = 'selected="selected"';
                                                         } else {
                                                             $selectDeviatesFromContact = '';
                                                         }
                         
                                                         $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">';
                                                         $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>';
                                                         $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>';
                                                         $inputfield .= '</select>';
                                                         $selectBillingAddressStatus = true;
                                                     }
                                                     break; */
                     /* case 'selectBillingAddress':
                                                 if(!$selectBillingAddressStatus) {
                                                     if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') {
                                                         $selectDeviatesFromContact = 'selected="selected"';
                                                     } else {
                                                         $selectDeviatesFromContact = '';
                                                     }
                     
                                                     $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">';
                                                     $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>';
                                                     $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>';
                                                     $inputfield .= '</select>';
                                                     $selectBillingAddressStatus = true;
                                                 }
                                                 break; */
                     case 'fieldset':
                         $inputfield = null;
                         break;
                 }
                 $field = '';
                 if ($arrInputfield['type'] == 'fieldset') {
                     $field = '</fieldset><fieldset><legend>' . $arrInputfield['name'][$_LANGID] . '</legend>';
                     $hide = true;
                 } else {
                     $required = $arrInputfield['required'] == 1 ? '<font class="calendarRequired"> *</font>' : '';
                     $label = $arrInputfield['name'][$_LANGID] . $required;
                 }
                 if (!$hide) {
                     $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $label, $this->moduleLangVar . '_FIELD_INPUT' => $inputfield, $this->moduleLangVar . '_FIELD_CLASS' => $affiliationClass));
                     $field = $objFieldTemplate->get();
                 }
                 $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $field);
                 $objTpl->parse('calendarRegistrationField');
             }
             break;
     }
 }
コード例 #14
0
 /**
  * Update the sort order in DB
  *
  * @param array $params supplied arguments from JsonData-request
  *
  * @return array it contains status and record count
  * @throws \Exception
  */
 public function updateOrder($params)
 {
     global $_ARRAYLANG, $objInit;
     //get the language interface text
     $langData = $objInit->loadLanguageData($this->getName());
     $_ARRAYLANG = array_merge($_ARRAYLANG, $langData);
     $post = is_array($params['post']) ? $params['post'] : array();
     if (empty($post) || empty($post['prePosition']) || empty($post['curPosition']) || empty($post['sortField']) || empty($post['component']) || empty($post['entity'])) {
         throw new \Exception($_ARRAYLANG['TXT_CORE_HTML_UPDATE_SORT_ORDER_FAILED']);
     }
     //Get all the 'POST' values
     $sortField = !empty($post['sortField']) ? contrexx_input2raw($post['sortField']) : '';
     $sortOrder = !empty($post['sortOrder']) ? contrexx_input2raw($post['sortOrder']) : '';
     $componentName = !empty($post['component']) ? contrexx_input2raw($post['component']) : '';
     $entityName = !empty($post['entity']) ? contrexx_input2raw($post['entity']) : '';
     $pagingPosition = !empty($post['pagingPosition']) ? contrexx_input2int($post['pagingPosition']) : 0;
     $currentPosition = isset($post['curPosition']) ? contrexx_input2int($post['curPosition']) : 0;
     $prePosition = isset($post['prePosition']) ? contrexx_input2int($post['prePosition']) : 0;
     $updatedOrder = isset($post['sorting' . $entityName]) && is_array($post['sorting' . $entityName]) ? array_map('contrexx_input2int', $post['sorting' . $entityName]) : array();
     $em = $this->cx->getDb()->getEntityManager();
     $componentRepo = $em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent');
     $objComponent = $componentRepo->findOneBy(array('name' => $componentName));
     $entityNameSpace = $objComponent->getNamespace() . '\\Model\\Entity\\' . $entityName;
     //check whether the entity namespace is a valid one or not
     if (!in_array($entityNameSpace, $objComponent->getEntityClasses())) {
         throw new \Exception(sprintf($_ARRAYLANG['TXT_CORE_HTML_SORTING_ENTITY_NOT_FOUND_ERROR'], $entityName, $componentName));
     }
     $entityObject = $em->getClassMetadata($entityNameSpace);
     $classMethods = get_class_methods($entityObject->newInstance());
     $primaryKeyName = $entityObject->getSingleIdentifierFieldName();
     //check whether the updating entity set/get method is a valid one or not
     if (!in_array('set' . ucfirst($sortField), $classMethods) || !in_array('get' . ucfirst($sortField), $classMethods) || !in_array('get' . ucfirst($primaryKeyName), $classMethods)) {
         throw new \Exception(sprintf($_ARRAYLANG['TXT_CORE_HTML_SORTING_GETTER_SETTER_NOT_FOUND_ERROR'], $entityName, $sortField, $primaryKeyName));
     }
     //update the entities order field in DB
     $oldPosition = $pagingPosition + $prePosition;
     $newPosition = $pagingPosition + $currentPosition;
     $min = min(array($newPosition, $oldPosition));
     $max = max(array($newPosition, $oldPosition));
     $offset = $min - 1;
     $limit = $max - $min + 1;
     $qb = $em->createQueryBuilder();
     $qb->select('e')->from($entityNameSpace, 'e')->orderBy('e.' . $sortField, $sortOrder);
     if (empty($updatedOrder)) {
         $qb->setFirstResult($offset)->setMaxResults($limit);
     }
     $entities = $qb->getQuery()->getResult();
     if (!$entities) {
         throw new \Exception($_ARRAYLANG['TXT_CORE_HTML_SORTING_NO_ENTITY_FOUND_ERROR']);
     }
     try {
         if ($oldPosition > $newPosition && empty($updatedOrder) || !empty($updatedOrder) && $sortOrder == 'DESC') {
             krsort($entities);
         }
         $i = 1;
         $recordCount = count($entities);
         $orderFieldSetMethodName = 'set' . ucfirst($sortField);
         $orderFieldGetMethodName = 'get' . ucfirst($sortField);
         $primaryGetMethodName = 'get' . ucfirst($primaryKeyName);
         foreach ($entities as $entity) {
             if (!empty($updatedOrder)) {
                 //If the same 'order' field value is repeated,
                 //we need to update all the entries.
                 $id = $entity->{$primaryGetMethodName}();
                 if (in_array($id, $updatedOrder)) {
                     $order = array_search($id, $updatedOrder);
                     $orderNo = $pagingPosition + $order + 1;
                     if ($sortOrder == 'DESC') {
                         $orderNo = $recordCount - ($pagingPosition + $order);
                     }
                     $entity->{$orderFieldSetMethodName}($orderNo);
                 } else {
                     $entity->{$orderFieldSetMethodName}($i);
                 }
             } else {
                 //If the same 'order' field value is not repeated,
                 //we need to update all the entries between dragged and dropped position
                 $currentOrder = $entity->{$orderFieldGetMethodName}();
                 if ($i == 1) {
                     $firstResult = $entity;
                     $sortOrder = $currentOrder;
                     $i++;
                     continue;
                 } else {
                     if ($i == count($entities)) {
                         $firstResult->{$orderFieldSetMethodName}($currentOrder);
                         $entity->{$orderFieldSetMethodName}($sortOrder);
                         continue;
                     }
                 }
                 $entity->{$orderFieldSetMethodName}($sortOrder);
                 $sortOrder = $currentOrder;
             }
             $i++;
         }
         $em->flush();
         return array('status' => 'success', 'recordCount' => $recordCount);
     } catch (\Exception $e) {
         throw new \Exception($_ARRAYLANG['TXT_CORE_HTML_UPDATE_SORT_ORDER_FAILED']);
     }
 }
コード例 #15
0
 /**
  * Save the registration
  *
  * @param array $data posted data from the form
  *
  * @return boolean true if the registration saved, false otherwise
  */
 function save($data)
 {
     global $objDatabase, $objInit, $_LANGID;
     /* foreach ($this->form->inputfields as $key => $arrInputfield) {
            if($arrInputfield['type'] == 'selectBillingAddress') {
                $affiliationStatus = $data['registrationField'][$arrInputfield['id']];
            }
        } */
     foreach ($this->form->inputfields as $key => $arrInputfield) {
         /* if($affiliationStatus == 'sameAsContact') {
                         if($arrInputfield['required'] == 1 && empty($data['registrationField'][$arrInputfield['id']]) && $arrInputfield['affiliation'] != 'billing') {
                             return false;
                         }
         
                         if($arrInputfield['required'] == 1 && $arrInputfield['type'] == 'mail' && $arrInputfield['affiliation'] != 'billing') {
                             $objValidator = new FWValidator();
         
                             if(!$objValidator->isEmail($data['registrationField'][$arrInputfield['id']])) {
                                 return false;
                             }
                         }
                     } else { */
         if ($arrInputfield['required'] == 1 && empty($data['registrationField'][$arrInputfield['id']])) {
             return false;
         }
         if ($arrInputfield['required'] == 1 && $arrInputfield['type'] == 'mail') {
             $objValidator = new \FWValidator();
             if (!$objValidator->isEmail($data['registrationField'][$arrInputfield['id']])) {
                 return false;
             }
         }
         /* } */
     }
     $regId = intval($data['regid']);
     $eventId = intval($data['id']);
     $formId = intval($data['form']);
     $eventDate = intval($data['date']);
     $userId = intval($data['userid']);
     $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId);
     if ($objEvent->seriesStatus && $objEvent->independentSeries) {
         $eventDate = isset($data['registrationEventDate']) ? contrexx_input2int($data['registrationEventDate']) : $eventDate;
         $endDate = new \DateTime();
         $endDate->modify('+10 years');
         $eventManager = new CalendarEventManager(null, $endDate);
         $eventManager->getEvent($objEvent, $eventDate, true);
         $objEvent = $eventManager->eventList[0];
         if (empty($objEvent)) {
             return false;
         }
     }
     $query = '
         SELECT
             `id`
         FROM
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field`
         WHERE
             `form` = ' . $formId . '
         AND
             `type` = "seating"
         LIMIT 1
     ';
     $objResult = $objDatabase->Execute($query);
     $numSeating = intval($data['registrationField'][$objResult->fields['id']]);
     $type = empty($regId) && intval($objEvent->getFreePlaces() - $numSeating) < 0 ? 2 : (isset($data['registrationType']) ? intval($data['registrationType']) : 1);
     $this->saveIn = intval($type);
     $paymentMethod = intval($data['paymentMethod']);
     $paid = intval($data['paid']);
     $hostName = 0;
     $ipAddress = 0;
     $key = $this->generateKey();
     if ($regId == 0) {
         $submissionDate = $this->getDbDateTimeFromIntern($this->getInternDateTimeFromUser());
         $query = 'INSERT INTO ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration
                     SET `event_id`         = ' . $eventId . ',
                         `submission_date`  = "' . $submissionDate->format('Y-m-d H:i:s') . '",
                         `date`             = ' . $eventDate . ',
                         `host_name`        = "' . $hostName . '",
                         `ip_address`       = "' . $ipAddress . '",
                         `type`             = ' . $type . ',
                         `key`              = "' . $key . '",
                         `user_id`          = ' . $userId . ',
                         `lang_id`          = ' . $_LANGID . ',
                         `export`           = 0,
                         `payment_method`   = ' . $paymentMethod . ',
                         `paid`             = ' . $paid . ' ';
         $objResult = $objDatabase->Execute($query);
         if ($objResult !== false) {
             $this->id = $objDatabase->Insert_ID();
         } else {
             return false;
         }
     } else {
         $query = 'UPDATE `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration`
                      SET `event_id` = ' . $eventId . ',
                          `date` = ' . $eventDate . ',
                          `host_name` = ' . $hostName . ',
                          `ip_address` = ' . $ipAddress . ',
                          `key` = "' . $key . '",
                          `user_id` = ' . $userId . ',
                          `type`    = ' . $type . ',
                          `lang_id` = ' . $_LANGID . ',
                          `payment_method` = ' . $paymentMethod . ',
                          `paid` = ' . $paid . '
                    WHERE `id` = ' . $regId;
         $objResult = $objDatabase->Execute($query);
         if ($objResult === false) {
             return false;
         }
     }
     if ($regId != 0) {
         $this->id = $regId;
         $deleteQuery = 'DELETE FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value
                         WHERE `reg_id` = ' . $this->id;
         $objDeleteResult = $objDatabase->Execute($deleteQuery);
         if ($objDeleteResult === false) {
             return false;
         }
     }
     foreach ($this->form->inputfields as $key => $arrInputfield) {
         $value = $data['registrationField'][$arrInputfield['id']];
         $id = $arrInputfield['id'];
         if (is_array($value)) {
             $subvalue = array();
             foreach ($value as $key => $element) {
                 if (!empty($data['registrationFieldAdditional'][$id][$element - 1])) {
                     $subvalue[] = $element . '[[' . $data['registrationFieldAdditional'][$id][$element - 1] . ']]';
                 } else {
                     $subvalue[] = $element;
                 }
             }
             $value = join(",", $subvalue);
         } else {
             if (isset($data['registrationFieldAdditional'][$id][$value - 1])) {
                 $value = $value . "[[" . $data['registrationFieldAdditional'][$id][$value - 1] . "]]";
             }
         }
         $query = 'INSERT INTO ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value
                               (`reg_id`, `field_id`, `value`)
                        VALUES (' . $this->id . ', ' . $id . ', "' . contrexx_input2db($value) . '")';
         $objResult = $objDatabase->Execute($query);
         if ($objResult === false) {
             return false;
         }
     }
     if ($objInit->mode == 'frontend') {
         $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager();
         $templateId = $objEvent->emailTemplate[FRONTEND_LANG_ID];
         $objMailManager->sendMail($objEvent, \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_CONFIRM_REG, $this->id, $templateId);
         $objMailManager->sendMail($objEvent, \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_ALERT_REG, $this->id);
     }
     return true;
 }
コード例 #16
0
ファイル: Orders.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Updates the Order status with parameter values from the GET request
  * @return  boolean             True on success, false on failure,
  *                              or null (on NOOP)
  * @todo    Should definitely use POST instead.
  */
 static function updateStatusFromGet()
 {
     global $objDatabase, $_ARRAYLANG;
     // Update the order status if valid
     if (!isset($_GET['changeOrderStatus']) || empty($_GET['order_id'])) {
         return null;
     }
     $status = intval($_GET['changeOrderStatus']);
     $order_id = intval($_GET['order_id']);
     if ($status < Order::STATUS_PENDING || $status >= Order::STATUS_MAX || $order_id <= 0) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     $objUser = \FWUser::getFWUserObject()->objUser;
     $oldStatus = $objDatabase->getOne('
         SELECT
             `status`
         FROM
             `' . DBPREFIX . 'module_shop' . MODULE_INDEX . '_orders`
         WHERE
             `id`=' . contrexx_input2int($order_id));
     $query = "\n            UPDATE `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders`\n               SET `status`={$status},\n                   `modified_by`='" . addslashes($objUser->getUsername()) . "',\n                   `modified_on`='" . date('Y-m-d H:i:s') . "'\n             WHERE `id`={$order_id}";
     if (!$objDatabase->Execute($query)) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     $order = new Order();
     $order->setId($order_id);
     if (!empty($_GET['stock_update']) && $_GET['stock_update'] == 1 && ($order->isStockIncreasable($oldStatus, $status) || $order->isStockDecreasable($oldStatus, $status))) {
         $order->updateStock($order->isStockIncreasable($oldStatus, $status));
     }
     // Send an email to the customer
     if (!empty($_GET['sendMail']) && !empty($_GET['order_id'])) {
         // TODO: It might be useful to move this to its own method:
         $hasMail = false;
         $result = null;
         switch ($status) {
             case Order::STATUS_CONFIRMED:
                 $result = ShopLibrary::sendConfirmationMail($_GET['order_id']);
                 $hasMail = true;
                 break;
             case Order::STATUS_COMPLETED:
                 $result = ShopManager::sendProcessedMail($_GET['order_id']);
                 $hasMail = true;
                 break;
         }
         if ($hasMail) {
             if (!empty($result)) {
                 \Message::ok(sprintf($_ARRAYLANG['TXT_EMAIL_SEND_SUCCESSFULLY'], $result));
             } else {
                 \Message::error($_ARRAYLANG['TXT_MESSAGE_SEND_ERROR']);
             }
         }
     }
     \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
 }
コード例 #17
0
 /**
  * Initialize the registration list
  *
  * @return null
  */
 function getRegistrationList()
 {
     global $objDatabase;
     $blnFirst = true;
     $arrWhere = array();
     if ($this->getRegistrations) {
         $arrWhere[] = 1;
     }
     if ($this->getDeregistrations) {
         $arrWhere[] = 0;
     }
     if ($this->getWaitlist) {
         $arrWhere[] = 2;
     }
     $strWhere = ' AND (';
     foreach ($arrWhere as $value) {
         $strWhere .= $blnFirst ? '`type` = ' . $value : ' OR `type` = ' . $value;
         $blnFirst = false;
     }
     $strWhere .= ')';
     if ($this->startDate && $this->endDate) {
         $strWhere .= ' AND (date >= ' . contrexx_input2int($this->startDate) . ' AND date <= ' . contrexx_input2int($this->endDate) . ')';
     } elseif ($this->startDate) {
         $strWhere .= ' AND (date >= ' . contrexx_input2int($this->startDate) . ')';
     } elseif ($this->endDate) {
         $strWhere .= ' AND (date <= ' . contrexx_input2int($this->startDate) . ')';
     }
     $query = '
         SELECT `id`
         FROM `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration`
         WHERE `event_id` = ' . $this->eventId . '
         ' . $strWhere . '
         ORDER BY `id` DESC';
     $objResult = $objDatabase->Execute($query);
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($this->formId, intval($objResult->fields['id']));
             $this->registrationList[$objResult->fields['id']] = $objRegistration;
             $objResult->MoveNext();
         }
     }
 }
コード例 #18
0
 /**
  * save the form input fields
  *      
  * @param array $data
  * 
  * @return boolean true on success false otherwise
  */
 function saveInputfields($data)
 {
     global $objDatabase, $_LANGID;
     $this->getFrontendLanguages();
     $query = '
         DELETE
             fn.*, ff.*
         FROM
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name` AS fn,
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field` AS ff
         WHERE
             fn.`form_id` = ' . contrexx_input2int($this->id) . '
         AND
             ff.`form` =' . contrexx_input2int($this->id) . '
     ';
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return false;
     }
     foreach ($data['inputfield'] as $intFieldId => $arrField) {
         $query = '
             INSERT INTO
                 `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field`
             SET
                 `id`          =  ' . contrexx_input2int($intFieldId) . ',
                 `form`        =  ' . contrexx_input2int($this->id) . ',
                 `type`        = "' . contrexx_input2db($arrField['type']) . '",
                 `required`    =  ' . (isset($arrField['required']) ? 1 : 0) . ',
                 `order`       =  ' . contrexx_input2int($arrField['order']) . ',
                 `affiliation` = "' . (isset($arrField['affiliation']) ? contrexx_input2db($arrField['affiliation']) : '') . '"
         ';
         $objResult = $objDatabase->Execute($query);
         if ($objResult === false) {
             continue;
         }
         foreach ($this->arrFrontendLanguages as $key => $arrLang) {
             if (empty($arrField['name'][0])) {
                 $arrField['name'][0] = '';
             }
             $strFieldName = $arrField['name'][$arrLang['id']];
             $strFieldDefaultValue = $arrField['default_value'][$arrLang['id']];
             if ($arrLang['id'] == $_LANGID) {
                 if ($this->inputfields[$intFieldId]['name'][0] == $strFieldName && $this->inputfields[$intFieldId]['name'][$arrLang['id']] != $strFieldName) {
                     $strFieldName = $arrField['name'][$_LANGID];
                 }
                 if ($this->inputfields[$intFieldId]['default_value'][0] == $strFieldDefaultValue && $this->inputfields[$intFieldId]['default_value'][$arrLang['id']] != $strFieldDefaultValue) {
                     $strFieldDefaultValue = $arrField['default_value'][$_LANGID];
                 }
                 if ($this->inputfields[$intFieldId]['name'][0] != $arrField['name'][0] && $this->inputfields[$intFieldId]['name'][$arrLang['id']] == $strFieldName || $this->inputfields[$intFieldId]['name'][0] != $arrField['name'][0] && $this->inputfields[$intFieldId]['name'][$arrLang['id']] != $strFieldName || $this->inputfields[$intFieldId]['name'][0] == $arrField['name'][0] && $this->inputfields[$intFieldId]['name'][$arrLang['id']] == $strFieldName) {
                     $strFieldName = $arrField['name'][0];
                 }
                 if ($this->inputfields[$intFieldId]['default_value'][0] != $arrField['default_value'][0] && $this->inputfields[$intFieldId]['default_value'][$arrLang['id']] == $strFieldDefaultValue || $this->inputfields[$intFieldId]['default_value'][0] != $arrField['default_value'][0] && $this->inputfields[$intFieldId]['default_value'][$arrLang['id']] != $strFieldDefaultValue || $this->inputfields[$intFieldId]['default_value'][0] == $arrField['default_value'][0] && $this->inputfields[$intFieldId]['default_value'][$arrLang['id']] == $strFieldDefaultValue) {
                     $strFieldDefaultValue = $arrField['default_value'][0];
                 }
             }
             if (empty($strFieldName)) {
                 $strFieldName = $arrField['name'][0];
             }
             if (empty($strFieldDefaultValue)) {
                 $strFieldDefaultValue = $arrField['default_value'][0];
             }
             $query = '
                 INSERT INTO
                     `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name`
                 SET
                     `field_id` =  ' . contrexx_input2int($intFieldId) . ',
                     `form_id`  =  ' . contrexx_input2int($this->id) . ',
                     `lang_id`  =  ' . contrexx_input2int($arrLang['id']) . ',
                     `name`     = "' . contrexx_input2db($strFieldName) . '",
                     `default`  = "' . contrexx_input2db($strFieldDefaultValue) . '"';
             $objResult = $objDatabase->Execute($query);
         }
     }
     return true;
 }
コード例 #19
0
 function ConfigDispatch()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->addBlockfile('NEWSLETTER_SETTINGS_FILE', 'settings_block', 'newsletter_config_dispatch.html');
     $this->_objTpl->setVariable('TXT_TITLE', $_ARRAYLANG['TXT_DISPATCH_SETINGS']);
     if (isset($_POST["update"])) {
         $queryUpdateSetting = '
             UPDATE
                 `' . DBPREFIX . 'module_newsletter_settings`
             SET `setvalue` = CASE `setname`
                              WHEN "sender_mail" THEN "' . contrexx_input2db($_POST['sender_email']) . '"
                              WHEN "sender_name" THEN "' . contrexx_input2db($_POST['sender_name']) . '"
                              WHEN "reply_mail" THEN "' . contrexx_input2db($_POST['return_path']) . '"
                              WHEN "mails_per_run" THEN "' . contrexx_input2int($_POST['mails_per_run']) . '"
                              WHEN "overview_entries_limit" THEN "' . contrexx_input2int($_POST["overview_entries"]) . '"
                              WHEN "test_mail" THEN "' . contrexx_input2db($_POST['test_mail']) . '"
                              WHEN "text_break_after" THEN "' . contrexx_input2int($_POST['text_break_after']) . '"
                              WHEN "rejected_mail_operation" THEN "' . contrexx_input2db($_POST['newsletter_rejected_mail_task']) . '"
                              WHEN "defUnsubscribe" THEN "' . contrexx_input2int($_POST['def_unsubscribe']) . '"
                              WHEN "notificationSubscribe" THEN "' . contrexx_input2int($_POST["mailSendSubscribe"]) . '"
                              WHEN "notificationUnsubscribe" THEN "' . contrexx_input2int($_POST["mailSendUnsubscribe"]) . '"
                              END
             WHERE `setname` IN("sender_mail", "sender_name", "reply_mail", "mails_per_run", "overview_entries_limit", "test_mail", "text_break_after", "rejected_mail_operation", "defUnsubscribe", "notificationSubscribe", "notificationUnsubscribe")';
         $objDatabase->Execute($queryUpdateSetting);
     }
     // Load Values
     $objSettings = $objDatabase->Execute("SELECT setname, setvalue FROM " . DBPREFIX . "module_newsletter_settings");
     if ($objSettings !== false) {
         while (!$objSettings->EOF) {
             $arrSettings[$objSettings->fields['setname']] = $objSettings->fields['setvalue'];
             $objSettings->MoveNext();
         }
     }
     $this->_objTpl->setVariable(array('TXT_SETTINGS' => $_ARRAYLANG['TXT_SETTINGS'], 'TXT_SENDER' => $_ARRAYLANG['TXT_SENDER'], 'TXT_LASTNAME' => $_ARRAYLANG['TXT_LASTNAME'], 'TXT_RETURN_PATH' => $_ARRAYLANG['TXT_RETURN_PATH'], 'TXT_SEND_LIMIT' => $_ARRAYLANG['TXT_SEND_LIMIT'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_FILL_OUT_ALL_REQUIRED_FIELDS' => $_ARRAYLANG['TXT_FILL_OUT_ALL_REQUIRED_FIELDS'], 'TXT_WILDCART_INFOS' => $_ARRAYLANG['TXT_WILDCART_INFOS'], 'TXT_USER_DATA' => $_ARRAYLANG["TXT_USER_DATA"], 'TXT_EMAIL_ADDRESS' => $_ARRAYLANG['TXT_EMAIL_ADDRESS'], 'TXT_LASTNAME' => $_ARRAYLANG['TXT_LASTNAME'], 'TXT_FIRSTNAME' => $_ARRAYLANG['TXT_FIRSTNAME'], 'TXT_NEWSLETTER_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_ADDRESS'], 'TXT_ZIP' => $_ARRAYLANG['TXT_ZIP'], 'TXT_CITY' => $_ARRAYLANG['TXT_CITY'], 'TXT_COUNTRY' => $_ARRAYLANG['TXT_COUNTRY'], 'TXT_PHONE' => $_ARRAYLANG['TXT_PHONE'], 'TXT_BIRTHDAY' => $_ARRAYLANG['TXT_BIRTHDAY'], 'TXT_GENERALLY' => $_ARRAYLANG['TXT_GENERALLY'], 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_NEWSLETTER_CONTENT' => $_ARRAYLANG['TXT_NEWSLETTER_CONTENT'], 'TXT_CONFIRM_MAIL' => $_ARRAYLANG['TXT_NEWSLETTER_CONFIRMATION_EMAIL'], 'TXT_NOTIFICATION_MAIL' => $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_MAIL'], 'TXT_ACTIVATE_MAIL' => $_ARRAYLANG['TXT_NEWSLETTER_ACTIVATION_EMAIL'], 'TXT_DISPATCH_SETINGS' => $_ARRAYLANG['TXT_DISPATCH_SETINGS'], 'TXT_NEWSLETTER_EMAIL_TEMPLATES' => $_ARRAYLANG['TXT_NEWSLETTER_EMAIL_TEMPLATES'], 'TXT_GENERATE_HTML' => $_ARRAYLANG['TXT_GENERATE_HTML'], 'TXT_NEWSLETTER_TEMPLATES' => $_ARRAYLANG['TXT_NEWSLETTER_TEMPLATES'], 'TXT_NEWSLETTER_INTERFACE' => $_ARRAYLANG['TXT_NEWSLETTER_INTERFACE'], 'TXT_BREAK_AFTER' => $_ARRAYLANG['TXT_NEWSLETTER_BREAK_AFTER'], 'TXT_TEST_MAIL' => $_ARRAYLANG['TXT_NEWSLETTER_TEST_RECIPIENT'], 'TXT_FAILED' => $_ARRAYLANG['TXT_NEWSLETTER_FAILED'], 'TXT_NEWSLETTER_INFO_ABOUT_ADMIN_INFORM' => $_ARRAYLANG['TXT_NEWSLETTER_INFO_ABOUT_ADMIN_INFORM'], 'TXT_NEWSLETTER_OVERVIEW_ENTRIES' => $_ARRAYLANG['TXT_NEWSLETTER_OVERVIEW_ENTRIES'], 'TXT_NEWSLETTER_REPLY_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_REPLY_EMAIL'], 'TXT_SYSTEM_SETINGS' => "System", 'TXT_NEWSLETTER_DO_NOTING' => $_ARRAYLANG['TXT_NEWSLETTER_DO_NOTING'], 'TXT_NEWSLETTER_TASK_REJECTED_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_TASK_REJECTED_EMAIL'], 'TXT_NEWSLETTER_DEACTIVATE_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_DEACTIVATE_EMAIL'], 'TXT_NEWSLETTER_DELETE_EMAIL_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_DELETE_EMAIL_ADDRESS'], 'TXT_NEWSLETTER_INFORM_ADMIN' => $_ARRAYLANG['TXT_NEWSLETTER_INFORM_ADMIN'], 'TXT_NEWSLETTER_REJECT_INFO_MAIL_TEXT' => $_ARRAYLANG['TXT_NEWSLETTER_REJECT_INFO_MAIL_TEXT'], 'TXT_NEWSLETTER_INFO_ABOUT_INFORM_TEXT' => $_ARRAYLANG['TXT_NEWSLETTER_INFO_ABOUT_INFORM_TEXT'], 'TXT_NEWSLETTER_UNSUBSCRIBE_DEACTIVATE' => $_CORELANG['TXT_DEACTIVATED'], 'TXT_NEWSLETTER_UNSUBSCRIBE_DELETE' => $_CORELANG['TXT_DELETED'], 'TXT_NEWSLETTER_DEF_UNSUBSCRIBE' => $_ARRAYLANG['TXT_STATE_OF_SUBSCRIBED_USER'], 'TXT_NEWSLETTER_NOTIFICATION_ACTIVATE' => $_ARRAYLANG['TXT_NEWSLETTER_ACTIVATE'], 'TXT_NEWSLETTER_NOTIFICATION_DEACTIVATE' => $_ARRAYLANG['TXT_NEWSLETTER_DEACTIVATE'], 'TXT_NEWSLETTER_SEND_BY_SUBSCRIBE' => $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_SEND_BY_SUBSCRIBE'], 'TXT_NEWSLETTER_SEND_BY_UNSUBSCRIBE' => $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_SEND_BY_UNSUBSCRIBE'], 'SENDERMAIL_VALUE' => htmlentities($arrSettings['sender_mail'], ENT_QUOTES, CONTREXX_CHARSET), 'SENDERNAME_VALUE' => htmlentities($arrSettings['sender_name'], ENT_QUOTES, CONTREXX_CHARSET), 'RETURNPATH_VALUE' => htmlentities($arrSettings['reply_mail'], ENT_QUOTES, CONTREXX_CHARSET), 'MAILSPERRUN_VALUE' => $arrSettings['mails_per_run'], 'OVERVIEW_ENTRIES_VALUE' => $arrSettings['overview_entries_limit'], 'TEST_MAIL_VALUE' => htmlentities($arrSettings['test_mail'], ENT_QUOTES, CONTREXX_CHARSET), 'BREAK_AFTER_VALUE' => htmlentities($arrSettings['text_break_after'], ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_REJECTED_MAIL_IGNORE' => $arrSettings['rejected_mail_operation'] == 'ignore' ? 'checked="checked"' : '', 'NEWSLETTER_REJECTED_MAIL_DEACTIVATE' => $arrSettings['rejected_mail_operation'] == 'deactivate' ? 'checked="checked"' : '', 'NEWSLETTER_REJECTED_MAIL_DELETE' => $arrSettings['rejected_mail_operation'] == 'delete' ? 'checked="checked"' : '', 'NEWSLETTER_REJECTED_MAIL_INFORM' => $arrSettings['rejected_mail_operation'] == 'inform' ? 'checked="checked"' : '', 'NEWSLETTER_UNSUBSCRIBE_DELETE_ON' => $arrSettings['defUnsubscribe'] == 1 ? 'checked="checked"' : '', 'NEWSLETTER_UNSUBSCRIBE_DEACTIVATE_ON' => $arrSettings['defUnsubscribe'] != 1 ? 'checked="checked"' : '', 'NEWSLETTER_SEND_BY_SUBSCRIBE_ON' => $arrSettings['notificationSubscribe'] == 1 ? 'checked="checked"' : '', 'NEWSLETTER_SEND_BY_SUBSCRIBE_OFF' => $arrSettings['notificationSubscribe'] != 1 ? 'checked="checked"' : '', 'NEWSLETTER_SEND_BY_UNSUBSCRIBE_ON' => $arrSettings['notificationUnsubscribe'] == 1 ? 'checked="checked"' : '', 'NEWSLETTER_SEND_BY_UNSUBSCRIBE_OFF' => $arrSettings['notificationUnsubscribe'] != 1 ? 'checked="checked"' : ''));
 }
コード例 #20
0
 /**
  * Save a record
  * 
  * @global ADO Connection $objDatabase
  * 
  * @return Boolean
  */
 function save()
 {
     global $objDatabase;
     $fields = array('customer_id' => isset($this->customerId) ? $this->customerId : '', 'customer_type' => isset($this->customerType) ? (int) $this->customerType : 0, 'customer_name' => isset($this->customerName) ? $this->customerName : '', 'customer_addedby' => isset($this->addedUser) ? (int) $this->addedUser : 1, 'company_size' => isset($this->companySize) ? $this->companySize : 0, 'customer_currency' => isset($this->currency) ? (int) $this->currency : 0, 'contact_familyname' => isset($this->family_name) ? $this->family_name : '', 'contact_role' => isset($this->contact_role) ? $this->contact_role : '', 'contact_customer' => isset($this->contact_customer) ? (int) $this->contact_customer : '', 'contact_language' => isset($this->contact_language) ? (int) $this->contact_language : '', 'notes' => isset($this->notes) ? $this->notes : '', 'industry_type' => isset($this->industryType) ? $this->industryType : '', 'contact_type' => isset($this->contactType) ? (int) $this->contactType : '', 'user_account' => isset($this->account_id) ? (int) $this->account_id : '', 'gender' => isset($this->contact_gender) ? (int) $this->contact_gender : '', 'profile_picture' => array('val' => isset($this->profile_picture) && !empty($this->profile_picture) ? $this->profile_picture : null, 'omitEmpty' => true), 'email_delivery' => isset($this->emailDelivery) ? contrexx_input2int($this->emailDelivery) : 1);
     if (!isset($this->id) || empty($this->id)) {
         $fields['datasource'] = isset($this->datasource) ? $this->datasource : '';
         $fields['added_date'] = date('Y-m-d H:i:s');
         \Env::get('cx')->getEvents()->triggerEvent('model/prePersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $query = \SQL::insert("module_{$this->moduleName}_contacts", $fields, array('escape' => true));
     } else {
         \Env::get('cx')->getEvents()->triggerEvent('model/preUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $query = \SQL::update("module_{$this->moduleName}_contacts", $fields, array('escape' => true)) . " WHERE `id` = {$this->id}";
     }
     //echo $query; exit();
     if ($objDatabase->execute($query)) {
         if (!isset($this->id) || empty($this->id)) {
             $this->id = $objDatabase->INSERT_ID();
             \Env::get('cx')->getEvents()->triggerEvent('model/postPersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         } else {
             if (!empty($this->id)) {
                 \Env::get('cx')->getEvents()->triggerEvent('model/postUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
             }
         }
         return true;
     }
     return false;
 }
コード例 #21
0
 /**
  * get the shared files by upload id
  *
  * @param integer $uploadId the upload id of the upload
  *
  * @return array with files of the last upload
  *
  * @access private
  */
 private function getSharedFiles($uploadId)
 {
     global $objDatabase;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $fileSystem = new \Cx\Lib\FileSystem\FileSystem();
     $imageUrl = clone \Env::get("Resolver")->getUrl();
     // get the image url
     $files = array();
     $directory = \Env::get('Resolver')->getCmd();
     if ($directory != 'Downloads') {
         $targetPath = $cx->getWebsiteMediaFileSharingPath() . '/' . (!empty($directory) ? $directory . '/' : '');
         $targetPathWeb = $cx->getWebsiteMediaFileSharingWebPath() . '/' . (!empty($directory) ? $directory . '/' : '');
     } else {
         $targetPath = $cx->getWebsiteImagesDownloadsPath() . '/';
         $targetPathWeb = $cx->getWebsiteImagesDownloadsWebPath() . '/';
     }
     $tup = FileSharingLib::getTemporaryFilePaths($uploadId);
     $dirTempPath = $tup[0] . '/' . $tup[2] . '/';
     //get the tmp/$uploadId files
     foreach (glob($dirTempPath . '/*') as $uploadedFile) {
         $file = basename($uploadedFile);
         $uploadedFileName = $fileSystem->copyFile($dirTempPath, $file, $targetPath, $file, false);
         if ($uploadedFileName === 'error') {
             continue;
         }
         \Cx\Lib\FileSystem\FileSystem::delete_file($dirTempPath . '/' . $file);
         $uploadedFileSource = $targetPathWeb . $uploadedFileName;
         $hash = self::createHash();
         $check = self::createCheck($hash);
         $objResult = $objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_filesharing (`file`, `source`, `cmd`, `hash`, `check`, `upload_id`)\n                                VALUES (\n                                    '" . contrexx_raw2db($uploadedFileName) . "',\n                                    '" . contrexx_raw2db($uploadedFileSource) . "',\n                                    '" . contrexx_raw2db($directory) . "',\n                                    '" . contrexx_raw2db($hash) . "',\n                                    '" . contrexx_raw2db($check) . "',\n                                    '" . contrexx_input2int($uploadId) . "'\n                                )");
         if (!$objResult) {
             continue;
         }
         $imageUrl->setParam("act", "image");
         $imageUrl->setParam("hash", $hash);
         $info = pathinfo($cx->getWebsiteOffsetPath() . $uploadedFileSource, PATHINFO_EXTENSION);
         // if the file is an image show a thumbnail of the image
         if (!in_array(strtoupper($info), array('JPEG', 'JPG', 'TIFF', 'GIF', 'BMP', 'PNG'))) {
             $imageUrl = false;
         }
         $fieldId = $objDatabase->Insert_ID();
         $files[] = array("name" => $uploadedFileName, "image" => $imageUrl->toString(), "download" => parent::getDownloadLink($fieldId), "delete" => parent::getDeleteLink($fieldId));
     }
     return $files;
 }
コード例 #22
0
 /**
  * Show modify block
  *
  * Show the block modification page
  *
  * @access private
  * @global array
  * @see blockLibrary::_getBlockContent(), blockLibrary::blockNamePrefix
  */
 private function _showModifyBlock($copy = false)
 {
     global $_ARRAYLANG;
     \JS::activate('cx');
     \JS::activate('ckeditor');
     \JS::activate('jqueryui');
     \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js');
     \JS::registerCss('lib/javascript/tag-it/css/tag-it.css');
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setCallback('ckeditor_image_button');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none'));
     $blockId = !empty($_REQUEST['blockId']) ? intval($_REQUEST['blockId']) : 0;
     $blockCat = 0;
     $blockName = '';
     $blockStart = 0;
     $blockEnd = 0;
     $blockRandom = 0;
     $blockRandom2 = 0;
     $blockRandom3 = 0;
     $blockRandom4 = 0;
     $blockGlobal = 0;
     $blockDirect = 0;
     $blockCategory = 0;
     $blockWysiwygEditor = 1;
     $blockContent = array();
     $blockAssociatedPageIds = array();
     $blockLangActive = array();
     $blockGlobalAssociatedPageIds = array();
     $blockDirectAssociatedPageIds = array();
     $blockCategoryAssociatedPageIds = array();
     $this->_objTpl->loadTemplateFile('module_block_modify.html');
     $this->_objTpl->setGlobalVariable(array('TXT_BLOCK_CONTENT' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_RANDOM' => $_ARRAYLANG['TXT_BLOCK_RANDOM'], 'TXT_BLOCK_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SHOW_IN_GLOBAL'], 'TXT_BLOCK_SAVE' => $_ARRAYLANG['TXT_BLOCK_SAVE'], 'TXT_BLOCK_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_DEACTIVATE'], 'TXT_BLOCK_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_ACTIVATE'], 'TXT_DONT_SHOW_ON_PAGES' => $_ARRAYLANG['TXT_DONT_SHOW_ON_PAGES'], 'TXT_SHOW_ON_ALL_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_ALL_PAGES'], 'TXT_SHOW_ON_SELECTED_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_SELECTED_PAGES'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_NONE' => $_ARRAYLANG['TXT_BLOCK_NONE'], 'TXT_BLOCK_SHOW_FROM' => $_ARRAYLANG['TXT_BLOCK_SHOW_FROM'], 'TXT_BLOCK_SHOW_UNTIL' => $_ARRAYLANG['TXT_BLOCK_SHOW_UNTIL'], 'TXT_BLOCK_SHOW_TIMED' => $_ARRAYLANG['TXT_BLOCK_SHOW_TIMED'], 'TXT_BLOCK_SHOW_ALWAYS' => $_ARRAYLANG['TXT_BLOCK_SHOW_ALWAYS'], 'TXT_BLOCK_LANG_SHOW' => $_ARRAYLANG['TXT_BLOCK_SHOW_BLOCK_IN_THIS_LANGUAGE'], 'TXT_BLOCK_BASIC_DATA' => $_ARRAYLANG['TXT_BLOCK_BASIC_DATA'], 'TXT_BLOCK_ADDITIONAL_OPTIONS' => $_ARRAYLANG['TXT_BLOCK_ADDITIONAL_OPTIONS'], 'TXT_BLOCK_SELECTED_PAGES' => $_ARRAYLANG['TXT_BLOCK_SELECTED_PAGES'], 'TXT_BLOCK_AVAILABLE_PAGES' => $_ARRAYLANG['TXT_BLOCK_AVAILABLE_PAGES'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_UNSELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_UNSELECT_ALL'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DISPLAY_TIME' => $_ARRAYLANG['TXT_BLOCK_DISPLAY_TIME'], 'TXT_BLOCK_FORM_DESC' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_USE_WYSIWYG_EDITOR' => $_ARRAYLANG['TXT_BLOCK_USE_WYSIWYG_EDITOR'], 'TXT_BLOCK_TARGETING' => $_ARRAYLANG['TXT_BLOCK_TARGETING'], 'TXT_BLOCK_TARGETING_SHOW_PANE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_SHOW_PANE'], 'TXT_BLOCK_TARGETING_ALL_USERS' => $_ARRAYLANG['TXT_BLOCK_TARGETING_ALL_USERS'], 'TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $_ARRAYLANG['TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW'], 'TXT_BLOCK_TARGETING_INCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_INCLUDE'], 'TXT_BLOCK_TARGETING_EXCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_EXCLUDE'], 'TXT_BLOCK_TARGETING_TYPE_LOCATION' => $_ARRAYLANG['TXT_BLOCK_TARGETING_TYPE_LOCATION'], 'TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING' => $_ARRAYLANG['TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING']));
     $targetingStatus = isset($_POST['targeting_status']) ? contrexx_input2int($_POST['targeting_status']) : 0;
     $targeting = array();
     foreach ($this->availableTargeting as $targetingType) {
         $targetingArr = isset($_POST['targeting'][$targetingType]) ? $_POST['targeting'][$targetingType] : array();
         if (empty($targetingArr)) {
             continue;
         }
         $targeting[$targetingType] = array('filter' => !empty($targetingArr['filter']) && in_array($targetingArr['filter'], array('include', 'exclude')) ? contrexx_input2raw($targetingArr['filter']) : 'include', 'value' => isset($targetingArr['value']) ? contrexx_input2raw($targetingArr['value']) : array());
     }
     if (isset($_POST['block_save_block'])) {
         $blockCat = !empty($_POST['blockCat']) ? intval($_POST['blockCat']) : 0;
         $blockContent = isset($_POST['blockFormText_']) ? array_map('contrexx_input2raw', $_POST['blockFormText_']) : array();
         $blockName = !empty($_POST['blockName']) ? contrexx_input2raw($_POST['blockName']) : $_ARRAYLANG['TXT_BLOCK_NO_NAME'];
         $blockStart = strtotime($_POST['inputStartDate']);
         $blockEnd = strtotime($_POST['inputEndDate']);
         $blockRandom = !empty($_POST['blockRandom']) ? intval($_POST['blockRandom']) : 0;
         $blockRandom2 = !empty($_POST['blockRandom2']) ? intval($_POST['blockRandom2']) : 0;
         $blockRandom3 = !empty($_POST['blockRandom3']) ? intval($_POST['blockRandom3']) : 0;
         $blockRandom4 = !empty($_POST['blockRandom4']) ? intval($_POST['blockRandom4']) : 0;
         $blockWysiwygEditor = isset($_POST['wysiwyg_editor']) ? 1 : 0;
         $blockLangActive = isset($_POST['blockFormLanguages']) ? array_map('intval', $_POST['blockFormLanguages']) : array();
         // placeholder configurations
         // global block
         // 0 = not activated , 1 = on all pages , 2 = selected pages
         $blockGlobal = !empty($_POST['blockGlobal']) ? intval($_POST['blockGlobal']) : 0;
         // direct block and category block placeholders
         // 0 = on all pages , 1 = selected pages
         $blockDirect = !empty($_POST['blockDirect']) ? intval($_POST['blockDirect']) : 0;
         $blockCategory = !empty($_POST['blockCategory']) ? intval($_POST['blockCategory']) : 0;
         // block on page relations for each placeholder
         $blockGlobalAssociatedPageIds = isset($_POST['globalSelectedPagesList']) ? array_map('intval', explode(",", $_POST['globalSelectedPagesList'])) : array();
         $blockDirectAssociatedPageIds = isset($_POST['directSelectedPagesList']) ? array_map('intval', explode(",", $_POST['directSelectedPagesList'])) : array();
         $blockCategoryAssociatedPageIds = isset($_POST['categorySelectedPagesList']) ? array_map('intval', explode(",", $_POST['categorySelectedPagesList'])) : array();
         if ($blockId) {
             if ($this->_updateBlock($blockId, $blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) {
                 if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) {
                     $this->storeTargetingSettings($blockId, $targetingStatus, $targeting);
                     \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&modified=true&blockname=' . $blockName);
                     exit;
                 }
             }
             $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_UPDATED'];
         } else {
             if ($blockId = $this->_addBlock($blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) {
                 if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) {
                     $this->storeTargetingSettings($blockId, $targetingStatus, $targeting);
                     \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&added=true&blockname=' . $blockName);
                     exit;
                 }
             }
             $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_ADDED'];
         }
     } elseif (($arrBlock = $this->_getBlock($blockId)) !== false) {
         $blockStart = $arrBlock['start'];
         $blockEnd = $arrBlock['end'];
         $blockCat = $arrBlock['cat'];
         $blockRandom = $arrBlock['random'];
         $blockRandom2 = $arrBlock['random2'];
         $blockRandom3 = $arrBlock['random3'];
         $blockRandom4 = $arrBlock['random4'];
         $blockWysiwygEditor = $arrBlock['wysiwyg_editor'];
         $blockContent = $arrBlock['content'];
         $blockLangActive = $arrBlock['lang_active'];
         $blockName = $arrBlock['name'];
         $blockGlobal = $arrBlock['global'];
         $blockDirect = $arrBlock['direct'];
         $blockCategory = $arrBlock['category'];
         $blockGlobalAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'global');
         $blockDirectAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'direct');
         $blockCategoryAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'category');
         $targeting = $this->loadTargetingSettings($blockId);
         if (!empty($targeting)) {
             $targetingStatus = 1;
         }
     }
     $pageTitle = $blockId != 0 ? sprintf($copy ? $_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'] : $_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($blockName)) : $_ARRAYLANG['TXT_BLOCK_ADD_BLOCK'];
     $this->_pageTitle = $pageTitle;
     if ($copy) {
         $blockId = 0;
     }
     $this->_objTpl->setVariable(array('BLOCK_ID' => $blockId, 'BLOCK_MODIFY_TITLE' => $pageTitle, 'BLOCK_NAME' => contrexx_raw2xhtml($blockName), 'BLOCK_CATEGORIES_PARENT_DROPDOWN' => $this->_getCategoriesDropdown($blockCat), 'BLOCK_START' => !empty($blockStart) ? strftime('%Y-%m-%d %H:%M', $blockStart) : $blockStart, 'BLOCK_END' => !empty($blockEnd) ? strftime('%Y-%m-%d %H:%M', $blockEnd) : $blockEnd, 'BLOCK_WYSIWYG_EDITOR' => $blockWysiwygEditor == 1 ? 'checked="checked"' : '', 'BLOCK_RANDOM' => $blockRandom == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_2' => $blockRandom2 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_3' => $blockRandom3 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_4' => $blockRandom4 == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_0' => $blockGlobal == '0' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_1' => $blockGlobal == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_2' => $blockGlobal == '2' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_SHOW_PAGE_SELECTOR' => $blockGlobal == '2' ? 'block' : 'none', 'BLOCK_DIRECT_0' => $blockDirect == '0' ? 'checked="checked"' : '', 'BLOCK_DIRECT_1' => $blockDirect == '1' ? 'checked="checked"' : '', 'BLOCK_DIRECT_SHOW_PAGE_SELECTOR' => $blockDirect == '1' ? 'block' : 'none', 'BLOCK_CATEGORY_0' => $blockCategory == '0' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_1' => $blockCategory == '1' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_SHOW_PAGE_SELECTOR' => $blockCategory == '1' ? 'block' : 'none', 'BLOCK_WYSIWYG_MEDIABROWSER' => $mediaBrowserCkeditor->getXHtml(), 'BLOCK_TARGETING_ALL_USERS' => $targetingStatus == 0 ? 'checked="checked"' : '', 'BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $targetingStatus == 1 ? 'checked="checked"' : '', 'BLOCK_TARGETING_COUNTRY_INCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'include' ? 'selected="selected"' : '', 'BLOCK_TARGETING_COUNTRY_EXCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'exclude' ? 'selected="selected"' : ''));
     if (!empty($targeting['country']) && !empty($targeting['country']['value'])) {
         foreach ($targeting['country']['value'] as $countryId) {
             $countryName = \Cx\Core\Country\Controller\Country::getNameById($countryId);
             if (empty($countryName)) {
                 continue;
             }
             $this->_objTpl->setVariable(array('BLOCK_TARGET_COUNTRY_ID' => contrexx_raw2xhtml($countryId), 'BLOCK_TARGET_COUNTRY_NAME' => contrexx_raw2xhtml($countryName)));
             $this->_objTpl->parse('block_targeting_country');
         }
     }
     $jsonData = new \Cx\Core\Json\JsonData();
     $pageTitlesTree = $jsonData->data('node', 'getPageTitlesTree');
     $pageTitlesTree = $pageTitlesTree['data'];
     $objJs = \ContrexxJavascript::getInstance();
     $blockGlobalPageSelects = $this->getPageSelections($pageTitlesTree, $blockGlobalAssociatedPageIds);
     $blockDirectPageSelects = $this->getPageSelections($pageTitlesTree, $blockDirectAssociatedPageIds);
     $blockCategoryPageSelects = $this->getPageSelections($pageTitlesTree, $blockCategoryAssociatedPageIds);
     $objJs->setVariable('globalPagesUnselectedOptions', $jsonData->json($blockGlobalPageSelects[1]), 'block');
     $objJs->setVariable('globalPagesSelectedOptions', $jsonData->json($blockGlobalPageSelects[0]), 'block');
     $objJs->setVariable('directPagesUnselectedOptions', $jsonData->json($blockDirectPageSelects[1]), 'block');
     $objJs->setVariable('directPagesSelectedOptions', $jsonData->json($blockDirectPageSelects[0]), 'block');
     $objJs->setVariable('categoryPagesUnselectedOptions', $jsonData->json($blockCategoryPageSelects[1]), 'block');
     $objJs->setVariable('categoryPagesSelectedOptions', $jsonData->json($blockCategoryPageSelects[0]), 'block');
     $objJs->setVariable('ckeditorconfigpath', substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'block');
     $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages();
     $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'global');
     $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'direct');
     $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'category');
     if (count($arrActiveSystemFrontendLanguages) > 0) {
         $intLanguageCounter = 0;
         $arrLanguages = array(0 => '', 1 => '', 2 => '');
         $strJsTabToDiv = '';
         foreach ($arrActiveSystemFrontendLanguages as $langId => $arrLanguage) {
             $boolLanguageIsActive = $blockId == 0 && $intLanguageCounter == 0 ? true : (isset($blockLangActive[$langId]) && $blockLangActive[$langId] == 1 ? true : false);
             $arrLanguages[$intLanguageCounter % 3] .= '<input id="languagebar_' . $langId . '" ' . ($boolLanguageIsActive ? 'checked="checked"' : '') . ' type="checkbox" name="blockFormLanguages[' . $langId . ']" value="1" onclick="switchBoxAndTab(this, \'lang_blockContent_' . $langId . '\');" /><label for="languagebar_' . $langId . '">' . contrexx_raw2xhtml($arrLanguage['name']) . ' [' . $arrLanguage['lang'] . ']</label><br />';
             $strJsTabToDiv .= 'arrTabToDiv["lang_blockContent_' . $langId . '"] = "langTab_' . $langId . '";' . "\n";
             ++$intLanguageCounter;
         }
         $this->_objTpl->setVariable(array('TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrLanguages[0], 'EDIT_LANGUAGES_2' => $arrLanguages[1], 'EDIT_LANGUAGES_3' => $arrLanguages[2], 'EDIT_JS_TAB_TO_DIV' => $strJsTabToDiv));
     }
     $arrLanguages = \FWLanguage::getLanguageArray();
     $i = 0;
     $activeFlag = 0;
     foreach ($arrLanguages as $langId => $arrLanguage) {
         if ($arrLanguage['frontend'] != 1) {
             continue;
         }
         $tmpBlockContent = isset($blockContent[$langId]) ? $blockContent[$langId] : '';
         $tmpBlockLangActive = isset($blockLangActive[$langId]) ? $blockLangActive[$langId] : 0;
         $tmpBlockContent = preg_replace('/\\{([A-Z0-9_-]+)\\}/', '[[\\1]]', $tmpBlockContent);
         if ($blockId != 0) {
             if (!$activeFlag && isset($blockLangActive[$langId])) {
                 $activeClass = 'active';
                 $activeFlag = 1;
             }
         } elseif (!$activeFlag) {
             $activeClass = 'active';
             $activeFlag = 1;
         }
         $this->_objTpl->setVariable(array('BLOCK_LANG_TAB_LANG_ID' => intval($langId), 'BLOCK_LANG_TAB_CLASS' => isset($activeClass) ? $activeClass : '', 'TXT_BLOCK_LANG_TAB_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name']), 'BLOCK_LANGTAB_DISPLAY' => $tmpBlockLangActive == 1 ? 'display:inline;' : ($blockId == 0 && $i == 0 ? 'display:inline;' : 'display:none;')));
         $this->_objTpl->parse('block_language_tabs');
         $this->_objTpl->setVariable(array('BLOCK_LANG_ID' => intval($langId), 'BLOCK_CONTENT_TEXT_HIDDEN' => contrexx_raw2xhtml($tmpBlockContent)));
         $this->_objTpl->parse('block_language_content');
         $activeClass = '';
         $i++;
     }
     if (!$this->getGeoIpComponent() || !$this->getGeoIpComponent()->getGeoIpServiceStatus()) {
         $this->_objTpl->touchBlock('warning_geoip_disabled');
     } else {
         $this->_objTpl->hideBlock('warning_geoip_disabled');
     }
 }
コード例 #23
0
 function saveLevel($arrData, $intLevelId = null)
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID;
     //get data
     $intId = intval($intLevelId);
     $intParentId = intval($arrData['levelPosition']);
     $intShowEntries = intval($arrData['levelShowEntries']);
     $intShowSublevels = isset($arrData['levelShowSublevels']) ? contrexx_input2int($arrData['levelShowSublevels']) : 0;
     $intShowCategories = intval($arrData['levelShowCategories']);
     $intActive = intval($arrData['levelActive']);
     $strPicture = contrexx_addslashes(contrexx_strip_tags($arrData['levelImage']));
     $arrName = $arrData['levelName'];
     $arrDescription = $arrData['levelDescription'];
     if (empty($intId)) {
         //insert new category
         $objInsertAttributes = $objDatabase->Execute("\n                INSERT INTO\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_levels\n                SET\n                    `parent_id`='" . $intParentId . "',\n                    `order`=0,\n                    `show_entries`='" . $intShowEntries . "',\n                    `show_sublevels`='" . $intShowSublevels . "',\n                    `show_categories`='" . $intShowCategories . "',\n                    `picture`='" . $strPicture . "',\n                    `active`='" . $intActive . "'\n            ");
         if ($objInsertAttributes !== false) {
             $intId = $objDatabase->Insert_ID();
             foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                 if (empty($arrName[0])) {
                     $arrName[0] = "[[" . $_ARRAYLANG['TXT_MEDIADIR_NEW_LEVEL'] . "]]";
                 }
                 if (empty($arrDescription[0])) {
                     $arrDescription[0] = isset($arrDescription[$_LANGID]) ? $arrDescription[$_LANGID] : '';
                 }
                 $strName = $arrName[$arrLang['id']];
                 $strDescription = $arrDescription[$arrLang['id']];
                 if (empty($strName)) {
                     $strName = $arrName[0];
                 }
                 if (empty($strDescription)) {
                     $strDescription = $arrDescription[0];
                 }
                 $objInsertNames = $objDatabase->Execute("\n                        INSERT INTO\n                            " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_level_names\n                        SET\n                            `lang_id`='" . intval($arrLang['id']) . "',\n                            `level_id`='" . intval($intId) . "',\n                            `level_name`='" . contrexx_raw2db(contrexx_input2raw($strName)) . "',\n                            `level_description`='" . contrexx_raw2db(contrexx_input2raw($strDescription)) . "'\n                    ");
             }
             if ($objInsertNames !== false) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         //update category
         if ($intParentId == $intLevelId) {
             $parentSql = null;
         } else {
             $parentSql = "`parent_id`='" . $intParentId . "',";
         }
         $objUpdateAttributes = $objDatabase->Execute("\n                UPDATE\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_levels\n                SET\n                    " . $parentSql . "\n                    `show_entries`='" . $intShowEntries . "',\n                    `show_sublevels`='" . $intShowSublevels . "',\n                    `show_categories`='" . $intShowCategories . "',\n                    `picture`='" . $strPicture . "',\n                    `active`='" . $intActive . "'\n                WHERE\n                    `id`='" . $intId . "'\n            ");
         if ($objUpdateAttributes !== false) {
             $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_level_names WHERE level_id='" . $intId . "'");
             foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                 if (empty($arrName[0])) {
                     $arrName[0] = "[[" . $_ARRAYLANG['TXT_MEDIADIR_NEW_LEVEL'] . "]]";
                 }
                 if (empty($arrDescription[0])) {
                     $arrDescription[0] = isset($arrDescription[$_LANGID]) ? $arrDescription[$_LANGID] : '';
                 }
                 $strName = $arrName[$arrLang['id']];
                 $strDescription = $arrDescription[$arrLang['id']];
                 if (empty($strName)) {
                     $strName = $arrName[0];
                 }
                 if (empty($strDescription)) {
                     $strDescription = $arrDescription[0];
                 }
                 $objInsertNames = $objDatabase->Execute("\n                        INSERT INTO\n                            " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_level_names\n                        SET\n                            `lang_id`='" . intval($arrLang['id']) . "',\n                            `level_id`='" . intval($intId) . "',\n                            `level_name`='" . contrexx_raw2db(contrexx_input2raw($strName)) . "',\n                            `level_description`='" . contrexx_raw2db(contrexx_input2raw($strDescription)) . "'\n                    ");
             }
             if ($objInsertNames !== false) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }
コード例 #24
0
 function getContent($intEntryId, $arrInputfield, $arrTranslationStatus)
 {
     global $objDatabase, $_LANGID;
     $intId = intval($arrInputfield['id']);
     $intEntryDefaultLang = $objDatabase->getOne("SELECT `lang_id` FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_entries WHERE id=" . intval($intEntryId) . " LIMIT 1");
     if ($this->arrSettings['settingsTranslationStatus'] == 1) {
         $intLangId = in_array($_LANGID, $arrTranslationStatus) ? $_LANGID : contrexx_input2int($intEntryDefaultLang);
     } else {
         $intLangId = $_LANGID;
     }
     $objResult = $objDatabase->Execute("\n            SELECT `value`\n              FROM " . DBPREFIX . "module_mediadir_rel_entry_inputfields\n             WHERE field_id={$intId}\n               AND entry_id={$intEntryId}\n               AND lang_id={$intLangId}\n             LIMIT 1 ");
     if (empty($objResult->fields['value'])) {
         $objResult = $objDatabase->Execute("\n                SELECT `value`\n                  FROM " . DBPREFIX . "module_mediadir_rel_entry_inputfields\n                 WHERE field_id={$intId}\n                   AND entry_id={$intEntryId}\n                   AND lang_id={$intEntryDefaultLang}\n                 LIMIT 1 ");
     }
     $strValue = strip_tags(htmlspecialchars($objResult->fields['value'], ENT_QUOTES, CONTREXX_CHARSET));
     if (empty($strValue) || $strValue == 'new_image') {
         return null;
     }
     $arrImageInfo = getimagesize(\Env::get('cx')->getWebsitePath() . $strValue);
     $imageWidth = $arrImageInfo[0] + 20;
     $imageHeight = $arrImageInfo[1] + 20;
     $arrImageInfo = pathinfo($strValue);
     $strImageName = $arrImageInfo['basename'];
     return array('TXT_MEDIADIR_INPUTFIELD_NAME' => htmlspecialchars($arrInputfield['name'][0], ENT_QUOTES, CONTREXX_CHARSET), 'MEDIADIR_INPUTFIELD_VALUE' => '<a rel="shadowbox[1];options={slideshowDelay:5}" href="' . $strValue . '">' . '<img src="' . $strValue . '.thumb" alt="" border="0" title="" ' . 'width="' . intval($this->arrSettings['settingsThumbSize']) . '" /></a>', 'MEDIADIR_INPUTFIELD_VALUE_SRC' => $strValue, 'MEDIADIR_INPUTFIELD_VALUE_FILENAME' => $strImageName, 'MEDIADIR_INPUTFIELD_VALUE_SRC_THUMB' => $strValue . ".thumb", 'MEDIADIR_INPUTFIELD_VALUE_POPUP' => '<a href="' . $strValue . '"' . ' onclick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $imageWidth . ',height=' . $imageHeight . ',status\');return false">' . '<img src="' . $strValue . '.thumb" title="' . $arrInputfield['name'][0] . '"' . ' width="' . intval($this->arrSettings['settingsThumbSize']) . '"' . ' alt="' . $arrInputfield['name'][0] . '" border="0" /></a>', 'MEDIADIR_INPUTFIELD_VALUE_IMAGE' => '<img src="' . $strValue . '" title="' . $arrInputfield['name'][0] . '"' . ' alt="' . $arrInputfield['name'][0] . '" />', 'MEDIADIR_INPUTFIELD_VALUE_THUMB' => '<img src="' . $strValue . '.thumb"' . ' width="' . intval($this->arrSettings['settingsThumbSize']) . '"' . ' title="' . $arrInputfield['name'][0] . '"' . ' alt="' . $arrInputfield['name'][0] . '" />');
 }
コード例 #25
0
 /**
  * Calculate the registration count (register, deregister, waitlist) of the event
  *
  * @staticvar boolean $calculated   Flag to check whether the registration is already
  *                                  calculated or not.
  * @return null
  */
 protected function calculateRegistrationCount()
 {
     global $objDatabase, $objInit, $_LANGID;
     if ($this->registrationCalculated) {
         return;
     }
     $isIndependentSeries = $this->seriesStatus && $this->independentSeries;
     $filterEventTime = '';
     if ($objInit->mode != 'backend' && $isIndependentSeries) {
         $filterEventTime = ' AND r.`date` = ' . $this->startDate->getTimestamp();
     }
     $queryCountRegistration = 'SELECT
                                     COUNT(1) AS numSubscriber,
                                     r.`type`
                                 FROM
                                     `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration` AS `r`
                                 WHERE
                                     r.`event_id` = ' . contrexx_input2int($this->id) . '
                                     ' . $filterEventTime . '
                                 GROUP BY
                                     r.`type`';
     $objCountRegistration = $objDatabase->Execute($queryCountRegistration);
     if ($objCountRegistration) {
         while (!$objCountRegistration->EOF) {
             switch ($objCountRegistration->fields['type']) {
                 case 1:
                     $this->registrationCount = (int) $objCountRegistration->fields['numSubscriber'];
                     break;
                 case 2:
                     $this->waitlistCount = (int) $objCountRegistration->fields['numSubscriber'];
                     break;
                 case 0:
                     $this->cancellationCount = (int) $objCountRegistration->fields['numSubscriber'];
                     break;
             }
             $objCountRegistration->MoveNext();
         }
     }
     $seatingOption = $objDatabase->getOne('
         SELECT
             `fn`.`default` AS `seating_option`
         FROM
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form` AS `f`
         INNER JOIN
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field` AS `ff`
         ON
             `f`.`id` = `ff`.`form`
         INNER JOIN
             `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name` AS `fn`
         ON
             `ff`.`id` = `fn`.`field_id`
         WHERE
             `f`.`id` = ' . contrexx_input2int($this->registrationForm) . '
         AND
             `ff`.`type` = "seating"
         ORDER BY CASE `fn`.lang_id
             WHEN ' . $_LANGID . ' THEN 1
             ELSE 2
             END
     ');
     $reservedSeating = 0;
     if ($seatingOption) {
         $seatingOptionArray = explode(',', $seatingOption);
         $queryRegistrations = '
             SELECT `v`.`value` AS `reserved_seating`
             FROM `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value` AS `v`
             INNER JOIN `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration` AS `r`
             ON `v`.`reg_id` = `r`.`id`
             INNER JOIN `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field` AS `f`
             ON `v`.`field_id` = `f`.`id`
             WHERE `r`.`event_id` = ' . contrexx_input2int($this->id) . '
                 ' . $filterEventTime . '
             AND `r`.`type` = 1
             AND `f`.`type` = "seating"
         ';
         $objResultRegistrations = $objDatabase->Execute($queryRegistrations);
         if ($objResultRegistrations !== false && $objResultRegistrations->RecordCount()) {
             while (!$objResultRegistrations->EOF) {
                 $selectedSeat = contrexx_input2int($objResultRegistrations->fields['reserved_seating']) - 1;
                 $reservedSeating += !empty($seatingOptionArray[$selectedSeat]) ? $seatingOptionArray[$selectedSeat] : 1;
                 $objResultRegistrations->MoveNext();
             }
         }
     } else {
         $reservedSeating = $this->registrationCount;
     }
     $freePlaces = intval($this->numSubscriber - $reservedSeating);
     $this->freePlaces = $freePlaces < 0 ? 0 : $freePlaces;
     $this->registrationCalculated = true;
 }
コード例 #26
0
 /**
  * Get Calendar month box for event detail view
  *
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event
  */
 public function getDetailMonthBox(CalendarEvent $event)
 {
     global $_ARRAYLANG;
     $monthnames = explode(",", $_ARRAYLANG['TXT_CALENDAR_MONTH_ARRAY']);
     $daynames = explode(',', $_ARRAYLANG['TXT_CALENDAR_DAY_ARRAY']);
     $year = !empty($_GET['yearID']) ? contrexx_input2int($_GET['yearID']) : 0;
     $month = !empty($_GET['monthID']) ? contrexx_input2int($_GET['monthID']) : 0;
     if (empty($year) && empty($month)) {
         $startdate = $this->getUserDateTimeFromIntern($event->startDate);
         $year = $startdate->format('Y');
         $month = $startdate->format('m');
     }
     $eventList = array($event);
     // If event series is enabled refresh the eventlist
     if ($event->seriesStatus == 1) {
         $endDate = new \DateTime('1-' . $month . '-' . $year);
         $endDate->modify('+1 month');
         $eventManager = new static(null, $endDate);
         $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($event->id));
         if ($eventManager->_addToEventList($objEvent)) {
             $eventManager->eventList[] = $objEvent;
         }
         $eventManager->_setNextSeriesElement($objEvent);
         $eventList = $eventManager->eventList;
     }
     $url = \Cx\Core\Core\Controller\Cx::instanciate()->getRequest()->getUrl();
     $cal = new \activeCalendar($year, $month);
     $cal->setMonthNames($monthnames);
     $cal->setDayNames($daynames);
     $cal->enableMonthNav($url->toString(false));
     $currentTime = time();
     $isNotIndependentSerieEventStarted = array();
     foreach ($eventList as $objEvent) {
         $eventDate = $this->getUserDateTimeFromIntern($objEvent->startDate);
         $eventYear = $eventDate->format('Y');
         $eventMonth = $eventDate->format('m');
         if ($eventYear != $year && $eventMonth != $month) {
             continue;
         }
         $eventDay = $eventDate->format('d');
         $isSeriesByNotIndependent = $objEvent->seriesStatus && !$objEvent->independentSeries;
         $isEventStarted = $currentTime >= $objEvent->startDate->getTimestamp();
         // check if non-independent-serie-event did already start
         if ($isSeriesByNotIndependent) {
             // the first date of a non-independent-serie-event does determine if
             // the event did already start
             if (!isset($isNotIndependentSerieEventStarted[$objEvent->getId()])) {
                 $isNotIndependentSerieEventStarted[$objEvent->getId()] = $isEventStarted;
             }
             // overwrite the started info from the serie data
             $isEventStarted = $isNotIndependentSerieEventStarted[$objEvent->getId()];
         }
         $freePlaces = $isEventStarted || in_array($objEvent->registration, array(CalendarEvent::EVENT_REGISTRATION_NONE, CalendarEvent::EVENT_REGISTRATION_EXTERNAL)) || $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && empty($objEvent->numSubscriber) || $isSeriesByNotIndependent ? 0 : $objEvent->getFreePlaces();
         $eventClass = ' event_full';
         $eventurl = false;
         if (!$isEventStarted && ($objEvent->registration == CalendarEvent::EVENT_REGISTRATION_NONE || $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL && !$objEvent->registrationExternalFullyBooked || $objEvent->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && (empty($objEvent->numSubscriber) || !\FWValidator::isEmpty($objEvent->getFreePlaces())))) {
             $eventClass = ' event_open';
             $eventurl = $this->_getDetailLink($objEvent);
         }
         $seatsLeft = empty($freePlaces) ? '&nbsp;' : $freePlaces . ' ' . $_ARRAYLANG['TXT_CALENDAR_EVENT_FREE'];
         $cal->setEvent($eventYear, $eventMonth, $eventDay, $eventClass, $eventurl);
         $cal->setEventContent($eventYear, $eventMonth, $eventDay, $seatsLeft, $eventurl, 'free_places');
     }
     return $cal->showMonth(false, true);
 }
コード例 #27
0
ファイル: validator.inc.php プロジェクト: Niggu/cloudrexx
/**
 * Ensures that data from any request is limited to integer values
 *
 * Apply to any string or array taken from a get or post request, or from a
 * cookie.
 * @param   mixed   $input    The input string or array
 * @return  mixed             The integer or array thereof
 * @author  Reto Kohli <*****@*****.**>
 */
function contrexx_input2int($input)
{
    if (is_array($input)) {
        $arr = array();
        foreach ($input as $i => $_input) {
            $arr[$i] = contrexx_input2int($_input);
        }
        return $arr;
    }
    return intval($input);
}
コード例 #28
0
 function saveInputfields($arrData)
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID;
     $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_inputfields WHERE form='" . $this->intFormId . "'");
     $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_inputfield_names WHERE form_id='" . $this->intFormId . "'");
     $inputfieldId = isset($arrData['inputfieldId']) ? $arrData['inputfieldId'] : array();
     foreach ($inputfieldId as $intKey => $intFieldId) {
         $intFieldId = intval($intFieldId);
         $intFieldOrder = intval($arrData['inputfieldOrder'][$intFieldId]);
         $arrFieldNames = contrexx_input2raw($arrData['inputfieldName'][$intFieldId]);
         $intFieldType = intval($arrData['inputfieldType'][$intFieldId]);
         $intFieldShowIn = intval($arrData['inputfieldShow'][$intFieldId]);
         $arrFieldDefaultValues = contrexx_input2raw($arrData['inputfieldDefaultvalue'][$intFieldId]);
         $arrFieldInfos = isset($arrData['inputfieldInfo'][$intFieldId]) ? contrexx_input2raw($arrData['inputfieldInfo'][$intFieldId]) : array();
         $intFieldVerification = intval($arrData['inputfieldVerification'][$intFieldId]);
         $intFieldMustfield = isset($arrData['inputfieldMustfield'][$intFieldId]) ? contrexx_input2int($arrData['inputfieldMustfield'][$intFieldId]) : 0;
         $intFieldExpSearch = isset($arrData['inputfieldExpSearch'][$intFieldId]) ? contrexx_input2int($arrData['inputfieldExpSearch'][$intFieldId]) : 0;
         $fieldContextType = contrexx_input2db($arrData['inputfieldContext'][$intFieldId]);
         //add inputfield
         $objSaveInputfield = $objDatabase->Execute("\n                INSERT INTO\n                    " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_inputfields\n                SET\n                    `id` = '" . $intFieldId . "',\n                    `form` = '" . $this->intFormId . "',\n                    `order` = '" . $intFieldOrder . "',\n                    `type` = '" . $intFieldType . "',\n                    `show_in` = '" . $intFieldShowIn . "',\n                    `verification` = '" . $intFieldVerification . "',\n                    `required` = '" . $intFieldMustfield . "',\n                    `search` = '" . $intFieldExpSearch . "',\n                    `context_type` = '" . $fieldContextType . "'\n\n            ");
         if ($objSaveInputfield === false) {
             return false;
         }
         //add inputfield names and default values
         $saveInputFieldName = $this->updateInputFields($intFieldId, $arrFieldNames, $arrFieldDefaultValues, $arrFieldInfos);
         if (!$saveInputFieldName) {
             return false;
         }
     }
     $selectorOrder = $selectorOrder2 = $selectorExpSearch = $selectorExpSearch2 = 0;
     if (isset($arrData['selectorOrder'])) {
         $selectorOrder = isset($arrData['selectorOrder'][1]) ? $arrData['selectorOrder'][1] : 0;
         $selectorOrder2 = isset($arrData['selectorOrder'][2]) ? $arrData['selectorOrder'][2] : 0;
     }
     if (isset($arrData['selectorExpSearch'])) {
         $selectorExpSearch = isset($arrData['selectorExpSearch'][1]) ? $arrData['selectorExpSearch'][1] : 0;
         $selectorExpSearch2 = isset($arrData['selectorExpSearch'][2]) ? $arrData['selectorExpSearch'][2] : 0;
     }
     $objCategorySelector = $objDatabase->Execute("UPDATE " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_order_rel_forms_selectors SET `selector_order`='" . contrexx_input2int($selectorOrder) . "', `exp_search`='" . intval($selectorExpSearch) . "' WHERE `selector_id`='9' AND `form_id`='" . $this->intFormId . "'");
     $objLevelSelector = $objDatabase->Execute("UPDATE " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_order_rel_forms_selectors SET `selector_order`='" . contrexx_input2int($selectorOrder2) . "', `exp_search`='" . intval($selectorExpSearch2) . "' WHERE `selector_id`='10' AND `form_id`='" . $this->intFormId . "'");
     if ($objCategorySelector === false || $objLevelSelector === false) {
         return false;
     }
     return true;
 }
コード例 #29
0
 /**
  * Searches the content and returns an array that is built as needed by the search module.
  *
  * @param string $searchTerm
  *
  * @return array
  */
 public function searchResultsForSearchModule($searchTerm)
 {
     $em = \Env::get('cx')->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     // only list results in case the associated page of the module is active
     $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION));
     //If page is not exists or page is inactive then return empty result
     if (!$page || !$page->isActive()) {
         return array();
     }
     //get the config site values
     \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml');
     $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config');
     $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config');
     //get the config otherConfigurations value
     \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml');
     $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config');
     $hasPageAccess = true;
     $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible();
     if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) {
         $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true);
     }
     //If the page is invisible and frontend access is denied then return empty result
     if ($isNotVisible || !$hasPageAccess) {
         return array();
     }
     //get the media directory entry by the search term
     $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName);
     $entries->getEntries(null, null, null, $searchTerm);
     //if no entries found then return empty result
     if (empty($entries->arrEntries)) {
         return array();
     }
     $results = array();
     $formEntries = array();
     $defaultEntries = null;
     $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName);
     $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']);
     foreach ($entries->arrEntries as $entry) {
         $pageUrlResult = null;
         $entryForm = $objForm->arrForms[$entry['entryFormId']];
         //Get the entry's link url
         //check the entry's form detail view exists if not,
         //check the entry's form overview exists if not,
         //check the default overview exists if not, dont show the corresponding entry in entry
         switch (true) {
             case $entries->checkPageCmd('detail' . $entry['entryFormId']):
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId']));
                 break;
             case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']):
             case $entries->checkPageCmd(''):
                 if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) {
                     $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']);
                 }
                 if (!$pageCmdExists && !isset($defaultEntries)) {
                     $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $defaultEntries->getEntries();
                 }
                 //get entry's form overview / default page paging position
                 $entriesPerPage = $numOfEntries;
                 if ($pageCmdExists) {
                     $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries;
                 }
                 $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : '';
                 $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries);
                 $entryPos = array_search($entry['entryId'], $entryKeys);
                 $position = floor($entryPos / $entriesPerPage);
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage));
                 break;
             default:
                 break;
         }
         //If page url is empty then dont show it in the result
         if (!$pageUrlResult) {
             continue;
         }
         //Get the search results title and content from the form context field 'title' and 'content'
         $title = current($entry['entryFields']);
         $content = '';
         $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName);
         $inputFields = $objInputfields->getInputfields();
         foreach ($inputFields as $arrInputfield) {
             $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : '';
             if (!in_array($contextType, array('title', 'content'))) {
                 continue;
             }
             $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : '';
             $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
             try {
                 $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                 $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null;
                 $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus);
                 if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) {
                     $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']);
                     \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage());
                 }
             } catch (\Exception $e) {
                 \DBG::log($e->getMessage());
                 continue;
             }
             $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE'];
             if (empty($inputFieldValue)) {
                 continue;
             }
             if ($contextType == 'title') {
                 $title = $inputFieldValue;
             } elseif ($contextType == 'content') {
                 $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength);
             }
         }
         $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString());
     }
     return $results;
 }
コード例 #30
0
ファイル: ShopManager.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Store the count discounts after editing
  * @return    boolean             True on success, false otherwise
  * @author    Reto Kohli <*****@*****.**>
  */
 function store_discount_count()
 {
     if (!isset($_POST['discountId'])) {
         return true;
     }
     $discountId = intval($_POST['discountId']);
     $discountGroupName = contrexx_input2raw($_POST['discountGroupName']);
     $discountGroupUnit = contrexx_input2raw($_POST['discountGroupUnit']);
     $arrDiscountCount = contrexx_input2int($_POST['discountCount']);
     $arrDiscountRate = contrexx_input2float($_POST['discountRate']);
     return Discount::storeDiscountCount($discountId, $discountGroupName, $discountGroupUnit, $arrDiscountCount, $arrDiscountRate);
 }