/**
  * Displays a list of a user's email subscriptions.
  * Performs also actions like editing or deleting subscriptions.
  * @param \tx_mmforum_base $forumObj
  * @return string
  */
 static function edit(\tx_mmforum_base $forumObj)
 {
     $content = '';
     $feUserId = intval($GLOBALS['TSFE']->fe_user->user['uid']);
     // can be
     //    "topic" - only topic subscriptions
     //    "forum" - only forum subscriptions
     //    "all"    - both of them (default)
     $displayMode = 'all';
     if ($forumObj->conf['havealook.']['displayOnlyTopics']) {
         $displayMode = 'topic';
     }
     if (isset($forumObj->piVars['displayMode'])) {
         $displayMode = $forumObj->piVars['displayMode'];
     }
     if ($feUserId) {
         // Delete a single subscription (through the link at every subscription)
         if ($forumObj->piVars['deltid']) {
             $deleleTopicId = intval($forumObj->piVars['deltid']);
             if ($forumObj->piVars['delmode'] == 'topic') {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery());
             } else {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery());
             }
             unset($forumObj->piVars['deltid']);
         }
         // Delete several subscriptions (through the checkboxes)
         if ($forumObj->piVars['havealook_action'] == 'delete') {
             foreach ((array) $forumObj->piVars['fav_delete']['topic'] as $deleleTopicId) {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery());
             }
             foreach ((array) $forumObj->piVars['fav_delete']['forum'] as $deleleTopicId) {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery());
             }
             unset($forumObj->piVars['havealook_action']);
         }
         // Determination of sorting mode
         $orderBy = $forumObj->piVars['order'] ? $forumObj->piVars['order'] : 'added';
         // rendering the settings
         $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['havealook']);
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_SETTINGS###');
         $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###ORDER_LPDATE###' => $orderBy == 'lpdate' ? 'selected="selected"' : '', '###ORDER_CAT###' => $orderBy == 'cat' ? 'selected="selected"' : '', '###ORDER_ADDED###' => $orderBy == 'added' ? 'selected="selected"' : '', '###ORDER_ALPHAB###' => $orderBy == 'alphab' ? 'selected="selected"' : '', '###LABEL_ORDERBY###' => $forumObj->pi_getLL('favorites.orderBy'), '###LABEL_ORDER_LPDATE###' => $forumObj->pi_getLL('favorites.orderBy.lpdate'), '###LABEL_ORDER_CAT###' => $forumObj->pi_getLL('favorites.orderBy.cat'), '###LABEL_ORDER_ADDED###' => $forumObj->pi_getLL('favorites.orderBy.added'), '###LABEL_ORDER_ALPHAB###' => $forumObj->pi_getLL('favorites.orderBy.alphab'));
         // Include hook to modify the output of the settings
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'] as $_classRef) {
                 $_procObj =& GeneralUtility::getUserObj($_classRef);
                 $marker = $_procObj->havealook_listsettings($marker, $forumObj);
             }
         }
         $content = $forumObj->cObj->substituteMarkerArray($template, $marker);
         // rendering the head part
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_BEGIN###');
         $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###LABEL_HAVEALOOK###' => $forumObj->pi_getLL('havealook.title'), '###LABEL_OPTIONS###' => $forumObj->pi_getLL('favorites.options'), '###LABEL_TOPICNAME###' => $forumObj->pi_getLL('topic.title'), '###LABEL_CONFIRMMULTIPLE###' => $forumObj->pi_getLL('havealook.confirmMultiple'));
         $content .= $forumObj->cObj->substituteMarkerArray($template, $marker);
         switch ($orderBy) {
             case 'lpdate':
                 $order = 'item_lastpost_uid DESC';
                 break;
             case 'cat':
                 $order = 'cat_order ASC, forum_order ASC, item_lastpost_uid DESC';
                 break;
             case 'added':
                 $order = 'mail_uid DESC';
                 break;
             case 'alphab':
             default:
                 $order = 'item_title ASC';
                 break;
         }
         $sqlTopic = 'SELECT' . '	t.topic_title			AS item_title,' . '	t.uid					AS item_uid,' . '	t.topic_last_post_id	AS item_lastpost_uid,' . '	t.solved				AS item_solved,' . '	t.topic_is				AS item_prefix,' . '	m.uid 					AS mail_uid,' . '	f.forum_name			AS forum_title,' . '	f.uid					AS forum_uid,' . '	f.forum_last_post_id	AS forum_lastpost_id,' . '	f.sorting 				AS forum_order,' . '	c.forum_name			AS cat_title,' . '	c.uid					AS cat_uid,' . '	c.sorting 				AS cat_order,' . '	"topic" 				AS notify_mode ' . 'FROM' . '	tx_mmforum_topicmail m' . '	LEFT JOIN tx_mmforum_topics t ON m.topic_id = t.uid ' . '	LEFT JOIN tx_mmforum_forums f ON t.forum_id = f.uid ' . '	LEFT JOIN tx_mmforum_forums c ON f.parentID = c.uid ' . 'WHERE' . '	m.user_id = ' . $feUserId . ' AND ' . '	m.deleted = 0 AND' . '	t.deleted = 0 AND' . '	f.deleted = 0 AND' . '	c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c');
         $sqlForum = 'SELECT' . '	f.forum_name			AS item_title,' . '	f.uid					AS item_uid,' . '	f.forum_last_post_id	AS item_lastpost_uid,' . '	0						AS item_solved,' . '	""						AS item_prefix,' . '	m.uid					AS mail_uid,' . '	f.forum_name			AS forum_title,' . '	f.uid					AS forum_uid,' . '	f.forum_last_post_id	AS forum_lastpost_uid,' . '	f.sorting				AS forum_order,' . '	c.forum_name			AS cat_title,' . '	c.uid					AS cat_uid,' . '	c.sorting				AS cat_order,' . '	"forum"					AS notify_mode ' . 'FROM' . '	tx_mmforum_forummail m' . '	LEFT JOIN tx_mmforum_forums f ON m.forum_id = f.uid ' . '	LEFT JOIN tx_mmforum_forums c ON (f.parentID = c.uid OR (f.parentID = 0 AND f.uid = c.uid)) ' . 'WHERE' . '	m.user_id = ' . $feUserId . ' AND ' . '	m.deleted = 0 AND ' . '	f.deleted = 0 AND ' . '	c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c');
         if ($displayMode == 'topic') {
             $sql = $sqlTopic;
         } else {
             if ($displayMode == 'forum') {
                 $sql = $sqlForum;
             } else {
                 $sql = '(' . $sqlTopic . ') UNION (' . $sqlForum . ')';
             }
         }
         $sql .= 'ORDER BY ' . $order;
         $res = $this->databaseHandle->sql_query($sql);
         if ($this->databaseHandle->sql_num_rows($res) == 0) {
             $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK_EMPTY###');
             $content .= $forumObj->cObj->substituteMarker($template, '###LLL_HAVEALOOK_EMPTY###', $forumObj->pi_getLL('havealook.empty'));
         } else {
             $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK###');
             // go through every found subscription
             while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
                 if ($row['notify_mode'] == 'topic') {
                     $linkParams[$forumObj->prefixId] = array('action' => 'list_post', 'tid' => $row['item_uid']);
                     $marker['###TOPICICON###'] = $forumObj->getTopicIcon($row['item_uid']);
                 } else {
                     $linkParams[$forumObj->prefixId] = array('action' => 'list_prefix', 'fid' => $row['item_uid']);
                     $marker['###TOPICICON###'] = $forumObj->getForumIcon($row['item_uid']);
                 }
                 $imgInfo = array('src' => $forumObj->conf['path_img'] . $forumObj->conf['images.']['solved'], 'alt' => $forumObj->pi_getLL('topic.isSolved'));
                 $marker['###SOLVED###'] = $row['item_solved'] == 1 ? $forumObj->buildImageTag($imgInfo) : '';
                 $marker['###PREFIX###'] = $row['item_prefix'] ? $forumObj->cObj->wrap($row['item_prefix'], $forumObj->conf['list_topics.']['prefix_wrap']) : '';
                 $marker['###NAME###'] = $forumObj->pi_linkToPage($forumObj->escape($row['item_title']), $forumObj->conf['pid_forum'], '', $linkParams);
                 $marker['###FORUMNAME###'] = $forumObj->escape($row['forum_title']);
                 $marker['###CATEGORY###'] = $forumObj->escape($row['cat_title']);
                 $marker['###TOPICNAME###'] = $marker['###PREFIX###'] . $marker['###NAME###'] . $marker['###SOLVED###'];
                 $marker['###TOPICSUB###'] = $marker['###CATEGORY###'] . ' / ' . $marker['###FORUMNAME###'] . ($row['notify_mode'] == 'topic' ? ' / ' . $forumObj->escape($row['item_title']) : '');
                 $marker['###TOPIC_CHECKBOX###'] = '<input type="checkbox" name="tx_mmforum_pi1[fav_delete][' . $row['notify_mode'] . '][]" value="' . $row['item_uid'] . '" />';
                 $linkParams[$forumObj->prefixId] = array('action' => 'havealook', 'deltid' => $row['item_uid'], 'delmode' => $row['notify_mode']);
                 $marker['###DELETELINK###'] = $marker['###TOPICDELLINK###'] = $forumObj->pi_linkTP($forumObj->pi_getLL('havealook.delete'), $linkParams);
                 // Include hook to modify the output of each item
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'] as $_classRef) {
                         $_procObj =& GeneralUtility::getUserObj($_classRef);
                         $marker = $_procObj->havealook_listitem($marker, $row, $forumObj);
                     }
                 }
                 $content .= $forumObj->cObj->substituteMarkerArrayCached($template, $marker);
             }
         }
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_END###');
         $marker = array('###LABEL_MARKEDTOPICS###' => $forumObj->pi_getLL('havealook.markedTopics'), '###LABEL_DELETE###' => $forumObj->pi_getLL('havealook.delete'), '###LABEL_GO###' => $forumObj->pi_getLL('havealook.go'));
     } else {
         $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['login_error']);
         $template = $forumObj->cObj->getSubpart($templateFile, '###LOGINERROR###');
         $marker = array('###LOGINERROR_MESSAGE###' => $forumObj->pi_getLL('subscr.noLogin'));
     }
     // Include hook to modify the output of the whole thing
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->havealook_edit($marker, $forumObj);
         }
     }
     $content .= $forumObj->cObj->substituteMarkerArray($template, $marker);
     return $content;
 }