Пример #1
0
 /**
  * show thread
  *
  * @param integer $intThreadId
  * @return bool
  */
 function showThread($intThreadId)
 {
     global $objDatabase, $_ARRAYLANG;
     $objFWUser = \FWUser::getFWUserObject();
     $this->_communityLogin();
     $intThreadId = intval($intThreadId);
     if (!empty($_REQUEST['notification_update']) && $_REQUEST['notification_update'] == $_ARRAYLANG['TXT_FORUM_UPDATE_NOTIFICATION']) {
         $this->_updateNotification($intThreadId);
     }
     $intCatId = !empty($_REQUEST['category_id']) ? intval($_REQUEST['category_id']) : '0';
     if ($intCatId == 0) {
         $intCatId = $this->_getCategoryIdFromThread($intThreadId);
     }
     if (empty($intCatId)) {
         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum');
         die;
     }
     if ($objFWUser->objUser->login()) {
         $this->_objTpl->touchBlock('notificationRow');
     } else {
         $this->_objTpl->hideBlock('notificationRow');
     }
     $intPostId = !empty($_REQUEST['postid']) ? intval($_REQUEST['postid']) : 0;
     $intPostId = $intPostId == 0 && !empty($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : $intPostId;
     $this->_objTpl->setVariable('FORUM_EDIT_POST_ID', $intPostId);
     $_REQUEST['act'] = !empty($_REQUEST['act']) ? $_REQUEST['act'] : '';
     if ($_REQUEST['act'] == 'delete') {
         if ($this->_checkAuth($intCatId, 'delete')) {
             if ($this->_deletePost($intCatId, $intThreadId, $_REQUEST['postid'])) {
                 $this->_objTpl->setVariable('TXT_FORUM_SUCCESS', '<br />' . $_ARRAYLANG['TXT_FORUM_DELETED_SUCCESSFULLY']);
             } else {
                 $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_DELETE_FAILED']);
             }
         } else {
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']);
         }
     }
     $pos = !empty($_REQUEST['pos']) ? intval($_REQUEST['pos']) : 0;
     $this->_objTpl->setVariable(array('FORUM_PAGING_POS' => $pos));
     if (!empty($_REQUEST['preview_new'])) {
         $pos = $this->_getLastPos($intPostId, $intThreadId);
     }
     if (!empty($_REQUEST['postid'])) {
         if ($_REQUEST['act'] == 'quote') {
             $pos = $this->_getLastPos($intPostId, $intThreadId);
         }
         if ($_REQUEST['act'] == 'edit') {
             $pos = $this->_getEditPos($intPostId, $intThreadId);
         }
     }
     if (!empty($_REQUEST['l']) && $_REQUEST['l'] == 1) {
         $pos = $this->_getEditPos($intPostId, $intThreadId);
     }
     $arrPosts = $this->createPostArray($intThreadId, $pos);
     if (!empty($_REQUEST['preview_edit']) && $_REQUEST['post_id'] != 0 && $_REQUEST['act'] != 'quote') {
         $intPostId = intval($intPostId);
         $pos = $this->_getEditPos($intPostId, $intThreadId);
         $arrPosts = $this->createPostArray($intThreadId, $pos);
         $arrPosts[$intPostId]['subject'] = !empty($_REQUEST['subject']) ? contrexx_strip_tags($_REQUEST['subject']) : $_ARRAYLANG['TXT_FORUM_NO_SUBJECT'];
         $arrPosts[$intPostId]['content'] = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput(contrexx_input2raw($_REQUEST['message']));
     }
     $userId = $objFWUser->objUser->login() ? $objFWUser->objUser->getId() : 0;
     $icon = !empty($_REQUEST['icons']) ? intval($_REQUEST['icons']) : 1;
     if ($_REQUEST['act'] == 'edit') {
         //submit is an edit
         $arrEditedPost = $this->_getPostingData($intPostId);
         $subject = addcslashes(htmlentities($arrEditedPost['subject'], ENT_QUOTES, CONTREXX_CHARSET), '\\');
         $content = $arrEditedPost['content'];
         $keywords = addcslashes(htmlentities($arrEditedPost['keywords'], ENT_QUOTES, CONTREXX_CHARSET), '\\');
         $attachment = $arrEditedPost['attachment'];
         $this->_objTpl->setVariable('FORUM_POST_EDIT_USERID', $arrPosts[$intPostId]['user_id']);
         if (!empty($attachment)) {
             $this->_objTpl->setVariable('TXT_FORUM_DELETE_ATTACHMENT', sprintf($_ARRAYLANG['TXT_FORUM_DELETE_ATTACHMENT'], $attachment));
         }
         $this->_objTpl->touchBlock('updatePost');
         $this->_objTpl->hideBlock('createPost');
         $this->_objTpl->hideBlock('previewNewPost');
         $this->_objTpl->touchBlock('previewEditPost');
     } else {
         //new post
         if ($this->_objTpl->blockExists('delAttachment')) {
             $this->_objTpl->hideBlock('delAttachment');
         }
         $subject = !empty($_REQUEST['subject']) ? contrexx_strip_tags($_REQUEST['subject']) : '';
         $content = !empty($_REQUEST['message']) ? contrexx_input2raw(strip_tags($_REQUEST['message'])) : '';
         $keywords = !empty($_REQUEST['keywords']) ? contrexx_strip_tags($_REQUEST['keywords']) : '';
         $attachment = !empty($_REQUEST['attachment']) ? contrexx_strip_tags($_REQUEST['attachment']) : '';
         $this->_objTpl->touchBlock('createPost');
         $this->_objTpl->hideBlock('updatePost');
         $this->_objTpl->touchBlock('previewNewPost');
         $this->_objTpl->hideBlock('previewEditPost');
     }
     if ($_REQUEST['act'] == 'quote') {
         $quoteContent = $this->_getPostingData($intPostId);
         $subject = 'RE: ' . addcslashes(htmlentities($quoteContent['subject'], ENT_QUOTES, CONTREXX_CHARSET), '\\');
         $content = '[quote=' . $arrPosts[$intPostId]['user_name'] . ']' . strip_tags($quoteContent['content']) . '[/quote]';
     }
     $firstPost = current($arrPosts);
     if ($this->_arrSettings['wysiwyg_editor'] == 1) {
         //IF WYSIWIG enabled..
         $strMessageInputHTML = new \Cx\Core\Wysiwyg\Wysiwyg('message', $content, 'bbcode');
     } else {
         //plain textarea
         $strMessageInputHTML = '<textarea style="width: 400px; height: 150px;" rows="5" cols="10" name="message">' . contrexx_raw2xhtml($content) . '</textarea>';
     }
     $this->_objTpl->setGlobalVariable(array('FORUM_JAVASCRIPT_GOTO' => $this->getJavascript('goto'), 'FORUM_JAVASCRIPT_DELETE' => $this->getJavascript('deletePost'), 'FORUM_JAVASCRIPT_SCROLLTO' => $this->getJavascript('scrollto'), 'FORUM_SCROLLPOS' => !empty($_REQUEST['scrollpos']) ? intval($_REQUEST['scrollpos']) : '0', 'FORUM_JAVASCRIPT_INSERT_TEXT' => $this->getJavascript('insertText', array($intCatId, $intThreadId, $firstPost)), 'FORUM_NAME' => $this->_shortenString($firstPost['subject'], $this->_maxStringlength), 'FORUM_TREE' => $this->_createNavTree($intCatId) . '<a title="' . $this->_arrTranslations[$intCatId][$this->_intLangId]['name'] . '" href="index.php?section=Forum&amp;cmd=board&amp;id=' . $intCatId . '">' . $this->_shortenString($this->_arrTranslations[$intCatId][$this->_intLangId]['name'], $this->_maxStringlength) . '</a> > ', 'FORUM_DROPDOWN' => $this->createForumDD('forum_quickaccess', $intCatId, 'onchange="gotoForum(this);"', ''), 'TXT_FORUM_COMMA_SEPARATED_KEYWORDS' => $_ARRAYLANG['TXT_FORUM_COMMA_SEPARATED_KEYWORDS'], 'TXT_FORUM_KEYWORDS' => $_ARRAYLANG['TXT_FORUM_KEYWORDS'], 'TXT_FORUM_FILE_ATTACHMENT' => $_ARRAYLANG['TXT_FORUM_FILE_ATTACHMENT'], 'TXT_FORUM_RATING' => $_ARRAYLANG['TXT_FORUM_RATING'], 'TXT_FORUM_ADD_POST' => $_ARRAYLANG['TXT_FORUM_ADD_POST'], 'TXT_FORUM_SUBJECT' => $_ARRAYLANG['TXT_FORUM_SUBJECT'], 'TXT_FORUM_MESSAGE' => $_ARRAYLANG['TXT_FORUM_MESSAGE'], 'TXT_FORUM_RESET' => $_ARRAYLANG['TXT_FORUM_RESET'], 'TXT_FORUM_CREATE_POST' => $_ARRAYLANG['TXT_FORUM_CREATE_POST'], 'TXT_FORUM_ICON' => $_ARRAYLANG['TXT_FORUM_ICON'], 'TXT_FORUM_QUOTE' => $_ARRAYLANG['TXT_FORUM_QUOTE'], 'TXT_FORUM_EDIT' => $_ARRAYLANG['TXT_FORUM_EDIT'], 'TXT_FORUM_DELETE' => $_ARRAYLANG['TXT_FORUM_DELETE'], 'TXT_FORUM_PREVIEW' => $_ARRAYLANG['TXT_FORUM_PREVIEW'], 'TXT_FORUM_UPDATE_POST' => $_ARRAYLANG['TXT_FORUM_UPDATE_POST'], 'TXT_FORUM_NOTIFY_NEW_POSTS' => $_ARRAYLANG['TXT_FORUM_NOTIFY_NEW_POSTS'], 'TXT_FORUM_QUICKACCESS' => $_ARRAYLANG['TXT_FORUM_QUICKACCESS'], 'TXT_FORUM_UPDATE_NOTIFICATION' => $_ARRAYLANG['TXT_FORUM_UPDATE_NOTIFICATION'], 'TXT_FORUM_THREAD_ACTION_DESC' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_DESC'], 'TXT_FORUM_THREAD_ACTION_MOVE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE'], 'TXT_FORUM_THREAD_ACTION_CLOSE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_CLOSE_' . $firstPost['is_locked']], 'TXT_FORUM_THREAD_ACTION_STICKY' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_STICKY_' . $firstPost['is_sticky']], 'TXT_FORUM_THREAD_ACTION_DELETE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_DELETE'], 'TXT_FORUM_CHOOSE_FILE' => $_ARRAYLANG['TXT_FORUM_CHOOSE_FILE'], 'FORUM_NOTIFICATION_CHECKBOX_CHECKED' => $this->_hasNotification($intThreadId) ? 'checked="checked"' : '', 'FORUM_SUBJECT' => stripslashes($subject), 'FORUM_KEYWORDS' => stripslashes($keywords), 'FORUM_ATTACHMENT_OLDNAME' => $attachment, 'FORUM_MESSAGE_INPUT' => $strMessageInputHTML, 'FORUM_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode(), 'FORUM_THREAD_ID' => $intThreadId, 'FORUM_CATEGORY_ID' => $intCatId, 'FORUM_POSTS_PAGING' => getPaging($this->_postCount, $pos, '&section=Forum&cmd=thread&id=' . $intThreadId, $_ARRAYLANG['TXT_FORUM_OVERVIEW_POSTINGS'], true, $this->_arrSettings['posting_paging'])));
     if ($objFWUser->objUser->login()) {
         $this->_objTpl->hideBlock('captcha');
     } else {
         $this->_objTpl->touchBlock('captcha');
     }
     $this->_setIcons($this->_getIcons());
     if (!$this->_checkAuth($intCatId, 'read')) {
         $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']);
         return false;
     }
     $intCounter = 0;
     foreach ($arrPosts as $postId => $arrValues) {
         $strRating = '<span id="forum_current_rating_' . $postId . '" class="rating_%s">%s</span>';
         if ($arrValues['rating'] == 0) {
             $class = 'none';
         } elseif ($arrValues['rating'] > 0) {
             $class = 'pos';
         } else {
             $class = 'neg';
         }
         $strRating = sprintf($strRating, $class, $arrValues['rating']);
         $strUserProfileLink = $arrValues['user_id'] > 0 ? '<a title="' . $arrValues['user_name'] . '" href="index.php?section=Access&amp;cmd=user&amp;id=' . $arrValues['user_id'] . '">' . $arrValues['user_name'] . '</a>' : $this->_anonymousName;
         $arrAttachment = $this->_getAttachment($arrValues['attachment']);
         $this->_objTpl->setGlobalVariable(array('FORUM_POST_ROWCLASS' => $intCounter++ % 2 + 1));
         $quoteLink = "id=" . $intThreadId . "&act=quote&postid=" . $postId;
         $quoteLinkLoggedIn = "location.href='" . \Cx\Core\Csrf\Controller\Csrf::enhanceURI("index.php?section=Forum") . "&amp;cmd=thread&amp;" . htmlentities($quoteLink) . "';";
         $quoteLinkNotLoggedIn = "location.href='" . \Cx\Core\Csrf\Controller\Csrf::enhanceURI("index.php?section=Login") . "&amp;redirect=" . base64_encode("index.php?section=Forum&cmd=thread&" . $quoteLink) . "';";
         $this->_objTpl->setVariable(array('FORUM_POST_DATE' => $arrValues['time_created'], 'FORUM_POST_LAST_EDITED' => $arrValues['time_edited'] != date(ASCMS_DATE_FORMAT, 0) ? $_ARRAYLANG['TXT_FORUM_LAST_EDITED'] . $arrValues['time_edited'] : '', 'FORUM_USER_ID' => $arrValues['user_id'], 'FORUM_USER_NAME' => $strUserProfileLink, 'FORUM_USER_IMAGE' => !empty($arrValues['user_image']) ? '<img border="0" width="60" height="60" src="' . $arrValues['user_image'] . '" title="' . $arrValues['user_name'] . '\'s avatar" alt="' . $arrValues['user_name'] . '\'s avatar" />' : '', 'FORUM_USER_GROUP' => '', 'FORUM_USER_RANK' => '', 'FORUM_USER_REGISTERED_SINCE' => '', 'FORUM_USER_POSTING_COUNT' => '', 'FORUM_USER_CONTACTS' => '', 'FORUM_POST_NUMBER' => '#' . $arrValues['post_number'], 'FORUM_POST_ICON' => $arrValues['post_icon'], 'FORUM_POST_SUBJECT' => $arrValues['subject'], 'FORUM_POST_MESSAGE' => $arrValues['content'], 'FORUM_POST_RATING' => $strRating, 'FORUM_POST_ATTACHMENT_LINK' => $arrAttachment['webpath'], 'FORUM_POST_ATTACHMENT_FILENAME' => $arrAttachment['name'], 'FORUM_POST_ATTACHMENT_ICON' => $arrAttachment['icon'], 'FORUM_POST_ATTACHMENT_FILESIZE' => $arrAttachment['size'], 'FORUM_QUOTE_ONCLICK' => $this->_checkAuth($intCatId, 'write') ? $quoteLinkLoggedIn : $quoteLinkNotLoggedIn));
         if (!$objFWUser->objUser->login() && !$this->_checkAuth($intCatId, 'write')) {
             $button = '<input type="button" value="' . $_ARRAYLANG['TXT_FORUM_CREATE_POST'] . '" onclick="location.href=\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?section=Login') . '&redirect=' . base64_encode($_SERVER['REQUEST_URI']) . '\';" />';
             $this->_objTpl->setVariable(array('FORUM_POST_REPLY_REDIRECT' => $button));
         }
         $this->_objTpl->setVariable(array('FORUM_POST_ID' => $postId, 'FORUM_RATING_POST_ID' => $postId));
         if ($firstPost['is_locked'] != 1 && ($this->_checkAuth($intCatId, 'edit') || $objFWUser->objUser->login() && $arrValues['user_id'] == $objFWUser->objUser->getId())) {
             $this->_objTpl->touchBlock('postEdit');
         } else {
             $this->_objTpl->hideBlock('postEdit');
         }
         if ($firstPost['is_locked'] != 1 && ($this->_checkAuth($intCatId, 'write') || !$firstPost['is_locked'])) {
             $this->_objTpl->touchBlock('postQuote');
         } else {
             $this->_objTpl->hideBlock('postQuote');
         }
         if ($this->_checkAuth($intCatId, 'delete') && $arrValues['post_number'] != 1) {
             $this->_objTpl->setVariable(array('FORUM_POST_ID' => $postId));
             $this->_objTpl->touchBlock('postDelete');
         } else {
             $this->_objTpl->hideBlock('postDelete');
         }
         if ($this->_objTpl->blockExists('rating')) {
             if ($objFWUser->objUser->login() && !$this->_hasRated($postId)) {
                 $this->_objTpl->parse('rating');
             } else {
                 $this->_objTpl->hideBlock('rating');
             }
         }
         if ($this->_objTpl->blockExists('attachment')) {
             if (!empty($arrValues['attachment'])) {
                 $this->_objTpl->parse('attachment');
             } else {
                 $this->_objTpl->hideBlock('attachment');
             }
         }
         $this->_objTpl->parse('forumPosts');
     }
     if (!$this->_checkAuth($intCatId, 'write') || $firstPost['is_locked'] == 1) {
         $this->_objTpl->hideBlock('addPost');
         $this->_objTpl->hideBlock('addPostAnchor');
     } else {
         $this->_objTpl->touchBlock('addPostAnchor');
     }
     // initialize the uploader
     $this->initForumUploader();
     //addpost code
     if (!empty($_REQUEST['create']) && $_REQUEST['create'] == $_ARRAYLANG['TXT_FORUM_CREATE_POST']) {
         if (!$this->_checkAuth($intCatId, 'write') && $firstPost['is_locked'] != 1) {
             //auth check
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']);
             $this->_objTpl->hideBlock('addPost');
             return false;
         }
         if (!$objFWUser->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             //captcha check
             return false;
         }
         if (strlen(trim($content)) < $this->_minPostlength) {
             //content check
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength));
             return false;
         }
         if (false !== ($match = $this->_hasBadWords($content))) {
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1]));
             return false;
         }
         $fileInfo = $this->_handleUpload('forum_attachment');
         if ($fileInfo === false) {
             //an error occured, the file wasn't properly transferred. exit function to display error set in _handleUpload()
             return false;
         }
         $lastPostIdQuery = '    SELECT max( id ) as last_post_id
                                 FROM ' . DBPREFIX . 'module_forum_postings
                                 WHERE category_id = ' . $intCatId . '
                                 AND      thread_id = ' . $intThreadId;
         if (($objRSmaxId = $objDatabase->SelectLimit($lastPostIdQuery, 1)) !== false) {
             $intPrevPostId = $objRSmaxId->fields['last_post_id'];
         } else {
             die('Database error: ' . $objDatabase->ErrorMsg());
         }
         $insertQuery = 'INSERT INTO ' . DBPREFIX . 'module_forum_postings (
                         id,             category_id,    thread_id,            prev_post_id,
                         user_id,         time_created,    time_edited,         is_locked,
                         is_sticky,         rating,         views,                 icon,
                         keywords,        subject,        content,             attachment
                     ) VALUES (
                         NULL, ' . $intCatId . ', ' . $intThreadId . ', ' . $intPrevPostId . ',
                         ' . $userId . ', ' . time() . ',         0,                     0,
                         0,                   0,        0, ' . $icon . ",\n                            '{$keywords}' ,'" . $subject . "',    '" . contrexx_raw2db($content) . "', '" . $fileInfo['name'] . "'\n                        )";
         if ($objDatabase->Execute($insertQuery) !== false) {
             $lastInsertId = $objDatabase->Insert_ID();
             $this->updateViewsNewItem($intCatId, $lastInsertId, true);
             $this->_updateNotification($intThreadId);
             $this->_sendNotifications($intThreadId, $subject, $content);
             $pageId = \Cx\Core\Core\Controller\Cx::instanciate()->getPage()->getId();
             $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager();
             $cacheManager->deleteSingleFile($pageId);
         }
         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&pos=' . $this->_getLastPos($postId, $intThreadId));
         die;
     }
     if (!empty($_REQUEST['preview_new'])) {
         $content = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($content);
         if (false !== ($match = $this->_hasBadWords($content))) {
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1]));
             return false;
         }
         if (strlen(trim($content)) < $this->_minPostlength) {
             //content check
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength));
             return false;
         }
         $this->_objTpl->setVariable(array('FORUM_POST_ROWCLASS' => $intCounter++ % 2 + 1, 'FORUM_POST_DATE' => date(ASCMS_DATE_FORMAT, time()), 'FORUM_USER_ID' => $userId, 'FORUM_USER_NAME' => $objFWUser->objUser->login() ? '<a href="index.php?section=Access&amp;cmd=user&amp;id=' . $userId . '" title="' . htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '">' . htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '</a>' : $this->_anonymousName, 'FORUM_USER_IMAGE' => !empty($arrValues['user_image']) ? '<img border="0" width="60" height="60" src="' . $arrValues['user_image'] . '" title="' . $arrValues['user_name'] . '\'s avatar" alt="' . $arrValues['user_name'] . '\'s avatar" />' : '', 'FORUM_USER_GROUP' => '', 'FORUM_USER_RANK' => '', 'FORUM_USER_REGISTERED_SINCE' => '', 'FORUM_USER_POSTING_COUNT' => '', 'FORUM_USER_CONTACTS' => '', 'FORUM_POST_NUMBER' => '#' . ($this->_postCount + 1), 'FORUM_POST_ICON' => $this->getThreadIcon($icon), 'FORUM_POST_SUBJECT' => stripslashes($subject), 'FORUM_POST_MESSAGE' => $content, 'FORUM_POST_RATING' => '0'));
         $this->_objTpl->touchBlock('createPost');
         $this->_objTpl->hideBlock('updatePost');
         if ($this->_objTpl->blockExists('attachment')) {
             $this->_objTpl->hideBlock('attachment');
         }
         $this->_objTpl->hideBlock('postEdit');
         $this->_objTpl->hideBlock('postQuote');
         $this->_objTpl->touchBlock('previewNewPost');
         $this->_objTpl->hideBlock('previewEditPost');
         $this->_objTpl->parse('forumPosts');
     }
     if (!empty($_REQUEST['update']) && $_REQUEST['update'] == $_ARRAYLANG['TXT_FORUM_UPDATE_POST']) {
         if (strlen(trim($content)) < $this->_minPostlength) {
             //content size check
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength));
             return false;
         }
         if (!$this->_checkAuth($intCatId, 'edit') && (!$objFWUser->objUser->login() || $arrValues['user_id'] != $objFWUser->objUser->getId())) {
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']);
             $this->_objTpl->hideBlock('postEdit');
             return false;
         }
         if (!$objFWUser->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             $this->_objTpl->touchBlock('updatePost');
             $this->_objTpl->hideBlock('createPost');
             return false;
         }
         if (false !== ($match = $this->_hasBadWords($content))) {
             $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1]));
             return false;
         }
         $fileInfo = $this->_handleUpload('forum_attachment');
         if ($fileInfo === false) {
             //an error occured, the file wasn't properly transferred. exit function to display error set in _handleUpload()
             return false;
         }
         if (empty($_POST['forum_delete_attachment']) && empty($fileInfo['name']) && !empty($_REQUEST['forum_attachment_oldname'])) {
             $fileInfo['name'] = contrexx_addslashes($_REQUEST['forum_attachment_oldname']);
         } elseif (!empty($_POST['forum_delete_attachment']) && $_POST['forum_delete_attachment'] == 1 || !empty($_REQUEST['forum_attachment_oldname']) && $fileInfo['name'] != $_REQUEST['forum_attachment_oldname']) {
             unlink(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteMediaForumUploadPath() . '/' . str_replace(array('./', '.\\'), '', $_REQUEST['forum_attachment_oldname']));
         }
         $updateQuery = 'UPDATE ' . DBPREFIX . 'module_forum_postings SET
                         time_edited = ' . mktime() . ',
                         icon = ' . $icon . ',
                         subject = \'' . $subject . '\',
                         keywords = \'' . $keywords . '\',
                         content = \'' . contrexx_raw2db($content) . '\',
                         attachment = \'' . $fileInfo['name'] . '\'
                         WHERE id = ' . $intPostId;
         if ($objDatabase->Execute($updateQuery) !== false) {
             $this->updateViews($intThreadId, $intPostId);
             $pageId = \Cx\Core\Core\Controller\Cx::instanciate()->getPage()->getId();
             $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager();
             $cacheManager->deleteSingleFile($pageId);
         }
         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&pos=' . $this->_getLastPos($postId, $intThreadId));
         die;
     }
     if (!empty($_REQUEST['preview_edit'])) {
         $this->_objTpl->touchBlock('updatePost');
         $this->_objTpl->hideBlock('createPost');
         $this->_objTpl->hideBlock('previewNewPost');
         $this->_objTpl->touchBlock('previewEditPost');
     }
     $hasAccess = false;
     foreach (array('STICKY', 'MOVE', 'CLOSE', 'DELETE') as $action) {
         if (!$this->_checkAuth($intCatId, strtolower($action))) {
             $this->_objTpl->setVariable('FORUM_THREAD_ACTIONS_DISABLED_' . $action, 'disabled="disabled"');
         } else {
             $hasAccess = true;
         }
     }
     if ($this->_objTpl->blockExists('threadActionsSelect')) {
         if ($userId < 1 || !$hasAccess) {
             $this->_objTpl->hideBlock('threadActionsSelect');
         } else {
             $this->_objTpl->touchBlock('threadActionsSelect');
         }
     }
     if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'move' && !empty($_REQUEST['id'])) {
         $thread = intval($_REQUEST['id']);
         $newCat = intval($_REQUEST['moveToThread']);
         $oldCat = $this->_getCategoryIdFromThread($thread);
         $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `category_id` = {$newCat} WHERE `thread_id` = " . $thread;
         if ($objDatabase->Execute($query)) {
             $intMovedPosts = $objDatabase->Affected_Rows();
             $query = "SELECT max( `id` ) as `lastid` FROM `" . DBPREFIX . "module_forum_postings` WHERE `thread_id` = {$thread}";
             $objRS = $objDatabase->SelectLimit($query, 1);
             $intMovedPostLastId = $objRS->fields['lastid'];
             $query = "SELECT max( `id` ) as `lastid` FROM `" . DBPREFIX . "module_forum_postings` WHERE `category_id` = {$oldCat}";
             $objRS = $objDatabase->SelectLimit($query, 1);
             $query = "UPDATE `" . DBPREFIX . "module_forum_statistics` SET `thread_count` = `thread_count` - 1, `post_count` = `post_count` - {$intMovedPosts}, `last_post_id` = " . (intval($objRS->fields['lastid']) > 0 ? intval($objRS->fields['lastid']) : 0) . " WHERE `category_id` = {$oldCat}";
             $objDatabase->Execute($query);
             $query = "SELECT `id` FROM `" . DBPREFIX . "module_forum_postings` WHERE `category_id` = {$newCat} GROUP BY `time_created` DESC";
             $objRS = $objDatabase->Execute($query);
             $query = "UPDATE `" . DBPREFIX . "module_forum_statistics` SET `thread_count` = `thread_count` + 1, `post_count` = `post_count` + {$intMovedPosts}, `last_post_id` = " . $objRS->fields['id'] . " WHERE `category_id` = {$newCat}";
             $objDatabase->Execute($query);
             $this->_objTpl->hideBlock('moveForm');
             $this->_objTpl->setVariable(array('TXT_THREAD_ACTION_' . ($success ? 'SUCCESS' : 'ERROR') => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE' . (!$success ? 'UN' : '') . 'SUCCESSFUL'], 'FORUM_CATEGORY_ID' => $intCatId, 'FORUM_THREAD_ID' => $intThreadId));
             \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $thread);
         }
     }
     if (!empty($_GET['a'])) {
         $this->_objTpl->setVariable(array('TXT_FORUM_' . ($_GET['r'] == 1 ? 'SUCCESS' : 'ERROR') => '<br />' . $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_' . strtoupper($_GET['a']) . '_' . (!$_GET['r'] ? 'UN' : '') . 'SUCCESSFUL' . $_GET['s']]));
     }
     $success = false;
     if (!empty($_REQUEST['thread_actions'])) {
         $action = contrexx_addslashes($_REQUEST['thread_actions']);
         if ($this->_checkAuth($intCatId, $action)) {
             switch ($action) {
                 case 'move':
                     $arrForums = $this->createForumArray($this->_intLangId);
                     foreach ($arrForums as $intCatID => $arrThread) {
                         $strOptions .= '<option value="' . $intCatID . '" ' . ($arrThread['level'] == 0 ? 'disabled="disabled"' : '') . '>' . str_repeat('&nbsp;', $arrThread['level'] * 2) . $arrThread['name'] . '</option>';
                     }
                     $this->_objTpl->setVariable(array('FORUM_THREADS' => $strOptions));
                     $success = true;
                     $suffix = '';
                     \Env::get('cx')->getPage()->setTitle($_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE']);
                     break;
                 case 'close':
                     $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `is_locked` = IF(`is_locked` = '0' OR `is_locked` = '', '1', '0') WHERE thread_id = " . intval($_REQUEST['id']);
                     if ($objDatabase->Execute($query) !== false) {
                         $success = true;
                     }
                     $suffix = '_' . $firstPost['is_locked'];
                     break;
                 case 'sticky':
                     $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `is_sticky` = IF(`is_sticky` = '0' OR `is_sticky` = '', '1', '0') WHERE thread_id = " . intval($_REQUEST['id']);
                     if ($objDatabase->Execute($query) !== false) {
                         $success = true;
                     }
                     $suffix = '_' . $firstPost['is_sticky'];
                     break;
                 default:
                     break;
             }
             if ($action != 'move') {
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&a=' . $action . '&r=' . $success . '&s=' . $suffix);
             }
         } else {
             $this->_objTpl->setVariable('TXT_THREAD_ACTION_ERROR', $_ARRAYLANG['TXT_FORUM_NO_ACCESS']);
         }
         $this->_objTpl->parse('threadActions');
         $this->_objTpl->touchBlock('threadActions');
         $this->_objTpl->hideBlock('threadDisplay');
     } else {
         $this->updateViews($intThreadId, $intPostId);
         $this->_objTpl->hideBlock('threadActions');
     }
     return true;
 }
Пример #2
0
 /**
  * Show all banners of a group
  *
  * @global    object        $objDatabase
  * @global     array        $_ARRAYLANG
  * @param     integer        $intGid: The group with this id will be shown
  */
 function showGroupDetails($intGid = 0)
 {
     global $objDatabase, $_ARRAYLANG;
     switch ($_POST['frmShowBanner_MultiAction']) {
         case 'delete':
             if (isset($_POST['selectedBannerId'])) {
                 foreach ($_POST['selectedBannerId'] as $intBannerId) {
                     $this->deleteBanner($intBannerId);
                 }
             }
             break;
         case 'activate':
             if (isset($_POST['selectedBannerId'])) {
                 foreach ($_POST['selectedBannerId'] as $intBannerId) {
                     $this->changeBannerStatus($intBannerId, 1);
                 }
             }
             break;
         case 'deactivate':
             if (isset($_POST['selectedBannerId'])) {
                 foreach ($_POST['selectedBannerId'] as $intBannerId) {
                     $this->changeBannerStatus($intBannerId, 0);
                 }
             }
             break;
         default:
             //do nothing
     }
     if (!empty($_POST['saveDefault'])) {
         $this->setDefaultBanner($intGid, $_POST['defaultBanner']);
     }
     $intGid = intval($intGid);
     $objContentTree = new ContentTree();
     $this->_objTpl->loadTemplateFile('module_banner_group_details.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_TITLE'];
     $this->_objTpl->setVariable(array('BANNER_GROUP_ID' => $intGid, 'TXT_BANNER_GROUP_DETAILS_STATUS' => $_ARRAYLANG['TXT_BANNER_ADD_STATUS'], 'TXT_BANNER_GROUP_DETAILS_STATUS_2' => $_ARRAYLANG['TXT_BANNER_ADD_STATUS'], 'TXT_BANNER_GROUP_DETAILS_DEFAULT' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DEFAULT'], 'TXT_BANNER_GROUP_DETAILS_NAME' => $_ARRAYLANG['TXT_BANNER_ADD_NAME'], 'TXT_BANNER_GROUP_DETAILS_RELATION_CONTENT' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_CONTENT'], 'TXT_BANNER_GROUP_DETAILS_RELATION_NEWS' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_NEWS'], 'TXT_BANNER_GROUP_DETAILS_RELATION_TEASER' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_TEASER'], 'TXT_BANNER_GROUP_DETAILS_FUNCTIONS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_FUNCTIONS'], 'TXT_BANNER_GROUP_DETAILS_DELETE' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE'], 'TXT_BANNER_GROUP_DETAILS_DELETE_JS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE_JS'], 'TXT_BANNER_GROUP_DETAILS_DELETE_ALL_JS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE_ALL_JS'], 'TXT_BANNER_GROUP_DETAILS_EDIT' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_EDIT'], 'TXT_BANNER_GROUP_DETAILS_SAVE' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_SAVE'], 'TXT_BANNER_GROUP_DETAILS_SELECT_ALL' => $_ARRAYLANG['TXT_BANNER_SELECT_ALL'], 'TXT_BANNER_GROUP_DETAILS_DESELECT_ALL' => $_ARRAYLANG['TXT_BANNER_DESELECT_ALL'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BANNER_SUBMIT_SELECT'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_EXPAND' => $_ARRAYLANG['TXT_BANNER_SUBMIT_EXPAND'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_COMPRESS' => $_ARRAYLANG['TXT_BANNER_SUBMIT_COMPRESS'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_DELETE'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_ACTIVATE'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_DEACTIVATE']));
     $objResult = $objDatabase->Execute('SELECT        id,
                                                     name
                                         FROM        ' . DBPREFIX . 'module_banner_groups
                                         ORDER BY    id ASC
                                     ');
     if ($objResult->RecordCount() > 0) {
         $strDropDown = '<select name="ddGroup" onChange="window.location=this.options[this.selectedIndex].value">';
         while (!$objResult->EOF) {
             $strDropDown .= '<option value="' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=banner') . '&act=group_details&id=' . $objResult->fields['id'] . '"' . ($objResult->fields['id'] == $intGid ? ' selected' : '') . '>' . $objResult->fields['name'] . '</option>';
             $objResult->MoveNext();
         }
         $strDropDown .= '</select>';
     }
     $this->_objTpl->setVariable('BANNER_GROUP_DROPDOWN', $strDropDown);
     //create news-cat-array
     $objResult = $objDatabase->Execute('SELECT         catid,
                                                     name
                                         FROM        ' . DBPREFIX . 'module_news_categories
                                         ORDER BY    name ASC
                                     ');
     if ($objResult->RecordCount() > 0) {
         while (!$objResult->EOF) {
             $arrNewsCategories[$objResult->fields['catid']] = $objResult->fields['name'];
             $objResult->MoveNext();
         }
     }
     //create teaser-cat-array ($arrTeaserCategories)
     $objResult = $objDatabase->Execute('SELECT         id,
                                                     name
                                         FROM        ' . DBPREFIX . 'module_news_teaser_frame
                                         ORDER BY    name ASC
                                     ');
     if ($objResult->RecordCount() > 0) {
         while (!$objResult->EOF) {
             $arrTeaserCategories[$objResult->fields['id']] = $objResult->fields['name'];
             $objResult->MoveNext();
         }
     }
     $objResult = $objDatabase->Execute('SELECT        id,
                                                     name,
                                                     banner_code,
                                                     status,
                                                     is_default
                                         FROM        ' . DBPREFIX . 'module_banner_system
                                         WHERE        parent_id=' . $intGid . '
                                         ORDER BY    is_default DESC,
                                                     name ASC
                                     ');
     $i = 0;
     if ($objResult->RecordCount() > 0) {
         while (!$objResult->EOF) {
             $objSubResult = $objDatabase->Execute('    SELECT    page_id,
                                                             type
                                                     FROM    ' . DBPREFIX . 'module_banner_relations
                                                     WHERE    banner_id=' . $objResult->fields['id'] . '
                                                 ');
             $strRelationsContent = '';
             $strRelationsNews = '';
             $strRelationsTeaser = '';
             if ($objSubResult->RecordCount() > 0) {
                 while (!$objSubResult->EOF) {
                     switch ($objSubResult->fields['type']) {
                         case 'news':
                             $strRelationsNews .= '<a href="?cmd=News&amp;act=newscat">' . $arrNewsCategories[$objSubResult->fields['page_id']] . ' (' . $objSubResult->fields['page_id'] . '</a>)<br />';
                             break;
                         case 'teaser':
                             $strRelationsTeaser .= '<a href="?cmd=News&amp;act=teasers&amp;tpl=editFrame&amp;frameId=' . $objSubResult->fields['page_id'] . '">' . $arrTeaserCategories[$objSubResult->fields['page_id']] . ' (' . $objSubResult->fields['page_id'] . '</a>)<br />';
                             break;
                         default:
                             $arrValues = $objContentTree->getThisNode($objSubResult->fields['page_id']);
                             $strRelationsContent .= '<a href="?cmd=ContentManager&amp;act=edit&amp;pageId=' . $arrValues['catid'] . '">' . $arrValues['catname'] . ' (' . $arrValues['catid'] . '</a>)<br />';
                     }
                     $objSubResult->MoveNext();
                 }
             }
             $strStatusIcon = $objResult->fields['status'] == 0 ? 'status_red.gif' : 'status_green.gif';
             $this->_objTpl->setVariable(array('BANNER_ROWCLASS' => $objResult->fields['is_default'] == 0 ? 'row' . ($i % 2 + 1) : 'rowWarn', 'BANNER_ID' => $objResult->fields['id'], 'BANNER_STATUS_ICON' => $strStatusIcon, 'BANNER_DEFAULT' => $objResult->fields['is_default'] == 0 ? '' : 'checked', 'BANNER_NAME' => stripslashes($objResult->fields['name']), 'BANNER_LIVE' => stripslashes($objResult->fields['banner_code']), 'BANNER_CODE' => htmlspecialchars($objResult->fields['banner_code'], ENT_QUOTES, CONTREXX_CHARSET), 'BANNER_RELATIONS_CONTENT' => $strRelationsContent, 'BANNER_RELATIONS_NEWS' => $strRelationsNews, 'BANNER_RELATIONS_TEASER' => $strRelationsTeaser));
             $this->_objTpl->parse('showBanner');
             $i++;
             $objResult->MoveNext();
         }
     } else {
         $this->_objTpl->hideBlock('showBanner');
     }
 }
Пример #3
0
    private function getJavaScriptCode($objCategory)
    {
        global $_ARRAYLANG;
        $fileDeleteTxt = preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_DELETE_DOWNLOAD']));
        $fileDeleteLink = \Cx\Core\Csrf\Controller\Csrf::enhanceURI(CONTREXX_SCRIPT_PATH . $this->moduleParamsJs) . '&category=' . $objCategory->getId() . '&delete_file=';
        $categoryDeleteTxt = preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_DELETE_CATEGORY']));
        $categoryDeleteLink = \Cx\Core\Csrf\Controller\Csrf::enhanceURI(CONTREXX_SCRIPT_PATH . $this->moduleParamsJs) . '&category=' . $objCategory->getId() . '&delete_category=';
        $javascript = <<<JS_CODE
<script type="text/javascript">
// <![CDATA[
function downloadsDeleteFile(id,name)
{
    msg = '{$fileDeleteTxt}'
    if (confirm(msg.replace('%s',name))) {
        window.location.href='{$fileDeleteLink}'+id;
    }
}

function downloadsDeleteCategory(id,name)
{
    msg = '{$categoryDeleteTxt}'
    if (confirm(msg.replace('%s',name))) {
        window.location.href='{$categoryDeleteLink}'+id;
    }
}

// ]]>
</script>
JS_CODE;
        return $javascript;
    }
Пример #4
0
 /**
  * Set the navigation with the media type drop-down menu in the file browser
  * @access private
  * @see FileBrowser::_getMediaTypeMenu, _objTpl, _mediaType, _arrDirectories
  */
 function _setNavigation()
 {
     global $_ARRAYLANG;
     $ckEditorFuncNum = isset($_GET['CKEditorFuncNum']) ? '&amp;CKEditorFuncNum=' . contrexx_raw2xhtml($_GET['CKEditorFuncNum']) : '';
     $ckEditor = isset($_GET['CKEditor']) ? '&amp;CKEditor=' . contrexx_raw2xhtml($_GET['CKEditor']) : '';
     $this->_objTpl->addBlockfile('FILEBROWSER_NAVIGATION', 'fileBrowser_navigation', 'module_fileBrowser_navigation.html');
     $this->_objTpl->setVariable(array('FILEBROWSER_MEDIA_TYPE_MENU' => $this->_getMediaTypeMenu('fileBrowserType', $this->_mediaType, 'onchange="window.location.replace(\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=FileBrowser') . '&amp;standalone=true&amp;langId=' . $this->_frontendLanguageId . '&amp;type=\'+this.value+\'' . $ckEditorFuncNum . '\')"'), 'TXT_FILEBROWSER_PREVIEW' => $_ARRAYLANG['TXT_FILEBROWSER_PREVIEW']));
     if ($this->_mediaType != 'webpages') {
         // only show directories if the files should be displayed
         if (count($this->_arrDirectories) > 0) {
             foreach ($this->_arrDirectories as $arrDirectory) {
                 $this->_objTpl->setVariable(array('FILEBROWSER_FILE_PATH' => "index.php?cmd=FileBrowser&amp;standalone=true&amp;langId={$this->_frontendLanguageId}&amp;type={$this->_mediaType}&amp;path={$arrDirectory['path']}" . $ckEditor . $ckEditorFuncNum, 'FILEBROWSER_FILE_NAME' => $arrDirectory['name'], 'FILEBROWSER_FILE_ICON' => $arrDirectory['icon']));
                 $this->_objTpl->parse('navigation_directories');
             }
         }
     }
     $this->_objTpl->parse('fileBrowser_navigation');
 }
Пример #5
0
 private function userList()
 {
     global $_ARRAYLANG, $_CORELANG, $_CONFIG;
     // add this to a new section maybe named like "maintenance"
     $this->removeUselessImages();
     $arrSettings = \User_Setting::getSettings();
     $templateFile = 'module_access_user_list';
     if (!$arrSettings['use_usernames']['status']) {
         $templateFile .= '_no_usernames';
     }
     $this->_objTpl->addBlockfile('ACCESS_USER_TEMPLATE', 'module_access_user_overview', $templateFile . '.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_ACCESS_USERS'];
     $objFWUser = \FWUser::getFWUserObject();
     $rowNr = 0;
     $groupId = !empty($_REQUEST['groupId']) ? $_REQUEST['groupId'] : 0;
     $accountType = !empty($_REQUEST['accountType']) ? intval($_REQUEST['accountType']) : 0;
     $limitOffset = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
     $orderDirection = !empty($_GET['sort']) ? $_GET['sort'] : 'desc';
     $orderBy = !empty($_GET['by']) ? $_GET['by'] : 'regdate';
     $search = isset($_REQUEST['search']) && !empty($_REQUEST['search']) ? preg_split('#\\s+#', $_REQUEST['search']) : array();
     $usernameFilter = isset($_REQUEST['username_filter']) && $_REQUEST['username_filter'] != '' && in_array(ord($_REQUEST['username_filter']), array_merge(array(48), range(65, 90))) ? $_REQUEST['username_filter'] : null;
     $userStatusFilter = isset($_REQUEST['user_status_filter']) && $_REQUEST['user_status_filter'] != '' ? intval($_REQUEST['user_status_filter']) : null;
     $userRoleFilter = isset($_REQUEST['user_role_filter']) && $_REQUEST['user_role_filter'] != '' ? intval($_REQUEST['user_role_filter']) : null;
     $this->_objTpl->setVariable(array('TXT_ACCESS_CONFIRM_DELETE_USER' => $_ARRAYLANG['TXT_ACCESS_CONFIRM_DELETE_USER'], 'TXT_ACCESS_CONFIRM_USER_NOTIFY_ABOUT_ACCOUNT_STATUS_NAMED' => $_ARRAYLANG['TXT_ACCESS_CONFIRM_USER_NOTIFY_ABOUT_ACCOUNT_STATUS_NAMED'], 'TXT_ACCESS_OPERATION_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACCESS_OPERATION_IRREVERSIBLE'], 'TXT_ACCESS_SEARCH' => $_ARRAYLANG['TXT_ACCESS_SEARCH'], 'TXT_ACCESS_USER_LIST' => $_ARRAYLANG['TXT_ACCESS_USER_LIST'], 'TXT_ACCESS_FILTER' => $_ARRAYLANG['TXT_ACCESS_FILTER'], 'ACCESS_GROUP_MENU' => $this->getGroupMenu($groupId, 'name="access_group_id" onchange="window.location.replace(\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Access') . '&amp;act=user&amp;groupId=\'+this.value+\'&amp;sort=' . htmlspecialchars($orderDirection) . '&amp;by=' . htmlspecialchars($orderBy) . '&amp;accountType=' . $accountType . '\')"'), 'ACCESS_USER_ACCOUNT_MENU' => $this->getUserAccountMenu($accountType, 'name="access_user_account_type" onchange="window.location.replace(\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Access') . '&amp;act=user&amp;groupId=' . $groupId . '&amp;sort=' . htmlspecialchars($orderDirection) . '&amp;by=' . htmlspecialchars($orderBy) . '&amp;accountType=\'+this.value)"'), 'ACCESS_USER_STATUS_MENU' => $this->getUserStatusMenu($userStatusFilter, 'name="user_status_filter" onchange="window.location.replace(\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Access') . '&amp;act=user&amp;groupId=' . $groupId . '&amp;sort=' . htmlspecialchars($orderDirection) . '&amp;by=' . htmlspecialchars($orderBy) . '&amp;user_status_filter=\'+this.value+\'&amp;user_role_filter=' . $userRoleFilter . '&amp;accountType=' . $accountType . '\')"'), 'ACCESS_USER_ROLE_MENU' => $this->getUserRoleMenu($userRoleFilter, 'name="user_role_filter" onchange="window.location.replace(\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Access') . '&amp;act=user&amp;groupId=' . $groupId . '&amp;sort=' . htmlspecialchars($orderDirection) . '&amp;by=' . htmlspecialchars($orderBy) . '&amp;user_status_filter=' . $userStatusFilter . '&amp;user_role_filter=\'+this.value+\'&amp;accountType=' . $accountType . '\')"'), 'ACCESS_GROUP_IP' => $groupId, 'ACCESS_ACCOUNT_TYPE' => $accountType, 'ACCESS_SEARCH_VALUE' => htmlentities(join(' ', $search), ENT_QUOTES, CONTREXX_CHARSET), 'ACCESS_SORT_DIRECTION' => $orderDirection, 'ACCESS_SORT_BY' => $orderBy, 'ACCESS_SEARCH_VALUE_ESCAPED' => urlencode(implode(' ', $search)), 'ACCESS_USER_USERNAME_FILTER_ESCAPED' => urlencode($usernameFilter), 'ACCESS_USER_STATUS_FILTER_ESCAPED' => urlencode($userStatusFilter), 'ACCESS_USER_ROLE_FILTER_ESCAPED' => urlencode($userRoleFilter)));
     $cx = \Env::get('cx');
     if ($cx->getLicense()->isInLegalComponents('Crm')) {
         $this->_objTpl->touchBlock('access_crm_filter');
     } else {
         $this->_objTpl->hideBlock('access_crm_filter');
     }
     $this->parseLetterIndexList('index.php?cmd=Access&amp;act=user&amp;groupId=' . $groupId . '&amp;user_status_filter=' . $userStatusFilter . '&amp;user_role_filter=' . $userRoleFilter, 'username_filter', $usernameFilter);
     $objGroup = $objFWUser->objGroup->getGroup($groupId);
     $userCount = $objGroup->getUserCount();
     $userFilter = array();
     if ($groupId) {
         $groupId = $groupId == 'groupless' ? 'groupless' : intval($groupId);
         $userFilter['group_id'] = $groupId;
     }
     if ($accountType) {
         $userFilter['crm'] = 1;
     }
     if ($usernameFilter !== null) {
         $userFilter['username'] = array('REGEXP' => '^' . ($usernameFilter == '0' ? '[0-9]|-|_' : $usernameFilter));
     }
     if ($userStatusFilter !== null) {
         $userFilter['active'] = $userStatusFilter;
     }
     if ($userRoleFilter !== null) {
         $userFilter['is_admin'] = $userRoleFilter;
     }
     if ($orderBy == 'expiration') {
         $arrOrder['special'] = 'field( tblU.`expiration`, 0' . ($orderDirection == 'desc' ? ', tblU.`expiration`' : null) . ')';
     }
     $arrOrder[$orderBy] = $orderDirection;
     if ($userCount > 0 && ($objUser = $objFWUser->objUser->getUsers($userFilter, $search, $arrOrder, null, $_CONFIG['corePagingLimit'], $limitOffset)) && ($userCount = $objUser->getFilteredSearchUserCount())) {
         if ($userCount > $_CONFIG['corePagingLimit']) {
             $this->_objTpl->setVariable('ACCESS_USER_PAGING', getPaging($userCount, $limitOffset, "&cmd=Access&act=user&groupId=" . $groupId . "&sort=" . htmlspecialchars($orderDirection) . "&by=" . htmlspecialchars($orderBy) . "&search=" . urlencode(urlencode(implode(' ', $search))) . "&username_filter=" . $usernameFilter . "&user_status_filter=" . $userStatusFilter . "&user_role_filter=" . $userRoleFilter, "<b>" . $_ARRAYLANG['TXT_ACCESS_USER'] . "</b>"));
         }
         $this->_objTpl->setVariable(array('TXT_ACCESS_LANGUAGE' => $_ARRAYLANG['TXT_ACCESS_LANGUAGE'], 'TXT_ACCESS_ADMINISTRATOR' => $_ARRAYLANG['TXT_ACCESS_ADMINISTRATOR'], 'TXT_ACCESS_FUNCTIONS' => $_ARRAYLANG['TXT_ACCESS_FUNCTIONS'], 'TXT_ACCESS_CHANGE_SORT_DIRECTION' => $_ARRAYLANG['TXT_ACCESS_CHANGE_SORT_DIRECTION'], 'ACCESS_SORT_ID' => $orderBy == 'id' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_STATUS' => $orderBy == 'active' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_USERNAME' => $orderBy == 'username' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_COMPANY' => $orderBy == 'company' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_FIRSTNAME' => $orderBy == 'firstname' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_LASTNAME' => $orderBy == 'lastname' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_EMAIL' => $orderBy == 'email' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_REGDATE' => $orderBy == 'regdate' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_LAST_ACTIVITY' => $orderBy == 'last_activity' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_SORT_EXPIRATION' => $orderBy == 'expiration' && $orderDirection == 'asc' ? 'desc' : 'asc', 'ACCESS_ID' => $_ARRAYLANG['TXT_ACCESS_ID'] . ($orderBy == 'id' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_STATUS' => $_ARRAYLANG['TXT_ACCESS_STATUS'] . ($orderBy == 'active' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_USERNAME' => $_ARRAYLANG['TXT_ACCESS_USERNAME'] . ($orderBy == 'username' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_COMPANY' => $_CORELANG['TXT_ACCESS_COMPANY'] . ($orderBy == 'company' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_FIRSTNAME' => $_CORELANG['TXT_ACCESS_FIRSTNAME'] . ($orderBy == 'firstname' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_LASTNAME' => $_CORELANG['TXT_ACCESS_LASTNAME'] . ($orderBy == 'lastname' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_EMAIL' => $_ARRAYLANG['TXT_ACCESS_EMAIL'] . ($orderBy == 'email' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_REGISTERED_SINCE' => $_ARRAYLANG['TXT_ACCESS_REGISTERED_SINCE'] . ($orderBy == 'regdate' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_LAST_ACTIVITY' => $_ARRAYLANG['TXT_ACCESS_LAST_ACTIVITY'] . ($orderBy == 'last_activity' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_EXPIRATION' => $_ARRAYLANG['TXT_ACCESS_VALIDITY_EXPIRATION'] . ($orderBy == 'expiration' ? $orderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'ACCESS_SEARCH_VALUE_ESCAPED' => urlencode(implode(' ', $search))));
         $this->_objTpl->setGlobalVariable(array('TXT_ACCESS_MODIFY_USER_ACCOUNT' => $_ARRAYLANG['TXT_ACCESS_MODIFY_USER_ACCOUNT'], 'ACCESS_GROUP_ID' => $groupId, 'ACCESS_USER_USERNAME_FILTER' => $usernameFilter, 'ACCESS_USER_STATUS_FILTER' => $userStatusFilter, 'ACCESS_USER_ROLE_FILTER' => $userRoleFilter, 'ACCESS_SEARCH_VALUE' => contrexx_raw2xhtml(join(' ', $search))));
         $this->_objTpl->setCurrentBlock('access_user_list');
         while (!$objUser->EOF) {
             $firstname = $objUser->getProfileAttribute('firstname');
             $lastname = $objUser->getProfileAttribute('lastname');
             $company = $objUser->getProfileAttribute('company');
             $this->_objTpl->setVariable(array('ACCESS_ROW_CLASS_ID' => $rowNr % 2 ? 1 : 0, 'ACCESS_USER_ID' => $objUser->getId(), 'ACCESS_USER_STATUS_IMG' => $objUser->getActiveStatus() ? 'led_green.gif' : 'led_red.gif', 'ACCESS_USER_STATUS' => $objUser->getActiveStatus() ? $_ARRAYLANG['TXT_ACCESS_ACTIVE'] : $_ARRAYLANG['TXT_ACCESS_INACTIVE'], 'ACCESS_USER_USERNAME' => htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET), 'ACCESS_USER_COMPANY' => !empty($company) ? htmlentities($company, ENT_QUOTES, CONTREXX_CHARSET) : '&nbsp;', 'ACCESS_USER_FIRSTNAME' => !empty($firstname) ? htmlentities($firstname, ENT_QUOTES, CONTREXX_CHARSET) : '&nbsp;', 'ACCESS_USER_LASTNAME' => !empty($lastname) ? htmlentities($lastname, ENT_QUOTES, CONTREXX_CHARSET) : '&nbsp;', 'ACCESS_USER_EMAIL' => htmlentities($objUser->getEmail(), ENT_QUOTES, CONTREXX_CHARSET), 'ACCESS_SEND_EMAIL_TO_USER' => sprintf($_ARRAYLANG['TXT_ACCESS_SEND_EMAIL_TO_USER'], htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET)), 'ACCESS_USER_ADMIN_IMG' => $objUser->getAdminStatus() ? 'admin.png' : 'no_admin.png', 'ACCESS_USER_ADMIN_TXT' => $objUser->getAdminStatus() ? $_ARRAYLANG['TXT_ACCESS_ADMINISTRATOR'] : $_ARRAYLANG['TXT_ACCESS_NO_ADMINISTRATOR'], 'ACCESS_DELETE_USER_ACCOUNT' => sprintf($_ARRAYLANG['TXT_ACCESS_DELETE_USER_ACCOUNT'], htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET)), 'ACCESS_USER_REGDATE' => date(ASCMS_DATE_FORMAT_DATE, $objUser->getRegistrationDate()), 'ACCESS_USER_LAST_ACTIVITY' => $objUser->getLastActivityTime() ? date(ASCMS_DATE_FORMAT_DATE, $objUser->getLastActivityTime()) : '-', 'ACCESS_USER_EXPIRATION' => $objUser->getExpirationDate() ? date(ASCMS_DATE_FORMAT_DATE, $objUser->getExpirationDate()) : '-', 'ACCESS_USER_EXPIRATION_STYLE' => $objUser->getExpirationDate() && $objUser->getExpirationDate() < time() ? 'color:#f00; font-weight:bold;' : null, 'ACCESS_CHANGE_ACCOUNT_STATUS_MSG' => sprintf($objUser->getActiveStatus() ? $_ARRAYLANG['TXT_ACCESS_DEACTIVATE_USER'] : $_ARRAYLANG['TXT_ACCESS_ACTIVATE_USER'], htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET))));
             $license = \Env::get('cx')->getLicense();
             if (($crmUserId = $objUser->getCrmUserId()) && $license->isInLegalComponents('Crm')) {
                 if ($this->_objTpl->blockExists('access_user_crm_account')) {
                     $this->_objTpl->setVariable(array('ACCESS_USER_CRM_ACCOUNT_ID' => $crmUserId, 'TXT_ACCESS_USER_CRM_ACCOUNT' => $_ARRAYLANG['TXT_ACCESS_USER_CRM_ACCOUNT']));
                     $this->_objTpl->parse('access_user_crm_account');
                 }
             }
             $rowNr++;
             $this->_objTpl->parseCurrentBlock();
             $objUser->next();
         }
         $this->_objTpl->parse('access_has_users');
         $this->_objTpl->hideBlock('access_no_user');
         $this->_objTpl->setVariable(array('TXT_ACCESS_CHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_CHECK_ALL'], 'TXT_ACCESS_UNCHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_UNCHECK_ALL'], 'TXT_ACCESS_SELECT_ACTION' => $_ARRAYLANG['TXT_ACCESS_SELECT_ACTION'], 'TXT_ACCESS_DELETE' => $_ARRAYLANG['TXT_ACCESS_DELETE'], 'ACCESS_CONFIRM_DELETE_USERS_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_ACCESS_CONFIRM_DELETE_USERS'])), 'ACCESS_SEARCH_VALUE_ESCAPED' => urlencode(implode(' ', $search))));
         $this->_objTpl->parse('access_user_action_dropdown');
     } else {
         $groupName = $groupId == 'groupless' ? $_ARRAYLANG['TXT_ACCESS_GROUPLESS_USERS'] : htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET);
         $this->_objTpl->setVariable('ACCESS_STATUS_MSG', count($search) || $usernameFilter != '' ? $_ARRAYLANG['TXT_ACCESS_NO_USERS_FOUND'] : sprintf($_ARRAYLANG['TXT_ACCESS_NO_USER_IN_GROUP'], '&laquo;' . $groupName . '&raquo;'));
         $this->_objTpl->parse('access_no_user');
         $this->_objTpl->hideBlock('access_has_users');
         $this->_objTpl->hideBlock('access_user_action_dropdown');
     }
     $this->_objTpl->parse('module_access_user_overview');
 }
