Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -664,8 +664,13 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'options' => array(
|
||||
'time' => 'forums_topic_show_meta_time',
|
||||
'moderation' => 'forums_topic_show_meta_moderation'
|
||||
),
|
||||
'toggles' => array(
|
||||
'moderation' => array( 'forums_mod_actions_anon' )
|
||||
) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_mod_actions_anon', !\IPS\Settings::i()->forums_mod_actions_anon, FALSE, array(), NULL, NULL, NULL, 'forums_mod_actions_anon' ) );
|
||||
|
||||
$form->addHeader('topic_summary_settings');
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'forums_topic_activity', \IPS\Settings::i()->forums_topic_activity ? json_decode( \IPS\Settings::i()->forums_topic_activity, TRUE ) : NULL, FALSE, array(
|
||||
@@ -685,6 +690,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* This setting needs to be reversed */
|
||||
$values['forums_mod_actions_anon'] = !$values['forums_mod_actions_anon'];
|
||||
|
||||
if ( isset( $values['forums_popular_now']['never'] ) )
|
||||
{
|
||||
$values['forums_popular_now'] = json_encode( array( 'posts' => 0, 'minutes' => 0 ) );
|
||||
|
||||
@@ -27,7 +27,12 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
@@ -42,7 +47,7 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $activeTab === 'total' )
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts" ), 'forums_posts', 'post_date', '', array(
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts" ), 'forums_posts', 'post_date', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e' ),
|
||||
@@ -50,6 +55,8 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
) );
|
||||
|
||||
$chart->where = array( array( \IPS\Db::i()->in( 'queued', array( -2, -3 ), TRUE ) ) );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack( 'stats_new_posts' ), 'number', 'COUNT(*)', FALSE );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_posts_title' );
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
@@ -74,14 +81,45 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_posts_title_byforum' );
|
||||
$chart->availableTypes = array( 'ColumnChart' );
|
||||
|
||||
$chart->where = array( array( \IPS\Db::i()->in( 'queued', array( -2, -3 ), TRUE ) ) );
|
||||
$chart->groupBy = 'forum_id';
|
||||
$chart->joins = array( array( 'forums_topics', 'forums_topics.tid=forums_posts.topic_id' ) );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'posts>?', 0 ) ) as $forum )
|
||||
{
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', TRUE, $forum['id'] );
|
||||
}
|
||||
|
||||
$customValues = ( isset( $chart->savedCustomFilters['chart_forums'] ) ? array_values( explode( ',', $chart->savedCustomFilters['chart_forums'] ) ) : 0 );
|
||||
|
||||
$chart->customFiltersForm = array(
|
||||
'form' => array(
|
||||
new \IPS\Helpers\Form\Node( 'chart_forums', $customValues, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'any', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->sub_can_post and !$forum->redirect_url;
|
||||
} ), NULL, NULL, NULL, 'chart_forums' )
|
||||
),
|
||||
'where' => function( $values )
|
||||
{
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
return \IPS\Db::i()->in( 'forums_topics.forum_id', $forumIds );
|
||||
},
|
||||
'groupBy' => 'forum_id',
|
||||
'series' => function( $values )
|
||||
{
|
||||
$series = array();
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
foreach( $forumIds as $id )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
|
||||
}
|
||||
return $series;
|
||||
},
|
||||
'defaultSeries' => function()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'posts>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', FALSE, $forum['id'] );
|
||||
}
|
||||
|
||||
return $series;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
|
||||
@@ -27,6 +27,11 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Manage
|
||||
@@ -52,7 +57,8 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
),
|
||||
'AreaChart'
|
||||
);
|
||||
|
||||
|
||||
$chart->where = array( array( \IPS\Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) ), array( \IPS\Db::i()->in( 'approved', array( -2, -3 ), TRUE ) ) );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack( 'stats_new_topics' ), 'number', 'COUNT(*)', FALSE );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_topics_title' );
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
@@ -74,16 +80,47 @@ class _topics extends \IPS\Dispatcher\Controller
|
||||
array(),
|
||||
'byforum'
|
||||
);
|
||||
|
||||
|
||||
$chart->where = array( array( \IPS\Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) ), array( \IPS\Db::i()->in( 'approved', array( -2, -3 ), TRUE ) ) );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack( 'stats_topics_title_byforum' );
|
||||
$chart->availableTypes = array( 'ColumnChart' );
|
||||
|
||||
$chart->groupBy = 'forum_id';
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>?', 0 ) ) as $forum )
|
||||
{
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', TRUE, $forum['id'] );
|
||||
}
|
||||
$customValues = ( isset( $chart->savedCustomFilters['chart_forums'] ) ? array_values( explode( ',', $chart->savedCustomFilters['chart_forums'] ) ) : 0 );
|
||||
|
||||
$chart->customFiltersForm = array(
|
||||
'form' => array(
|
||||
new \IPS\Helpers\Form\Node( 'chart_forums', $customValues, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'any', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->sub_can_post and !$forum->redirect_url;
|
||||
} ), NULL, NULL, NULL, 'chart_forums' )
|
||||
),
|
||||
'where' => function( $values )
|
||||
{
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
return \IPS\Db::i()->in( 'forum_id', $forumIds );
|
||||
},
|
||||
'groupBy' => 'forum_id',
|
||||
'series' => function( $values )
|
||||
{
|
||||
$series = array();
|
||||
$forumIds = \is_array( $values['chart_forums'] ) ? array_keys( $values['chart_forums'] ) : explode( ',', $values['chart_forums'] );
|
||||
foreach( $forumIds as $id )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $id ), 'number', 'COUNT(*)', FALSE, $id );
|
||||
}
|
||||
return $series;
|
||||
},
|
||||
'defaultSeries' => function()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'topics>?', 0 ), 'last_post desc', array( 0, 50 ) ) as $forum )
|
||||
{
|
||||
$series[] = array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_forum_' . $forum['id'] ), 'number', 'COUNT(*)', FALSE, $forum['id'] );
|
||||
}
|
||||
|
||||
return $series;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
|
||||
@@ -51,8 +51,6 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function _forum( $forum )
|
||||
{
|
||||
$this->themeGroup = \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' );
|
||||
|
||||
$forum->clubCheckRules();
|
||||
|
||||
/* Is simple mode on? If so, redirect to the index page */
|
||||
@@ -80,6 +78,7 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Theme */
|
||||
$forum->setTheme();
|
||||
$this->themeGroup = \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' );
|
||||
|
||||
/* Users can see topics posted by other users? */
|
||||
$where = array();
|
||||
@@ -179,8 +178,6 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
'solved_topics' => 'topic_answered_pid>0',
|
||||
'unsolved_topics' => 'topic_answered_pid=0',
|
||||
);
|
||||
|
||||
$table->sortOptions['question_rating'] = 'forums_topics.question_rating';
|
||||
}
|
||||
|
||||
/* Are we a moderator? */
|
||||
@@ -188,6 +185,17 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$filterOptions['queued_topics'] = 'queued_topics';
|
||||
$filterOptions['queued_posts'] = 'queued_posts';
|
||||
|
||||
$table->filters['filter_hidden_topics'] = 'approved=-1';
|
||||
$table->filters['filter_hidden_posts_in_topics'] = 'topic_hiddenposts=1';
|
||||
}
|
||||
|
||||
/* Are we filtering by queued topics or posts? */
|
||||
if( \IPS\Request::i()->filter == 'queued_topics' OR \IPS\Request::i()->filter == 'queued_posts' )
|
||||
{
|
||||
\IPS\Request::i()->advanced_search_submitted = 1;
|
||||
\IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
|
||||
\IPS\Request::i()->topic_type = \IPS\Request::i()->filter;
|
||||
}
|
||||
|
||||
$table->advancedSearch = array(
|
||||
@@ -389,7 +397,7 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
break;
|
||||
}
|
||||
|
||||
$popularQuestions = \IPS\forums\Topic::getItemsWithPermission( array( array( 'forum_id=?', $forum->id ), array( 'start_date>?', \IPS\DateTime::ts( time() - ( 86400 * 30 ) )->getTimestamp() ), array( 'question_rating>0' ) ), 'question_rating DESC', 5 );
|
||||
$popularQuestions = \IPS\forums\Topic::getItemsWithPermission( array( array( 'forum_id=?', $forum->id ), array( 'start_date>?', \IPS\DateTime::ts( time() - ( 86400 * 30 ) )->getTimestamp() ), array( 'question_rating>0' ) ), 'question_rating DESC, views DESC', 5 );
|
||||
$newQuestionsWhere = array( array( 'forum_id=?', $forum->id ) );
|
||||
|
||||
if ( !\IPS\Settings::i()->forums_new_questions )
|
||||
@@ -409,7 +417,8 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
$forumOutput = (string) $table;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $this->themeGroup->forumDisplay( $forum, $forumOutput );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_forum.js', 'forums' ) );
|
||||
\IPS\Output::i()->output = $this->themeGroup->forumDisplay( $forum, $forumOutput );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,6 +501,7 @@ class _forums extends \IPS\Dispatcher\Controller
|
||||
\IPS\Session::i()->setLocation( $forum->url(), explode( ",", $permissions['perm_view'] ), 'loc_forums_creating_topic', array( "forums_forum_{$forum->id}" => TRUE ) );
|
||||
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) $forum->url()->setQueryString( 'do', 'add' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->createTopic( $formTemplate, $forum, $title );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
|
||||
|
||||
|
||||
@@ -115,7 +115,13 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
/* Display */
|
||||
if ( \IPS\forums\Forum::isSimpleView() )
|
||||
{
|
||||
$where = array( 'container' => array( array( 'forums_forums.password IS NULL' ) ) );
|
||||
$where = array();
|
||||
|
||||
if ( \IPS\forums\Forum::hasPasswordForums() )
|
||||
{
|
||||
$where = array( 'container' => array( array( 'forums_forums.password IS NULL' ) ) );
|
||||
}
|
||||
|
||||
if ( !\IPS\Settings::i()->club_nodes_in_apps OR !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
$where['container'][] = array( 'forums_forums.club_id IS NULL' );
|
||||
@@ -171,7 +177,16 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedForumTable' );
|
||||
$table->classes = array( 'cTopicList' );
|
||||
$table->limit = \IPS\Settings::i()->forums_topics_per_page;
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
|
||||
if ( \IPS\forums\Forum::getMemberListView() == 'snippet' )
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRowSnippet' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
}
|
||||
|
||||
$table->honorPinned = \IPS\Settings::i()->forums_fluid_pinned;
|
||||
$table->hover = TRUE;
|
||||
$table->sortOptions['num_replies'] = $table->sortOptions['num_comments'];
|
||||
|
||||
@@ -283,6 +283,18 @@ class _topic extends \IPS\Content\Controller
|
||||
$topic->markRead( NULL, $maxTime );
|
||||
}
|
||||
}
|
||||
elseif( $topic->isLastPage() )
|
||||
{
|
||||
/* See if the last comment is hidden or pending approval. If so, force the topic read because it won't be done so automatically. */
|
||||
$lastComment = end( $comments );
|
||||
|
||||
if( $lastComment and $lastComment->hidden() !== 0 )
|
||||
{
|
||||
$topic->markRead( NULL, NULL, NULL, TRUE );
|
||||
}
|
||||
|
||||
reset( $comments );
|
||||
}
|
||||
|
||||
$votes = array();
|
||||
$topicVotes = array();
|
||||
@@ -320,41 +332,26 @@ class _topic extends \IPS\Content\Controller
|
||||
|
||||
/* Add Json-LD */
|
||||
$isQuestion = ( $topic->isQuestion() or $topic->isSolved() );
|
||||
\IPS\Output::i()->jsonLd['topic'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => $isQuestion ? 'Question' : 'DiscussionForumPosting',
|
||||
'@id' => (string) $topic->url(),
|
||||
'isPartOf' => array(
|
||||
'@id' => \IPS\Settings::i()->base_url . '#website'
|
||||
),
|
||||
'publisher' => array(
|
||||
'@id' => \IPS\Settings::i()->base_url . '#organization'
|
||||
),
|
||||
'url' => (string) $topic->url(),
|
||||
'discussionUrl' => (string) $topic->url(),
|
||||
'mainEntityOfPage' => array(
|
||||
'@type' => 'WebPage',
|
||||
'@id' => (string) $topic->url()
|
||||
)
|
||||
);
|
||||
|
||||
/* Do we have a real author */
|
||||
if( $topic->starter_id )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['author']['url'] = (string) \IPS\Member::load( $topic->starter_id )->url();
|
||||
|
||||
\IPS\Output::i()->jsonLd['topic']['publisher']['member'] = array(
|
||||
'@type' => "Person",
|
||||
'name' => \IPS\Member::load( $topic->starter_id )->name,
|
||||
'image' => (string) \IPS\Member::load( $topic->starter_id )->get_photo(),
|
||||
'url' => (string) \IPS\Member::load( $topic->starter_id )->url(),
|
||||
if ( $isQuestion )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => 'QAPage',
|
||||
'@id' => (string) $topic->url(),
|
||||
'url' => (string) $topic->url(),
|
||||
'mainEntity' => [
|
||||
'@type' => "Question",
|
||||
'name' => $topic->title,
|
||||
'text' => $topic->comments( 1, 0 )->truncated( TRUE, NULL ),
|
||||
'answerCount' => $topic->posts ? $topic->posts - 1 : 0,
|
||||
'dateCreated' => \IPS\DateTime::ts( $topic->start_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'author' => [
|
||||
'@type' => 'Person',
|
||||
'name' => $topic->author()->name
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if( $isQuestion )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['answerCount'] = $topic->posts ? $topic->posts - 1 : 0;
|
||||
\IPS\Output::i()->jsonLd['topic']['upvoteCount'] = \intval( $topic->question_rating );
|
||||
|
||||
if( $topic->topic_answered_pid )
|
||||
{
|
||||
@@ -362,22 +359,27 @@ class _topic extends \IPS\Content\Controller
|
||||
{
|
||||
$answer = \IPS\forums\Topic\Post::load( $topic->topic_answered_pid );
|
||||
|
||||
\IPS\Output::i()->jsonLd['topic']['acceptedAnswer'] = array(
|
||||
\IPS\Output::i()->jsonLd['topic']['mainEntity']['acceptedAnswer'] = array(
|
||||
'@type' => 'Answer',
|
||||
'text' => $answer->truncated( TRUE, NULL ),
|
||||
'url' => (string) $answer->url(),
|
||||
'dateCreated' => \IPS\DateTime::ts( $answer->post_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'upvoteCount' => $answer->post_field_int,
|
||||
'dateCreated' => \IPS\DateTime::ts( $answer->post_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'upvoteCount' => $answer->reactionCount(),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => $answer->author_name ?: \IPS\Member::load( $answer->author_id )->name,
|
||||
'image' => \IPS\Member::load( $answer->author_id )->get_photo()
|
||||
'image' => \IPS\Member::load( $answer->author_id )->get_photo( TRUE, TRUE )
|
||||
),
|
||||
);
|
||||
|
||||
if( $topic->isQuestion() )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['mainEntity']['acceptedAnswer']['upvoteCount'] = $answer->post_field_int;
|
||||
}
|
||||
|
||||
if( $answer->author_id )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['acceptedAnswer']['author']['url'] = (string) \IPS\Member::load( $answer->author_id )->url();
|
||||
\IPS\Output::i()->jsonLd['topic']['mainEntity']['acceptedAnswer']['author']['url'] = (string) \IPS\Member::load( $answer->author_id )->url();
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
@@ -385,9 +387,41 @@ class _topic extends \IPS\Content\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['comment'] = array();
|
||||
\IPS\Output::i()->jsonLd['topic'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => 'DiscussionForumPosting',
|
||||
'@id' => (string) $topic->url(),
|
||||
'isPartOf' => array(
|
||||
'@id' => \IPS\Settings::i()->base_url . '#website'
|
||||
),
|
||||
'publisher' => array(
|
||||
'@id' => \IPS\Settings::i()->base_url . '#organization'
|
||||
),
|
||||
'url' => (string) $topic->url(),
|
||||
'discussionUrl' => (string) $topic->url(),
|
||||
'mainEntityOfPage' => array(
|
||||
'@type' => 'WebPage',
|
||||
'@id' => (string) $topic->url()
|
||||
),
|
||||
'pageStart' => 1,
|
||||
'pageEnd' => $topic->commentPageCount(),
|
||||
);
|
||||
}
|
||||
|
||||
/* Add in comments */
|
||||
if( $topic->posts > 1 )
|
||||
{
|
||||
if ( $isQuestion )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['mainEntity']['suggestedAnswer'] = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['comment'] = [];
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$commentJson = [];
|
||||
foreach( $comments as $comment )
|
||||
{
|
||||
// Don't include the first post as a "comment"
|
||||
@@ -396,27 +430,70 @@ class _topic extends \IPS\Content\Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = $topic->url()->setPage( 'page', \IPS\Request::i()->page );
|
||||
\IPS\Output::i()->jsonLd['topic']['comment'][ $i ] = array(
|
||||
'@type' => 'Comment',
|
||||
'@id' => (string) $url->setFragment( 'comment-' . $comment->pid ),
|
||||
'url' => (string) $url->setFragment( 'comment-' . $comment->pid ),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => $comment->author_name ?: \IPS\Member::load( $comment->author_id )->name,
|
||||
'image' => \IPS\Member::load( $comment->author_id )->get_photo()
|
||||
),
|
||||
'dateCreated' => \IPS\DateTime::ts( $comment->post_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'text' => $comment->truncated( TRUE, NULL ),
|
||||
);
|
||||
|
||||
if( $comment->author_id )
|
||||
// Don't include the answer as the suggested answer
|
||||
if( $isQuestion and ( $comment->pid === $topic->mapped('solved_comment_id') ) )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['comment'][ $i ]['author']['url'] = (string) \IPS\Member::load( $comment->author_id )->url();
|
||||
continue;
|
||||
}
|
||||
|
||||
$i++;
|
||||
if ( $truncatedComment = $comment->truncated( TRUE, NULL ) )
|
||||
{
|
||||
$url = $topic->url()->setPage( 'page', \IPS\Request::i()->page );
|
||||
|
||||
$commentJson[$i] = array(
|
||||
'@type' => $isQuestion ? 'Answer' : 'Comment',
|
||||
'@id' => (string)$url->setFragment( 'comment-' . $comment->pid ),
|
||||
'url' => (string)$url->setFragment( 'comment-' . $comment->pid ),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => $comment->author_name ?: \IPS\Member::load( $comment->author_id )->name,
|
||||
'image' => \IPS\Member::load( $comment->author_id )->get_photo( TRUE, TRUE )
|
||||
),
|
||||
'dateCreated' => \IPS\DateTime::ts( $comment->post_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'upvoteCount' => $comment->reactionCount(),
|
||||
'text' => $truncatedComment,
|
||||
);
|
||||
|
||||
if ( $comment->author_id )
|
||||
{
|
||||
$commentJson[$i]['author']['url'] = (string)\IPS\Member::load( $comment->author_id )->url();
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $isQuestion )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['mainEntity']['suggestedAnswer'] = $commentJson;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['comment'] = $commentJson;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we have a real author */
|
||||
if( $topic->starter_id )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['topic']['author']['url'] = (string) \IPS\Member::load( $topic->starter_id )->url();
|
||||
|
||||
\IPS\Output::i()->jsonLd['topic']['publisher']['member'] = array(
|
||||
'@type' => "Person",
|
||||
'name' => \IPS\Member::load( $topic->starter_id )->name,
|
||||
'image' => (string) \IPS\Member::load( $topic->starter_id )->get_photo( TRUE, TRUE ),
|
||||
'url' => (string) \IPS\Member::load( $topic->starter_id )->url(),
|
||||
);
|
||||
}
|
||||
|
||||
/* Enable caching for archived topics */
|
||||
if( $topic->isArchived() AND !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
/* We do not want to use the \IPS\CACHE_PRIVATE_TIMEOUT constant here, as we explicitly want to cache archived topics for longer times */
|
||||
$httpHeaders = array( 'Expires' => \IPS\DateTime::create()->add( new \DateInterval( 'PT12H' ) )->rfc1123() ,
|
||||
'Cache-Control' => "max-age=" . ( 60 * 60 * 12 ) . ", s-maxage=" . ( 60 * 60 * 12 ) . ", public, stale-if-error, stale-while-revalidate" );
|
||||
|
||||
\IPS\Output::i()->httpHeaders += $httpHeaders;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->jsonLd['topic'] = array_merge_recursive( array(
|
||||
@@ -426,14 +503,12 @@ class _topic extends \IPS\Content\Controller
|
||||
'dateCreated' => \IPS\DateTime::ts( $topic->start_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'datePublished' => \IPS\DateTime::ts( $topic->start_date )->format( \IPS\DateTime::ISO8601 ),
|
||||
'dateModified' => \IPS\DateTime::ts( $topic->last_post )->format( \IPS\DateTime::ISO8601 ),
|
||||
'pageStart' => 1,
|
||||
'pageEnd' => $topic->commentPageCount(),
|
||||
/* Image is required, but we don't have "topic images", so we'll use topic starter's profile photo for now */
|
||||
'image' => (string) \IPS\Member::load( $topic->starter_id )->get_photo(),
|
||||
'image' => (string) \IPS\Member::load( $topic->starter_id )->get_photo( TRUE, TRUE ),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => $topic->starter_name ?: \IPS\Member::load( $topic->starter_id )->name,
|
||||
'image' => \IPS\Member::load( $topic->starter_id )->get_photo()
|
||||
'image' => \IPS\Member::load( $topic->starter_id )->get_photo( TRUE, TRUE )
|
||||
),
|
||||
'interactionStatistic' => array(
|
||||
array(
|
||||
@@ -625,6 +700,9 @@ class _topic extends \IPS\Content\Controller
|
||||
|
||||
$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_RESTORE;
|
||||
$topic->save();
|
||||
|
||||
/* Make sure the task is enabled */
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'unarchive' ) );
|
||||
|
||||
/* Log */
|
||||
\IPS\Session::i()->modLog( 'modlog__unarchived_topic', array( $topic->url()->__toString() => FALSE, $topic->mapped( 'title' ) => FALSE ), $topic );
|
||||
@@ -813,13 +891,6 @@ class _topic extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
$topic->toggleSolveComment( $post->pid, TRUE );
|
||||
|
||||
if( $post->author()->member_id != \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$notification = new \IPS\Notification( \IPS\Application::load( 'core' ), 'best_answer', $topic, array( $post ), array( $post->author()->member_id ) );
|
||||
$notification->recipients->attach( $post->author() );
|
||||
$notification->send();
|
||||
}
|
||||
|
||||
/* Log */
|
||||
if ( \IPS\Member::loggedIn()->modPermission('can_set_best_answer') )
|
||||
@@ -859,19 +930,16 @@ class _topic extends \IPS\Content\Controller
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
if ( $topic->topic_answered_pid )
|
||||
try
|
||||
{
|
||||
try
|
||||
$topic->toggleSolveComment( $post->pid, FALSE );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->modPermission('can_set_best_answer') )
|
||||
{
|
||||
$topic->toggleSolveComment( $post->pid, FALSE );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->modPermission('can_set_best_answer') )
|
||||
{
|
||||
\IPS\Session::i()->modLog( 'modlog__best_answer_unset', array( $topic->topic_answered_pid => FALSE ), $topic );
|
||||
}
|
||||
\IPS\Session::i()->modLog( 'modlog__best_answer_unset', array( $post->pid => FALSE ), $topic );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
\IPS\Output::i()->redirect( $post->url() );
|
||||
}
|
||||
@@ -1026,8 +1094,28 @@ class _topic extends \IPS\Content\Controller
|
||||
$where[] = array( $hiddenWhereClause );
|
||||
}
|
||||
}
|
||||
$answers = \IPS\Db::i()->select( 'archive_id, @rownum := @rownum + 1 AS position', 'forums_archive_posts', $where, 'archive_is_first DESC, archive_bwoptions DESC, archive_field_int DESC, archive_content_date' )->join( array( '(SELECT @rownum := 0)', 'r' ), NULL, 'JOIN' );
|
||||
$commentPosition = \IPS\Db::i()->select( 'position', $answers, array( 'archive_id=?', $comment->id ) )->first() - 1;
|
||||
|
||||
/* Connect to the remote DB if needed */
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
$storage = \IPS\Cicloud\getForumArchiveDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
$storage = !\IPS\Settings::i()->archive_remote_sql_host ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
}
|
||||
|
||||
$answers = $storage->select( 'archive_id, @rownum := @rownum + 1 AS position', 'forums_archive_posts', $where, 'archive_is_first DESC, archive_bwoptions DESC, archive_field_int DESC, archive_content_date' )->join( array( '(SELECT @rownum := 0)', 'r' ), NULL, 'JOIN' );
|
||||
$commentPosition = $storage->select( 'position', $answers, array( 'archive_id=?', $comment->id ) )->first() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user