Ejemplo n.º 1
0
 /**
  * Outputs a list of all posts alerted by users.
  *
  * This function output a list of all post alerts submitted by users.
  * It allows a filtering by post alert status and different ordering options.
  * @param  array  $conf The calling plugin's configuration vars
  * @return string       The post alert list
  */
 function list_alerts($conf)
 {
     $param = GeneralUtility::_GP('tx_mmforum_pi1');
     if ($param['update'] == 'update_status') {
         foreach ($param as $key => $value) {
             $key = str_replace('status_', '', $key);
             if (is_numeric($key)) {
                 $key = $this->databaseHandle->fullQuoteStr($key, 'tx_mmforum_post_alert');
                 $value = $this->databaseHandle->fullQuoteStr($value, 'tx_mmforum_post_alert');
                 $updateArray = array('status' => $value, 'tstamp' => $GLOBALS['EXEC_TIME']);
                 $this->databaseHandle->exec_UPDATEquery('tx_mmforum_post_alert', 'uid=' . $key . ' AND status <> ' . $value, $updateArray);
             }
         }
     }
     $template = $this->cObj->fileResource($conf['template.']['post_alert']);
     $template = $this->cObj->getSubpart($template, "###ALERT_LIST###");
     $template_sub = $this->cObj->getSubpart($template, "###ALERT_LIST_SUB###");
     // Language dependent markers
     $marker = array('###LABEL_POSTALERTS###' => $this->pi_getLL('postalert.title'), '###LABEL_ORDERBY###' => $this->pi_getLL('postalert.orderby'), '###LABEL_ORDERBY_STATUS###' => $this->pi_getLL('postalert.orderby.status'), '###LABEL_ORDERBY_DATE###' => $this->pi_getLL('postalert.orderby.date'), '###LABEL_ORDERBY_USER###' => $this->pi_getLL('postalert.orderby.user'), '###LABEL_ORDERASC###' => $this->pi_getLL('postalert.ordermode.asc'), '###LABEL_ORDERDESC###' => $this->pi_getLL('postalert.ordermode.desc'), '###LABEL_DISPLAY###' => $this->pi_getLL('postalert.display'), '###LABEL_OPEN###' => $this->pi_getLL('postalert.status.open'), '###LABEL_INPROGRESS###' => $this->pi_getLL('postalert.status.progress'), '###LABEL_DONE###' => $this->pi_getLL('postalert.status.done'), '###LABEL_NR###' => $this->pi_getLL('postalert.number'), '###LABEL_DATE###' => $this->pi_getLL('postalert.date'), '###LABEL_PROBLEM###' => $this->pi_getLL('postalert.problem'), '###LABEL_POST###' => $this->pi_getLL('postalert.post'), '###LABEL_USER###' => $this->pi_getLL('postalert.user'), '###LABEL_STATUS###' => $this->pi_getLL('postalert.status'), '###LABEL_POSTTEXT###' => $this->pi_getLL('postalert.posttext'));
     $marker['###ORDERBY_USER###'] = '';
     $marker['###ORDERBY_DATE###'] = '';
     $marker['###ORDERBY_STAT###'] = '';
     $marker['###ORDERASC###'] = '';
     $marker['###ORDERDESC###'] = '';
     $marker['###VIEW_OPEN###'] = '';
     $marker['###VIEW_WORK###'] = '';
     $marker['###VIEW_CLOSE###'] = '';
     // Determine ordering mode
     switch ($param['order_by']) {
         case "user":
             $order_by = 'cruser_id';
             $marker['###ORDERBY_USER###'] = 'selected';
             break;
         case "date":
             $order_by = 'crdate';
             $marker['###ORDERBY_DATE###'] = 'selected';
             break;
         case "status":
             $order_by = 'status';
             $marker['###ORDERBY_STAT###'] = 'selected';
             break;
         default:
             $order_by = 'status';
             $marker['###ORDERBY_STAT###'] = 'selected';
             break;
     }
     switch ($param['order']) {
         case "up":
             $order = 'ASC';
             $marker['###ORDERASC###'] = 'selected';
             break;
         case "down":
             $order = 'DESC';
             $marker['###ORDERDESC###'] = 'selected';
             break;
         default:
             $order = 'ASC';
             $marker['###ORDERASC###'] = 'selected';
             break;
     }
     $allowedStatus = array();
     // Determine filtering mode
     if ($param['view_open'] == 1) {
         $marker['###VIEW_OPEN###'] = 'checked';
         #$where .= 'OR status = -1 ';
         $allowedStatus[] = -1;
     }
     if ($param['view_work'] == 1) {
         $marker['###VIEW_WORK###'] = 'checked';
         #$where .= 'OR status = 0 ';= -1 ';
         $allowedStatus[] = 0;
     }
     if ($param['view_close'] == 1) {
         $marker['###VIEW_CLOSE###'] = 'checked';
         #$where .= 'OR status = 1 ';= -1 ';
         $allowedStatus[] = 1;
     }
     if ($param['view_close'] == '' and $param['view_work'] == '' and $param['view_open'] == '' and empty($param)) {
         $marker['###VIEW_OPEN###'] = 'checked';
         $marker['###VIEW_WORK###'] = 'checked';
         $marker['###VIEW_CLOSE###'] = '';
         #$where = ' OR status = -1 OR status = 0';
         $allowedStatus = array(0, -1);
     }
     $where = count($allowedStatus) ? ' AND status IN (' . implode(',', $allowedStatus) . ') ' : '';
     $boards = tx_mmforum_postalert::getModeratorBoards();
     if ($boards === false) {
         $accessWhere = ' AND 0=1 ';
     } elseif ($boards === true) {
         $accessWhere = ' AND 1=1 ';
     } else {
         $accessWhere = ' AND t.forum_id IN (' . implode(',', $boards) . ') ';
     }
     // Load post alert records from database
     $res = $this->databaseHandle->exec_SELECTquery('a.*', 'tx_mmforum_post_alert a LEFT JOIN tx_mmforum_topics t ON a.topic_id = t.uid', "1 = 1 {$where} {$accessWhere}", '', $order_by . ' ' . $order);
     $content_sub = '';
     while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
         $marker['###STATUS###'] = '';
         switch ($row['status']) {
             case '-1':
                 $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['open'];
                 $marker['###STATUS###'] .= '<option value="-1" selected>' . $this->pi_getLL('postalert.status.open') . '</option>';
                 $marker['###STATUS###'] .= '<option value="0">' . $this->pi_getLL('postalert.status.progress') . '</option>';
                 $marker['###STATUS###'] .= '<option value="1">' . $this->pi_getLL('postalert.status.done') . '</option>';
                 break;
             case '0':
                 $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['work'];
                 $marker['###STATUS###'] .= '<option value="-1">' . $this->pi_getLL('postalert.status.open') . '</option>';
                 $marker['###STATUS###'] .= '<option value="0" selected>' . $this->pi_getLL('postalert.status.progress') . '</option>';
                 $marker['###STATUS###'] .= '<option value="1">' . $this->pi_getLL('postalert.status.done') . '</option>';
                 break;
             case '1':
                 $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['done'];
                 $marker['###STATUS###'] .= '<option value="-1">' . $this->pi_getLL('postalert.status.open') . '</option>';
                 $marker['###STATUS###'] .= '<option value="0">' . $this->pi_getLL('postalert.status.progress') . '</option>';
                 $marker['###STATUS###'] .= '<option value="1" selected>' . $this->pi_getLL('postalert.status.done') . '</option>';
                 break;
         }
         $linkparams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['topic_id'], 'pid' => $row['post_id']);
         list($posttext) = $this->databaseHandle->sql_fetch_row($this->databaseHandle->exec_SELECTquery('post_text', 'tx_mmforum_posts_text', 'deleted="0" AND hidden="0" AND post_id="' . $row['post_id'] . '"'));
         $marker['###UID###'] = $row['uid'];
         $marker['###TOPIC###'] = $this->pi_linkToPage($this->escape($this->get_topic_name($row['topic_id'])), $conf['pid_forum'], $target = '_self', $linkparams);
         $marker['###DATE###'] = $this->formatDate($row['crdate']);
         $marker['###POST_TEXT###'] = nl2br($this->escape($posttext));
         $marker['###TEXT_SHORT###'] = $this->escape(tx_mmforum_tools::textCut($row['alert_text'], 15, ''));
         $marker['###TEXT###'] = nl2br($this->escape($row['alert_text']));
         $mod_data = tx_mmforum_tools::get_userdata($row['cruser_id']);
         $marker['###MOD###'] = $mod_data[$this->getUserNameField()];
         $marker['###POST_USER###'] = $this->pi_linkToPage($mod_data[$this->getUserNameField()], $conf['pm_id'], '', array('tx_mmforum_pi3[action]' => 'message_write', 'userid' => $row['cruser_id']));
         $content_sub .= $this->cObj->substituteMarkerArrayCached($template_sub, $marker);
     }
     $content = $this->cObj->substituteSubpart($template, '###ALERT_LIST_SUB###', $content_sub);
     $marker['###FORMACTION###'] = $this->escapeURL($this->pi_getPageLink($GLOBALS["TSFE"]->id, '', $linkparams));
     $content = $this->cObj->substituteMarkerArrayCached($content, $marker);
     return $content;
 }
