本文整理汇总了PHP中contrexx_input2int函数的典型用法代码示例。如果您正苦于以下问题:PHP contrexx_input2int函数的具体用法?PHP contrexx_input2int怎么用?PHP contrexx_input2int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contrexx_input2int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllNews
/**
* 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: showEntry
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: getContent
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: getSortingOption
/**
* 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: removeFileFromFolderWidget
/**
* 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: loadEventManager
//.........这里部分代码省略.........
} 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: getHeadlines
/**
* 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'])) . '&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);
//.........这里部分代码省略.........
示例8: getNewsFilterQuery
/**
* 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: overview
/**
* 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, "&cmd=" . $this->moduleName . "&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: searchByName
/**
* 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: settings_save_mask
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: saveForm
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: showForm
//.........这里部分代码省略.........
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 . '/> ' . $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) . '" /> ' . $name . '<br />';
}
break;
case 'agb':
$inputfield = '<input class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" /> ' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />';
break;
/* case 'selectBillingAddress':
if(!$selectBillingAddressStatus) {
if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') {
$selectDeviatesFromContact = 'selected="selected"';
示例14: updateOrder
/**
* 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;
//.........这里部分代码省略.........
示例15: save
/**
* 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`
//.........这里部分代码省略.........