function getLatestPlacholder() { $this->strPlaceholder = null; $intLimitEnd = intval($this->arrSettings['settingsLatestNumOverview']); $objEntries = new MediaDirectoryEntry($this->moduleName); $objEntries->getEntries(null, null, null, null, true, null, 1, null, $intLimitEnd); foreach ($objEntries->arrEntries as $intEntryId => $arrEntry) { if ($objEntries->checkPageCmd('detail' . intval($arrEntry['entryFormId']))) { $strDetailCmd = 'detail' . intval($arrEntry['entryFormId']); } else { $strDetailCmd = 'detail'; } $strDetailUrl = 'index.php?section=' . $this->moduleName . '&cmd=' . $strDetailCmd . '&eid=' . $arrEntry['entryId']; $this->strPlaceholder .= '<li><a href="' . $strDetailUrl . '">' . $arrEntry['entryFields'][0] . '</a></li>'; } return '<ul id="' . $this->moduleNameLC . 'LatestPlacholder">' . $this->strPlaceholder . '</ul>'; }
function deleteEntry() { global $_ARRAYLANG, $_CORELANG; $this->_objTpl->setTemplate($this->pageContent, true, true); //save entry data if (isset($_POST['submitEntryModfyForm']) && intval($_POST['entryId'])) { $objEntry = new MediaDirectoryEntry($this->moduleName); $strStatus = $objEntry->deleteEntry(intval($_POST['entryId'])); if ($strStatus == true) { $strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_DELETED']; } else { $strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_DELETED']; } } //check id if (intval($_GET['eid']) != 0) { $intEntryId = intval($_GET['eid']); } else { $intEntryId = null; } $objEntry = new MediaDirectoryEntry($this->moduleName); if ($this->arrSettings['settingsReadyToConfirm'] == 1) { $objEntry->getEntries($intEntryId, null, null, null, null, null, true, null, 1, null, null, null, true); } else { $objEntry->getEntries($intEntryId, null, null, null, null, null, 1, null, 1); } $objEntry->listEntries($this->_objTpl, 2); //parse global variables $this->_objTpl->setVariable(array($this->moduleLangVar . '_ENTRY_ID' => $intEntryId, 'TXT_' . $this->moduleLangVar . '_DELETE' => $_CORELANG['TXT_ACCESS_DELETE_ENTRY'], 'TXT_' . $this->moduleLangVar . '_ABORT' => $_CORELANG['TXT_CANCEL'], 'TXT_' . $this->moduleLangVar . '_OK_MESSAGE' => $strOkMessage, 'TXT_' . $this->moduleLangVar . '_ERROR_MESSAGE' => $strErrMessage)); if (!empty($strOkMessage)) { $this->_objTpl->parse($this->moduleNameLC . 'EntryOkMessage'); $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryErrMessage'); $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryModifyForm'); } else { if (!empty($strErrMessage)) { $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryOkMessage'); $this->_objTpl->parse($this->moduleNameLC . 'EntryErrMessage'); $this->_objTpl->parse($this->moduleNameLC . 'EntryModifyForm'); } else { $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryOkMessage'); $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryErrMessage'); $this->_objTpl->parse($this->moduleNameLC . 'EntryModifyForm'); } } }
function checkAccess($strAction) { global $objInit; if ($objInit->mode == 'backend') { //backend access } else { //frontend access $strStatus = ''; $objFWUser = \FWUser::getFWUserObject(); //get user attributes $objUser = $objFWUser->objUser; $intUserId = intval($objUser->getId()); $bolUserLogin = $objUser->login(); $intUserIsAdmin = $objUser->getAdminStatus(); $intSelectedFormId = empty($_REQUEST['selectedFormId']) ? substr($_REQUEST['cmd'], 3) : intval($_REQUEST['selectedFormId']); $accessId = 0; //used to remember which access id the user needs to have. this is passed to Permission::checkAccess() later. if (!$intUserIsAdmin) { self::getSettings(); switch ($strAction) { case 'add_entry': $accessId = MediaDirectoryAccessIDs::AddEntry; if ($this->arrSettings['settingsAllowAddEntries']) { if ($this->arrSettings['settingsAddEntriesOnlyCommunity'] == 1) { if ($bolUserLogin) { $bolAdd = true; } else { $bolAdd = false; } } else { $bolAdd = true; } if ($bolAdd) { //get groups attributes $arrUserGroups = array(); $objGroup = $objFWUser->objGroup->getGroups($filter = array('is_active' => true, 'type' => 'frontend')); while (!$objGroup->EOF) { if (in_array($objGroup->getId(), $objUser->getAssociatedGroupIds())) { $arrUserGroups[] = $objGroup->getId(); } $objGroup->next(); } self::getCommunityGroups(); $strMaxEntries = 0; $bolFormAllowed = false; //check max entries foreach ($arrUserGroups as $intGroupId) { $strNewMaxEntries = $this->arrCommunityGroups[$intGroupId]['num_entries']; if ($strNewMaxEntries === 'n' || $strMaxEntries === 'n') { $strMaxEntries = 'n'; } else { if ($strNewMaxEntries >= $strMaxEntries) { $strMaxEntries = $strNewMaxEntries; } } if ($this->arrCommunityGroups[$intGroupId]['status_group'][$intSelectedFormId] == 1 && !$bolFormAllowed) { $bolFormAllowed = true; } } $objEntries = new MediaDirectoryEntry($this->moduleName); $objEntries->getEntries(null, null, null, null, null, null, null, null, 'n', $intUserId); if ($strMaxEntries <= intval(count($objEntries->arrEntries)) && $strMaxEntries !== 'n' && $this->arrSettings['settingsAddEntriesOnlyCommunity'] == 1) { $strStatus = 'redirect'; } //OSEC CUSTOMIZING if ($intSelectedFormId == 5) { // entry is not yet ready to get confirmed $objEntries = new MediaDirectoryEntry($this->moduleName); $objEntries->getEntries(null, null, null, null, null, true, null, null, 'n', $intUserId, null, $intSelectedFormId); if (count($objEntries->arrEntries) >= 1) { foreach ($objEntries->arrEntries as $intEntryId => $arrEntry) { $strStatus = 'osec' . $intEntryId; } } // entry is ready to get confirmed $objEntries = new MediaDirectoryEntry($this->moduleName); $objEntries->getEntries(null, null, null, null, null, null, null, null, 'n', $intUserId, null, $intSelectedFormId, true); if (count($objEntries->arrEntries) >= 1) { foreach ($objEntries->arrEntries as $intEntryId => $arrEntry) { $strStatus = 'osec' . $intEntryId; } } } //check from type if (!$bolFormAllowed && $intSelectedFormId != 0 && $this->arrSettings['settingsAddEntriesOnlyCommunity'] == 1) { $strStatus = 'no_access'; } } else { $strStatus = 'login'; } } else { $strStatus = 'redirect'; } break; case 'edit_entry': $accessId = MediaDirectoryAccessIDs::ModifyEntry; if ($this->arrSettings['settingsAllowEditEntries']) { if ($bolUserLogin) { $objEntries = new MediaDirectoryEntry($this->moduleName); if (isset($_POST['submitEntryModfyForm'])) { $intEntryId = intval($_POST['entryId']); } else { $intEntryId = intval($_GET['eid']); } $objEntries->getEntries($intEntryId, null, null, null, null, null, null, null, 'n', $intUserId, null, $intSelectedFormId, true); if ($objEntries->arrEntries[$intEntryId]['entryAddedBy'] !== $intUserId) { $strStatus = 'confirm_in_progress'; } } else { $strStatus = 'login'; } } else { $strStatus = 'redirect'; } break; case 'delete_entry': $accessId = MediaDirectoryAccessIDs::ModifyEntry; if ($this->arrSettings['settingsAllowDelEntries']) { if ($bolUserLogin) { $objEntries = new MediaDirectoryEntry($this->moduleName); $objEntries->getEntries(intval($_GET['eid'])); if ($objEntries->arrEntries[intval($_GET['eid'])]['entryAddedBy'] !== $intUserId) { $strStatus = 'no_access'; } } else { $strStatus = 'login'; } } else { $strStatus = 'redirect'; } break; case 'show_entry': //no access rules define break; case 'my_entries': if (!$bolUserLogin) { $strStatus = 'login'; } break; } //only run Permission::checkAccess if user is logged in. //logged out users are redirected to a login page with redirect param //a few lines below if ($bolUserLogin && $accessId) { \Permission::checkAccess($accessId, 'static'); } switch ($strStatus) { case 'no_access': header('Location: ' . CONTREXX_SCRIPT_PATH . '?section=Login&cmd=noaccess'); exit; break; case 'login': $link = base64_encode(CONTREXX_SCRIPT_PATH . '?' . $_SERVER['QUERY_STRING']); header("Location: " . CONTREXX_SCRIPT_PATH . "?section=Login&redirect=" . $link); exit; break; case 'redirect': header('Location: ' . CONTREXX_SCRIPT_PATH . '?section=' . $this->moduleName); exit; break; case 'confirm_in_progress': header('Location: ' . CONTREXX_SCRIPT_PATH . '?section=' . $this->moduleName . '&cmd=confirm_in_progress'); exit; break; default: if (substr($strStatus, 0, 4) == 'osec') { header('Location: ' . CONTREXX_SCRIPT_PATH . '?section=' . $this->moduleName . '&cmd=edit5&eid=' . intval(substr($strStatus, 4))); exit; } break; } } } }
function exportCSV($intFormId, $arrCategoryIds = null, $arrLevelIds = null, $intMaskId = null) { global $_ARRAYLANG, $_CORELANG, $_LANGID, $objDatabase; if ($intFormId != null) { $objValidator = new \FWValidator(); $arrEntries = array(); $arrEntriesData = array(); $arrInputfields = array(); $arrMask = array(); if ($intMaskId != null && $intMaskId != 0) { $objResultMask = $objDatabase->Execute("SELECT\n fields, form_id\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_masks\n WHERE id = '" . $intMaskId . "'\n "); if ($objResultMask !== false) { $arrMask = explode(',', $objResultMask->fields['fields']); $intFormId = $objResultMask->fields['form_id']; } } $objForm = new MediaDirectoryForm($intFormId, $this->moduleName); $objInputfields = new MediaDirectoryInputfield($intFormId, false, null, $this->moduleName); $strFilename = contrexx_raw2encodedUrl($objForm->arrForms[$intFormId]['formName'][0]) . "_" . mktime() . ".csv"; if ($arrCategoryIds != null) { foreach ($arrCategoryIds as $intKey => $intCategoryId) { if ($arrLevelIds != null) { $strDatabaseLevel = "," . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_levels AS level"; $strLevels = join(',', $arrLevelIds); $strWhereLevel = " AND ((cat.entry_id = level.entry_id) AND (level.level_id IN (" . $strLevels . ")))"; } $objResultCategories = $objDatabase->Execute("SELECT\n cat.entry_id AS entryId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_categories AS cat\n " . $strDatabaseLevel . "\n WHERE\n cat.category_id ='" . $intCategoryId . "'\n " . $strWhereLevel . "\n "); if ($objResultCategories !== false) { while (!$objResultCategories->EOF) { $arrEntries[$objResultCategories->fields['entryId']] = $objResultCategories->fields['entryId']; $objResultCategories->MoveNext(); } } } } else { if ($arrLevelIds != null) { foreach ($arrLevelIds as $intKey => $intLevelId) { $objResultLevels = $objDatabase->Execute("SELECT\n level.entry_id AS entryId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_levels AS level\n WHERE\n level.level_id ='" . $intLevelId . "'\n "); if ($objResultLevels !== false) { while (!$objResultLevels->EOF) { $arrEntries[$objResultLevels->fields['entryId']] = $objResultLevels->fields['entryId']; $objResultLevels->MoveNext(); } } } } else { $objEntry = new MediaDirectoryEntry($this->moduleName); $objEntry->getEntries(null, null, null, null, null, null, true, null, 'n', null, null, $intFormId); foreach ($objEntry->arrEntries as $intEntryId => $arrEntry) { $arrEntries[$intEntryId] = $intEntryId; } } } foreach ($arrEntries as $intKey => $intEntryId) { $objResultEntry = $objDatabase->Execute("SELECT\n entry.value AS value, entry.form_id AS formId, entry.field_id AS fieldId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields AS entry\n WHERE\n entry.entry_id ='" . $intEntryId . "'\n AND\n entry.lang_id ='" . $_LANGID . "'\n "); if ($objResultEntry !== false) { while (!$objResultEntry->EOF) { if ($objResultEntry->fields['formId'] == $intFormId) { $arrEntriesData[$intEntryId][$objResultEntry->fields['fieldId']] = $objResultEntry->fields['value']; } $objResultEntry->MoveNext(); } } } foreach ($objInputfields->arrInputfields as $intFieldId => $arrField) { $arrInputfields[$arrField['order']]['id'] = $intFieldId; $arrInputfields[$arrField['order']]['name'] = $arrField['name'][0]; } ksort($arrInputfields); header("Content-Type: text/comma-separated-values; charset=" . CONTREXX_CHARSET, true); header("Content-Disposition: attachment; filename=\"{$strFilename}\"", true); foreach ($arrInputfields as $intKey => $arrField) { if ($intMaskId == null || $arrMask != null && in_array($arrField['id'], $arrMask)) { print self::escapeCsvValue($arrField['name']) . $this->csvSeparator; } } print "\r\n"; foreach ($arrEntriesData as $intEntryId => $arrEntry) { foreach ($arrInputfields as $intFieldOrder => $arrField) { if ($intMaskId == null || $arrMask != null && in_array($arrField['id'], $arrMask)) { switch ($arrField['id']) { case 1: $arrCategories = self::getCategoriesLevels(1, $intEntryId); $strFieldValue = join($this->elementSeparator, $arrCategories); break; case 2: $arrLevels = self::getCategoriesLevels(2, $intEntryId); $strFieldValue = join($this->elementSeparator, $arrLevels); break; default: $strFieldValue = isset($arrEntriesData[$intEntryId][$arrField['id']]) ? $arrEntriesData[$intEntryId][$arrField['id']] : ''; $strFieldValue = strip_tags($strFieldValue); $strFieldValue = self::escapeCsvValue($strFieldValue); $strFieldValue = html_entity_decode($strFieldValue, ENT_QUOTES, CONTREXX_CHARSET); break; } if (CONTREXX_CHARSET == 'UTF-8') { $strFieldValue = utf8_decode($strFieldValue); } print $strFieldValue . $this->csvSeparator; } } print "\r\n"; } exit; } else { return false; } }
function manageEntries() { global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID; $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_manage_entries.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_MEDIADIR_MANAGE_ENTRIES']; $this->initFilterSession(); if (isset($_REQUEST['cat_id'])) { $_SESSION[$this->moduleName]['searchFilter']['cat_id'] = intval($_REQUEST['cat_id']); } if (isset($_REQUEST['level_id'])) { $_SESSION[$this->moduleName]['searchFilter']['level_id'] = intval($_REQUEST['level_id']); } if (isset($_REQUEST['form_id'])) { $_SESSION[$this->moduleName]['searchFilter']['form_id'] = intval($_REQUEST['form_id']); } if (isset($_REQUEST['term'])) { $_SESSION[$this->moduleName]['searchFilter']['term'] = $_REQUEST['term'] != $_ARRAYLANG['TXT_MEDIADIR_ID_OR_SEARCH_TERM'] ? $_REQUEST['term'] : null; } //assign the searchFilter session values to corresponding variables $intCategoryId = $_SESSION[$this->moduleName]['searchFilter']['cat_id']; $intLevelId = $_SESSION[$this->moduleName]['searchFilter']['level_id']; $intFormId = $_SESSION[$this->moduleName]['searchFilter']['form_id']; $strTerm = $_SESSION[$this->moduleName]['searchFilter']['term']; $objCategories = new MediaDirectoryCategory(null, null, 1, $this->moduleName); $catDropdown = $objCategories->listCategories(null, 3, $intCategoryId); $objLevels = new MediaDirectoryLevel(null, null, 1, $this->moduleName); $levelDropdown = $objLevels->listLevels(null, 3, $intLevelId); $objForms = new MediaDirectoryForm(null, $this->moduleName); $formDropdown = $objForms->listForms(null, 4, $intFormId); //parse global variables $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_PAGE_TITLE' => $this->pageTitle, 'TXT_' . $this->moduleLangVar . '_SUBMIT' => $_ARRAYLANG['TXT_' . $this->moduleLangVar . '_SUBMIT'], 'TXT_EDIT' => $_ARRAYLANG['TXT_MEDIADIR_EDIT'], 'TXT_SEARCH' => $_CORELANG['TXT_SEARCH'], 'TXT_MEDIADIR_STATUS' => $_CORELANG['TXT_STATUS'], 'TXT_SELECT_ALL' => $_CORELANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_CORELANG['TXT_DESELECT_ALL'], 'TXT_SELECT_ACTION' => $_CORELANG['TXT_MULTISELECT_SELECT'], 'TXT_FUNCTIONS' => $_ARRAYLANG['TXT_MEDIADIR_FUNCTIONS'], 'TXT_DELETE' => $_ARRAYLANG['TXT_MEDIADIR_DELETE'], 'TXT_DELETE_ALL' => $_CORELANG['TXT_MULTISELECT_DELETE'], 'TXT_' . $this->moduleLangVar . '_VOTING' => $_ARRAYLANG['TXT_MEDIADIR_VOTING'], 'TXT_' . $this->moduleLangVar . '_COMMENTS' => $_ARRAYLANG['TXT_MEDIADIR_COMMENTS'], 'TXT_' . $this->moduleLangVar . '_NAME' => $_CORELANG['TXT_NAME'], 'TXT_' . $this->moduleLangVar . '_DATE' => $_CORELANG['TXT_DATE'], 'TXT_' . $this->moduleLangVar . '_AUTHOR' => $_ARRAYLANG['TXT_MEDIADIR_AUTHOR'], 'TXT_' . $this->moduleLangVar . '_HITS' => $_ARRAYLANG['TXT_MEDIADIR_HITS'], 'TXT_' . $this->moduleLangVar . '_ACTION' => $_CORELANG['TXT_HISTORY_ACTION'], $this->moduleLangVar . '_SEARCH_TERM' => $strTerm != null ? $strTerm : $_ARRAYLANG['TXT_MEDIADIR_ID_OR_SEARCH_TERM'], 'TXT_' . $this->moduleLangVar . '_ID_OR_SEARCH_TERM' => $_ARRAYLANG['TXT_MEDIADIR_ID_OR_SEARCH_TERM'], $this->moduleLangVar . '_SEARCH_CATEGORY_ID' => $intCategoryId, $this->moduleLangVar . '_SEARCH_LEVEL_ID' => $intLevelId, 'TXT_' . $this->moduleLangVar . '_MOVE_ALL' => $_ARRAYLANG['TXT_MEDIADIR_MOVE_ALL'], 'TXT_' . $this->moduleLangVar . '_RESTORE_VOTING_ALL' => $_ARRAYLANG['TXT_MEDIADIR_RESTORE_VOTING_ALL'], 'TXT_' . $this->moduleLangVar . '_RESTORE_COMMENTS_ALL' => $_ARRAYLANG['TXT_MEDIADIR_RESTORE_COMMENTS_ALL'], 'TXT_' . $this->moduleLangVar . '_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_MEDIADIR_CONFIRM_DELETE_DATA'], 'TXT_' . $this->moduleLangVar . '_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_MEDIADIR_ACTION_IS_IRREVERSIBLE'], 'TXT_' . $this->moduleLangVar . '_MAKE_SELECTION' => $_ARRAYLANG['TXT_MEDIADIR_MAKE_SELECTION'], 'TXT_SELECT_ALL' => $_CORELANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_CORELANG['TXT_DESELECT_ALL'], 'TXT_SELECT_ACTION' => $_CORELANG['TXT_MULTISELECT_SELECT'], 'TXT_DELETE_ALL' => $_CORELANG['TXT_MULTISELECT_DELETE'], 'TXT_' . $this->moduleLangVar . '_MOVE_ALL' => $_ARRAYLANG['TXT_MEDIADIR_MOVE_ALL'], 'TXT_' . $this->moduleLangVar . '_ALL_LEVELS' => $_ARRAYLANG['TXT_MEDIADIR_ALL_LEVELS'], 'TXT_' . $this->moduleLangVar . '_ALL_CATEGORIES' => $_ARRAYLANG['TXT_MEDIADIR_ALL_CATEGORIES'], 'TXT_' . $this->moduleLangVar . '_ALL_FORMS' => $_ARRAYLANG['TXT_MEDIADIR_ALL_FORMS'], $this->moduleLangVar . '_CATEGORIES_DROPDOWN_OPTIONS' => $catDropdown, $this->moduleLangVar . '_LEVELS_DROPDOWN_OPTIONS' => $levelDropdown, $this->moduleLangVar . '_FORMS_DROPDOWN_OPTIONS' => $formDropdown, 'TXT_' . $this->moduleLangVar . '_FORM' => $_ARRAYLANG['TXT_MEDIADIR_FORM'])); //get seting values parent::getSettings(); if ($this->arrSettings['settingsShowLevels'] == 1) { $this->_objTpl->touchBlock($this->moduleNameLC . 'LevelDropdown'); } else { $this->_objTpl->hideBlock($this->moduleNameLC . 'LevelDropdown'); } if (count($objForms->arrForms) > 1) { $this->_objTpl->touchBlock($this->moduleNameLC . 'FormDropdown'); } else { $this->_objTpl->hideBlock($this->moduleNameLC . 'FormDropdown'); } $objEntries = new MediaDirectoryEntry($this->moduleName); if (isset($_POST['submitEntriesOrderForm'])) { if ($objEntries->saveOrder($_POST)) { $this->strOkMessage = $_CORELANG['TXT_SETTINGS_UPDATED']; } else { $this->strErrMessage = $_CORELANG['TXT_DATABASE_QUERY_ERROR']; } } $objSettings = new MediaDirectorySettings($this->moduleName); if ($this->_objTpl->blockExists('mediadirTableHeaderComments')) { if ($objSettings->arrSettings['settingsAllowComments']) { $this->_objTpl->touchBlock('mediadirTableHeaderComments'); } } if ($this->_objTpl->blockExists('mediadirTableHeaderVotes')) { if ($objSettings->arrSettings['settingsAllowVotes']) { $this->_objTpl->touchBlock('mediadirTableHeaderVotes'); } } switch ($_GET['act']) { case 'move_entry': $this->strErrMessage = "Diese Funktion ist zurzeit noch nicht implementiert."; break; case 'delete_entry': \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static'); if (!isset($_GET['id'])) { foreach ($_POST["entriesFormSelected"] as $intEntryId) { $strStatus = $objEntries->deleteEntry(intval($intEntryId)); } } else { $strStatus = $objEntries->deleteEntry(intval($_GET['id'])); } if ($strStatus) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_DELETED']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_DELETED']; } break; case 'restore_voting': \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static'); $objVotes = new MediaDirectoryVoting($this->moduleName); if (!isset($_GET['id'])) { foreach ($_POST["entriesFormSelected"] as $intEntryId) { $strStatus = $objVotes->restoreVoting(intval($intEntryId)); } } else { $strStatus = $objVotes->restoreVoting(intval($_GET['id'])); } if ($strStatus) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_VOTING'] . " " . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_DELETED']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_VOTING'] . " " . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_DELETED']; } break; case 'restore_comments': \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static'); $objComments = new MediaDirectoryComment($this->moduleName); if (!isset($_GET['id'])) { foreach ($_POST["entriesFormSelected"] as $intEntryId) { $strStatus = $objComments->restoreComments(intval($intEntryId)); } } else { $strStatus = $objComments->restoreComments(intval($_GET['id'])); } if ($strStatus) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_COMMENTS'] . " " . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_DELETED']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_COMMENTS'] . " " . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_DELETED']; } break; break; case 'confirm_entry': \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static'); if (!isset($_GET['id'])) { foreach ($_POST["entriesFormSelected"] as $intEntryId) { $strStatus = $objEntries->confirmEntry(intval($intEntryId)); } } else { $strStatus = $objEntries->confirmEntry(intval($_GET['id'])); } if ($strStatus) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_CONFIRM']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_CONFIRM']; } break; } $objEntries->getEntries(null, $intLevelId, $intCategoryId, $strTerm, null, null, null, null, 'n', null, null, $intFormId, null, $this->limit, $this->offset); $objEntries->listEntries($this->_objTpl, 1); // Paging $count = $objEntries->countEntries(); $filter = (!empty($strTerm) ? '&term=' . $strTerm : '') . (!empty($intCategoryId) ? '&cat_id=' . $intCategoryId : '') . (!empty($intFormId) ? '&form_id=' . $intFormId : '') . (!empty($intLevelId) ? '&level_id=' . $intLevelId : ''); $term = !empty($strTerm) ? '&term=' . $strTerm : ''; $paging = getPaging($count, $this->offset, '&cmd=' . $this->moduleName . '&act=entries' . $filter, '', true); $this->_objTpl->setGlobalVariable($this->moduleLangVar . '_PAGING', $paging); if (!empty($strTerm)) { $this->_objTpl->setVariable($this->moduleLangVar . '_SEARCH_TERM_PARAMETER', '&term=' . $strTerm); } if (empty($objEntries->arrEntries)) { $this->_objTpl->hideBlock($this->moduleNameLC . 'EntriesSelectAction'); } else { $this->_objTpl->touchBlock($this->moduleNameLC . 'EntriesSelectAction'); } }
function parsePlaceholders() { global $objDatabase, $_LANGID, $_CONFIG; if ($this->objUser != false) { $strUserNick = $this->objUser->getUsername(); $strUserFirstname = $this->objUser->getProfileAttribute('firstname'); $strUserLastname = $this->objUser->getProfileAttribute('lastname'); } $objRSEntryFormId = $objDatabase->Execute("SELECT form_id FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_entries\n WHERE\n id='" . $this->intEntryId . "'\n LIMIT 1"); if ($objRSEntryFormId !== false) { $intEntryFormId = intval($objRSEntryFormId->fields['form_id']); } $strRelQuery = "SELECT inputfield.`id` AS `id` FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_inputfields AS inputfield WHERE (inputfield.`type` != 16 AND inputfield.`type` != 17) AND (inputfield.`form` = " . $intEntryFormId . ") ORDER BY inputfield.`order` ASC LIMIT 1"; $objRSEntryTitle = $objDatabase->Execute("SELECT\n rel_inputfield.`value` AS `value`\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_entries AS entry,\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields AS rel_inputfield\n WHERE (rel_inputfield.`entry_id`='" . $this->intEntryId . "')\n AND (rel_inputfield.`field_id` = (" . $strRelQuery . ")) \n AND (rel_inputfield.`lang_id` = '" . $_LANGID . "')\n AND (rel_inputfield.`value` != '')\n GROUP BY value\n "); if ($objRSEntryTitle !== false) { $strEntryTitle = $objRSEntryTitle->fields['value']; } $objEntry = new MediaDirectoryEntry($this->moduleName); if ($objEntry->checkPageCmd('detail' . intval($intEntryFormId))) { $strDetailCmd = 'detail' . intval($intEntryFormId); } else { $strDetailCmd = 'detail'; } $strProtocol = ASCMS_PROTOCOL; $strDomain = $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath(); $strDate = date(ASCMS_DATE_FORMAT); $strEntryLink = urldecode($strProtocol . "://" . $strDomain . '/index.php?section=' . $this->moduleName . '&cmd=' . $strDetailCmd . '&eid=' . $this->intEntryId); $arrPlaceholder = array('[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[TITLE]]', '[[LINK]]', '[[URL]]', '[[DATE]]'); $arrReplaceContent = array($strUserNick, $strUserFirstname, $strUserLastname, $strEntryTitle, $strEntryLink, $strDomain, $strDate); for ($x = 0; $x < 7; $x++) { $this->strTitle = str_replace($arrPlaceholder[$x], $arrReplaceContent[$x], $this->strTitle); } for ($x = 0; $x < 7; $x++) { $this->strTemplate = str_replace($arrPlaceholder[$x], $arrReplaceContent[$x], $this->strTemplate); } }
protected function parseGoogleMapPlaceholder($template, $placeholder) { if (!$template->placeholderExists($placeholder)) { return false; } if (!isset(self::$currentFetchedEntryDataObject)) { return false; } self::$currentFetchedEntryDataObject->listEntries($template, 4, $placeholder); }
/** * This function is called after the activation of new language * update existing forms, inputfields and entries values for activated new language * * @return null */ public function updateFormsAndEntries() { global $objDatabase; foreach ($this->arrFrontendLanguages as $lang) { $activeLang[] = $lang['id']; } $objForms = new MediaDirectoryForm(null, $this->moduleName); foreach ($objForms->arrForms as $objForm) { $formId = $objForm['formId']; $formName = $objForm['formName']; $formDescription = $objForm['formDescription']; //update form values $objForms->updateFormLocale($formName, $formDescription, $formId); $objInputField = new MediaDirectoryInputfield($formId, false, null, $this->moduleName); $inputFields = $objInputField->getInputfields(); //Before updating the form InputFields names, remove the corresponding InputFields names from db. $objDatabase->Execute('DELETE FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_inputfield_names WHERE form_id="' . $formId . '" AND lang_id IN("' . implode('","', $activeLang) . '")'); foreach ($inputFields as $inputField) { // skip '1' => categories, '2' => levels if (in_array($inputField['id'], array(1, 2))) { continue; } $intFieldId = intval($inputField['id']); $arrFieldNames = $inputField['name']; $arrFieldDefaultValues = $inputField['default_value']; $arrFieldInfos = $inputField['info']; //update form inputfields $objInputField->updateInputFields($intFieldId, $arrFieldNames, $arrFieldDefaultValues, $arrFieldInfos); } } $objEntries = new MediaDirectoryEntry($this->moduleName); //update entries $objEntries->updateEntries(); }