Ejemplo n.º 2
0
 /**
  * Displays the form for writing a new private message or replying to an
  * existing one. Also saves the new private message to database.
  *
  * @author  Georg Ringer <*****@*****.**>
  * @author  Martin Helmich <*****@*****.**>
  * @version 2008-01-11
  * @param   string $content The content
  * @param   array  $conf    The plugin's configuration vars
  * @return  string          The plugin content
  */
 function message_write($content, $conf)
 {
     $messageId = intval($this->piVars['messid']);
     // Load message to reply to from database
     $res = $this->databaseHandle->exec_SELECTquery('uid,from_name,message,subject', 'tx_mmforum_pminbox', 'hidden=0 AND deleted=0 AND uid=' . $messageId . ' AND to_uid=' . $GLOBALS['TSFE']->fe_user->user['uid'] . $this->getStoragePIDQuery(), '', 'sendtime ASC', '1');
     $isReply = $this->databaseHandle->sql_num_rows($res) > 0;
     $originalMsg = $this->databaseHandle->sql_fetch_assoc($res);
     $this->databaseHandle->sql_free_result($res);
     // Commit user search
     if ($this->piVars['save'] == $this->pi_getLL('write.search')) {
         // If a messsage text has already been entered, store this text
         // in the session variables in order to have it available later on.
         if (!empty($this->piVars['message'])) {
             session_start();
             $_SESSION['mm_forum']['pm']['message'] = $this->piVars['message'];
         }
         $content .= $this->list_user($content, $conf);
     } else {
         if ($this->piVars['save'] == $this->pi_getLL('write.send')) {
             $subject = $this->piVars['subject'];
             $message = $this->piVars['message'];
             $to_username = $this->piVars['user'];
             $error = 0;
             // Check subject
             if (!$subject) {
                 $error = 1;
                 $errormessage = $this->pi_getLL('errorNoSubject');
             }
             // Check message
             if (!$message) {
                 $error = 1;
                 $errormessage = $this->pi_getLL('errorNoMessage');
             }
             // Check recipient
             if (!$to_username) {
                 $error = 1;
                 $errormessage = $this->pi_getLL('errorNoRecipient');
             }
             // Spam protection: just one message per $conf['block_time']
             // Load last sent message from database
             $res = $this->databaseHandle->exec_SELECTquery('crdate', 'tx_mmforum_pminbox', 'from_uid=' . $GLOBALS['TSFE']->fe_user->user['uid'] . ' AND mess_type=0' . $this->getStoragePIDQuery(), '', 'crdate DESC', '1');
             $lastMessage = $this->databaseHandle->sql_fetch_assoc($res);
             $this->databaseHandle->sql_free_result($res);
             $errormessage = '';
             // Compare with current time and spam block interval
             if ($GLOBALS['EXEC_TIME'] - $conf['block_time'] <= $lastMessage['crdate']) {
                 $error = 1;
                 $errormessage = sprintf($this->pi_getLL('errorBlockinTime'), $conf['block_time']);
             }
             $marker = array();
             // Check if an error has occurred so far. If so, abort.
             if ($error > 0) {
                 $template = $this->cObj->fileResource($conf['template.']['error_message']);
                 $marker['###ERROR###'] = $errormessage;
                 $marker['###BACKLINK###'] = '<a href="javascript:history.back()">' . $this->pi_getLL('back') . '</a>';
             } else {
                 // Retrieve userId from username
                 $res = $this->databaseHandle->exec_SELECTquery('uid,email,tx_mmforum_pmnotifymode,' . $this->getUserNameField(), 'fe_users', 'deleted=0 AND disable=0 AND username='******'fe_users') . ' AND pid=' . $this->conf['userPID']);
                 $recipient = $this->databaseHandle->sql_fetch_assoc($res);
                 $this->databaseHandle->sql_free_result($res);
                 $recipientId = intval($recipient['uid']);
                 // Save and send the private message
                 if ($recipientId > 0) {
                     // Save the private message for the recipient
                     $val = array('pid' => $this->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'cruser_id' => $GLOBALS['TSFE']->fe_user->user['uid'], 'sendtime' => $GLOBALS['EXEC_TIME'], 'from_uid' => $GLOBALS['TSFE']->fe_user->user['uid'], 'from_name' => $GLOBALS['TSFE']->fe_user->user['username'], 'to_uid' => $recipientId, 'to_name' => $to_username, 'subject' => $subject, 'message' => $message);
                     $this->databaseHandle->exec_INSERTquery('tx_mmforum_pminbox', $val);
                     $mess_id = $this->databaseHandle->sql_insert_id();
                     // Save as sent private message
                     $val = array('pid' => $this->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'cruser_id' => $GLOBALS['TSFE']->fe_user->user['uid'], 'sendtime' => $GLOBALS['EXEC_TIME'], 'to_uid' => $GLOBALS['TSFE']->fe_user->user['uid'], 'to_name' => $GLOBALS['TSFE']->fe_user->user['username'], 'from_uid' => $recipientId, 'from_name' => $to_username, 'subject' => $subject, 'message' => $message, 'mess_type' => 1);
                     $this->databaseHandle->exec_INSERTquery('tx_mmforum_pminbox', $val);
                     session_start();
                     unset($_SESSION['mm_forum']['pm']['message']);
                     // Notification to the recipient via email
                     if ($recipient['tx_mmforum_pmnotifymode'] == 0 && GeneralUtility::validEmail($recipient['email'])) {
                         $template = $this->pi_getLL('ntfmail.content');
                         $linkParams[$this->prefixId] = array('messid' => $mess_id, 'action' => 'message_read');
                         if ($this->useRealUrl()) {
                             $linkParams[$this->prefixId]['folder'] = 'inbox';
                         }
                         $msgLink = $this->pi_getPageLink($this->conf['pm_id'], '', $linkParams);
                         $msgLink = $this->tools->escapeBrackets($msgLink);
                         $marker = array('###USERNAME###' => $recipient[$this->getUserNameField()], '###PMLINK###' => $msgLink, '###SITENAME###' => $conf['siteName'], '###MESSAGE###' => $message, '###SUBJECT###' => $this->pi_getLL('messageReplySubjectPrefix') . $subject, '###FROM###' => $GLOBALS['TSFE']->fe_user->user[$this->getUserNameField()], '###LINK##' => $conf['siteName'] . '/' . $msgLink);
                         $mailtext = $this->cObj->substituteMarkerArrayCached($template, $marker);
                         // Compose mail and send
                         $mail = GeneralUtility::makeInstance('t3lib_mail_Message');
                         $mail->setFrom(array($this->conf['mailerEmail'] => $this->conf['siteName']));
                         $mail->setTo(array($recipient['email'] => $recipient['username']));
                         $mail->setSubject($this->pi_getLL('ntfmail.subject'));
                         $mail->setBody($mailtext, 'text/plain');
                         $mail->send();
                         $updateArray = array('notified' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']);
                         $this->databaseHandle->exec_UPDATEquery('tx_mmforum_pminbox', 'uid=' . $mess_id, $updateArray);
                     } elseif ($recipient['tx_mmforum_pmnotifymode'] == 1) {
                         $linkParams[$this->prefixId] = array('action' => 'message_read', 'messid' => $mess_id);
                         $link = $this->pi_getPageLink($this->conf['pm_id'], '', $linkParams);
                         tx_mmforum_tools::storeCacheVar('pm.urlCache.' . $mess_id, $link);
                     }
                     // Redirect user to inbox
                     $link = $this->pi_getPageLink($conf['pm_id']);
                     HttpUtility::redirect($link);
                     // Display an error message in case the recipient does not exist
                 } else {
                     $template = $this->cObj->fileResource($conf['template.']['error_message']);
                     $marker['###ERROR###'] = $this->pi_getLL('errorRecipientNotExists');
                     $marker['###BACKLINK###'] = '<a href="javascript:history.back()">' . $this->pi_getLL('back') . '</a>';
                 }
             }
             // Display message form
         } else {
             $content = $this->top_navi($content, $conf);
             // Load template
             $template = $this->cObj->fileResource($conf['template.']['message_write']);
             $template = $this->cObj->getSubpart($template, '###MESSAGE_WRITE###');
             // Set language-dependent markers
             $marker = array('###LABEL_WRITEMESSAGE###' => $this->pi_getLL('write.writeMessage'), '###LABEL_TO###' => $this->pi_getLL('headerTofromOutbox'), '###LABEL_SUBJECT###' => $this->pi_getLL('headerSubject'), '###LABEL_SEND###' => $this->pi_getLL('write.send'), '###LABEL_RESET###' => $this->pi_getLL('write.reset'), '###LABEL_SEARCH###' => $this->pi_getLL('write.search'), '###EXT_PATH###' => ExtensionManagementUtility::siteRelPath("mm_forum"), '###PID###' => $conf['userPID'], '###LANG###' => $this->pi_getLL('write.search'), '###PM###' => $conf['pm_id'], '###AJAX_URL###' => ExtensionManagementUtility::siteRelPath('mm_forum') . 'pi3/tx_mmforum_usersearch.php', '###JAVASCRIPTUSERSEARCHREFRESH###' => $conf['pm_refreshUserSearch'], '###JAVASCRIPTUSERSEARCHHIDE###' => $conf['pm_hideUserSearch'], '###JAVASCRIPTUSERSEARCH###' => str_replace('###AJAX_URL###', ExtensionManagementUtility::siteRelPath('mm_forum') . 'pi3/tx_mmforum_usersearch.php', $conf['pm_UserSearch']));
             session_start();
             $_SESSION[$this->prefixId]['userPID'] = $this->conf['userPID'];
             $_SESSION[$this->prefixId]['userGID'] = $this->conf['userGroup'];
             $_SESSION[$this->prefixId]['usernameField'] = 'username';
             //$this->getUserNameField();
             // If PM is a reply to another PM, there is a prefix in subject/msg-text
             if ($isReply) {
                 $msgPrefix = $this->pi_getLL('messageReplyTextPrefix');
                 $initialText = $msgPrefix . str_replace("\n", "\n" . $msgPrefix, $originalMsg['message']);
                 $marker['###ACTION###'] = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', array($this->prefixId => array('action' => 'message_write')));
                 $marker['###SUBJECT###'] = $this->pi_getLL('messageReplySubjectPrefix') . $originalMsg['subject'];
                 $marker['###TO_USER###'] = $this->escape($originalMsg['from_name']);
                 $marker['###MESSAGE###'] = $this->escape($initialText);
                 // Create entirely new PM
             } else {
                 $to_userid = $this->piVars['userid'] ? intval($this->piVars['userid']) : intval(GeneralUtility::_GP('userid'));
                 if ($to_userid != 0) {
                     $res = $this->databaseHandle->exec_SELECTquery('username', 'fe_users', 'uid=' . $to_userid);
                     list($username) = $this->databaseHandle->sql_fetch_row($res);
                     $this->databaseHandle->sql_free_result($res);
                 } else {
                     $username = '';
                 }
                 $linkVars = array('action' => 'message_write');
                 $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', array($this->prefixId => $linkVars));
                 $marker['###ACTION###'] = htmlspecialchars($link);
                 $marker['###SUBJECT###'] = '';
                 $marker['###TO_USER###'] = $this->escape($username);
                 $marker['###DATE###'] = '';
                 $marker['###MESSAGE###'] = '';
                 if ($_SESSION['mm_forum']['pm']['message']) {
                     $marker['###MESSAGE###'] = $_SESSION['mm_forum']['pm']['message'];
                 }
             }
         }
     }
     $content .= $this->cObj->substituteMarkerArrayCached($template, (array) $marker);
     return $content;
 }
 /**
  * Substitutes smilie tags like :) or ;) with corresponding <img> tags.
  * The smilie tags and there image equivalents are loaded from database.
  *
  * @author  Björn Detert <*****@*****.**>
  * @version 20. 9. 2006
  * @param   string $text   The text to be parsed
  * @param   object $parent The calling object (regulary of type tx_mmforum_pi1), so this
  *                         object inherits all configuration and language options from the
  *                         calling object.
  * @param   array  $conf   The calling plugin's configuration vars
  * @return  string         The parsed string
  */
 function generate_smilies($text, $parent, $conf)
 {
     $res = $this->databaseHandle->exec_SELECTquery('code,smile_url', 'tx_mmforum_smilies', 'deleted=0', '', 'LENGTH(code) DESC');
     while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
         $uploadPath = 'uploads/tx_mmforum/' . $row['smile_url'];
         if (!file_exists($uploadPath)) {
             if (substr($conf['postparser.']['bb_code_path_smilie'], 0, 4) == 'EXT:') {
                 $smiliepath = tx_mmforum_tools::generateSiteRelExtPath($conf['postparser.']['bb_code_path_smilie'] . $row['smile_url']);
             } else {
                 $smiliepath = $conf['postparser.']['bb_code_path_smilie'] . $row['smile_url'];
             }
         } else {
             $smiliepath = $uploadPath;
         }
         $smilieimage = '<img src="' . $smiliepath . '" alt="' . $row['smile_url'] . '" />';
         #$text 			= 	str_replace(' '.$row['code'].' ',$smilieimage,$text);
         $text = str_replace($row['code'], $smilieimage, $text);
     }
     return $text;
 }