Пример #6
0
 /**
  * task type overview
  *
  * @global object $objDatabase
  * @global array $_ARRAYLANG
  * @return true
  */
 public function taskTypesoverview()
 {
     global $objDatabase, $_ARRAYLANG;
     //For task type Upload
     $options = array('id' => 'taskUploader', 'style' => 'display:none;', 'upload-limit' => 1);
     $uploaderCodeTaskType = $this->initUploader('taskUploadFinished', 'taskCallbackJs', '', $_ARRAYLANG['TXT_BROWSE'], $options);
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Crm&act=getImportFilename');
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE_TASK_TYPE' => $uploaderCodeTaskType, 'REDIRECT_URL' => $redirectUrl));
     $fn = isset($_REQUEST['fn']) ? $_REQUEST['fn'] : '';
     if (!empty($fn)) {
         switch ($fn) {
             case 'editTaskType':
                 $this->editTaskType();
                 break;
         }
         return;
     }
     $objTpl = $this->_objTpl;
     $objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', 'module_' . $this->moduleNameLC . '_settings_task_types.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_CRM_SETTINGS'];
     $objTpl->setGlobalVariable(array('MODULE_NAME' => $this->moduleName, 'TXT_CRM_IMAGE_EDIT' => $_ARRAYLANG['TXT_CRM_IMAGE_EDIT'], 'TXT_CRM_IMAGE_DELETE' => $_ARRAYLANG['TXT_CRM_IMAGE_DELETE']));
     \JS::activate("jquery");
     $msg = base64_decode($_REQUEST['msg']);
     switch ($msg) {
         case 'taskUpdated':
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_TYPE_UPDATED_SUCCESSFULLY'];
             break;
         default:
             break;
     }
     $action = isset($_REQUEST['actionType']) ? $_REQUEST['actionType'] : '';
     $tasktypeIds = isset($_REQUEST['taskTypeId']) ? array_map('intval', $_REQUEST['taskTypeId']) : 0;
     $tasktypeSorting = isset($_REQUEST['sorting']) ? array_map('intval', $_REQUEST['sorting']) : 0;
     $ajax = isset($_REQUEST['ajax']);
     switch ($action) {
         case 'changestatus':
             $this->activateTaskType((int) $_GET['taskTypeId']);
             if ($ajax) {
                 exit;
             }
         case 'activate':
             $this->activateTaskTypes($tasktypeIds);
             break;
         case 'deactivate':
             $this->activateTaskTypes($tasktypeIds, true);
             break;
         case 'delete':
             $this->deleteTaskTypes($tasktypeIds);
             break;
         case 'deletecatalog':
             $this->deleteTaskType((int) $_GET['taskTypeId']);
             if ($ajax) {
                 exit;
             }
             break;
         default:
             break;
     }
     if (!empty($action)) {
         $this->saveSortingTaskType($tasktypeSorting);
         if ($action == 'savesorting' || $action == 'Save') {
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_PROJECTSTATUS_SORTING_COMPLETE'];
         }
     }
     if ($_POST['saveTaskType']) {
         $this->saveTaskTypes();
         $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_TYPE_ADDED_SUCCESSFULLY'];
     }
     $this->getModifyTaskTypes();
     $this->showTaskTypes();
     $objTpl->setVariable(array('TXT_CRM_ICON' => $_ARRAYLANG['TXT_CRM_ICON'], 'TXT_CRM_ICON_PATH' => \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesCrmWebPath() . '/', 'TXT_CRM_TASK_TYPES' => $_ARRAYLANG['TXT_CRM_TASK_TYPES'], 'TXT_CRM_ADD_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_ADD_TASK_TYPE'], 'TXT_CRM_TASK_TYPE_STATUS' => $_ARRAYLANG['TXT_CRM_TASK_TYPE_STATUS'], 'TXT_CRM_FUNCTIONS' => $_ARRAYLANG['TXT_CRM_FUNCTIONS'], 'TXT_CRM_NO_TASKTYPES' => $_ARRAYLANG['TXT_CRM_NO_TASKTYPES'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], '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_DELETE_SELECTED' => $_ARRAYLANG['TXT_CRM_DELETE_SELECTED'], 'TXT_CRM_ACTIVATE_SELECTED' => $_ARRAYLANG['TXT_CRM_ACTIVATE_SELECTED'], 'TXT_CRM_DEACTIVATE_SELECTED' => $_ARRAYLANG['TXT_CRM_DEACTIVATE_SELECTED'], 'TXT_CRM_SAVE_SORTING' => $_ARRAYLANG['TXT_CRM_SAVE_SORTING'], 'TXT_SELECT_ENTRIES' => $_ARRAYLANG['TXT_CRM_NO_OPERATION'], 'TXT_CRM_STATUS_SUCCESSFULLY_CHANGED' => $_ARRAYLANG['TXT_CRM_TASK_TYPE_STATUS_CHANGED_SUCCESSFULLY'], 'TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES' => $_ARRAYLANG['TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
Пример #7
0
 /**
  * It displayes the import menu
  *
  * @return customer import screen
  */
 function showImport()
 {
     global $_ARRAYLANG, $objDatabase;
     \JS::activate('cx');
     \JS::activate('jqueryui');
     \JS::registerCSS('modules/Crm/View/Style/main.css');
     \JS::registerJS('modules/Crm/View/Script/contactexport.js');
     \JS::registerJS('lib/javascript/jquery.form.js');
     \JS::registerJS('lib/javascript/jquery.tmpl.min.js');
     \JS::registerJS('lib/javascript/jquery.base64.js');
     \JS::registerJS('lib/javascript/jquery.format.js');
     $objTpl = $this->_objTpl;
     $objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', "module_{$this->moduleNameLC}_interface_import_options.html");
     $objTpl->setGlobalVariable(array('MODULE_NAME' => $this->moduleName));
     foreach ($this->_delimiter as $key => $value) {
         $objTpl->setVariable(array('CRM_DELIMITER_VALUE' => $key, 'CRM_DELIMITER_TITLE' => $_ARRAYLANG[$value['placeholder']]));
         $objTpl->parse('crm_delimiter');
     }
     foreach ($this->_enclosure as $key => $value) {
         $objTpl->setVariable(array('CRM_ENCLOSURE_VALUE' => $key, 'CRM_ENCLOSURE_TITLE' => $_ARRAYLANG[$value['placeholder']]));
         $objTpl->parse('crm_enclosure');
     }
     $options = array('upload-limit' => 1, 'id' => 'importUploader', 'style' => 'display:none;', 'allowed-extensions' => array('csv'));
     $uploaderCode = $this->initUploader('uploadFinished', 'importCallbackJs', '', '', $options);
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Crm&act=getImportFilename');
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $uploaderCode, 'REDIRECT_URL' => $redirectUrl));
     $objTpl->setVariable(array('TXT_CRM_TITLE_IMPORT_CONTACTS' => $_ARRAYLANG['TXT_CRM_TITLE_IMPORT_CONTACTS'], 'TXT_CRM_IMPORT_HEADER' => $_ARRAYLANG['TXT_CRM_IMPORT_HEADER'], 'TXT_CRM_IMPORT_NOTE' => $_ARRAYLANG['TXT_CRM_IMPORT_NOTE'], 'TXT_CRM_IMPORT_NOTE_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_IMPORT_NOTE_DESCRIPTION'], 'TXT_CRM_CSV_SETTINGS' => $_ARRAYLANG['TXT_CRM_CSV_SETTINGS'], 'TXT_CRM_SKIP' => $_ARRAYLANG['TXT_CRM_SKIP'], 'TXT_CRM_OVERWRITE' => $_ARRAYLANG['TXT_CRM_OVERWRITE'], 'TXT_CRM_DUPLICATE' => $_ARRAYLANG['TXT_CRM_DUPLICATE'], 'TXT_CRM_CHOOSE_FILE' => $_ARRAYLANG['TXT_CRM_CHOOSE_FILE'], 'TXT_CRM_CSV_SEPARATOR' => $_ARRAYLANG['TXT_CRM_CSV_SEPARATOR'], 'TXT_CRM_CSV_ENCLOSURE' => $_ARRAYLANG['TXT_CRM_CSV_ENCLOSURE'], 'TXT_CRM_ON_DUPLICATES' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATES'], 'TXT_CRM_CHOOSE_CSV' => $_ARRAYLANG['TXT_CRM_CHOOSE_CSV'], 'TXT_CRM_ON_DUPLICATES_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATES_INFO'], 'TXT_CRM_ON_DUPLICATE_SKIP_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_SKIP_INFO'], 'TXT_CRM_ON_DUPLICATE_OVERWRITE_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_OVERWRITE_INFO'], 'TXT_CRM_ON_DUPLICATE_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_INFO'], 'TXT_CRM_IGNORE_FIRST_ROW' => $_ARRAYLANG['TXT_CRM_IGNORE_FIRST_ROW'], 'TXT_CRM_CONTINUE' => $_ARRAYLANG['TXT_CRM_CONTINUE'], 'TXT_CRM_CANCEL' => $_ARRAYLANG['TXT_CRM_CANCEL'], 'TXT_CRM_VERIFY_FIELDS' => $_ARRAYLANG['TXT_CRM_VERIFY_FIELDS'], 'TXT_CRM_VERIFY_INFO' => $_ARRAYLANG['TXT_CRM_VERIFY_INFO'], 'TXT_CRM_FILE_COLUMN' => $_ARRAYLANG['TXT_CRM_FILE_COLUMN'], 'TXT_CRM_CORRESPONDING_FIELD' => $_ARRAYLANG['TXT_CRM_CORRESPONDING_FIELD'], 'TXT_CRM_CSV_VALUE' => $_ARRAYLANG['TXT_CRM_CSV_VALUE'], 'TXT_CRM_CHANGE' => $_ARRAYLANG['TXT_CRM_CHANGE'], 'TXT_CRM_LOADING' => $_ARRAYLANG['TXT_CRM_LOADING'], 'TXT_CRM_PREVIOUS_RECORD' => $_ARRAYLANG['TXT_CRM_PREVIOUS_RECORD'], 'TXT_CRM_NEXT_RECORD' => $_ARRAYLANG['TXT_CRM_NEXT_RECORD'], 'TXT_CRM_TITLE_SAVING_CONTACTS' => $_ARRAYLANG['TXT_CRM_TITLE_SAVING_CONTACTS'], 'TXT_CRM_INTERFACE_FINAL_INFO' => $_ARRAYLANG['TXT_CRM_INTERFACE_FINAL_INFO'], 'TXT_CRM_RECORD_DONE' => $_ARRAYLANG['TXT_CRM_RECORD_DONE'], 'TXT_CRM_RECORD_SKIPPED' => $_ARRAYLANG['TXT_CRM_RECORD_SKIPPED'], 'TXT_CRM_RECORD_IMPORT' => $_ARRAYLANG['TXT_CRM_RECORD_IMPORT'], 'TXT_CRM_RECORD_PROCESS' => $_ARRAYLANG['TXT_CRM_RECORD_PROCESS'], 'TXT_CRM_IMPORT_NAME' => $_ARRAYLANG['TXT_CRM_IMPORT_NAME'], 'TXT_CRM_EXPORT_NAME' => $_ARRAYLANG['TXT_CRM_EXPORT_NAME']));
 }
Пример #8
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;
 }
Пример #9
0
 /**
  * notes overview page
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 function notesOverview()
 {
     global $_CORELANG, $_ARRAYLANG, $objDatabase, $objJs;
     //For notes type Upload
     $options = array('id' => 'notesUploader', 'upload-limit' => 1, 'style' => 'display:none;');
     $uploaderCodeTaskType = $this->initUploader('notesUploadFinished', 'notesCallbackJs', '', $_ARRAYLANG['TXT_BROWSE'], $options);
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Crm&act=getImportFilename');
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE_NOTES' => $uploaderCodeTaskType, 'REDIRECT_URL' => $redirectUrl));
     $fn = isset($_REQUEST['fn']) ? $_REQUEST['fn'] : '';
     if (!empty($fn)) {
         switch ($fn) {
             case 'editnotestype':
                 $this->editnotes();
                 break;
         }
         return;
     }
     $this->_objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', 'module_' . $this->moduleNameLC . '_settings_notes.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_CRM_SETTINGS'];
     $this->_objTpl->setGlobalVariable(array('MODULE_NAME' => $this->moduleName));
     if (!isset($_GET['message'])) {
         $_GET['message'] = '';
     }
     switch ($_GET['message']) {
         case 'updatenotes':
             $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_NOTES_UPDATED'];
             break;
     }
     $name = isset($_POST['name']) ? contrexx_input2db($_POST['name']) : '';
     $status = isset($_POST['status']) ? intval($_POST['status']) : '';
     $icon = isset($_POST['icon']) ? contrexx_input2db($_POST['icon']) : '';
     $position = isset($_POST['sorting']) ? intval($_POST['sorting']) : '';
     $id = isset($_GET['idr']) ? intval($_GET['idr']) : '';
     if (isset($_GET['idr'])) {
         $objComment = $objDatabase->Execute("SELECT notes_type_id FROM " . DBPREFIX . "module_" . $this->moduleNameLC . "_customer_comment WHERE notes_type_id = '{$id}'");
         if ($objComment->fields['notes_type_id'] != $id) {
             $objResult = $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes WHERE id = '{$id}'");
             $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_NOTES_DELETED'];
         } else {
             $this->_strErrMessage = $_ARRAYLANG['TXT_CRM_NOTES_ERROR'];
         }
     }
     if (isset($_GET['chg']) and $_GET['chg'] == 1 and isset($_POST['selected']) and is_array($_POST['selected'])) {
         if ($_POST['form_activate'] != '' or $_POST['form_deactivate'] != '') {
             $ids = $_POST['selected'];
             $to = $_POST['form_activate'] ? 1 : 0;
             foreach ($ids as $id) {
                 $query = "UPDATE " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes\n                                                                   SET   status  = '" . $to . "'\n                                                                   WHERE id      = '" . intval($id) . "'";
                 $objDatabase->SelectLimit($query, 1);
             }
             $this->_strOkMessage = $to == 1 ? $_ARRAYLANG['TXT_CRM_ACTIVATED_SUCCESSFULLY'] : $_ARRAYLANG['TXT_CRM_DEACTIVATED_SUCCESSFULLY'];
         }
         if ($_POST['form_delete'] != '') {
             $ids = $_POST['selected'];
             $x = 0;
             foreach ($ids as $id) {
                 $objComment = $objDatabase->Execute("SELECT notes_type_id FROM " . DBPREFIX . "module_" . $this->moduleNameLC . "_customer_comment WHERE notes_type_id = '{$id}'");
                 if ($objComment->fields['notes_type_id'] != $id) {
                     $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes\n                                                                       WHERE system_defined != 1 AND id = '" . intval($id) . "'";
                     $objDelete = $objDatabase->SelectLimit($query, 1);
                     if ($objDelete) {
                         $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_NOTES_DELETED'];
                     }
                 } else {
                     $this->_strErrMessage = $_ARRAYLANG['TXT_CRM_NOTES_ERROR'];
                 }
             }
         }
     }
     if (isset($_GET['chg']) and $_GET['chg'] == 1 and $_POST['form_sort'] == 1) {
         for ($x = 0; $x < count($_POST['form_id']); $x++) {
             $query = "UPDATE " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes\n                                                  SET   pos   = '" . intval($_POST['form_pos'][$x]) . "'\n                                                  WHERE id    = '" . intval($_POST['form_id'][$x]) . "'";
             $objDatabase->Execute($query);
         }
         $this->_strOkMessage = $_POST['form_sort'] == 1 ? $_ARRAYLANG['TXT_CRM_SORTING_COMPLETE'] : '';
     }
     if (isset($_POST['save'])) {
         $validate = $this->validation($name);
         if ($validate) {
             $objResult = $objDatabase->Execute("INSERT " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes SET name   ='{$name}',\n                                                                                                                  status = '{$status}',\n                                                                                                                  icon   = '{$icon}',\n                                                                                                                  pos    = '{$position}'");
             $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_NOTES_INSERTED'];
         } else {
             $this->_strErrMessage = $_ARRAYLANG['TXT_CRM_ERROR'];
         }
     }
     if (isset($_POST['notes_save'])) {
         for ($x = 0; $x < count($_POST['form_id']); $x++) {
             $query = "UPDATE " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes\n                                           SET   pos   = '" . intval($_POST['form_pos'][$x]) . "'\n                                           WHERE id    = '" . intval($_POST['form_id'][$x]) . "'";
             $objDatabase->Execute($query);
         }
         $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_SORTING_COMPLETE'];
     }
     $sortf = isset($_GET['sortf']) && isset($_GET['sorto']) ? $_GET['sortf'] == 1 ? 'pos' : 'name' : 'pos';
     $sorto = isset($_GET['sortf']) && isset($_GET['sorto']) ? $_GET['sorto'] == 'ASC' ? 'DESC' : 'ASC' : 'ASC';
     $objResult = $objDatabase->Execute("SELECT id, name, status, pos, system_defined, icon FROM " . DBPREFIX . "module_" . $this->moduleNameLC . "_notes ORDER BY {$sortf} {$sorto}");
     $row = 'row2';
     while (!$objResult->EOF) {
         $stat = $objResult->fields['status'];
         if ($objResult->fields['system_defined']) {
             $this->_objTpl->hideBlock('noteDeleteIcon');
         } else {
             $this->_objTpl->touchBlock('noteDeleteIcon');
         }
         if (!empty($objResult->fields['icon'])) {
             $iconPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesCrmWebPath() . '/' . contrexx_raw2xhtml($objResult->fields['icon']) . "_16X16.thumb";
         } else {
             $iconPath = '../modules/Crm/View/Media/customer_note.png';
         }
         $this->_objTpl->setVariable(array('TXT_NOTES_ID' => (int) $objResult->fields['id'], 'TXT_NOTES_NAME' => contrexx_raw2xhtml($objResult->fields['name']), 'TXT_NOTES_ICON' => $iconPath, 'TXT_NOTES_STATVAL' => $stat, 'TXT_NOTES_STATUS' => $stat == 1 ? 'green' : 'red', 'TXT_NOTES_SORTING' => (int) $objResult->fields['pos'], 'TXT_ROW' => $row = $row == 'row2' ? 'row1' : 'row2', 'TXT_ORDER' => $sorto));
         $this->_objTpl->parse('users');
         $objResult->MoveNext();
     }
     $this->_objTpl->setVariable(array('TXT_CRM_ICON' => $_ARRAYLANG['TXT_CRM_ICON'], 'TXT_CRM_GENERAL' => $_ARRAYLANG['TXT_CRM_GENERAL'], 'TXT_CRM_CUSTOMER_TYPES' => $_ARRAYLANG['TXT_CRM_CUSTOMER_TYPES'], 'TXT_CRM_CURRENCY' => $_ARRAYLANG['TXT_CRM_CURRENCY'], 'TXT_CRM_NOTES' => $_ARRAYLANG['TXT_CRM_NOTES'], 'TXT_CRM_NAME' => $_ARRAYLANG['TXT_CRM_LABEL'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_TITLEACTIVE' => $_ARRAYLANG['TXT_CRM_TITLEACTIVE'], 'TXT_CRM_SORTING_NUMBER' => $_ARRAYLANG['TXT_CRM_SORTING_NUMBER'], 'TXT_CRM_ADD_NOTES_TYPES' => $_ARRAYLANG['TXT_CRM_ADD_NOTES_TYPES'], 'TXT_CRM_TITLE_STATUS' => $_ARRAYLANG['TXT_CRM_TITLE_STATUS'], 'TXT_CRM_SORTING' => $_ARRAYLANG['TXT_CRM_SORTING'], 'TXT_CRM_FUNCTIONS' => $_ARRAYLANG['TXT_CRM_FUNCTIONS'], 'TXT_ENTRIES_MARKED' => $_ARRAYLANG['TXT_ENTRIES_MARKED'], '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_PROJECTSTATUS_SAVE_SORTING' => $_ARRAYLANG['TXT_CRM_PROJECTSTATUS_SAVE_SORTING'], 'TXT_CRM_NOTES_DELETED' => $_ARRAYLANG['TXT_CRM_NOTES_DELETED'], 'TXT_CRM_DELETE_CONFIRM' => $_ARRAYLANG['TXT_CRM_DELETE_CONFIRM'], 'TXT_CRM_CHANGE_STATUS' => $_ARRAYLANG['TXT_CRM_CHANGE_STATUS'], 'TXT_CRM_DELETE_SELECTED' => $_ARRAYLANG['TXT_CRM_DELETE_SELECTED'], 'PM_SETTINGS_CURRENCY_JAVASCRIPT' => $objJs->getAddNotesJavascript(), 'TXT_BROWSE' => $_ARRAYLANG['TXT_BROWSE'], 'TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES' => $_ARRAYLANG['TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES']));
 }
Пример #10
0
 /**
  * Shows the UploadForm
  *
  * @global    ADONewConnection
  * @global    array
  */
 function showUploadForm()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     /**
      * Uploader button handling
      */
     //paths we want to remember for handling the uploaded files
     $paths = array('path' => ASCMS_GALLERY_PATH, 'webPath' => ASCMS_GALLERY_WEB_PATH);
     $uploader = new Uploader();
     //        $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
     $uploader->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Gallery/Controller/GalleryManager.class.php', '\\Cx\\Modules\\Gallery\\Controller\\GalleryManager', 'uploadFinished'));
     $uploader->setData($paths);
     $uploader->addClass('uploadbutton');
     $uploader->setOptions(array('allowed-extensions' => array('jpg', 'gif', 'png')));
     $uploader->setCallback('finishedGalleryUpload');
     //set instance name to combo_uploader so we are able to catch the instance with js
     //        $comboUp->setJsInstanceName('exposed_combo_uploader');
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Gallery&act=validate_form');
     $this->_objTpl->loadTemplateFile('module_gallery_upload_images.html', true, true);
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM_SUBMIT']), 'REDIRECT_URL' => $redirectUrl));
     //end of uploader button handling
     //get enabled filetypes
     $strEnabledTypes = '';
     if ($this->boolGifEnabled == true) {
         $strEnabledTypes .= 'GIF ';
     }
     if ($this->boolJpgEnabled == true) {
         $strEnabledTypes .= 'JPG ';
     }
     if ($this->boolPngEnabled == true) {
         $strEnabledTypes .= 'PNG ';
     }
     $objResult = $objDatabase->Execute('SELECT         *
                                                 FROM         ' . DBPREFIX . 'module_gallery_pictures
                                                 WHERE         validated="0"
                                                 ORDER BY     lastedit ASC');
     while (!$objResult->EOF) {
         $this->_objTpl->setVariable('GALLERY_UPLOADED_IMAGE', '<img src="' . $this->strImageWebPath . $objResult->fields['path'] . '" class="galleryImageVisible" />');
         $this->_objTpl->parse('uploadedImages');
         $objResult->MoveNext();
     }
     if ($objResult->_numOfRows == 0) {
         $this->_objTpl->setVariable('GALLERY_ALREADY_UPLOADED_IMAGES', 'confirmImages');
     }
     $this->_objTpl->setVariable(array('TXT_TITLE' => $_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM'], 'TXT_GALLERY_UPLOAD_CONFIRM_IMAGES' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_CONFIRM_IMAGES'], 'TXT_GALLERY_UPLOAD_IMAGES' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_IMAGES'], 'TXT_GALLERY_UPLOAD_HELP' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_HELP'], 'TXT_IMAGENUMBER' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_FORM_IMAGE_NUMBER'], 'TXT_ENABLED_IMAGE_TYPE' => $_ARRAYLANG['TXT_GALLERY_FORMAT_SUPPORT'] . ' ' . $strEnabledTypes . '. ' . $_ARRAYLANG['TXT_GALLERY_NO_UPLOAD'], 'TXT_BUTTON_SUBMIT' => $_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM_SUBMIT']));
 }
