Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -60,7 +60,7 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set deleted date
|
||||
*
|
||||
* @param \IPS\DateTime A DateTime object
|
||||
* @param \IPS\DateTime $time A DateTime object
|
||||
* @return void
|
||||
*/
|
||||
public function set_deleted_date( \IPS\DateTime $time )
|
||||
@@ -81,7 +81,7 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set Deleted By
|
||||
*
|
||||
* @param \IPS\Member The member
|
||||
* @param \IPS\Member $member The member
|
||||
* @return void
|
||||
*/
|
||||
public function set_deleted_by( \IPS\Member $member )
|
||||
@@ -103,7 +103,7 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function get__deleted_by()
|
||||
{
|
||||
if ( $this->_deletedBy === NULL )
|
||||
if ( $this->_deletedBy === NULL AND $this->_data['deleted_by'] !== NULL )
|
||||
{
|
||||
$this->_deletedBy = \IPS\Member::load( $this->_data['deleted_by'] );
|
||||
}
|
||||
@@ -153,14 +153,17 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set Content and Member
|
||||
*
|
||||
* @param \IPS\Content The content being deleted.
|
||||
* @param \IPS\Member|NULL The member performing the deletion, or NULL for the currently logged in member
|
||||
* @param \IPS\Content $content The content being deleted.
|
||||
* @param \IPS\Member|NULL $member The member performing the deletion, NULL for the currently logged in member, or FALSE for no member (i.e. system task)
|
||||
* @return void
|
||||
* @note Convenience ftw
|
||||
*/
|
||||
public function setContentAndMember( \IPS\Content $content, \IPS\Member $member = NULL )
|
||||
public function setContentAndMember( \IPS\Content $content, $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
if( $member === NULL )
|
||||
{
|
||||
$member = \IPS\Member::loggedIn();
|
||||
}
|
||||
|
||||
$idField = $content::$databaseColumnId;
|
||||
|
||||
@@ -171,14 +174,28 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Content Data */
|
||||
$this->content_class = get_class( $content );
|
||||
$this->content_class = \get_class( $content );
|
||||
$this->content_id = $content->$idField;
|
||||
$this->content_title = $item->mapped('title');
|
||||
$this->content_seo_title = \IPS\Http\Url\Friendly::seoTitle( $item->mapped('title') );
|
||||
$this->content_permissions = $item->deleteLogPermissions();
|
||||
|
||||
try
|
||||
{
|
||||
$this->content_container_id = $item->container()->_id;
|
||||
$this->content_container_class = $item::$containerNodeClass;
|
||||
}
|
||||
catch( \BadMethodCallException | \OutOfRangeException $e )
|
||||
{
|
||||
$this->content_container_id = 0;
|
||||
$this->content_container_class = NULL;
|
||||
}
|
||||
|
||||
/* Member Data */
|
||||
$this->deleted_by = $member;
|
||||
if( $member )
|
||||
{
|
||||
$this->deleted_by = $member;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,10 +222,9 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Load and check perms
|
||||
*
|
||||
* @param int ID
|
||||
* @param int $id ID
|
||||
* @return static
|
||||
* @throws
|
||||
* @li \OutOfRangeException
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public static function loadAndCheckPerms( $id )
|
||||
{
|
||||
@@ -222,22 +238,52 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load from content
|
||||
*
|
||||
* @param \IPS\Content $content The content object
|
||||
* @param \IPS\Member $member Member for permission checking
|
||||
* @return static
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public static function loadFromContent( \IPS\Content $content, ?\IPS\Member $member = NULL ): \IPS\core\DeletionLog
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
try
|
||||
{
|
||||
$idColumn = $content::$databaseColumnId;
|
||||
$log = static::constructFromData( \IPS\Db::i()->select( '*', 'core_deletion_log', array( "dellog_content_class=? AND dellog_content_id=?", \get_class( $content ), $content->$idColumn ) )->first() );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
if ( !$log->canView( $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can View
|
||||
*
|
||||
* @param \IPS\Member|NULL The member, or NULL for currently logged in
|
||||
* @param \IPS\Member|NULL $member The member, or NULL for currently logged in
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( \IPS\Member $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( !is_array( $this->content_permissions ) AND $this->content_permissions == '*' )
|
||||
if ( !\is_array( $this->content_permissions ) AND $this->content_permissions == '*' )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( in_array( $member->member_id, $this->content_permissions['members'] ) )
|
||||
if ( \in_array( $member->member_id, $this->content_permissions['members'] ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -253,7 +299,7 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* URL
|
||||
*
|
||||
* @param string|NULL "action" parameter or NULL to go to the content
|
||||
* @param string|NULL $action "action" parameter or NULL to go to the content
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
@@ -288,4 +334,24 @@ class _DeletionLog extends \IPS\Patterns\ActiveRecord
|
||||
return \IPS\Http\Url::internal( "app=core&module=modcp&controller=modcp&tab=deleted", 'front', 'modcp_deleted' )->setQueryString( array( 'id' => $this->id, 'action' => $action ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass update permissions for a specific node
|
||||
*
|
||||
* @param string $class The Node Class to update
|
||||
* @param int $id The ID of the container
|
||||
* @param string|array $perms The permissions to update with
|
||||
* @return void
|
||||
*/
|
||||
public static function updateNodePermissions( $class, $id, $perms )
|
||||
{
|
||||
if ( \is_array( $perms ) )
|
||||
{
|
||||
$perms = implode( ',', $perms );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_deletion_log', array(
|
||||
'dellog_content_permissions' => $perms
|
||||
), array( "dellog_content_container_id=? AND dellog_content_container_class=?", $id, $class ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user