/**
  * Outputs information about a specific user for the post listing.
  * @param  int    $uid          The UID of the user whose information are to be displayed
  * @param  array  $conf         The configuration vars of the plugin
  * @param  bool   $threadauthor TRUE, if the user is the author of the thread displayed. In
  *                              this case, a special string telling that this user is the author
  *                              of the thread is displayed.
  * @return string               The user information
  */
 function ident_user($uid, $conf, $threadauthor = FALSE)
 {
     $userData = !is_array($uid) ? tx_mmforum_tools::get_userdata($uid) : $uid;
     $template = $this->cObj->fileResource($this->conf['template.']['list_post']);
     $template = $this->cObj->getSubpart($template, '###USERINFO###');
     if ($template) {
         $avatar = $this->getUserAvatar($userData);
         $marker = array('###LLL_DELETED###' => $this->pi_getLL('user-deleted'), '###USERNAME###' => $this->cObj->stdWrap($userData[$this->getUserNameField()], $this->conf['list_posts.']['userinfo.']['username_stdWrap.']), '###USERREALNAME###' => $this->cObj->stdWrap($userData['name'], $this->conf['list_posts.']['userinfo.']['realname_stdWrap.']), '###USERRANKS###' => $this->get_userranking($uid, $conf), '###TOPICCREATOR###' => $uid == $threadauthor ? $this->cObj->stdWrap($this->pi_getLL('topic-topicauthor'), $this->conf['list_posts.']['userinfo.']['creator_stdWrap.']) : '', '###AVATAR###' => $avatar, '###LLL_REGSINCE###' => $this->pi_getLL('user-regSince'), '###LLL_POSTCOUNT###' => $this->pi_getLL('user-posts'), '###REGSINCE###' => $this->cObj->stdWrap($userData['crdate'], $this->conf['list_posts.']['userinfo.']['crdate_stdWrap.']), '###POSTCOUNT###' => intval($userData['tx_mmforum_posts']), '###USER_RATING###' => $this->isUserRating() ? $this->getRatingDisplay('fe_users', $userData['uid']) : '');
         if ($userData === false) {
             $template = $this->cObj->substituteSubpart($template, '###USERINFO_REGULAR###', '');
         } else {
             $template = $this->cObj->substituteSubpart($template, '###USERINFO_DELETED###', '');
         }
         // Include hooks
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'] as $_classRef) {
                 $_procObj =& GeneralUtility::getUserObj($_classRef);
                 $marker = $_procObj->userInformation_marker($marker, $userData, $this);
             }
         }
         $content = $this->cObj->substituteMarkerArray($template, $marker);
     } else {
         if ($userData === false) {
             return '<strong>' . $this->pi_getLL('user.deleted') . '</strong>';
         }
         $content = '<strong>' . $userData[$this->getUserNameField()] . '</strong><br />';
         if ($this->conf['list_posts.']['userinfo_realName'] && $userData['name']) {
             $content .= $this->cObj->wrap($userData['name'], $this->conf['list_posts.']['userinfo_realName_wrap']);
         }
         $userranking = $this->get_userranking($uid, $conf) . '<br />';
         if ($uid == $threadauthor) {
             $userranking .= $this->cObj->wrap($this->pi_getLL('topic.topicauthor'), $this->conf['list_posts.']['userinfo_topicauthor_wrap']);
         }
         $content .= $userranking;
         if ($userData['tx_mmforum_avatar']) {
             $content .= $this->tools->res_img($conf['path_avatar'] . $userData['tx_mmforum_avatar'], $conf['avatar_height'], $conf['avatar_width']);
         }
         $content .= $this->cObj->wrap($this->pi_getLL('user.regSince') . ': ' . date('d.m.Y', $userData['crdate']) . '<br />' . $this->pi_getLL('user.posts') . ': ' . $userData['tx_mmforum_posts'], $this->conf['list_posts.']['userinfo_content_wrap']);
     }
     return $content;
 }
 /**
  * Displays information about a certain user, whose UID is submitted via GP-Vars.
  * @param  string $content The content of the plugin
  * @param  array  $conf    The configuration vars for the plugin
  * @return string          The new content of the plugin
  */
 function view_profil($content, $conf)
 {
     $imgInfo = array('border' => $conf['img_border'], 'alt' => '', 'src' => '', 'style' => '');
     #$user_id = intval($this->piVars['user_id']);
     if ($this->useRealUrl() && $this->piVars['fid']) {
         $user = tx_mmforum_FeUser::getByUsername($this->piVars['fid']);
     } else {
         $user = tx_mmforum_FeUser::getByUID($this->piVars['user_id']);
     }
     $template = $this->cObj->fileResource($conf['template.']['userdetail']);
     $template = $this->cObj->getSubpart($template, "###USERDETAIL###");
     if ($user === null) {
         return $this->errorMessage($conf, $this->pi_getLL('user.error_notExist'));
     }
     // Language-dependent field labels
     $marker = array('###LABEL_ABOUT###' => $this->pi_getLL('user.allAbout'), '###LABEL_REGDATE###' => $this->pi_getLL('user.regDate'), '###LABEL_TOTALPOSTS###' => $this->pi_getLL('user.totalPosts'), '###LABEL_LOCATION###' => $this->pi_getLL('user.location'), '###LABEL_WEBSITE###' => $this->pi_getLL('user.website'), '###LABEL_PROFESSION###' => $this->pi_getLL('user.profession'), '###LABEL_INTERESTS###' => $this->pi_getLL('user.interests'), '###LABEL_CONTACT###' => $this->pi_getLL('user.contact'), '###LABEL_POSTHISTORY###' => $this->pi_getLL('user.posthistory'), '###LABEL_10TOPICS###' => $this->pi_getLL('user.10topics'), '###LABEL_AVATAR###' => $this->pi_getLL('user.avatar'), '###LABEL_USERNAME###' => $this->pi_getLL('user.username'), '###LABEL_FIELD###' => $this->pi_getLL('user.field'), '###LABEL_VALUE###' => $this->pi_getLL('user.value'), '###LABEL_USERPROFILE###' => $this->pi_getLL('user.profile'), '###LABEL_RATING###' => $this->pi_getLL('user.rating'));
     // Username
     $marker['###USER###'] = $this->escape($user->gD($this->getUserNameField()));
     // Date of registration
     $marker['###REGDATE###'] = $this->cObj->stdWrap($user->getCrdate(), $this->conf['user_profile.']['crdate_stdWrap.']);
     // Number of posts
     $marker['###TOTALPOSTS###'] = $user->getPostCount();
     if ($user->getPostCount() >= $this->conf['user_hotposts']) {
         // Special icon for users with more than a certain number posts defined in TypoScript
         $str = $this->cObj->substituteMarker($this->pi_getLL('user.hot'), '###HOTPOSTS###', $this->conf['user_hotposts']);
         $imgInfo['src'] = $this->conf['path_img'] . $this->conf['images.']['5kstar'];
         $imgInfo['alt'] = $str;
         $imgInfo['title'] = $str;
         $marker['###TOTALPOSTS###'] .= $this->buildImageTag($imgInfo);
     }
     // Rating
     if ($this->isUserRating()) {
         $marker['###RATING###'] = $this->getRatingDisplay('fe_users', $user->getUid());
     } else {
         $template = $this->cObj->substituteSubpart($template, '###SUBP_RATING###', '');
     }
     // Avatar
     $marker['###AVATAR###'] = '';
     if ($user->hasAvatar()) {
         $marker['###AVATAR###'] = tx_mmforum_tools::res_img($user->getAvatar($conf['path_avatar']), $conf['avatar_width'], $conf['avatar_height']);
     }
     // E-Mail (currently deactivated)
     $marker['###MAIL###'] = '';
     #'<a href="index.php?id='.$GLOBALS["TSFE"]->id.'&tx_mmforum_pi1[action]=send_mail&tx_mmforum_pi1[uid]='.$row['uid'].'"><img src="'.$conf['path_img'].'mail.gif" border="0"></a>';
     // Private Messaging
     if ($GLOBALS['TSFE']->fe_user->user['username'] && !(isset($conf['pm_enabled']) && intval($conf['pm_enabled']) === 0)) {
         $linkParams['tx_mmforum_pi3'] = array('action' => 'message_write', 'folder' => 'inbox', 'messid' => $this->pi_getLL('realurl.pmnew'), 'userid' => $user->getUID());
         $marker['###PM###'] = $this->createButton('pm', $linkParams, $this->conf['pm_id'], true);
     } else {
         $marker['###PM###'] = '';
     }
     // A link to a page presenting the last 10 posts by this user
     $linkparams = array();
     $linkparams[$this->prefixId] = array('action' => 'post_history', 'user_id' => $user->getUID());
     if ($this->useRealUrl()) {
         unset($linkparams[$this->prefixId]['user_id']);
         $linkparams[$this->prefixId]['fid'] = $user->getUsername();
     }
     $marker['###10POSTS###'] = $this->pi_linkToPage($this->pi_getLL('user.lastPostsLink'), $GLOBALS['TSFE']->id, '', $linkparams) . '<br />';
     // A list of the last 10 topic created by this user
     $marker['###10TOPICS###'] = $this->view_last_10_topics($user->getUID());
     // The number of topics created by this user (currently not used?)
     $res = $this->databaseHandle->exec_SELECTquery('COUNT(uid)', 'tx_mmforum_topics', "topic_poster='{$user->getUID()}'" . $this->getStoragePIDQuery());
     list($topic_num) = $this->databaseHandle->sql_fetch_row($res);
     $marker['###THEMEN###'] = "<strong>" . $topic_num . "</strong>";
     // The last post made by this user (currently not used?)
     $res = $this->databaseHandle->exec_SELECTquery('uid,topic_id', 'tx_mmforum_posts', "deleted='0' AND hidden='0' AND poster_id='{$user->getUID()}'" . $this->getStoragePIDQuery(), '', 'crdate DESC', '1');
     list($lastpost_id, $lastpost_topic_id) = $this->databaseHandle->sql_fetch_row($res);
     $res = $this->databaseHandle->exec_SELECTquery('topic_title', 'tx_mmforum_topics', "uid='{$lastpost_topic_id}'" . $this->getStoragePIDQuery());
     list($lastpost_topic_name) = $this->databaseHandle->sql_fetch_row($res);
     $lastpost_topic_name = str_replace('<', '&lt;', $lastpost_topic_name);
     $lastpost_topic_name = str_replace('>', '&gt;', $lastpost_topic_name);
     // User defined fields
     $userField_template = $this->cObj->getSubpart($template, '###USERFIELDS###');
     $userField_content = '';
     $userField_private = $this->getIsAdmin() || $this->getIsMod() ? '' : ' AND f.public=1';
     /*$res = $this->databaseHandle->exec_SELECTquery(
     			'f.*,c.field_value',
     			'tx_mmforum_userfields f, tx_mmforum_userfields_contents c',
     			'f.hidden=0 AND f.deleted=0 AND c.deleted=0 AND c.field_id=f.uid AND c.user_id='.$user_id.$userField_private,
     			'',
     			'f.sorting DESC'
     		);*/
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields f', 'f.hidden=0 AND f.deleted=0' . $userField_private, '', 'sorting DESC');
     $parser = GeneralUtility::makeInstance('t3lib_TSparser');
     while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
         $cRes = $this->databaseHandle->exec_SELECTquery('field_value', 'tx_mmforum_userfields_contents c', 'c.deleted=0 AND c.field_id=' . $arr['uid'] . ' AND c.user_id=' . $user->getUid());
         if ($this->databaseHandle->sql_num_rows($cRes)) {
             list($fieldContent) = $this->databaseHandle->sql_fetch_row($cRes);
             $arr['field_value'] = $fieldContent;
         } else {
             $fieldContent = '';
         }
         $parser->setup = array();
         if (strlen($arr['config']) > 0) {
             $parser->parse($arr['config']);
             $config = $parser->setup;
         } else {
             $config = array();
         }
         if ($config['label']) {
             $label = $this->cObj->cObjGetSingle($config['label'], $config['label.']);
         } else {
             $label = $arr['label'] . ':';
         }
         if ($config['datasource']) {
             if ($config['datasource'] != 'password') {
                 $fieldContent = $user->gD($config['datasource']);
             } else {
                 $fieldContent = $arr['field_value'];
             }
         } else {
             $fieldContent = $arr['field_value'];
         }
         if ($config['output']) {
             $tmpArr = $this->cObj->data;
             $this->cObj->data = array('fieldvalue' => $fieldContent);
             $output = $this->cObj->cObjGetSingle($config['output'], $config['output.']);
             $this->cObj->data = $tmpArr;
         } else {
             $output = $this->escape($fieldContent);
         }
         $userField_marker = array('###LABEL_USERFIELD###' => $label, '###USERFIELD###' => $output, '###USERFIELD_VALUE###' => $fieldContent, '###USERFIELD_UID###' => $this->escape($arr['uid']), '###USERFIELD_LABEL###' => $this->escape($arr['label']), '###USERFIELD_NAME###' => '');
         $userField_content .= $this->cObj->substituteMarkerArrayCached($userField_template, $userField_marker);
     }
     $template = $this->cObj->substituteSubpart($template, '###USERFIELDS###', $userField_content);
     $marker['###ROWSPAN###'] = 15 + $this->databaseHandle->sql_num_rows($res);
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userProfile_marker'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userProfile_marker'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->userProfile_marker($marker, $user->data, $this);
         }
     }
     $content .= $this->cObj->substituteMarkerArrayCached($template, $marker);
     return $content;
 }