Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Report Comment Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 15 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -64,14 +64,50 @@ class _Comment extends \IPS\Content\Comment
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'report_comment';
|
||||
|
||||
|
||||
/**
|
||||
* Get mapped value
|
||||
*
|
||||
* @param string $key date,content,ip_address,first
|
||||
* @return mixed
|
||||
*/
|
||||
public function mapped( $key )
|
||||
{
|
||||
/* Get the reported content items title */
|
||||
if ( $key === 'title' )
|
||||
{
|
||||
return $this->item()->mapped( 'title' );
|
||||
}
|
||||
|
||||
return parent::mapped( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can view this entry
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member or NULL for currently logged in member.
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
$return = parent::canView($member);
|
||||
|
||||
if ( $return AND $member->modPermission('can_view_reports') )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
public function url( $action='find' )
|
||||
{
|
||||
$url = parent::url( $action );
|
||||
if ( isset( $url->queryString['do'] ) )
|
||||
@@ -80,4 +116,4 @@ class _Comment extends \IPS\Content\Comment
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Report Index Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 15 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -45,6 +45,11 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
*/
|
||||
protected static $databaseIdFields = array( 'content_id' );
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
|
||||
/* !\IPS\Content\Item */
|
||||
|
||||
/**
|
||||
@@ -56,6 +61,11 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
* @brief Application
|
||||
*/
|
||||
public static $module = 'modcp';
|
||||
|
||||
/**
|
||||
* @brief Allow the title to be editable via AJAX
|
||||
*/
|
||||
public $editableTitle = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
@@ -94,7 +104,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get mapped value
|
||||
*
|
||||
@@ -103,23 +113,32 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
*/
|
||||
public function mapped( $key )
|
||||
{
|
||||
/* Get the reported content items title */
|
||||
if ( $key === 'title' )
|
||||
{
|
||||
$class = $this->_data['class'];
|
||||
|
||||
if( in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
|
||||
try
|
||||
{
|
||||
$class = $class::$itemClass;
|
||||
}
|
||||
$class = $this->_data['class'];
|
||||
$thing = $class::load( $this->_data['content_id'] );
|
||||
$item = ( $thing instanceof \IPS\Content\Comment ) ? $thing->item() : $thing;
|
||||
|
||||
if( isset( $class::$databaseColumnMap['content'] ) AND $class::$databaseColumnMap['title'] === $class::$databaseColumnMap['content'] )
|
||||
if( isset( $item::$databaseColumnMap['content'] ) AND $item::$databaseColumnMap['content'] == $item::$databaseColumnMap['title'] )
|
||||
{
|
||||
$title = trim( mb_substr( strip_tags( $item->mapped( 'title' ) ), 0, 85 ) );
|
||||
return $title ?: \IPS\Member::loggedIn()->language()->addToStack('report_no_title_available');
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = trim( strip_tags( $item->mapped( 'title' ) ) );
|
||||
return $title ?: \IPS\Member::loggedIn()->language()->addToStack('report_no_title_available');
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->get( $class::$title );
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unknown' );
|
||||
}
|
||||
|
||||
return strip_tags( parent::mapped( 'title' ) );
|
||||
}
|
||||
|
||||
|
||||
return parent::mapped( $key );
|
||||
}
|
||||
|
||||
@@ -168,7 +187,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
{
|
||||
$types[ $row->class ][ $row->content_id ] = $row;
|
||||
}
|
||||
|
||||
|
||||
foreach ( $types as $class => $objects )
|
||||
{
|
||||
if ( in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
|
||||
@@ -179,13 +198,13 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
$itemTitleField = $itemClass::$databaseColumnMap['title']; # Strange PHP issue can cause this to be lost when added to the query below.
|
||||
|
||||
foreach( \IPS\Db::i()->select(
|
||||
"{$databaseTable}.{$class::$databasePrefix}{$class::$databaseColumnId}, {$databaseTable}.{$class::$databasePrefix}{$class::$databaseColumnMap['item']} AS itemId, {$itemClass::$databaseTable}.{$itemClass::$databasePrefix}{$itemTitleField} AS title",
|
||||
"{$databaseTable}.{$class::$databasePrefix}{$class::$databaseColumnId} as commentId, {$databaseTable}.{$class::$databasePrefix}{$class::$databaseColumnMap['item']} AS itemId, {$itemClass::$databaseTable}.{$itemClass::$databasePrefix}{$itemTitleField} AS title",
|
||||
$databaseTable,
|
||||
\IPS\Db::i()->in( $class::$databasePrefix . $class::$databaseColumnId, array_keys( $objects ) )
|
||||
)->join(
|
||||
$itemDatabaseTable,
|
||||
"{$itemDatabaseTable}.{$itemClass::$databasePrefix}{$itemClass::$databaseColumnId}={$databaseTable}.{$class::$databasePrefix}{$class::$databaseColumnMap['item']}"
|
||||
)->setKeyField( $class::$databasePrefix . $class::$databaseColumnId ) as $k => $data
|
||||
)->setKeyField( 'commentId' ) as $k => $data
|
||||
)
|
||||
{
|
||||
$objects[ $k ]->_data = array_merge( $objects[ $k ]->_data, $data );
|
||||
@@ -194,10 +213,10 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
elseif ( in_array( 'IPS\Content\Item', class_parents( $class ) ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select(
|
||||
"{$class::$databasePrefix}{$class::$databaseColumnId}, {$class::$databasePrefix}{$class::$databaseColumnMap['title']} AS title",
|
||||
"{$class::$databasePrefix}{$class::$databaseColumnId} as itemId, {$class::$databasePrefix}{$class::$databaseColumnMap['title']} AS title",
|
||||
$class::$databaseTable,
|
||||
\IPS\Db::i()->in( $class::$databasePrefix . $class::$databaseColumnId, array_keys( $objects ) )
|
||||
)->setKeyField( $class::$databasePrefix . $class::$databaseColumnId ) as $k => $data
|
||||
)->setKeyField( 'itemId' ) as $k => $data
|
||||
)
|
||||
{
|
||||
$objects[ $k ]->_data = array_merge( $objects[ $k ]->_data, $data );
|
||||
@@ -213,7 +232,26 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
*/
|
||||
public function tableDescription()
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'tables', 'core', 'front' )->icon( $this->class );
|
||||
$className = $this->class;
|
||||
try
|
||||
{
|
||||
$reportedContent = $className::load( $this->content_id );
|
||||
|
||||
if( $reportedContent instanceof \IPS\Content\Comment )
|
||||
{
|
||||
$container = ( $reportedContent->item()->containerWrapper() !== NULL ) ? $reportedContent->item()->container() : NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$container = ( $reportedContent->containerWrapper() !== NULL ) ? $reportedContent->container() : NULL;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $ex )
|
||||
{
|
||||
$container = NULL;
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'tables', 'core', 'front' )->icon( $className, $container );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,4 +428,4 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
'read', 'unread', 'report_status_1', 'report_status_2', 'report_status_3'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user