Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+30
-9
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief memberactivity
|
||||
* @brief Community Activity
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
@@ -18,9 +18,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
}
|
||||
|
||||
/**
|
||||
* memberactivity
|
||||
* Community Activity
|
||||
*/
|
||||
class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
class _communityactivity extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
@@ -29,7 +29,7 @@ class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'memberactivity_manage' );
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'communityactivity_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Callback(
|
||||
\IPS\Http\Url::internal( 'app=core&module=activitystats&controller=memberactivity' ),
|
||||
\IPS\Http\Url::internal( 'app=core&module=activitystats&controller=communityactivity' ),
|
||||
array( $this, 'getResults' ),
|
||||
'',
|
||||
array(
|
||||
@@ -67,7 +67,7 @@ class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_memberactivity');
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_communityactivity');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'stats' )->activitymessage();
|
||||
\IPS\Output::i()->output .= (string) $chart;
|
||||
}
|
||||
@@ -82,8 +82,29 @@ class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Get results */
|
||||
$results = array();
|
||||
|
||||
$results = array_replace_recursive( $results, $this->getSqlResults( 'core_search_index', 'index_date_updated', 'index_author', $chart ) );
|
||||
|
||||
if ( \IPS\Settings::i()->search_method == 'mysql' )
|
||||
{
|
||||
$results = array_replace_recursive( $results, $this->getSqlResults( 'core_search_index', 'index_date_updated', 'index_author', $chart ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter' ) as $contentRouter )
|
||||
{
|
||||
foreach ( $contentRouter->classes as $class )
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['author'] ) )
|
||||
{
|
||||
$results = array_replace_recursive( $results, $this->getSqlResults(
|
||||
$class::$databaseTable,
|
||||
$class::$databasePrefix . ( isset( $class::$databaseColumnMap['updated'] ) ? $class::$databaseColumnMap['updated'] : $class::$databaseColumnMap['date'] ),
|
||||
$class::$databasePrefix . $class::$databaseColumnMap['author'],
|
||||
$chart
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$results = array_replace_recursive( $results, $this->getSqlResults( 'core_reputation_index', 'rep_date', 'member_id', $chart ) );
|
||||
$results = array_replace_recursive( $results, $this->getSqlResults( 'core_follow', 'follow_added', 'follow_member_id', $chart ) );
|
||||
|
||||
@@ -140,7 +161,7 @@ class _memberactivity extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* First we need to get search index activity */
|
||||
$fromUnixTime = "FROM_UNIXTIME( IFNULL( {$date}, 0 ) )";
|
||||
if ( !$chart->timezoneError and \IPS\Member::loggedIn()->timezone and in_array( \IPS\Member::loggedIn()->timezone, \DateTimeZone::listIdentifiers() ) )
|
||||
if ( !$chart->timezoneError and \IPS\Member::loggedIn()->timezone and in_array( \IPS\Member::loggedIn()->timezone, \IPS\DateTime::getTimezoneIdentifiers() ) )
|
||||
{
|
||||
$fromUnixTime = "CONVERT_TZ( {$fromUnixTime}, @@session.time_zone, '" . \IPS\Db::i()->escape_string( \IPS\Member::loggedIn()->timezone ) . "' )";
|
||||
}
|
||||
@@ -133,6 +133,13 @@ class _keywords extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
$class = $data['class'];
|
||||
|
||||
/* Check that the class exists */
|
||||
if( !class_exists( $class ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
$item = $class::load( $data['id'] );
|
||||
|
||||
return $item->author()->link();
|
||||
@@ -149,6 +156,13 @@ class _keywords extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
$class = $data['class'];
|
||||
|
||||
/* Check that the class exists */
|
||||
if( !class_exists( $class ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
$item = $class::load( $data['id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $item->url(), TRUE, ( $item instanceof \IPS\Content\Comment ) ? $item->item()->mapped('title') : $item->mapped('title'), TRUE );
|
||||
@@ -162,7 +176,7 @@ class _keywords extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_keywords');
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table, TRUE, 'ipsPad ipsSpacer_top' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief reactions
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 19 Jan 2018
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* reactions
|
||||
*/
|
||||
class _reactions extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reactionsstats_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction statistics
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$tabs = array(
|
||||
'type' => 'stats_reactions_by_type',
|
||||
'app' => 'stats_reactions_by_app',
|
||||
'list' => 'stats_reactions_top_content',
|
||||
'givers' => 'stats_reactions_top_givers',
|
||||
'getters' => 'stats_reactions_top_receivers',
|
||||
);
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'type';
|
||||
|
||||
if ( $activeTab === 'type' OR $activeTab === 'app' )
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=reactions&tab=" . $activeTab ), 'core_reputation_index', 'rep_date', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'PieChart',
|
||||
'monthly',
|
||||
array( 'start' => 0, 'end' => 0 ),
|
||||
array(),
|
||||
$activeTab
|
||||
);
|
||||
|
||||
if ( $activeTab === 'type' )
|
||||
{
|
||||
$chart->groupBy = 'reaction';
|
||||
|
||||
foreach( \IPS\Content\Reaction::roots() as $reaction )
|
||||
{
|
||||
$chart->addSeries( $reaction->_title, 'number', 'COUNT(*)', TRUE, $reaction->id );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart->groupBy = 'app';
|
||||
|
||||
foreach( \IPS\Application::roots() as $app )
|
||||
{
|
||||
$chart->addSeries( $app->_title, 'number', 'COUNT(*)', TRUE, $app->directory );
|
||||
}
|
||||
}
|
||||
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart', 'PieChart' );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Database table helpers don't support grouping, so we will manually fetch the results and then let the table helper display */
|
||||
$contentWhere = array();
|
||||
$idToRatingMap = array();
|
||||
|
||||
if( $activeTab == 'list' )
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', NULL, 'rating DESC', array( 0, 20 ), array( 'app', 'type', 'type_id' ) );
|
||||
}
|
||||
elseif( $activeTab == 'givers' )
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', NULL, 'rating DESC', array( 0, 20 ), array( 'member_id' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = \IPS\Db::i()->select( 'MAX(id) as id, SUM(rep_rating) as rating', 'core_reputation_index', NULL, 'rating DESC', array( 0, 20 ), array( 'member_received' ) );
|
||||
}
|
||||
|
||||
foreach( $query as $reputation )
|
||||
{
|
||||
$contentWhere[] = $reputation['id'];
|
||||
$idToRatingMap[ $reputation['id'] ] = $reputation['rating'];
|
||||
}
|
||||
|
||||
/* Create the table */
|
||||
$chart = new \IPS\Helpers\Table\Db( 'core_reputation_index', \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=reactions&type=list' ), array( \IPS\Db::i()->in( 'id', $contentWhere ) ) );
|
||||
$chart->quickSearch = NULL;
|
||||
|
||||
/* Columns we need */
|
||||
if( $activeTab == 'list' )
|
||||
{
|
||||
$chart->langPrefix = 'reactstats_';
|
||||
$chart->include = array( 'type_id', 'rep_date', 'member_id', 'rating' );
|
||||
$chart->mainColumn = 'type_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart->langPrefix = 'reactstatsm_';
|
||||
$column = ( $activeTab == 'givers' ) ? 'member_id' : 'member_received';
|
||||
$chart->include = array( $column, 'rep_date', 'rating' );
|
||||
$chart->mainColumn = $column;
|
||||
}
|
||||
|
||||
$chart->noSort = array( 'member_id', 'type_id', 'rep_date', 'rating' );
|
||||
|
||||
$chart->sortBy = $chart->sortBy ?: 'rating';
|
||||
$chart->sortDirection = $chart->sortDirection ?: 'desc';
|
||||
|
||||
/* Custom parsers */
|
||||
$chart->parsers = array(
|
||||
'rep_date' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'member_id' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::load( $val )->link();
|
||||
},
|
||||
'member_received' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::load( $val )->link();
|
||||
},
|
||||
'rating' => function( $val, $row ) use ( $idToRatingMap )
|
||||
{
|
||||
/* Return the reputation total */
|
||||
return $idToRatingMap[ $row['id'] ];
|
||||
},
|
||||
'type_id' => function( $val, $row )
|
||||
{
|
||||
$class = $row['rep_class'];
|
||||
|
||||
try
|
||||
{
|
||||
$item = $class::load( $row['type_id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats' )->contentCell( $item );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_reactions');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, \IPS\Http\Url::internal( "app=core&module=activitystats&controller=reactions" ), 'tab', '', 'ipsPad' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Tag Usage
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 24 Jan 2018
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag Usage
|
||||
*/
|
||||
class _tags extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'tagsusage_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a graph of tag usage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=tags" ), 'core_tags', 'tag_added', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'AreaChart',
|
||||
'daily',
|
||||
array( 'start' => \IPS\DateTime::create()->sub( new \DateInterval( 'P1M' ) ), 'end' => 0 )
|
||||
);
|
||||
$chart->groupBy = 'tag_text';
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart', 'PieChart' );
|
||||
|
||||
$where = $chart->where;
|
||||
$where[] = array( "tag_added>?", 0 );
|
||||
if ( $chart->start )
|
||||
{
|
||||
$where[] = array( "tag_added>?", $chart->start->getTimestamp() );
|
||||
}
|
||||
if ( $chart->end )
|
||||
{
|
||||
$where[] = array( "tag_added<?", $chart->end->getTimestamp() );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'tag_text', 'core_tags', $where, NULL, NULL, array( 'tag_text' ) ) as $tag )
|
||||
{
|
||||
$chart->addSeries( $tag, 'number', 'COUNT(*)', TRUE, $tag );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_tags');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user