Esempio n. 1
0
 /**
  * Generates an error message.
  * @author Martin Helmich <*****@*****.**>
  * @param  array $conf The plugin's configuration vars
  * @param  string $message The error message
  * @return string       The HTML error message
  */
 function errorMessage($conf, $message)
 {
     $templateFile = $this->cObj->fileResource($conf['template.']['login_error']);
     $template = $this->cObj->getSubpart($templateFile, '###LOGINERROR###');
     $marker = '';
     if (is_array($message)) {
         foreach ($message as $singleMessage) {
             $marker .= $this->cObj->stdWrap($singleMessage, $conf['errorMessage.']);
         }
     } else {
         $marker = $this->cObj->stdWrap($message, $conf['errorMessage.']);
     }
     return $this->cObj->substituteMarker($template, '###LOGINERROR_MESSAGE###', $marker);
 }
Esempio n. 2
0
 /**
  * The plugin's main function
  * @author Martin Helmich <*****@*****.**>
  *
  * @param  string $content The content
  * @param  array  $conf    The plugin's configuration vars
  * @return string          The plugin content
  *
  * @uses getConfig
  * @uses setHeaders
  * @uses display
  */
 function main($content, $conf)
 {
     $time = $this->microtime_float();
     $this->init($conf);
     // Configuring so caching is not expected. This value means that no cHash params are ever set.
     // We do this, because it's a USER_INT object!
     $this->pi_USER_INT_obj = 1;
     $this->getConfig();
     $this->small = $this->piVars['ext'] ? !$this->piVars['ext'] : TRUE;
     $content = $this->display($content);
     $time = $this->microtime_float() - $time;
     if ($this->conf['debug']) {
         $content .= $this->cObj->substituteMarker($this->pi_getLL('debug'), '###EXECUTIONTIME###', round($time, 4));
     }
     return $this->pi_wrapInBaseClass($content);
 }
Esempio n. 3
0
 /**
  * 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;
 }