Ejemplo n.º 4
0
 /**
  * Determines the groups a user is in.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-06-06
  * @param   int   $user_id The UID of the user whose groups are to be
  *                         determined.
  * @return  array          An array containing all groups the user is a
  *                         member of.
  */
 function getUserGroupList($user_id)
 {
     if ($user_id == $GLOBALS['TSFE']->fe_user->user['uid']) {
         $groups = $GLOBALS['TSFE']->fe_user->user['usergroup'];
     } else {
         $res = $this->databaseHandle->exec_SELECTquery('usergroup', 'fe_users', 'uid=' . intval($user_id));
         if ($this->databaseHandle->sql_num_rows($res) == 0) {
             return 0;
         } else {
             list($groups) = $this->databaseHandle->sql_fetch_row($res);
         }
     }
     $aGroup = GeneralUtility::intExplode(',', $groups);
     $aGroup = tx_mmforum_tools::processArray_numeric($aGroup);
     return $aGroup;
 }
Ejemplo n.º 5
0
 /**
  * Generates a link to a specific page of a user's post history.
  * @param  string $label  The label of the page link
  * @param  int    $page   The number of the page to be linked to
  * @param  int    $userId The UID of the user whose post history is to be displayed.
  * @return string         A link to the specified page.
  */
 function listpost_pagelink($label, $page, $userId)
 {
     $linkParams[$this->prefixId] = array('action' => 'post_history', 'user_id' => $userId, 'page' => $page);
     if ($this->useRealUrl()) {
         $linkParams[$this->prefixId] = array('action' => 'post_history', 'fid' => tx_mmforum_tools::get_username($userId), 'tid' => $this->pi_getLL('realurl.page') . '_' . $page);
     }
     return '| ' . $this->pi_linkToPage($label, $GLOBALS['TSFE']->id, '', $linkParams) . ' |';
 }
