/**
  * 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;
 }
Example #2
0
 /**
  * The plugin main function. Generates all content.
  * @param  string $content The content
  * @param  array  $conf    The plugin configuration vars
  * @return string          The plugin content
  */
 function main($content, $conf)
 {
     /* Initialize base object */
     $this->init($conf);
     $this->pi_USER_INT_obj = $this->conf['cache'] ? 0 : 1;
     $this->config['code'] = $this->cObj->stdWrap($this->conf['code'], $this->conf['code.']);
     $this->tx_mmforum_postfunctions = GeneralUtility::makeInstance('tx_mmforum_postfunctions', $conf, $this->cObj);
     /* Evaluate flexform values */
     $this->evalConfigValues();
     /* Store a reference to the global configuration array */
     $conf =& $this->conf;
     /* Load template file */
     $this->templateFile = $conf['templateFile'];
     /* Load plugin code */
     $codes = GeneralUtility::trimExplode(',', $this->config['code'] ? $this->config['code'] : $this->conf['defaultCode'], 1);
     if (!count($codes)) {
         $codes = array('');
     }
     /* Include RSS feed to header */
     $this->tx_mmforum_rss->setHTMLHeadData('all');
     /* Change page title */
     if ($this->conf['substitutePagetitle']) {
         $this->createPageTitle();
     }
     foreach ($codes as $theCode) {
         list($theCode, $cat, $aFlag) = explode('/', $theCode);
         $theCode = (string) strtoupper(trim($theCode));
         $this->theCode = $theCode;
         switch ($theCode) {
             case 'HAVEALOOK':
                 $content = $this->tx_mmforum_havealook->edit($this);
                 break;
             case 'FAVORITES':
                 $content = $this->favorites($content, $conf);
                 break;
             case 'POSTALERTLIST':
                 $content = $this->tx_mmforum_postalert->list_alerts($conf);
                 break;
             case 'LIST_POSTS':
                 $content = $this->post_history($conf);
                 break;
             case 'LATEST':
                 $content = $this->list_latest($conf);
                 break;
             case 'USERLIST':
                 $content = $this->list_users();
                 break;
             case 'POSTQUEUE':
                 $content = $this->list_postqueue();
                 break;
             case 'RSS':
                 $content = $this->list_rss();
                 break;
             case 'FEADMIN':
                 $content = $this->frontendAdministration();
                 break;
             default:
                 // Include hook to add own content and do change the action to direct it differently
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['preDispatchHook'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['preDispatchHook'] as $_classRef) {
                         $_params = array('content' => &$content, 'conf' => &$conf);
                         $_procObj =& GeneralUtility::getUserObj($_classRef);
                         $_procObj->preDispatchHook($_params, $this);
                     }
                 }
                 if ($this->redirectTo) {
                     HttpUtility::redirect($this->redirectTo);
                 }
                 switch ($this->piVars['action']) {
                     case 'list_unread':
                         $content = $this->list_unread($content, $conf);
                         break;
                     case 'list_unans':
                         $content = $this->list_unanswered($content, $conf);
                         break;
                     case 'list_cat':
                         $content = $this->list_category($content, $conf);
                         break;
                     case 'list_topic':
                         $content = $this->list_topic($content, $conf);
                         break;
                     case 'list_post':
                         $content = $this->tx_mmforum_postfunctions->list_post($content, $conf, '');
                         break;
                     case 'new_topic':
                         $content = $this->new_topic($content, $conf);
                         break;
                     case 'new_post':
                         $content = $this->new_post($content, $conf);
                         break;
                     case 'send_mail':
                         /** @noinspection PhpDeprecationInspection */
                         $content = $this->send_mail($content, $conf);
                         break;
                     case 'forum_view_profil':
                     case 'view_profile':
                         $content = $this->view_profil($content, $conf);
                         break;
                     case 'post_del':
                         $content = $this->tx_mmforum_postfunctions->post_del($content, $conf);
                         break;
                     case 'post_edit':
                         $content = $this->post_edit($content, $conf);
                         break;
                     case 'change_userdata':
                         $content = $this->change_userdata($content, $conf);
                         break;
                     case 'reset_read':
                         $content = $this->reset_unreadpost($content, $conf);
                         break;
                     case 'set_havealook':
                         $content = $this->tx_mmforum_havealook->set($this);
                         break;
                     case 'del_havealook':
                         $content = $this->tx_mmforum_havealook->delete($this);
                         break;
                     case 'set_havealookforum':
                         $content = tx_mmforum_havealookforum::set($this);
                         break;
                     case 'del_havealookforum':
                         $content = tx_mmforum_havealookforum::delete($this);
                         break;
                     case 'set_favorite':
                         $content = $this->set_favorite();
                         break;
                     case 'del_favorite':
                         $content = $this->del_favorite();
                         break;
                     case 'open_topic':
                         $this->open_topic($content, $conf);
                         break;
                     case 'post_alert':
                         $content = $this->tx_mmforum_postalert->post_alert($conf);
                         break;
                     case 'list_prefix':
                         $content = $this->list_prefix($content, $conf, $this->piVars['list_prefix']['prfx']);
                         break;
                     case 'post_history':
                         $content = $this->post_history($conf);
                         break;
                     case 'get_attachment':
                         $content = $this->getAttachment($conf);
                         break;
                     default:
                         if (empty($content)) {
                             $content = $this->list_forum($content, $conf);
                         }
                         break;
                 }
                 if ($this->piVars['solve']) {
                     $content = $this->topic_solve();
                 }
                 if ($this->piVars['unsolve']) {
                     $content = $this->topic_unsolve();
                 }
                 $content = $this->page_header($conf) . $content;
                 break;
         }
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['mainContentHook'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['mainContentHook'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $content = $_procObj->mainContentHook($content, $this);
         }
     }
     $content .= $this->page_footer($conf);
     return $this->pi_wrapInBaseClass($content);
 }