Пример #11
0
 /**
  * Shows the UploadForm
  *
  * @global    ADONewConnection
  * @global    array
  */
 function showUploadForm()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     /**
      * Uploader button handling
      */
     //paths we want to remember for handling the uploaded files
     $paths = array('path' => ASCMS_GALLERY_PATH, 'webPath' => ASCMS_GALLERY_WEB_PATH);
     $uploader = new Uploader();
     //        $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo');
     $uploader->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Gallery/Controller/GalleryManager.class.php', '\\Cx\\Modules\\Gallery\\Controller\\GalleryManager', 'uploadFinished'));
     $uploader->setData($paths);
     $uploader->addClass('uploadbutton');
     $uploader->setCallback('finishedGalleryUpload');
     //set instance name to combo_uploader so we are able to catch the instance with js
     //        $comboUp->setJsInstanceName('exposed_combo_uploader');
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Gallery&act=validate_form');
     $this->_objTpl->loadTemplateFile('module_gallery_upload_images.html', true, true);
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM_SUBMIT']), 'REDIRECT_URL' => $redirectUrl));
     //end of uploader button handling
     //get enabled filetypes
     $strEnabledTypes = '';
     if ($this->boolGifEnabled == true) {
         $strEnabledTypes .= 'GIF ';
     }
     if ($this->boolJpgEnabled == true) {
         $strEnabledTypes .= 'JPG ';
     }
     if ($this->boolPngEnabled == true) {
         $strEnabledTypes .= 'PNG ';
     }
     $this->_objTpl->setVariable(array('TXT_TITLE' => $_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM'], 'TXT_GALLERY_UPLOAD_CONFIRM_IMAGES' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_CONFIRM_IMAGES'], 'TXT_GALLERY_UPLOAD_IMAGES' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_IMAGES'], 'TXT_GALLERY_UPLOAD_HELP' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_HELP'], 'TXT_IMAGENUMBER' => $_ARRAYLANG['TXT_GALLERY_UPLOAD_FORM_IMAGE_NUMBER'], 'TXT_ENABLED_IMAGE_TYPE' => $_ARRAYLANG['TXT_GALLERY_FORMAT_SUPPORT'] . ' ' . $strEnabledTypes . '. ' . $_ARRAYLANG['TXT_GALLERY_NO_UPLOAD'], 'TXT_BUTTON_SUBMIT' => $_ARRAYLANG['TXT_GALLERY_MENU_UPLOAD_FORM_SUBMIT']));
 }