Ejemplo n.º 6
0
 /**
  * Determines if the user that is currently logged in is allowed to create a poll.
  * This function determines if the user that is currently logged
  * in is allowed to create a poll. This checks if polls are enabled in
  * general and if poll creation is limited to certain user groups.
  *
  * @param tx_mmforum_base $pObj
  * @return  boolean TRUE, if the current user may create a post, otherwise false.
  * @version 2007-05-22
  */
 function getMayCreatePoll($pObj)
 {
     if (!$pObj->conf['polls.']['enable']) {
         return false;
     }
     if ($pObj->conf['polls.']['restrictToGroups']) {
         $authPolls = GeneralUtility::intExplode(',', $pObj->conf['polls.']['restrictToGroups']);
         $groups = $GLOBALS['TSFE']->fe_user->groupData['uid'];
         $authPolls = tx_mmforum_tools::processArray_numeric($authPolls);
         $groups = tx_mmforum_tools::processArray_numeric($groups);
         if (count($authPolls) == 0) {
             return true;
         }
         $i = array_intersect($authPolls, $groups);
         return count($i) > 0;
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * @deprecated: use the direct call to the tools method
  */
 function removeLeadingSlash($str)
 {
     return $this->tools->removeLeadingSlash($str);
 }
Ejemplo n.º 8
0
 /**
  * Generates a MySQL-query to determine in which boards the current user may read.
  *
  * @param string $prefix
  * @return string A MySQL-WHERE-query, beginning with "AND", checking which boards the
  *                 user that is currently logged in may read in.
  * @author Martin Helmich <*****@*****.**>
  */
 function getMayRead_forum_query($prefix = '')
 {
     if (strlen($prefix) > 0) {
         $prefix = "{$prefix}.";
     }
     if (!$GLOBALS['TSFE']->fe_user->user) {
         return " AND (" . $prefix . "grouprights_read='')";
     }
     $groups = $GLOBALS['TSFE']->fe_user->groupData['uid'];
     $groups = tx_mmforum_tools::processArray_numeric($groups);
     $queryParts = array();
     foreach ($groups as $group) {
         $queryParts[] = "FIND_IN_SET({$group}," . $prefix . "grouprights_read)";
     }
     $query = implode(' OR ', $queryParts);
     $query = " AND (({$query}) OR " . $prefix . "grouprights_read='') ";
     return $query;
 }
Ejemplo n.º 9
0
 /**
  * Generates an absolute link.
  * This function generates an absolute link from a relative link
  * that is submitted as parameter.
  * For this, the config.baseURL property is used. If this property
  * is not set, the absolute URL will be determined using the
  * $_ENV[HTTP_HOST] variable.
  * This function was introduced due to problems with some realUrl
  * configuration.
  *
  * @param  string $link A relative link
  * @return string       The submitted string converted into an absolute link
  * @author Martin Helmich <*****@*****.**>
  * @deprecated
  */
 static function getAbsoluteUrl($link)
 {
     if (substr($link, 0, 7) == 'http://' || substr($link, 0, 8) == 'https://') {
         return $link;
     }
     if (isset($GLOBALS['TSFE']->config['config']['baseURL'])) {
         $baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
         if (substr($baseUrl, -1, 1) != '/') {
             $baseUrl .= '/';
         }
         $result = $baseUrl;
     } else {
         $useSSL = GeneralUtility::getIndpEnv('SERVER_PORT') == 443;
         $dirname = dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME'));
         // on windows, dirname returns a backslash for the root directory, replace it with a forward slash
         $dirname = $dirname == '\\' ? '/' : $dirname;
         $dirname = tx_mmforum_tools::appendTrailingSlash($dirname);
         $dirname = tx_mmforum_tools::removeLeadingSlash($dirname);
         if ($dirname == '/') {
             $dirname = '';
         }
         $host = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST');
         $host = tx_mmforum_tools::appendTrailingSlash($host);
         if (substr($host, 0, 8) != 'https://' && substr($host, 0, 7) != 'http://') {
             $host = ($useSSL ? 'https' : 'http') . '://' . $host;
         }
         $result = $host . $dirname;
     }
     $link = tx_mmforum_tools::removeLeadingSlash($link);
     return $result . $link;
 }
Ejemplo n.º 10
0
 /**
  * Generates a MySQL-query to determine in which boards the current user may read.
  * @param string $prefix
  * @return string  $prefix A MySQL-WHERE-query, beginning with "AND", checking which boards the
  *                 user that is currently logged in may read in.
  * @author Martin Helmich <*****@*****.**>
  */
 function getMayRead_forum_query($prefix = '')
 {
     $userId = $this->getUserID();
     // First search for query in cache. In case of a hit, just return the result.
     $cacheRes = $this->cache->restore('getMayRead_forum_query_' . $userId . '_' . $prefix);
     if ($cacheRes !== null) {
         return $cacheRes;
     }
     // If the user is an administrator, just return a dummy query.
     if ($this->getIsAdmin()) {
         return ' AND 1 ';
     }
     // If no user is logged in, select only boards where no read access is specified. */
     $dprefix = strlen($prefix) > 0 ? $prefix . '.' : '';
     if (!$GLOBALS['TSFE']->fe_user->user) {
         $this->cache->save('getMayRead_forum_query_' . $userId . '_' . $prefix, $query = ' AND (' . $dprefix . 'grouprights_read=\'\')');
         return $query;
     }
     // Get all groups the current user is a member of.
     $groups = $GLOBALS['TSFE']->fe_user->groupData['uid'];
     $groups = tx_mmforum_tools::processArray_numeric($groups);
     $queryParts = NULL;
     // If the user is not in any group, build a subquery that always returns FALSE.
     if (!is_array($groups) || count($groups) == 0) {
         $queryParts = '1=2';
     } else {
         foreach ($groups as $group) {
             $queryParts[] = 'FIND_IN_SET(' . $group . ', ' . $dprefix . 'grouprights_read)';
         }
     }
     $query = is_array($queryParts) ? implode(' OR ', $queryParts) : $queryParts;
     $query = ' AND ((' . $query . ') OR ' . $dprefix . 'grouprights_read=\'\') ';
     // Store query to cache and return.
     $this->cache->save('getMayRead_forum_query_' . $userId . '_' . $prefix, $query);
     return $query;
 }
Ejemplo n.º 11
0
 /**
  * Generates a custom rootline menu.
  * This function generates a custom rootline menu. This function can be included
  * as special.userfunc in HMENUs in TypoScript in order to merge the mm_forum
  * internal rootline with a global page rootline. On the same time, the property
  * tx_mmforum_pi1.disableRootline should be set to 1.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-07-23
  * @param   string $content The content variable
  * @param   array  $conf    The configuration array
  * @return  array           An array containing a set of HMENU items
  */
 function createRootline($content, $conf)
 {
     $this->menuInit($conf);
     $result = array();
     $action = $this->piVars['action'];
     switch ($action) {
         // List post view, new post form, post alert form
         // Displays a rootline like "mm_forum page -> Category -> Board -> Topic (-> New post/Report post)"
         case 'list_post':
         case 'new_post':
         case 'post_alert':
             $res = $this->databaseHandle->exec_SELECTquery('t.uid, t.forum_id, c.uid, topic_title, f.forum_name, c.forum_name', 'tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 't.uid="' . intval($this->piVars['tid']) . '" AND f.uid=t.forum_id AND c.uid=f.parentID');
             list($topicId, $forumId, $catId, $topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             $topicTitle = stripslashes($topicTitle);
             $topicTitle = str_replace('<', '&lt;', $topicTitle);
             $topicTitle = str_replace('>', '&gt;', $topicTitle);
             if ($action == 'new_post') {
                 $linkParams[$this->prefixId] = array('action' => 'new_post', 'tid' => $topicId, 'fid' => $forumId);
                 $result[] = array('title' => $this->pi_getLL('rootline.reply'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             } elseif ($action == 'post_alert') {
                 $linkParams[$this->prefixId] = array('action' => 'post_alert', 'tid' => $topicId, 'fid' => $forumId);
                 $result[] = array('title' => $this->pi_getLL('rootline.post_alert'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             }
             break;
             // New topic form, topic listing view
             // Displays a rootline like "mm_forum page -> Category -> Board (-> New topic)"
         // New topic form, topic listing view
         // Displays a rootline like "mm_forum page -> Category -> Board (-> New topic)"
         case 'new_topic':
         case 'list_topic':
             $res = $this->databaseHandle->exec_SELECTquery('f.uid,f.forum_name,c.uid,c.forum_name', 'tx_mmforum_forums f, tx_mmforum_forums c', 'f.uid="' . intval($this->piVars['fid']) . '" AND c.uid=f.parentID');
             list($forumId, $forumTitle, $catId, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             if ($action == 'new_topic') {
                 $linkParams[$this->prefixId] = array('action' => 'new_topic', 'fid' => $forumId);
                 $result[] = array('title' => $this->pi_getLL('rootline.new_topic'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             }
             break;
             // Post editing form
             // Displays a rootline like "mm_forum page -> Category -> Board -> Topic -> Edit post"
         // Post editing form
         // Displays a rootline like "mm_forum page -> Category -> Board -> Topic -> Edit post"
         case 'post_edit':
             $res = $this->databaseHandle->exec_SELECTquery('t.uid,t.forum_id,c.uid,topic_title,f.forum_name,c.forum_name', 'tx_mmforum_posts p, tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 'p.uid="' . intval($this->piVars['pid']) . '" AND t.uid=p.topic_id AND f.uid=p.forum_id AND c.uid=f.parentID');
             list($topicId, $forumId, $catId, $topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             $topicTitle = stripslashes($topicTitle);
             $topicTitle = str_replace('<', '&lt;', $topicTitle);
             $topicTitle = str_replace('>', '&gt;', $topicTitle);
             $linkParams[$this->prefixId] = array('action' => 'post_edit', 'fid' => $forumId, 'tid' => $topicId, 'pid' => $this->piVars['pid']);
             $result[] = array('title' => $this->pi_getLL('rootline.edit_post'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             break;
             // User profile
             // Displays a rootline like "mm_forum page -> User profile: Username"
         // User profile
         // Displays a rootline like "mm_forum page -> User profile: Username"
         case 'forum_view_profil':
             if ($this->piVars['fid']) {
                 $user_id = tx_mmforum_tools::get_userid($this->piVars['fid']);
             } else {
                 $user_id = $this->piVars['user_id'];
             }
             $conf['userNameField'] ? $conf['userNameField'] : ($conf['userNameField'] = 'username');
             $res = $this->databaseHandle->exec_SELECTquery($conf['userNameField'], 'fe_users', 'uid="' . intval($user_id) . '"');
             list($username) = $this->databaseHandle->sql_fetch_row($res);
             $linkParams[$this->prefixId] = array('action' => 'forum_view_profil', 'user_id' => $this->piVars['user_id']);
             $result[] = array('title' => sprintf($this->pi_getLL('rootline.userprofile'), $username), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             break;
             // List unread or unanswered topics
             // Displays a rootline like "mm_forum page -> List unread/unanswered topics"
         // List unread or unanswered topics
         // Displays a rootline like "mm_forum page -> List unread/unanswered topics"
         case 'list_unread':
         case 'list_unans':
             $linkParams[$this->prefixId] = array('action' => $action);
             $result[] = array('title' => $this->pi_getLL('rootline.' . $action), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams));
             break;
     }
     if ($topicId) {
         $topicParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $topicId, 'fid' => $forumId);
         $result[] = array('title' => $topicTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $topicParams));
     }
     if ($forumId) {
         $boardParams[$this->prefixId] = array('action' => 'list_topic', 'fid' => $forumId);
         $result[] = array('title' => $forumTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $boardParams));
     }
     if ($catId) {
         $catParams[$this->prefixId] = array('action' => 'list_forum');
         $result[] = array('title' => $catTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id) . '#cat' . $catId);
     }
     $result = array_reverse($result);
     if ($conf['entryLevel']) {
         $pageRootline = array_slice($GLOBALS['TSFE']->config['rootLine'], $conf['entryLevel']);
     } else {
         $pageRootline = $GLOBALS['TSFE']->config['rootLine'];
     }
     if (!$conf['includeNotInMenu']) {
         $pageRootline_final = array();
         foreach ($pageRootline as $pageRootline_element) {
             if ($pageRootline_element['nav_hide'] != 1) {
                 $pageRootline_final[] = $pageRootline_element;
             }
         }
     } else {
         $pageRootline_final = $pageRootline;
     }
     $result = array_merge((array) $pageRootline_final, $result);
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['rootlineArray'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['rootlineArray'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $result = $_procObj->processRootlineArray($result, $this);
         }
     }
     return $result;
 }
 /**
  *
  * Checks if the user that is currently logged in has access to a specific area
  * of the frontend administration module.
  * These ACLs can be configured using the TS property
  * "tx_mmforum_pi1.feAdmin.acl"
  *
  * @param  String $group  The type of element that is edited. This may be either
  *                        "forum" or "category".
  * @param  String $action The action that is to be performed (create, edit,
  *                        remove, order, ...)
  * @return Boolean        TRUE, if the action is allowed, otherwise FALSE.
  */
 function checkActionAllowance($group, $action)
 {
     $aclList = $this->conf['acl.']["{$group}."][$action];
     if ($aclList == 'all') {
         return TRUE;
     }
     if ($aclList == '' || $aclList == 'none') {
         return FALSE;
     }
     $authGroups = array_filter(explode(',', tx_mmforum_tools::getParentUserGroups($aclList)), 'intval');
     $groups = $GLOBALS['TSFE']->fe_user->groupData['uid'];
     return count(array_intersect($authGroups, $groups)) > 0;
 }