Page MenuHomeIn-Portal Phabricator

in-bulletin
No OneTemporary

File Metadata

Created
Thu, Oct 30, 3:38 PM

in-bulletin

Index: branches/5.2.x/units/private_messages/private_message_tp.php
===================================================================
--- branches/5.2.x/units/private_messages/private_message_tp.php (revision 15154)
+++ branches/5.2.x/units/private_messages/private_message_tp.php (revision 15155)
@@ -1,164 +1,164 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PrivateMessageTagProcessor extends kDBTagProcessor {
/**
* Checks if private message is unread
*
* @param Array $params
* @return bool
*/
function IsNew($params)
{
- $object =& $this->getObject();
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return $object->GetDBField('Status') < PM_STATUS_READ;
}
/**
* Allows to check what folder is currently active
*
* @param Array $params
* @return bool
*/
function FolderSelected($params)
{
$folder_mapping = Array ('inbox' => PM_FOLDER_INBOX, 'sent' => PM_FOLDER_SENT);
return (int)$this->Application->GetVar('folder_id') == $folder_mapping[ strtolower($params['folder']) ];
}
/**
* Creates link to specific private message folder
*
* @param Array $params
* @return string
*/
function FolderLink($params)
{
$folder_mapping = Array ('inbox' => PM_FOLDER_INBOX, 'sent' => PM_FOLDER_SENT);
$params['folder_id'] = $folder_mapping[ strtolower($params['folder']) ];
unset($params['folder']);
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function MessageSubject($params)
{
- $object =& $this->getObject();
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$params['field'] = 'Subject';
$value = $this->Field($params);
if (!$value && isset($params['empty_title'])) {
return '['.$this->Application->Phrase($params['empty_title']).']';
}
return $value;
}
function MessageBody($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
// 2. parse post body
$sub_blocks = Array (
'smileys' => $params['smiley_render_as'],
'bbcode' => $params['bbcode_render_as'],
);
return $post_helper->parsePostBody($object->GetDBField('Body'), $object->GetDBField('Options'), $sub_blocks);
}
function DeleteLink($params)
{
$params['pass'] = 'm,'.$this->getPrefixSpecial();
$params[$this->getPrefixSpecial().'_event'] = 'OnDelete';
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function ReplyLink($params)
{
$params['reply_to'] = $this->Application->GetVar($this->getPrefixSpecial().'_id');
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* User can reply message only in case, when it is not it's own message
*
* @param Array $params
* @return bool
*/
function CanReplyMessage($params)
{
- $object =& $this->getObject();
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return $object->GetDBField('FromId') != $this->Application->RecallVar('user_id');
}
/**
* Marks private message as read
*
* @param Array $params
*/
function MarkAsRead($params)
{
- $object =& $this->getObject();
+ $object = $this->getObject($params);
/* @var $object kDBItem */
if ($object->GetDBField('Status') < PM_STATUS_READ) {
$object->SetDBField('Status', PM_STATUS_READ);
$object->Update();
}
}
/**
* Returns link to private message sender/recipient public profile
*
* @param Array $params
* @return string
*/
function ProfileLink($params)
{
$user_field = strtolower($params['type']) == 'from' ? 'FromId' : 'ToId';
unset($params['type']);
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$params['user_id'] = $object->GetDBField($user_field);
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Returns link for sending private message from user's public profile page
*
* @param Array $params
* @return string
*/
function SendMessageLink($params)
{
$params['user_id'] = $this->Application->GetVar('user_id');
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/topics/topics_tag_processor.php
===================================================================
--- branches/5.2.x/units/topics/topics_tag_processor.php (revision 15154)
+++ branches/5.2.x/units/topics/topics_tag_processor.php (revision 15155)
@@ -1,79 +1,79 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class TopicsTagProcessor extends kCatDBTagProcessor {
function TopicLink($params)
{
return $this->ItemLink($params, 'topic');
}
function ListTopics($params)
{
return $this->PrintList2($params);
}
function PostingLink($params)
{
$item_id = getArrayValue($params, 'posting_id');
if (!$item_id) {
$item_id = $this->Application->GetVar($this->Prefix.'_post_id');
}
$params[$this->Prefix.'_post_id'] = $item_id;
return $this->TopicLink($params);
}
function PostingDeleteLink($params)
{
$params['Action'] = 'bb_post_delete';
return $this->PostingLink($params);
}
/**
* Returns topic replies count
*
* @param Array $params
* @return int
*/
function TopicReplies($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
// -1 - don't count post created together with topic
return $object->GetDBField('Posts') ? $object->GetDBField('Posts') - 1 : 0;
}
/**
* Returns topic lock statis
*
* @param Array $params
* @return bool
*/
function IsLocked($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
return $object->GetDBField('TopicType') == 0;
}
function LockToggleLink($params)
{
$params[$this->Prefix.'_event'] = 'OnTopicLockToggle';
$params['pass'] = 'm,'.$this->Prefix;
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/posts/post_tp.php
===================================================================
--- branches/5.2.x/units/posts/post_tp.php (revision 15154)
+++ branches/5.2.x/units/posts/post_tp.php (revision 15155)
@@ -1,311 +1,311 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PostTagProcessor extends kDBTagProcessor {
function ListPosts($params)
{
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
if ($main_object->isLoaded()) {
$main_object->RegisterHit();
}
return $this->PrintList2($params);
}
/**
* Returns link to post author public profile
*
* @param Array $params
* @return string
*/
function ProfileLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$params['user_id'] = $object->GetDBField('CreatedById');
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function PosterField($params)
{
static $posters = null;
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$poster = $this->Application->recallObject('u.poster', null, Array('skip_autoload' => true));
/* @var $poster UsersItem */
if ( !isset($posters) ) {
$poster_ids = array_unique( $object->GetCol('CreatedById') );
$sql = $poster->GetSelectSQL() . '
WHERE ' . $poster->TableName . '.' . $poster->IDField . ' IN (' . implode(',', $poster_ids) . ')';
$posters = $this->Conn->Query($sql, $poster->IDField);
}
$poster_id = $object->GetDBField('CreatedById');
if ($poster_id <= 0) {
// guest and root users
return '';
}
if ($poster->GetID() != $poster_id) {
// previous poster differs from requested
$poster->LoadFromHash( $posters[$poster_id] );
}
return $this->Application->ProcessParsedTag('u.poster', 'Field', $params);
}
/**
* Checks if post is made by real user (not Guest or root)
*
* @param Array $params
* @return bool
*/
function PosterFound($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
return $object->GetDBField('CreatedById') > 0;
}
/**
* Posts count created by current poster
*
* @param Array $params
* @return int
*/
function PosterPostsCount($params)
{
static $posts_count = null;
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if (!isset($posts_count)) {
$poster_ids = array_unique($object->GetCol('CreatedById'));
$sql = 'SELECT VariableValue, PortalUserId
FROM '.TABLE_PREFIX.'UserPersistentSessionData
WHERE PortalUserId IN ('.implode(',', $poster_ids).') AND VariableName = "bb_posts"';
$posts_count = $this->Conn->GetCol($sql, 'PortalUserId');
}
return $posts_count[$object->GetDBField('CreatedById')];
}
function PostSubject($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
return $post_helper->CensorText( $object->GetDBField('Subject') );
}
function PostBody($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$body = $object->GetDBField('PostingText');
// 2. parse post body
$sub_blocks = Array (
'smileys' => $params['smiley_render_as'],
'bbcode' => $params['bbcode_render_as'],
'quote' => $params['quote_render_as'],
);
$body = $post_helper->parsePostBody($body, $object->GetDBField('Options'), $sub_blocks);
return $body;
}
/**
* Checks if poster signature needs to be shown together with post
*
* @param Array $params
* @return bool
*/
function ShowPostSignature($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$post_options = $object->GetDBField('Options');
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
// show poster signature in this post
if ($post_helper->GetPostOption('show_sig', $post_options)) {
// logged-in user wishes to view signatures in posts
$show_other_signatures = $this->Application->RecallPersistentVar('bb_signatures');
if ($show_other_signatures) {
// don't show signature when it is empty
$signature = $this->getUserSignature($object->GetDBField('CreatedById'));
return strlen(trim($signature)) ? true : false;
}
}
return false;
}
/**
* Returns parsed poster (from current post) signature
*
* @param Array $params
* @return string
*/
function PostSignature($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$sub_blocks = Array (
'smileys' => $params['smiley_render_as'],
'bbcode' => $params['bbcode_render_as'],
);
$signature = $this->getUserSignature($object->GetDBField('CreatedById'));
return $post_helper->parsePostBody($signature, $object->GetDBField('Options'), $sub_blocks);
}
/**
* Returns user signature (cached for all viewed posts on page)
*
* @param int $user_id
* @return string
*/
function getUserSignature($user_id)
{
static $user_signatures = null;
- $object =& $this->getObject();
+ $object = $this->getObject();
if (!isset($user_signatures)) {
$poster_ids = array_unique($object->GetCol('CreatedById'));
$sql = 'SELECT VariableValue, PortalUserId
FROM '.TABLE_PREFIX.'UserPersistentSessionData
WHERE PortalUserId IN ('.implode(',', $poster_ids).') AND VariableName = "my_signature"';
$user_signatures = $this->Conn->GetCol($sql, 'PortalUserId');
}
$poster_id = $object->GetDBField('CreatedById');
return isset($user_signatures[$poster_id]) ? $user_signatures[$poster_id] : '';
}
/**
* Creates link to individual post in topic
*
* @param Array $params
* @return string
*/
function PostLink($params)
{
$params['pass'] = 'm,bb,bb-post';
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function ReplyQuotedLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$params['pass'] = 'm,bb';
$params['reply_to'] = $object->GetID();
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function HasPermission($params)
{
static $category_path = null;
if (!isset($category_path)) {
// get topic category
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
$parent_item = $this->Application->recallObject($parent_prefix, null, Array ('raise_warnings' => 0));
$category_path = $parent_item->isLoaded() ? $parent_item->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
}
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$params['raise_warnings'] = 0;
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
// 1. category restriction
$params['cat_id'] = $category_path;
// 2. owner restriction
$is_owner = $object->GetDBField('CreatedById') == $this->Application->RecallVar('user_id');
return $perm_helper->TagPermissionCheck($params, $is_owner);
}
function CategoryItemCount($params)
{
$count_helper = $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
return $count_helper->CategoryItemCount('bb', $params, 'SUM(Posts)'); // - COUNT(TopicId)
}
function ItemCount($params)
{
$count_helper = $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
$today_only = isset($params['today']) && $params['today'];
return $count_helper->ItemCount('bb', $today_only, 'SUM(Posts)'); // - COUNT(TopicId)
}
/**
* Preserve main item id in subitem pagination url
*
* @param Array $params
* @return string
*/
function PageLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var kDBList */
$parent_info = $object->getLinkedInfo();
if ($parent_info['ParentId'] > 0) {
$params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix'];
}
return parent::PageLink($params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/polls/poll_tp.php
===================================================================
--- branches/5.2.x/units/polls/poll_tp.php (revision 15154)
+++ branches/5.2.x/units/polls/poll_tp.php (revision 15155)
@@ -1,119 +1,119 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PollTagProcessor extends kDBTagProcessor {
/**
* Allows to tell if user from current ip has voted already for current poll
*
* @param Array $params
* @return bool
*/
function HasVoted($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
if (!$object->GetDBField('AllowMultipleVotings')) {
$sql = 'SELECT StatisticsId
FROM '.TABLE_PREFIX.'PollsStatistics
WHERE PollId = '.$object->GetID().' AND CreatedById = '.$this->Application->RecallVar('user_id').' AND UserIP = '.$this->Conn->qstr(getenv('REMOTE_ADDR'));
return $this->Conn->GetOne($sql) > 0;
}
return false;
}
/**
* Allows to tell if user from current ip has voted already for current poll
*
* @param Array $params
* @return bool
*/
function HasCommented($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$spam_helper = $this->Application->recallObject('SpamHelper');
/* @var $spam_helper SpamHelper */
$spam_helper->InitHelper($object->GetID(), 'PollComment', 0); // PollId used for SpamControl only
return $spam_helper->InSpamControl();
}
/**
* Prints out only filled in answers of current poll
*
* @param Array $params
* @return string
*/
function PrintPoll($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$sql = 'SELECT COUNT(AnswerNum), AnswerNum
FROM '.TABLE_PREFIX.'PollsStatistics
WHERE PollId = '.$object->GetID().'
GROUP BY AnswerNum';
$statistics = $this->Conn->GetCol($sql, 'AnswerNum');
$total_votes = array_sum($statistics);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
$i = 1;
$ret = '';
while ($i < 8) {
$answer = $object->GetDBField('Answer'.$i);
if ($answer) {
$answer_votes = isset($statistics[$i]) ? $statistics[$i] : 0;
if ($total_votes > 0) {
$block_params['percent'] = round((100 * $answer_votes) / $total_votes, 0);
}
else {
$block_params['percent'] = 0;
}
$block_params['answer'] = $answer;
$block_params['answer_num'] = $i;
$ret .= $this->Application->ParseBlock($block_params);
}
$i++;
}
return $ret;
}
/**
* Prints link to comments of of current poll
*
* @param Array $params
* @return string
*/
function CommentsLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$params['pass'] = 'm,poll';
$params['poll_id'] = $object->GetID();
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
}
\ No newline at end of file

Event Timeline