Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

@@ -2,18 +2,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Ajax Functions For Topics
* Last Updated: $Date: 2010-10-20 09:03:17 -0400 (Wed, 20 Oct 2010) $
* Last Updated: $Date: 2011-09-26 10:20:55 -0400 (Mon, 26 Sep 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @version $Revision: 7003 $
* @link http://hatynka.in
* @version $Revision: 9547 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -28,10 +28,17 @@ class public_forums_ajax_topics extends ipsAjaxCommand
* Class entry point
*
* @param object Registry reference
* @return void [Outputs for the ajax handler]
* @return @e void [Outputs for the ajax handler]
*/
public function doExecute( ipsRegistry $registry )
{
/* Load topic class */
if ( ! $this->registry->isClassLoaded('topics') )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
$this->registry->setClass( 'topics', new $classToLoad( $this->registry ) );
}
$this->lang->loadLanguageFile( array( 'public_topic', 'public_mod' ), 'forums' );
//-----------------------------------------
@@ -52,10 +59,6 @@ class public_forums_ajax_topics extends ipsAjaxCommand
case 'saveTopicTitle':
$this->saveTopicTitle();
break;
case 'saveTopicDescription':
$this->saveTopicDescription();
break;
case 'rateTopic':
$this->rateTopic();
@@ -68,68 +71,574 @@ class public_forums_ajax_topics extends ipsAjaxCommand
case 'preview':
$this->_topicPreview();
break;
case 'reply':
$this->_reply();
break;
case 'reputation':
$this->reputation();
case 'quote':
case 'mqquote':
$this->_quote();
break;
case 'pollForReplies':
$this->_pollForReplies();
break;
case 'getNewPosts':
$this->_getNewPosts();
break;
case 'markRead':
$this->_markRead();
break;
case 'sigCloseMenu':
$this->_sigCloseMenu();
break;
case 'ignoreSig':
$this->_ignoreSig();
break;
}
}
/**
* Displays reputation popup
*
* @return void
*/
protected function reputation()
protected function _ignoreSig()
{
if ( !$this->memberData['gbw_view_reps'] )
$memberId = trim( $this->request['memberId'] );
$memberId = ( is_numeric( $memberId ) ) ? $memberId : 'all';
/* Whut */
if ( $memberId == 'all' )
{
$this->returnJsonError('no_permission');
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'view_sigs' => 0 ) ) );
}
else
{
/* Insert or update? */
$ignored = IPSMember::fetchIgnoredUsers( $this->memberData );
if ( ! empty( $ignored[ $memberId ] ) )
{
/* Update */
$this->DB->update( 'ignored_users', array( 'ignore_signatures' => 1 ), 'ignore_owner_id=' . $this->memberData['member_id'] . ' AND ignore_ignore_id=' . $memberId );
}
else
{
$this->DB->insert( 'ignored_users', array( 'ignore_owner_id' => $this->memberData['member_id'],
'ignore_ignore_id' => $memberId,
'ignore_messages' => 0,
'ignore_topics' => 0,
'ignore_signatures' => 1 ) );
}
/* Rebuild cache */
IPSMember::rebuildIgnoredUsersCache( $this->memberData );
}
$this->returnJsonArray( array( 'status' => 'ok' ) );
}
$postID = intval( $this->request['post'] );
protected function _sigCloseMenu()
{
$pid = intval( $this->request['pid'] );
/* Get data */
$reps = array();
$this->DB->build( array(
'select' => 'member_id, rep_rating',
'from' => 'reputation_index',
'where' => "app='forums' AND type='pid' AND type_id='{$postID}'",
'order' => 'rep_date',
) );
$q = $this->DB->execute();
while ( $r = $this->DB->fetch( $q ) )
/* Fetch post */
$post = $this->registry->getClass('topics')->getPostById( $pid );
$this->registry->getClass('topics')->setTopicData( $post );
if ( $this->registry->getClass('topics')->canView() )
{
$r['member'] = IPSMember::load( $r['member_id'] );
$reps[] = $r;
return $this->returnHtml( $this->registry->output->getTemplate('topic')->ajaxSigCloseMenu( $post ) );
}
else
{
$this->returnJsonError( 'nopermission' );
}
}
protected function _markRead()
{
$tid = intval( $this->request['tid'] );
return $this->returnHtml( $this->registry->output->getTemplate('topic')->reputationPopup( $reps ) );
/* Get latest post */
$post = $this->registry->getClass('topics')->getPosts( array( 'topicId' => $tid, 'sortField' => 'pid', 'sortOrder' => 'desc', 'offset' => 0, 'limit' => 1 ) );
$post = array_pop( $post );
$forum = $this->registry->class_forums->getForumById( $post['forum_id'] );
$this->registry->getClass('classItemMarking')->markRead( array( 'forumID' => $post['forum_id'], 'itemID' => $tid, 'markDate' => $post['post_date'], 'containerLastActivityDate' => $forum['last_post'] ) );
$this->returnJsonArray( array( 'status' => 'ok' ) );
}
/**
* Polls for replies innit
*/
protected function _pollForReplies()
{
$topicId = intval( $this->request['t'] );
$topPid = intval( $this->request['pid'] );
/* Can we view this topic? */
$this->registry->getClass('topics')->setTopicData( $topicId );
/* Can we view? */
if ( $this->registry->getClass('topics')->canView() !== true )
{
$this->returnJsonArray( array( 'count' => 0 ) );
}
/* Get posts */
$posts = $this->_getPosts( $topicId, $topPid, $this->registry->getClass('topics')->getTopicData('forum_id') );
/* Got anything sailor? */
if ( ! count( $posts ) )
{
$this->returnJsonArray( array( 'count' => 0 ) );
}
else
{
$this->returnJsonArray( array( 'count' => count( $posts ), 'data' => $posts ) );
}
}
/**
* Fetches the new posts to insert into the live page ...
*/
protected function _getNewPosts()
{
$topicId = intval( $this->request['t'] );
$topPid = intval( $this->request['pid'] );
/* Can we view this topic? */
$this->registry->getClass('topics')->setTopicData( $topicId );
/* Can we view? */
if ( $this->registry->getClass('topics')->canView() !== true )
{
$this->returnHtml( '' );
}
/* Get posts */
$posts = $this->_getPosts( $topicId, $topPid, $this->registry->getClass('topics')->getTopicData('forum_id') );
/* Got anything sailor? */
if ( ! count( $posts ) )
{
$this->returnHtml( '' );
}
else
{
$html = '';
foreach( $posts as $pid => $data )
{
$html .= $this->registry->output->getTemplate('topic')->post( $data, array(), $this->registry->getClass('topics')->getTopicData() );
}
$this->returnHtml( $html );
}
}
/**
* Fetches posts
* @param INT Topic ID
* @param INT Top PID
* @param INT Forum ID
*/
protected function _getPosts( $topicId, $topPid, $forumId )
{
IPSDebug::fireBug( 'info', array( 'Retrieving posts for topic id ' . $topicId . ' where pid is greater than ' . $topPid ) );
/* Reset viewing member id - can be set to someone else by post class (e.g. in the sendOutQuoteNotifications() method) */
$this->registry->getClass('topics')->setMemberData( $this->memberData );
/* Get posts */
$posts = $this->registry->getClass('topics')->getPosts( array( 'topicId' => $topicId,
'pidIsGreater' => $topPid,
'onlyViewable' => true,
'onlyVisible' => true,
'parse' => true,
'forumId' => $forumId,
'limit' => 50,
'sortKey' => 'date',
'sortOrder' => 'asc' ) );
if ( count( $posts ) )
{
/* Fetch post count ID */
$this->registry->getClass('topics')->getPosts( array( 'topicId' => $topicId,
'pidIsLess' => $topPid,
'onlyViewable' => true,
'onlyVisible' => true,
'parse' => false,
'getCount' => true,
'forumId' => $forumId,
'limit' => 50,
'sortKey' => 'date',
'sortOrder' => 'asc' ) );
$count = $this->registry->getClass('topics')->getPostsCount();
$count++;
foreach( $posts as $id => $data )
{
$posts[ $id ]['post']['post_count'] = ++$count;
}
}
/* Parse attachments */
$topic = $this->registry->getClass('topics')->getTopicData();
if( $topic['topic_hasattach'] )
{
//-----------------------------------------
// INIT. Yes it is
//-----------------------------------------
$postHTML = array();
//-----------------------------------------
// Separate out post content
//-----------------------------------------
foreach( $posts as $id => $post )
{
$postHTML[ $id ] = $post['post']['post'];
}
//-----------------------------------------
// Grab render attach class
//-----------------------------------------
if ( ! is_object( $this->class_attach ) )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$this->class_attach = new $classToLoad( $this->registry );
}
//-----------------------------------------
// Not got permission to view downloads?
//-----------------------------------------
if ( $this->registry->permissions->check( 'download', $this->registry->class_forums->forum_by_id[ $topic['forum_id'] ] ) === FALSE )
{
$this->settings['show_img_upload'] = 0;
}
//-----------------------------------------
// Continue...
//-----------------------------------------
$this->class_attach->type = 'post';
$this->class_attach->init();
$attachHTML = $this->class_attach->renderAttachments( $postHTML, array_keys( $posts ) );
/* Now parse back in the rendered posts */
if( is_array($attachHTML) AND count($attachHTML) )
{
foreach( $attachHTML as $id => $data )
{
/* Get rid of any lingering attachment tags */
if ( stristr( $data['html'], "[attachment=" ) )
{
$data['html'] = IPSText::stripAttachTag( $data['html'] );
}
$posts[ $id ]['post']['post'] = $data['html'];
$posts[ $id ]['post']['attachmentHtml'] = $data['attachmentHtml'];
}
}
}
return $posts;
}
/**
* Fetches data to quote
*
* @return @e void
*/
protected function _quote()
{
/* Init */
$tid = intval( $this->request['t'] );
$pid = intval( $this->request['p'] );
$pids = explode( ',', IPSText::cleanPermString( $this->request['pids'] ) );
$posts = array();
$_post = '';
/* Load editor stuff */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$this->editor = new $classToLoad();
/* Set up topic */
if( $pid )
{
$posts[] = $this->registry->getClass('topics')->getPostById( $pid );
}
else
{
foreach( $pids as $pid )
{
$posts[] = $this->registry->getClass('topics')->getPostById( $pid );
}
}
/* Permission ids */
$perm_id = $this->memberData['org_perm_id'] ? $this->memberData['org_perm_id'] : $this->memberData['g_perm_id'];
$perm_array = explode( ",", $perm_id );
/* Naughty boy chex */
foreach( $posts as $post )
{
/* Set up data */
$this->registry->getClass('topics')->setTopicData( $post );
if ( $this->registry->getClass('topics')->canView() !== true )
{
$this->returnJsonError( 'nopermission' );
}
if ( $this->registry->permissions->check( 'read', $this->registry->class_forums->getForumById( $post['forum_id'] ), $perm_array ) !== TRUE )
{
$this->returnJsonError( 'nopermission' );
}
/* Post visible? */
if ( $this->registry->getClass('class_forums')->fetchHiddenType( $post ) != 'visible' )
{
$this->returnJsonError( 'nopermission' );
}
/* Phew that was a toughy wasn't it? */
if ( $this->settings['strip_quotes'] )
{
$post['post'] = IPSText::getTextClass( 'bbcode' )->stripQuotes( $post['post'] );
}
/* Strip shared media in quotes */
$post['post'] = IPSText::getTextClass( 'bbcode' )->stripSharedMedia( $post['post'] );
/* We don't use makeQuoteSafe() here because the result is returned via AJAX and inserted as text into the editor. + shows as &#043; as a result if we do */
$_quoted = preg_replace( '/(<br\s*\/?>\s*)+$/', "<br />", "<br />" . rtrim($post['post']) . "<br />" );
$_post .= "[quote name='" . ( $post['members_display_name'] ? $post['members_display_name'] : $post['author_name'] ) . "' timestamp='" . $post['post_date'] . "' post='" . $post['pid'] . "']{$_quoted}[/quote]<br />";
}
$this->editor->setContent( $_post, 'topics' );
$this->returnHtml( $this->editor->getContent() );
}
/**
* Saves the post
*
* @return @e void
*/
protected function _reply()
{
/* Init */
$fid = intval( $this->request['f'] );
$tid = intval( $this->request['t'] );
$topPid = intval( $this->request['pid'] );
/* Basic checks */
if ( ! $tid )
{
$this->returnJsonError( $this->lang->words['ajax_reply_noperm'] );
}
if ( $this->memberData['member_id'] )
{
if ( $this->memberData['restrict_post'] )
{
if ( $this->memberData['restrict_post'] == 1 )
{
$this->returnJsonError( $this->lang->words['ajax_reply_noperm'] );
}
$post_arr = IPSMember::processBanEntry( $this->memberData['restrict_post'] );
if ( time() >= $post_arr['date_end'] )
{
//-----------------------------------------
// Update this member's profile
//-----------------------------------------
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'restrict_post' => 0 ) ) );
}
else
{
$this->returnJsonError( $this->lang->words['ajax_reply_noperm'] );
}
}
}
/* Load lang and classes */
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_topics' ) );
if ( ! is_object( $this->postClass ) )
{
require_once( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPost.php' );/*noLibHook*/
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
$this->postClass = new $classToLoad( $this->registry );
}
/* Fetch topic data */
$topicData = $this->registry->getClass('topics')->getTopicById( $tid );
if ( ! $this->registry->getClass('topics')->canView( $topicData ) )
{
$this->returnJsonError( $this->lang->words['ajax_reply_noperm'] );
}
/* Duplicate posts */
if ( time() - $this->memberData['last_post'] <= 4 )
{
$_lastPost = $this->DB->buildAndFetch( array( 'select' => 'topic_id',
'from' => 'posts',
'where' => 'author_id=' . $this->memberData['member_id'],
'order' => 'post_date DESC',
'limit' => array( 0, 1 ) ) );
/* We made a reply within the last 4 seconds to this topic.. */
if ( $_lastPost['topic_id'] == $tid )
{
$this->returnJsonError( $this->lang->words['topic_duplicate_post'] );
}
}
/* Set post class data */
$this->postClass->setForumData( $this->registry->getClass('class_forums')->getForumById( $topicData['forum_id'] ) );
$this->postClass->setTopicID( $tid );
$this->postClass->setForumID( $fid );
$this->postClass->setSettings( array( 'enableSignature' => 1,
'enableEmoticons' => 1,
'post_htmlstatus' => 0,
'enableTracker' => 0 ) );
/* Topic Data */
$this->postClass->setTopicData( $topicData );
$this->postClass->setAuthor( $this->member->fetchMemberData() );
$this->postClass->setIsAjax( TRUE );
$this->postClass->setPublished( 'reply' );
$this->postClass->setPostContent( $_POST['Post'] );
/* POST */
try
{
/**
* If there was an error, return it as a JSON error
*/
if ( $this->postClass->addReply() === FALSE )
{
$this->returnJsonError( $this->postClass->getPostError() );
}
/* If it requires preview, return a message */
if( $this->postClass->getPublished() === false )
{
$this->returnJsonArray( array( 'success' => 1, 'message' => $this->lang->words['thanks_need_preview'] ) );
}
IPSDebug::fireBug( 'info', array( 'The post was successfully saved...' ) );
$topic = $this->postClass->getTopicData();
$post = $this->postClass->getPostData();
/* If we are merging, back up one */
if( $post['pid'] == $topPid )
{
$topPid--;
}
/* Mark topic as read */
$this->registry->getClass('classItemMarking')->markRead( array( 'forumID' => $topic['forum_id'], 'itemID' => $topic['tid'] ) );
/* Can we report? */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core' );
$reports = new $classToLoad( $this->registry );
/* Can we view this topic? */
$this->registry->getClass('topics')->setTopicData( $topic );
$topic = $this->registry->getClass('topics')->getTopicData();
$topic['_canReport'] = $reports->canReport( 'post' );
/* Get posts */
$posts = $this->_getPosts( $tid, $topPid, $this->registry->getClass('topics')->getTopicData('forum_id') );
IPSDebug::fireBug( 'info', array( 'Found ' . count($posts) . ' posts...' ) );
/* Got anything sailor? */
if ( ! count( $posts ) )
{
$this->returnHtml( '' );
}
else
{
$html = '';
$lastpid = 0;
foreach( $posts as $pid => $data )
{
$html .= $this->registry->output->getTemplate('topic')->post( $data, array(), $topic, $this->postClass->getForumData() );
$lastpid = $pid;
}
if( count($posts) == 1 )
{
$this->returnJsonArray( array( 'success' => 1, 'post' => $html, 'postid' => $lastpid ), true );
}
else
{
$this->returnHtml( $html );
}
}
}
catch ( Exception $error )
{
$this->returnJsonError( $error->getMessage() );
}
}
/**
* Displays a topic preview
*
* @return void
* @return @e void
*/
protected function _topicPreview()
{
/* INIT */
$tid = intval( $this->request['tid'] );
$pid = intval( $this->request['pid'] );
$sTerm = trim( $this->request['searchTerm'] );
$topic = array();
$posts = array();
$query = '';
$tid = intval( $this->request['tid'] );
$pid = intval( $this->request['pid'] );
$sTerm = trim( $this->request['searchTerm'] );
$topic = array();
$posts = array();
$permissions = array();
$query = '';
/* Topic visibility */
$_perms = array( 'visible' );
if ( $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics( false ) )
{
$_perms[] = 'sdelete';
}
if ( $this->registry->getClass('class_forums')->canQueuePosts( false ) )
{
$_perms[] = 'hidden';
}
/* Grab topic data and first post */
$topic = $this->DB->buildAndFetch( array( 'select' => 't.*, t.title as topic_title, t.posts as topic_posts, t.last_post as topic_last_post',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=' . $tid,
'where' => $this->registry->class_forums->fetchTopicHiddenQuery( $_perms, 't.' ) . ' AND t.tid=' . $tid,
'add_join' => array( array( 'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid=topic_firstpost',
'where' => 'p.pid=t.topic_firstpost',
'type' => 'left' ),
array( 'select' => 'm.*',
'from' => array( 'members' => 'm' ),
@@ -148,7 +657,8 @@ class public_forums_ajax_topics extends ipsAjaxCommand
/* Permission check */
if ( $this->registry->class_forums->forumsCheckAccess( $topic['forum_id'], 0, 'topic', $topic, true ) !== true )
{
return $this->returnHtml( $this->registry->output->getTemplate('global_other')->ajaxPopUpNoPermission() );
return $this->returnString( 'no_permission' );
//return $this->returnHtml( $this->registry->output->getTemplate('global_other')->ajaxPopUpNoPermission() );
}
/* Build permissions */
@@ -228,6 +738,9 @@ class public_forums_ajax_topics extends ipsAjaxCommand
while( $r = $this->DB->fetch() )
{
$r['tid'] = $topic['tid'];
$r['title_seo'] = $topic['title_seo'];
if ( $r['pid'] == $count['max'] )
{
$posts['last'] = $r;
@@ -278,15 +791,26 @@ class public_forums_ajax_topics extends ipsAjaxCommand
{
$data = IPSMember::buildDisplayData( $data );
IPSText::getTextClass( 'bbcode' )->parse_smilies = $data['use_emo'];
IPSText::getTextClass( 'bbcode' )->parse_html = ( $this->registry->class_forums->forum_by_id[ $topic['forum_id'] ]['use_html'] and $this->caches['group_cache'][ $data['member_group_id'] ]['g_dohtml'] and $data['post_htmlstate'] ) ? 1 : 0;
IPSText::getTextClass( 'bbcode' )->parse_nl2br = $data['post_htmlstate'] == 2 ? 1 : 0;
IPSText::getTextClass( 'bbcode' )->parse_bbcode = $this->registry->class_forums->forum_by_id[ $topic['forum_id'] ]['use_ibc'];
IPSText::getTextClass( 'bbcode' )->parsing_section = 'topics';
IPSText::getTextClass( 'bbcode' )->parsing_mgroup = $data['member_group_id'];
IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $data['mgroup_others'];
$data['post'] = IPSText::getTextClass( 'bbcode' )->stripQuotes( $data['post'] );
$data['post'] = IPSText::getTextClass( 'bbcode' )->preDisplayParse( $data['post'] );
/* Search term? */
if ( $k == 'search' AND $pid AND $sTerm )
{
$data['post'] = IPSText::truncateTextAroundPhrase( IPSText::getTextClass( 'bbcode' )->stripAllTags( str_replace( '<br />', ' ', $data['post'] ) ), $sTerm );
$data['post'] = IPSText::truncateTextAroundPhrase( IPSText::getTextClass( 'bbcode' )->stripAllTags( str_replace( '<br />', ' ', strip_tags( $data['post'], '<br>' ) ) ), $sTerm );
$data['post'] = IPSText::searchHighlight( $data['post'], $sTerm );
}
else
{
$data['post'] = IPSText::truncate( IPSText::getTextClass( 'bbcode' )->stripAllTags( $data['post'] ), 500 );
$data['post'] = IPSText::truncate( IPSText::getTextClass( 'bbcode' )->stripAllTags( strip_tags( $data['post'], '<br>' ) ), 500 );
}
$data['_isVisible'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $data ) == 'visible' ) ? true : false;
@@ -304,7 +828,7 @@ class public_forums_ajax_topics extends ipsAjaxCommand
/**
* Toggle the posts approve thingy
*
* @return void
* @return @e void
*/
protected function _postApproveToggle()
{
@@ -350,7 +874,7 @@ class public_forums_ajax_topics extends ipsAjaxCommand
/**
* Add vote to rating
*
* @return void
* @return @e void
*/
public function rateTopic()
{
@@ -468,18 +992,14 @@ class public_forums_ajax_topics extends ipsAjaxCommand
/**
* Saves a ajax topic title edit
*
* @return void
* @return @e void
*/
public function saveTopicTitle()
{
/* INIT */
IPSDebug::fireBug( 'info', array( 'Initial name: ' . $_POST['name'] ) );
$name = $_POST['name'];
IPSDebug::fireBug( 'info', array( 'after convert and make safe: ' . $name ) );
$tid = intval( $this->request['tid'] );
$can_edit = 0;
IPSDebug::fireBug( 'info', array( 'The topic title after converting is: ' . $name ) );
/* Check ID */
if( ! $tid )
@@ -600,74 +1120,12 @@ class public_forums_ajax_topics extends ipsAjaxCommand
$title = trim( $title );
return $title;
}
/**
* Saves a ajax topic description edit
*
* @return void
*/
public function saveTopicDescription()
{
/* INIT */
$description = $this->convertAndMakeSafe( $this->request['description'], TRUE );
$tid = intval( $this->request['tid'] );
$can_edit = 0;
/* Check ID */
if( ! $tid )
{
$this->returnString( $this->lang->words['ajax_no_topic_id'] );
}
/* Load Topic */
$topic = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid=' . $tid ) );
if( ! $topic['tid'] )
{
$this->returnString( $this->lang->words['ajax_topic_not_found'] );
}
/* Check Permissions */
if ( $this->memberData['g_is_supmod'] )
{
$can_edit = 1;
}
if( $this->memberData['forumsModeratorData'][ $topic['forum_id'] ]['edit_topic'] )
{
$can_edit = 1;
}
if( ! $can_edit )
{
$this->class_ajax->returnString( $this->lang->words['ajax_no_t_permission'] );
}
/* Update the description */
$this->DB->update( 'topics', array( 'description' => $description ), 'tid=' . $tid );
$this->DB->insert( 'moderator_logs', array(
'forum_id' => intval( $topic['forum_id'] ),
'topic_id' => $tid,
'member_id' => $this->memberData['member_id'],
'member_name' => $this->memberData['members_display_name'],
'ip_address' => $this->input['IP_ADDRESS'],
'http_referer'=> htmlspecialchars( my_getenv('HTTP_REFERER') ),
'ctime' => time(),
'topic_title' => $topic['title'],
'action' => $this->lang->words['ajax_topicdesc'],
'query_string'=> htmlspecialchars( my_getenv('QUERY_STRING') ),
) );
/* All Done */
$this->returnString( 'success' );
}
/**
* Saves the post
*
* @return void
* @return @e void
*/
public function editBoxSave()
{
@@ -731,7 +1189,7 @@ class public_forums_ajax_topics extends ipsAjaxCommand
if ( ! is_object( $this->postClass ) )
{
require_once( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPost.php' );
require_once( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPost.php' );/*noLibHook*/
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
$this->postClass = new $classToLoad( $this->registry );
@@ -744,8 +1202,9 @@ class public_forums_ajax_topics extends ipsAjaxCommand
$this->postClass->setTopicID( $tid );
$this->postClass->setPostID( $pid );
$this->postClass->setForumID( $fid );
$this->postClass->setPublished( 'reply' );
if( isset($this->request['post_htmlstatus']) ) // Off is "0"
if( isset($this->request['post_htmlstatus']) ) // Off is "0"
{
$this->postClass->setSettings( array( 'post_htmlstatus' => $this->request['post_htmlstatus'] ) );
}
@@ -854,7 +1313,7 @@ class public_forums_ajax_topics extends ipsAjaxCommand
/**
* Shows the edit box
*
* @return void
* @return @e void
*/
public function editBoxShow()
{
@@ -910,32 +1369,19 @@ class public_forums_ajax_topics extends ipsAjaxCommand
{
$this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_editors' ), 'core' );
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/post/classPost.php" );
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/post/classPost.php" );/*noLibHook*/
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
$this->postClass = new $classToLoad( $this->registry );
}
# Forum Data
$this->postClass->setForumData( $this->registry->getClass('class_forums')->forum_by_id[ $fid ] );
# IDs
/* Set post class data */
$this->postClass->setForumData( $this->registry->getClass('class_forums')->getForumById( $fid ) );
$this->postClass->setTopicID( $tid );
$this->postClass->setPostID( $pid );
$this->postClass->setForumID( $fid );
$this->postClass->setPostID( $pid );
/* Topic Data */
$this->postClass->setTopicData( $this->DB->buildAndFetch( array(
'select' => 't.*, p.poll_only',
'from' => array( 'topics' => 't' ),
'where' => "t.forum_id={$fid} AND t.tid={$tid}",
'add_join' => array(
array(
'type' => 'left',
'from' => array( 'polls' => 'p' ),
'where' => 'p.tid=t.tid'
)
)
) ) );
$this->postClass->setTopicData( $this->registry->getClass('topics')->getTopicById( $tid ) );
# Set Author
$this->postClass->setAuthor( $this->member->fetchMemberData() );