private function parseSpecialDownloads($arrBlocks, $arrFilter, $arrSort, $limit) { global $_ARRAYLANG; if (!$this->objTemplate->blockExists($arrBlocks[0])) { return; } $objDownload = new Download(); $objDownload->loadDownloads($arrFilter, null, $arrSort, null, $limit); if ($objDownload->EOF) { $this->objTemplate->hideBlock($arrBlocks[0]); } else { $row = 1; while (!$objDownload->EOF) { // select category $arrAssociatedCategories = $objDownload->getAssociatedCategoryIds(); $categoryId = $arrAssociatedCategories[0]; // parse download info $this->parseDownloadAttributes($objDownload, $categoryId); $this->objTemplate->setVariable('DOWNLOADS_FILE_ROW_CLASS', 'row' . ($row++ % 2 + 1)); $this->objTemplate->parse($arrBlocks[1]); $objDownload->next(); } $this->objTemplate->setVariable(array('TXT_DOWNLOADS_MOST_VIEWED' => $_ARRAYLANG['TXT_DOWNLOADS_MOST_VIEWED'], 'TXT_DOWNLOADS_MOST_DOWNLOADED' => $_ARRAYLANG['TXT_DOWNLOADS_MOST_DOWNLOADED'], 'TXT_DOWNLOADS_NEW_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_NEW_DOWNLOADS'], 'TXT_DOWNLOADS_RECENTLY_UPDATED' => $_ARRAYLANG['TXT_DOWNLOADS_RECENTLY_UPDATED'])); $this->objTemplate->touchBlock($arrBlocks[0]); } }
private function download() { global $_ARRAYLANG, $_LANGID; $objFWUser = \FWUser::getFWUserObject(); $objDownload = new Download(); $objDownload->load(isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0); if ($objDownload->getId() && !\Permission::checkAccess(143, 'static', true) && (($objFWUser = \FWUser::getFWUserObject()) == false || !$objFWUser->objUser->login() || $objDownload->getOwnerId() != $objFWUser->objUser->getId())) { $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_DOWNLOADS_MODIFY_DOWNLOAD_PROHIBITED']; return $this->downloads(); } $arrAssociatedGroupOptions = array(); $arrNotAssociatedGroupOptions = array(); $arrAssociatedGroups = array(); $arrAssociatedCategoryOptions = array(); $arrNotAssociatedCategoryOptions = array(); $arrAssociatedCategories = array(); $arrAssociatedDownloadOptions = array(); $arrNotAssociatedDownloadOptions = array(); if (isset($_POST['downloads_download_save'])) { $objDownload->setNames(isset($_POST['downloads_download_name']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_name'])) : array()); $objDownload->setDescriptions(isset($_POST['downloads_download_description']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_description'])) : array()); $this->arrConfig['use_attr_metakeys'] ? $objDownload->setMetakeys(isset($_POST['downloads_download_metakeys']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_metakeys'])) : array()) : null; $objDownload->setType(isset($_POST['downloads_download_type']) ? contrexx_stripslashes($_POST['downloads_download_type']) : ''); $objDownload->setSources(isset($_POST['downloads_download_' . $objDownload->getType() . '_source']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_' . $objDownload->getType() . '_source'])) : array()); $objDownload->setActiveStatus(!empty($_POST['downloads_download_is_active'])); $objDownload->setMimeType(isset($_POST['downloads_download_mime_type']) ? contrexx_stripslashes($_POST['downloads_download_mime_type']) : ''); $this->arrConfig['use_attr_size'] ? $objDownload->setSize(isset($_POST['downloads_download_size']) ? intval($_POST['downloads_download_size']) : '') : null; $this->arrConfig['use_attr_license'] ? $objDownload->setLicense(isset($_POST['downloads_download_license']) ? contrexx_stripslashes($_POST['downloads_download_license']) : '') : null; $this->arrConfig['use_attr_version'] ? $objDownload->setVersion(isset($_POST['downloads_download_version']) ? contrexx_stripslashes($_POST['downloads_download_version']) : '') : null; $this->arrConfig['use_attr_author'] ? $objDownload->setAuthor(isset($_POST['downloads_download_author']) ? contrexx_stripslashes($_POST['downloads_download_author']) : '') : null; $this->arrConfig['use_attr_website'] ? $objDownload->setWebsite(isset($_POST['downloads_download_website']) ? contrexx_stripslashes($_POST['downloads_download_website']) : '') : null; $objDownload->setImage(isset($_POST['downloads_download_image']) ? contrexx_stripslashes($_POST['downloads_download_image']) : ''); $objDownload->setValidityTimePeriod(!empty($_POST['downloads_download_validity']) ? intval($_POST['downloads_download_validity']) : 0); $objDownload->setVisibility(!empty($_POST['downloads_download_visibility'])); $objDownload->setProtection(!empty($_POST['downloads_download_access'])); $objDownload->setGroups($objDownload->getProtection() && !empty($_POST['downloads_download_access_associated_groups']) ? array_map('intval', $_POST['downloads_download_access_associated_groups']) : array()); $objDownload->setCategories(!empty($_POST['downloads_download_associated_categories']) ? array_map('intval', $_POST['downloads_download_associated_categories']) : array(0)); $objDownload->setDownloads(!empty($_POST['downloads_download_associated_downloads']) ? array_map('intval', $_POST['downloads_download_associated_downloads']) : array()); $objDownload->updateMTime(); if ($objDownload->store()) { if (!empty($this->parentCategoryId)) { header('location: ' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Downloads&act=categories&parent_id=' . $this->parentCategoryId)); } else { return $this->downloads(); } } else { $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objDownload->getErrorMsg()); } } $this->_pageTitle = $objDownload->getId() ? $_ARRAYLANG['TXT_DOWNLOADS_EDIT_DOWNLOAD'] : $_ARRAYLANG['TXT_DOWNLOADS_ADD_DOWNLOAD']; $this->objTemplate->addBlockFile('DOWNLOADS_DOWNLOAD_TEMPLATE', 'module_downloads_downloads', 'module_downloads_download_modify.html'); $this->objTemplate->setVariable(array('TXT_DOWNLOADS_GENERAL' => $_ARRAYLANG['TXT_DOWNLOADS_GENERAL'], 'TXT_DOWNLOADS_PERMISSIONS' => $_ARRAYLANG['TXT_DOWNLOADS_PERMISSIONS'], 'TXT_DOWNLOADS_DOWNLOAD_VISIBILITY_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_VISIBILITY_DESC'], 'TXT_DOWNLOADS_NAME' => $_ARRAYLANG['TXT_DOWNLOADS_NAME'], 'TXT_DOWNLOADS_DESCRIPTION' => $_ARRAYLANG['TXT_DOWNLOADS_DESCRIPTION'], 'TXT_DOWNLOADS_SOURCE' => $_ARRAYLANG['TXT_DOWNLOADS_SOURCE'], 'TXT_DOWNLOADS_LOCAL_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_LOCAL_FILE'], 'TXT_DOWNLOADS_URL' => $_ARRAYLANG['TXT_DOWNLOADS_URL'], 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_STATUS' => $_ARRAYLANG['TXT_DOWNLOADS_STATUS'], 'TXT_DOWNLOADS_VALIDITY_EXPIRATION' => $_ARRAYLANG['TXT_DOWNLOADS_VALIDITY_EXPIRATION'], 'TXT_DOWNLOADS_ACTIVE' => $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'], 'TXT_DOWNLOADS_TYPE' => $_ARRAYLANG['TXT_DOWNLOADS_TYPE'], 'TXT_DOWNLOADS_METAKEYS' => $_ARRAYLANG['TXT_DOWNLOADS_METAKEYS'], 'TXT_DOWNLOADS_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_SIZE'], 'TXT_DOWNLOADS_LICENSE' => $_ARRAYLANG['TXT_DOWNLOADS_LICENSE'], 'TXT_DOWNLOADS_VERSION' => $_ARRAYLANG['TXT_DOWNLOADS_VERSION'], 'TXT_DOWNLOADS_AUTHOR' => $_ARRAYLANG['TXT_DOWNLOADS_AUTHOR'], 'TXT_DOWNLOADS_WEBSITE' => $_ARRAYLANG['TXT_DOWNLOADS_WEBSITE'], 'TXT_DOWNLOADS_IMAGE' => $_ARRAYLANG['TXT_DOWNLOADS_IMAGE'], 'TXT_DOWNLOADS_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_CATEGORIES'], 'TXT_DOWNLOADS_AVAILABLE_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_CATEGORIES'], 'TXT_DOWNLOADS_ASSIGNED_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_CATEGORIES'], 'TXT_DOWNLOADS_RELATED_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_RELATED_DOWNLOADS'], 'TXT_DOWNLOADS_AVAILABLE_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_DOWNLOADS'], 'TXT_DOWNLOADS_ASSIGNED_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_DOWNLOADS'], 'TXT_DOWNLOADS_DOWNLOAD_ALL_ACCESS_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_ALL_ACCESS_DESC'], 'TXT_DOWNLOADS_DOWNLOAD_SELECTED_ACCESS_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_SELECTED_ACCESS_DESC'], 'TXT_DOWNLOADS_AVAILABLE_USER_GROUPS' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_USER_GROUPS'], 'TXT_DOWNLOADS_ASSIGNED_USER_GROUPS' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_USER_GROUPS'], 'TXT_DOWNLOADS_CHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_CHECK_ALL'], 'TXT_DOWNLOADS_UNCHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_UNCHECK_ALL'], 'TXT_DOWNLOADS_CANCEL' => $_ARRAYLANG['TXT_DOWNLOADS_CANCEL'], 'TXT_DOWNLOADS_SAVE' => $_ARRAYLANG['TXT_DOWNLOADS_SAVE'])); // parse sorting & paging of the categories overview section $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => !empty($_GET['category_sort']) ? $_GET['category_sort'] : '', 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => !empty($_GET['category_by']) ? $_GET['category_by'] : '', 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => !empty($_GET['download_sort']) ? $_GET['download_sort'] : '', 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => !empty($_GET['download_by']) ? $_GET['download_by'] : '', 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => !empty($_GET['category_pos']) ? intval($_GET['category_pos']) : 0, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => !empty($_GET['download_pos']) ? intval($_GET['download_pos']) : 0)); // parse id $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ID', $objDownload->getId()); // parse name and description attributres $arrLanguages = \FWLanguage::getLanguageArray(); foreach ($arrLanguages as $langId => $arrLanguage) { if ($arrLanguage['frontend'] == 1) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_name_list'); $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($objDownload->getDescription($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_DESCRIPTION' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_description_list'); if ($this->arrConfig['use_attr_metakeys']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_METAKEYS' => htmlentities($objDownload->getMetakeys($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_METAKEYS' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_metakeys_list'); } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_FILE_SOURCE' => $objDownload->getType() == 'file' ? htmlentities($objDownload->getSource($langId), ENT_QUOTES, CONTREXX_CHARSET) : '', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_file_source_list'); $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_URL_SOURCE' => $objDownload->getType() == 'url' ? htmlentities($objDownload->getSource($langId), ENT_QUOTES, CONTREXX_CHARSET) : 'http://', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_url_source_list'); } } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED'])); $this->objTemplate->parse('downloads_download_name'); $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($objDownload->getDescription(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED'])); $this->objTemplate->parse('downloads_download_description'); // parse metakeys if ($this->arrConfig['use_attr_metakeys']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_METAKEYS' => htmlentities($objDownload->getMetakeys(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED'])); $this->objTemplate->parse('downloads_download_metakeys'); $this->objTemplate->parse('downloads_download_attr_metakeys'); } else { $this->objTemplate->hideBlock('downloads_download_attr_metakeys'); } // parse type $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_TYPE_FILE_CHECKED' => $objDownload->getType() == 'file' ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_TYPE_URL_CHECKED' => $objDownload->getType() == 'url' ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_TYPE_FILE_CONFIG_DISPLAY' => $objDownload->getType() == 'file' ? 'block' : 'none', 'DOWNLOADS_DOWNLOAD_TYPE_URL_CONFIG_DISPLAY' => $objDownload->getType() == 'url' ? 'block' : 'none', 'DOWNLOADS_DOWNLOAD_FILE_SOURCE' => $objDownload->getType() == 'file' ? $objDownload->getSource() : '', 'DOWNLOADS_DOWNLOAD_URL_SOURCE' => $objDownload->getType() == 'url' ? $objDownload->getSource() : 'http://', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED'])); foreach (Download::$arrMimeTypes as $mimeType => $arrMimeType) { if (!count($arrMimeType['extensions'])) { continue; } $this->objTemplate->setVariable(array('DOWNLOADS_MIME_TYPE' => $mimeType, 'DOWNLOADS_FILE_EXTENSION_REGEXP' => implode('|', $arrMimeType['extensions']))); $this->objTemplate->parse('downloads_download_file_ext_regexp'); } // parse mime type $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_MIME_TYPE_MENU', $this->getDownloadMimeTypeMenu($objDownload->getMimeType())); $attrRow = 0; // parse size if ($this->arrConfig['use_attr_size']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_BYTES' => $_ARRAYLANG['TXT_DOWNLOADS_BYTES'], 'DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_SIZE' => $objDownload->getSize())); $this->objTemplate->parse('downloads_download_attr_size'); } else { $this->objTemplate->hideBlock('downloads_download_attr_size'); } // parse license if ($this->arrConfig['use_attr_license']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADs_DOWNLOAD_LICENSE' => htmlentities($objDownload->getLicense(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_attr_license'); } else { $this->objTemplate->hideBlock('downloads_download_attr_license'); } // parse version if ($this->arrConfig['use_attr_version']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_VERSION' => htmlentities($objDownload->getVersion(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_attr_version'); } else { $this->objTemplate->hideBlock('downloads_download_attr_version'); } // parse author if ($this->arrConfig['use_attr_author']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_AUTHOR' => htmlentities($objDownload->getAuthor(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_attr_author'); } else { $this->objTemplate->hideBlock('downloads_download_attr_author'); } // parse website if ($this->arrConfig['use_attr_website']) { $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_WEBSITE' => htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->parse('downloads_download_attr_website'); } else { $this->objTemplate->hideBlock('downloads_download_attr_website'); } // parse validity expiration menu $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_VALIDITY_EXPIRATION_MENU' => $this->getValidityMenu($objDownload->getValidityTimePeriod(), $objDownload->getExpirationDate()))); // parse active status $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_IS_ACTIVE_CHECKED' => $objDownload->getActiveStatus() ? 'checked="checked"' : '')); // parse image attribute $image = $objDownload->getImage(); if (!empty($image) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $image)) { $thumb_name = \ImageManager::getThumbnailFilename($image); if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $thumb_name)) { $imageSrc = $thumb_name; } else { $imageSrc = $image; } } else { $image = ''; $imageSrc = $this->defaultDownloadImage['src']; } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_IMAGE' => $image, 'DOWNLOADS_DOWNLOAD_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE' => $this->defaultDownloadImage['src'], 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE_WIDTH' => $this->defaultDownloadImage['width'] . 'px', 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE_HEIGHT' => $this->defaultDownloadImage['height'] . 'px', 'DOWNLOADS_DOWNLOAD_IMAGE_REMOVE_DISPLAY' => empty($image) ? 'none' : '')); // parse associated categories $arrCategories = $this->getParsedCategoryListForDownloadAssociation(); $arrAssociatedCategories = $objDownload->getAssociatedCategoryIds(); $length = count($arrCategories); for ($i = 0; $i < $length; $i++) { if (\Permission::checkAccess(143, 'static', true) || !in_array($arrCategories[$i]['id'], $arrAssociatedCategories) && (!$arrCategories[$i]['add_files_access_id'] || \Permission::checkAccess($arrCategories[$i]['add_files_access_id'], 'dynamic', true)) || in_array($arrCategories[$i]['id'], $arrAssociatedCategories) && (!$arrCategories[$i]['manage_files_access_id'] || \Permission::checkAccess($arrCategories[$i]['manage_files_access_id'], 'dynamic', true)) || $objFWUser->objUser->login() && $arrCategories[$i]['owner_id'] == $objFWUser->objUser->getId()) { $disabled = false; } else { $disabled = true; } $option = '<option value="' . $arrCategories[$i]['id'] . '"' . ($disabled ? ' disabled="disabled"' : '') . '>' . htmlentities($arrCategories[$i]['name'], ENT_QUOTES, CONTREXX_CHARSET) . '</option>'; if (in_array($arrCategories[$i]['id'], $arrAssociatedCategories) || !$objDownload->getId() && $arrCategories[$i]['id'] == $this->parentCategoryId) { $arrAssociatedCategoryOptions[] = $option; } else { $arrNotAssociatedCategoryOptions[] = $option; } } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ASSOCIATED_CATEGORIES' => implode("\n", $arrAssociatedCategoryOptions), 'DOWNLOADS_DOWNLOAD_NOT_ASSOCIATED_CATEGORIES' => implode("\n", $arrNotAssociatedCategoryOptions))); // parse related downloads $arrRelatedDownloads = $objDownload->getRelatedDownloadIds(); $objAvailableDownload = new Download(); $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']]; $objAvailableDownload->loadDownloads(null, null, $sortOrder); while (!$objAvailableDownload->EOF) { if ($objAvailableDownload->getId() == $objDownload->getId()) { $objAvailableDownload->next(); continue; } $option = '<option value="' . $objAvailableDownload->getId() . '">' . htmlentities($objAvailableDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . ' (' . htmlentities($objAvailableDownload->getDescription($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . ')</option>'; if (in_array($objAvailableDownload->getId(), $arrRelatedDownloads)) { $arrAssociatedDownloadOptions[] = $option; } else { $arrNotAssociatedDownloadOptions[] = $option; } $objAvailableDownload->next(); } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ASSOCIATED_DOWNLOADS' => implode("\n", $arrAssociatedDownloadOptions), 'DOWNLOADS_DOWNLOAD_NOT_ASSOCIATED_DOWNLOADS' => implode("\n", $arrNotAssociatedDownloadOptions))); // parse access permissions if ($objDownload->getAccessId()) { $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $objDownload->getAccessId())); $arrAssociatedGroups = $objGroup->getLoadedGroupIds(); } elseif ($objDownload->getProtection()) { $arrAssociatedGroups = $objDownload->getAccessGroupIds(); } else { //$arrAssociatedCategories = $objDownload->getAssociatedCategoryIds(); if (count($arrAssociatedCategories)) { $objCategory = Category::getCategories(array('id' => $arrAssociatedCategories), null, null, array('id', 'read_access_id')); while (!$objCategory->EOF) { if ($objCategory->getReadAccessId()) { $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $objCategory->getReadAccessId())); $arrAssociatedGroups = array_merge($arrAssociatedGroups, $objGroup->getLoadedGroupIds()); } $objCategory->next(); } } else { // TODO: WHY THAT? $objGroup = $objFWUser->objGroup->getGroups(); $arrAssociatedGroups = $objGroup->getLoadedGroupIds(); } } $objGroup = $objFWUser->objGroup->getGroups(); while (!$objGroup->EOF) { $option = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . ' [' . $objGroup->getType() . ']</option>'; if (in_array($objGroup->getId(), $arrAssociatedGroups)) { $arrAssociatedGroupOptions[] = $option; } else { $arrNotAssociatedGroupOptions[] = $option; } $objGroup->next(); } $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ACCESS_ALL_CHECKED' => !$objDownload->getProtection() ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_ACCESS_SELECTED_CHECKED' => $objDownload->getProtection() ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_ACCESS_DISPLAY' => $objDownload->getProtection() ? '' : 'none', 'DOWNLOADS_DOWNLOAD_ACCESS_ASSOCIATED_GROUPS' => implode("\n", $arrAssociatedGroupOptions), 'DOWNLOADS_DOWNLOAD_ACCESS_NOT_ASSOCIATED_GROUPS' => implode("\n", $arrNotAssociatedGroupOptions), 'DOWNLOADS_DOWNLOAD_VISIBILITY_CHECKED' => $objDownload->getVisibility() ? 'checked="checked"' : '')); // parse cancel link $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CANCEL_LINK_SECITON' => $this->parentCategoryId ? 'categories' : 'downloads', 'DOWNLOADS_PARENT_CATEGORY_ID' => $this->parentCategoryId, 'DOWNLOADS_MEDIA_BROWSER_BUTTON' => self::getMediaBrowserButton('mediabrowser_button', 'filebrowser'))); return true; }