Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Base mutator class for nodes
|
||||
* @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 9 Nov 2018
|
||||
*/
|
||||
|
||||
namespace IPS\Node\Api\GraphQL;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Base mutator class for nodes
|
||||
*/
|
||||
class _NodeMutator
|
||||
{
|
||||
/**
|
||||
* Mark a node as read
|
||||
*
|
||||
* @param int $reactionID ID of reaction to add
|
||||
* @param \IPS\Content\Comment $comment The comment to add a reaction on
|
||||
* @return void
|
||||
*/
|
||||
protected function _markRead( $node )
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'NOT_LOGGED_IN', 'GQL/0004/1', 403 );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$itemClass = $node::$contentItemClass;
|
||||
$itemClass::markContainerRead( $node );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_NODE', 'GQL/0004/2', 403 );
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Base class for Nodes
|
||||
* @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 28 Aug 2018
|
||||
*/
|
||||
|
||||
namespace IPS\Node\Api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Base class for Nodes
|
||||
*/
|
||||
class _NodeType extends ObjectType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $nodeClass = '\IPS\Node\Model';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'core_Node';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'A generic node';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$config = [
|
||||
'name' => static::$typeName,
|
||||
'description' => static::$typeDescription,
|
||||
'fields' => function () {
|
||||
return $this->fields();
|
||||
}
|
||||
];
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields that this type supports
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
return array(
|
||||
'id' => [
|
||||
'type' => TypeRegistry::id(),
|
||||
'resolve' => function ($node) {
|
||||
return $node->_id;
|
||||
}
|
||||
],
|
||||
'name' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($node) {
|
||||
return $node->getTitleForLanguage( \IPS\Member::loggedIn()->language() );
|
||||
}
|
||||
],
|
||||
'url' => [
|
||||
'type' => TypeRegistry::url(),
|
||||
'resolve' => function ($node) {
|
||||
return $node->url();
|
||||
}
|
||||
],
|
||||
'itemCount' => [
|
||||
'type' => TypeRegistry::int(),
|
||||
'resolve' => function ($node) {
|
||||
return static::$nodeClass::$contentItemClass::contentCount($node, TRUE, FALSE);
|
||||
}
|
||||
],
|
||||
'commentCount' => [
|
||||
'type' => TypeRegistry::int(),
|
||||
'resolve' => function ($node) {
|
||||
return static::$nodeClass::$contentItemClass::contentCount($node, FALSE, TRUE);
|
||||
}
|
||||
],
|
||||
'children' => [
|
||||
'type' => TypeRegistry::listOf( $this ),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return static::children($node, $args, $context);
|
||||
}
|
||||
],
|
||||
'hasUnread' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($node) {
|
||||
return static::$nodeClass::$contentItemClass::containerUnread( $node );
|
||||
}
|
||||
],
|
||||
'items' => [
|
||||
'type' => TypeRegistry::listOf( static::getItemType() ),
|
||||
'args' => static::getItemType()::args(),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return static::items($node, $args);
|
||||
}
|
||||
],
|
||||
'follow' => [
|
||||
'type' => TypeRegistry::follow(),
|
||||
'resolve' => function ($node) {
|
||||
if( isset( static::$followData ) && \is_array( static::$followData ) ){
|
||||
return array_merge( static::$followData, array(
|
||||
'id' => $node->_id,
|
||||
'node' => $node,
|
||||
'nodeClass' => static::$nodeClass
|
||||
));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
],
|
||||
'nodePermissions' => [
|
||||
'type' => new ObjectType([
|
||||
'name' => static::$typeName . '_nodePermissions',
|
||||
'fields' => static::getNodePermissionFields()
|
||||
]),
|
||||
'resolve' => function ($node) {
|
||||
return $node;
|
||||
}
|
||||
],
|
||||
'uploadPermissions' => [
|
||||
'type' => \IPS\core\api\GraphQL\TypeRegistry::attachmentPermissions(),
|
||||
'args' => [
|
||||
'postKey' => TypeRegistry::nonNull( TypeRegistry::string() ),
|
||||
],
|
||||
'resolve' => function( $node, $args, $context ) {
|
||||
return array( 'postKey' => $args['postKey'] );
|
||||
}
|
||||
],
|
||||
'tagPermissions' => \IPS\Api\GraphQL\Fields\TagsEditField::getDefinition(static::$typeName . '_tags')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comment type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
{
|
||||
return \IPS\Content\Api\GraphQL\TypeRegistry::item();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field config for the node permissions query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getNodePermissionFields()
|
||||
{
|
||||
return array(
|
||||
'canCreate' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return $node->can('add', \IPS\Member::loggedIn(), FALSE);
|
||||
}
|
||||
],
|
||||
'itemsRequireApproval' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return static::$nodeClass::$contentItemClass::moderateNewItems( \IPS\Member::loggedIn(), $node, FALSE );
|
||||
}
|
||||
],
|
||||
'commentsRequireApproval' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return null;
|
||||
//return static::$nodeClass::$contentItemClass::moderateNewComments( \IPS\Member::loggedIn(), FALSE );
|
||||
}
|
||||
],
|
||||
'reviewsRequireApproval' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($node, $args, $context) {
|
||||
return null;
|
||||
//return static::$nodeClass::$contentItemClass::moderateNewReviews( \IPS\Member::loggedIn(), FALSE );
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve children field
|
||||
*
|
||||
* @param \IPS\Node\Model
|
||||
* @return array
|
||||
*/
|
||||
protected static function children($node, $args, $context)
|
||||
{
|
||||
return $node->children('view');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the topics field
|
||||
*
|
||||
* @param \IPS\forums\Forum
|
||||
* @param array Arguments passed to this resolver
|
||||
* @return array
|
||||
*/
|
||||
protected static function items($node, $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if( $args['orderBy'] === NULL )
|
||||
{
|
||||
$orderBy = $node->_sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$orderBy = static::$nodeClass::$contentItemClass::$databaseColumnMap[ $args['orderBy'] ];
|
||||
}
|
||||
|
||||
if( $args['orderBy'] === 'last_comment' )
|
||||
{
|
||||
$orderBy = \is_array( $orderBy ) ? array_pop( $orderBy ) : $orderBy;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$orderBy = 'title';
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$sortBy = "{$orderBy} {$args['orderDir']}";
|
||||
$class = static::$nodeClass::$contentItemClass;
|
||||
|
||||
// Container
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=?', $node->_id );
|
||||
|
||||
if( $args['honorPinned'] )
|
||||
{
|
||||
$column = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['pinned'];
|
||||
$sortBy = "{$column} DESC, {$sortBy}";
|
||||
}
|
||||
|
||||
$offset = max( $args['offset'], 0 );
|
||||
$limit = min( $args['limit'], 50 );
|
||||
|
||||
return $class::getItemsWithPermission( $where, $sortBy, array( $offset, $limit ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Type registry for \IPS\Node types
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 29 Aug 2018
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Node\Api\GraphQL;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* \IPS\Node base types
|
||||
*/
|
||||
class _TypeRegistry
|
||||
{
|
||||
protected static $node;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Defined to suppress static warnings
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommentType
|
||||
*/
|
||||
public static function node()
|
||||
{
|
||||
return self::$node ?: (self::$node = new \IPS\Node\Api\GraphQL\NodeType());
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Node\Api;
|
||||
|
||||
/* 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;
|
||||
@@ -32,7 +32,7 @@ class _NodeController extends \IPS\Api\Controller
|
||||
{
|
||||
$class = $this->class;
|
||||
|
||||
if ( $this->member and in_array( 'IPS\Node\Permissions', class_implements( $class ) ) )
|
||||
if ( $this->member and \in_array( 'IPS\Node\Permissions', class_implements( $class ) ) )
|
||||
{
|
||||
$where[] = array( '(' . \IPS\Db::i()->findInSet( 'core_permission_index.perm_' . $class::$permissionMap['view'], $this->member->permissionArray() ) . ' OR ' . 'core_permission_index.perm_' . $class::$permissionMap['view'] . '=? )', '*' );
|
||||
if ( $class::$databaseColumnEnabledDisabled )
|
||||
@@ -40,9 +40,17 @@ class _NodeController extends \IPS\Api\Controller
|
||||
$where[] = array( $class::$databasePrefix . $class::$databaseColumnEnabledDisabled . '=1' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Exclude clubs? */
|
||||
if ( \IPS\IPS::classUsesTrait( $class, 'IPS\Content\ClubContainer' ) AND isset( \IPS\Request::i()->clubs ) AND !\IPS\Request::i()->clubs )
|
||||
{
|
||||
$where[] = array( $class::$databasePrefix . $class::clubIdColumn() . ' IS NULL' );
|
||||
}
|
||||
|
||||
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, $where, $class::$databaseColumnOrder ? $class::$databasePrefix . $class::$databaseColumnOrder . " asc" : NULL, NULL, NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
|
||||
if ( $this->member and in_array( 'IPS\Node\Permissions', class_implements( $class ) ) )
|
||||
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, $where, $class::$databaseColumnOrder ? $class::$databasePrefix . $class::$databaseColumnOrder . " asc" : NULL );
|
||||
|
||||
/* Return permissions */
|
||||
if ( \in_array( 'IPS\Node\Permissions', class_implements( $class ) ) )
|
||||
{
|
||||
$select->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . $class::$databaseTable . "." . $class::$databasePrefix . $class::$databaseColumnId, $class::$permApp, $class::$permType ) );
|
||||
}
|
||||
@@ -53,7 +61,7 @@ class _NodeController extends \IPS\Api\Controller
|
||||
$select,
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
$class,
|
||||
$select->count( TRUE ),
|
||||
$select->count(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
);
|
||||
@@ -81,17 +89,50 @@ class _NodeController extends \IPS\Api\Controller
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 1S359/1 INVALID_ID The member ID does not exist
|
||||
* @param int $id ID Number
|
||||
* @param int|NULL $deleteChildrenOrMove -1 to delete all child nodes, or the new parent node ID to move the children to
|
||||
* @throws 1S359/1 INVALID_ID The node ID does not exist
|
||||
* @throws 1S359/2 INVALID_TARGET The target node cannot be deleted because the new parent node does not exist
|
||||
* @throws 1S359/3 HAS_CHILDREN The target node cannot be deleted because it has children (pass deleteChildrenOrMove in the request to specify how to handle the children)
|
||||
* @return \IPS\Api\Response
|
||||
*/
|
||||
protected function _delete( $id )
|
||||
protected function _delete( $id, $deleteChildrenOrMove = NULL )
|
||||
{
|
||||
$class = $this->class;
|
||||
|
||||
try
|
||||
{
|
||||
$class::load( $id )->delete();
|
||||
$node = $class::load( $id );
|
||||
|
||||
if ( $node->hasChildren( NULL, NULL, TRUE ) )
|
||||
{
|
||||
/* -1 means delete everything */
|
||||
if ( $deleteChildrenOrMove AND $deleteChildrenOrMove == -1 )
|
||||
{
|
||||
$node->deleteOrMoveFormSubmit( array( 'node_move_children' => FALSE ) );
|
||||
}
|
||||
else if ( $deleteChildrenOrMove )
|
||||
{
|
||||
try
|
||||
{
|
||||
$target = $class::load( $deleteChildrenOrMove );
|
||||
$node->deleteOrMoveFormSubmit( array( 'node_move_children' => TRUE, 'node_destination' => $target->_id ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_TARGET', '1S359/2', 404 );
|
||||
}
|
||||
}
|
||||
/* Or return an exception if no action was set */
|
||||
if ( !$deleteChildrenOrMove )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'HAS_CHILDREN', '1S359/3', 404 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$node->delete();
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, NULL );
|
||||
}
|
||||
@@ -111,6 +152,25 @@ class _NodeController extends \IPS\Api\Controller
|
||||
{
|
||||
$node->save();
|
||||
|
||||
if( $node instanceof \IPS\Node\Permissions AND isset( \IPS\Request::i()->permissions ) AND \IPS\Request::i()->permissions )
|
||||
{
|
||||
$insert = array(
|
||||
'app' => $node::$permApp,
|
||||
'perm_type' => $node::$permType,
|
||||
'perm_type_id' => $node->_id,
|
||||
);
|
||||
|
||||
foreach( $node::$permissionMap as $key => $field )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->permissions[ $key ] ) )
|
||||
{
|
||||
$insert[ 'perm_' . $field ] = \is_array( \IPS\Request::i()->permissions[ $key ] ) ? implode( ',', \IPS\Request::i()->permissions[ $key ] ) : \IPS\Request::i()->permissions[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$node->setPermissions( $insert );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $node;
|
||||
}
|
||||
|
||||
Whitespace-only changes.
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Node;
|
||||
|
||||
/* 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;
|
||||
@@ -132,13 +132,14 @@ trait Colorize
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param bool $escape If the title should be escaped for HTML output. If FALSE, the feature color will not be used, because that requires HTML output
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public static function titleFromIndexData( $indexData, $itemData, $containerData )
|
||||
public static function titleFromIndexData( $indexData, $itemData, $containerData, $escape = TRUE )
|
||||
{
|
||||
if ( ! isset( $containerData[ static::$databasePrefix . static::$featureColumnName ] ) )
|
||||
if ( !$escape or !isset( $containerData[ static::$databasePrefix . static::$featureColumnName ] ) )
|
||||
{
|
||||
return parent::titleFromIndexData( $indexData, $itemData, $containerData );
|
||||
return parent::titleFromIndexData( $indexData, $itemData, $containerData, $escape );
|
||||
}
|
||||
|
||||
$node = $containerData;
|
||||
|
||||
+236
-157
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Node;
|
||||
|
||||
/* 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;
|
||||
@@ -194,7 +194,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$id = ( $node instanceof $nodeClass ) ? $node->_id : "s.{$node->_id}";
|
||||
$class = get_class( $node );
|
||||
$class = \get_class( $node );
|
||||
|
||||
$buttons = $node->getButtons( $this->url, !( $node instanceof $this->nodeClass ) );
|
||||
if ( isset( \IPS\Request::i()->searchResult ) and isset( $buttons['edit'] ) )
|
||||
@@ -594,13 +594,14 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( $multiRedirectUrl,
|
||||
function( $doneSoFar ) use ( $nodeClass )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, \IPS\Request::i()->nodes == 0 ? NULL : \IPS\Db::i()->in( $nodeClass::$databasePrefix . $nodeClass::$databaseColumnId, explode( ',',\IPS\Request::i()->nodes) ), $nodeClass::$databasePrefix . $nodeClass::$databaseColumnId, array( $doneSoFar, 50 ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
|
||||
$count = $select->count( TRUE );
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', $nodeClass::$databaseTable, \IPS\Request::i()->nodes == 0 ? NULL : \IPS\Db::i()->in( $nodeClass::$databasePrefix . $nodeClass::$databaseColumnId, explode( ',',\IPS\Request::i()->nodes) ) )->first();
|
||||
if ( !$count )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$select = \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, \IPS\Request::i()->nodes == 0 ? NULL : \IPS\Db::i()->in( $nodeClass::$databasePrefix . $nodeClass::$databaseColumnId, explode( ',',\IPS\Request::i()->nodes) ), $nodeClass::$databasePrefix . $nodeClass::$databaseColumnId, array( $doneSoFar, 50 ) );
|
||||
|
||||
$did = 0;
|
||||
foreach ( $select as $row )
|
||||
{
|
||||
@@ -616,7 +617,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
$k = preg_replace( '#^' . preg_quote( $nodeClass::$databasePrefix, '#' ) . '#', "", $k );
|
||||
$val = $_node->$k;
|
||||
|
||||
if( is_array( $v ) )
|
||||
if( \is_array( $v ) )
|
||||
{
|
||||
foreach( $v as $_k => $_v )
|
||||
{
|
||||
@@ -675,6 +676,8 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function enableToggle()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Work out which class we're using */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( mb_substr( \IPS\Request::i()->id, 0, 2 ) === 's.' )
|
||||
@@ -714,7 +717,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
$this->logToggleAndRedirect( $node );
|
||||
$this->_logToggleAndRedirect( $node );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -723,7 +726,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
* @param \IPS\Node\Model $node The node we are working with
|
||||
* @return void
|
||||
*/
|
||||
public function logToggleAndRedirect( $node )
|
||||
public function _logToggleAndRedirect( $node )
|
||||
{
|
||||
/* Log */
|
||||
if ( $node->_enabled )
|
||||
@@ -780,6 +783,13 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
$form->ajaxOutput = TRUE;
|
||||
}
|
||||
} ) );
|
||||
|
||||
/* A multiredirect has been initiated so we need to let the code flow to the MR helper below, but check CSRF key first */
|
||||
if( \IPS\Request::i()->node_copy_children )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
}
|
||||
|
||||
if ( $values = $form->values() OR \IPS\Request::i()->node_copy_children )
|
||||
{
|
||||
/* Copy Children */
|
||||
@@ -793,7 +803,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
function( $data ) use ( $node, $nodeClass )
|
||||
{
|
||||
/* Init */
|
||||
if ( !is_array( $data ) )
|
||||
if ( !\is_array( $data ) )
|
||||
{
|
||||
return array( array( 'copy' => array( array( 'id' => $node->_id, 'subnode' => 0 ) ), 'ids' => array() ), \IPS\Member::loggedIn()->language()->addToStack('copying') );
|
||||
}
|
||||
@@ -818,12 +828,12 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Copy it */
|
||||
$new = clone $item;
|
||||
$data['ids'][ get_class( $item ) ][ $item->_id ] = $new->_id;
|
||||
$data['ids'][ \get_class( $item ) ][ $item->_id ] = $new->_id;
|
||||
|
||||
/* Update it's parent */
|
||||
if ( $item->parent() )
|
||||
{
|
||||
if ( array_key_exists( $item->parent()->_id, $data['ids'][ get_class( $item->parent() ) ] ) )
|
||||
if ( array_key_exists( $item->parent()->_id, $data['ids'][ \get_class( $item->parent() ) ] ) )
|
||||
{
|
||||
$parentColumn = $nodeClass::$databaseColumnParent;
|
||||
if ( $itemData['subnode'] )
|
||||
@@ -831,7 +841,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
$parentColumn = $nodeClass::$parentNodeColumnId;
|
||||
}
|
||||
|
||||
$new->$parentColumn = $data['ids'][ get_class( $item->parent() ) ][ $item->parent()->_id ];
|
||||
$new->$parentColumn = $data['ids'][ \get_class( $item->parent() ) ][ $item->parent()->_id ];
|
||||
$new->save();
|
||||
}
|
||||
}
|
||||
@@ -871,6 +881,10 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
}
|
||||
|
||||
/* Copy it */
|
||||
$new = clone $node;
|
||||
@@ -894,7 +908,9 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
* @return void
|
||||
*/
|
||||
protected function reorder()
|
||||
{
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Init */
|
||||
$nodeClass = $this->nodeClass;
|
||||
|
||||
@@ -929,7 +945,9 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( mb_substr( $id, 0, 2 ) === 's.' )
|
||||
{
|
||||
$node = call_user_func( array( $nodeClass::$subnodeClass, 'load' ), mb_substr( $id, 2 ) );
|
||||
$subnodeClass = $nodeClass::$subnodeClass;
|
||||
|
||||
$node = $subnodeClass::load( mb_substr( $id, 2 ) );
|
||||
$parentColumn = $node::$parentNodeColumnId;
|
||||
}
|
||||
else
|
||||
@@ -958,14 +976,15 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Do it */
|
||||
if ( $parentColumn )
|
||||
{
|
||||
if ( is_numeric( $parent ) and $node->$idColumn == $parent AND !isset( $nodeClass::$subnodeClass ) )
|
||||
if ( \is_numeric( $parent ) and $node->$idColumn == $parent AND !isset( $nodeClass::$subnodeClass ) )
|
||||
{
|
||||
/* It is attempting to assign a parent ID of itself which will break the tree */
|
||||
$parent = $nodeClass::$databaseColumnParentRootValue;
|
||||
}
|
||||
|
||||
$node->$parentColumn = ( $parent === 'null' ) ? 0 : is_numeric( $parent ) ? $parent : $nodeClass::$databaseColumnParentRootValue;
|
||||
|
||||
$node->$parentColumn = ( $parent === 'null' ) ? $nodeClass::$databaseColumnParentRootValue : ( \is_numeric( $parent ) ? $parent : $nodeClass::$databaseColumnParentRootValue );
|
||||
}
|
||||
|
||||
$node->$orderColumn = $position;
|
||||
$node->save();
|
||||
}
|
||||
@@ -1112,17 +1131,17 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
$groupId = mb_substr( $key, 0, -( 2 + mb_strlen( $k ) ) );
|
||||
$disabled = FALSE;
|
||||
|
||||
if ( array_key_exists( $groupId, $disabledPermissions ) and is_array( $disabledPermissions[ $groupId ] ) )
|
||||
if ( array_key_exists( $groupId, $disabledPermissions ) and \is_array( $disabledPermissions[ $groupId ] ) )
|
||||
{
|
||||
$disabled = in_array( $v, array_values( $disabledPermissions[ $groupId ] ) );
|
||||
$disabled = \in_array( $v, array_values( $disabledPermissions[ $groupId ] ) );
|
||||
}
|
||||
|
||||
if ( $disabled === FALSE )
|
||||
{
|
||||
$disabled = ( $groupId == \IPS\Settings::i()->guest_group AND in_array( $k, array('review', 'rate' ) ) ) ? TRUE : FALSE;
|
||||
$disabled = ( $groupId == \IPS\Settings::i()->guest_group AND \in_array( $k, array('review', 'rate' ) ) ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
$fieldValue = ( isset( $current[ "perm_{$v}" ] ) and ( $current[ "perm_{$v}" ] === '*' or in_array( $groupId, explode( ',', $current[ "perm_{$v}" ] ) ) ) );
|
||||
$fieldValue = ( isset( $current[ "perm_{$v}" ] ) and ( $current[ "perm_{$v}" ] === '*' or \in_array( $groupId, explode( ',', $current[ "perm_{$v}" ] ) ) ) );
|
||||
|
||||
return new \IPS\Helpers\Form\Checkbox( $key, ( $disabled ? 0 : $fieldValue ), NULL, array( 'disabled' => $disabled ) );
|
||||
};
|
||||
@@ -1170,7 +1189,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach ( $nodeClass::$permissionMap as $k => $v )
|
||||
{
|
||||
if ( isset( $perms[ $k ] ) and $perms[ $k ] and is_array( $_perms[ $v ] ) )
|
||||
if ( isset( $perms[ $k ] ) and $perms[ $k ] and \is_array( $_perms[ $v ] ) )
|
||||
{
|
||||
$_perms[ $v ][] = $group;
|
||||
}
|
||||
@@ -1180,11 +1199,11 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Finalise */
|
||||
foreach ( $_perms as $k => $v )
|
||||
{
|
||||
$insert[ "perm_{$k}" ] = is_array( $v ) ? implode( $v, ',' ) : $v;
|
||||
$insert[ "perm_{$k}" ] = \is_array( $v ) ? implode( ',', $v ) : $v;
|
||||
}
|
||||
|
||||
/* Set the permissions */
|
||||
$node->setPermissions( $insert, $matrix );
|
||||
$node->setPermissions( $insert );
|
||||
|
||||
unset(\IPS\Data\Store::i()->modules);
|
||||
|
||||
@@ -1238,10 +1257,22 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Do we have any children or content? */
|
||||
if ( $node->hasChildren( NULL, NULL, TRUE ) or $node->showDeleteOrMoveForm() or isset( \IPS\Request::i()->ajaxValidate ) )
|
||||
{
|
||||
$form = $node->deleteOrMoveForm( FALSE, TRUE );
|
||||
$form = $node->deleteOrMoveForm( FALSE );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$node->deleteOrMoveFormSubmit( $values );
|
||||
$node->deleteOrMoveFormSubmit( $values );
|
||||
|
||||
if ( isset( $values['node_move_children'] ) AND $values['node_move_children'] )
|
||||
{
|
||||
$moveToId = ( isset( $values['node_destination'] ) ) ? $values['node_destination'] : \IPS\Request::i()->node_move_children;
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted_m', array( $this->title => TRUE, $node->titleForLog() => FALSE, $node::load( $moveToId )->titleForLog() => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted_c', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
}
|
||||
else
|
||||
@@ -1315,122 +1346,18 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Build Wizard */
|
||||
\IPS\Output::i()->title = $node->_title;
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\Wizard(
|
||||
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard(
|
||||
array(
|
||||
'node_mass_content_form' => function( $data ) use( $nodeClass, $node, $contentItemClass )
|
||||
{
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form( 'delete_node_form', 'continue', $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id, '_step' => 'node_mass_content_form' ) ) );
|
||||
$form->addHeader('node_mass_move_delete_if');
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'node_move_author', isset( $data['additional']['author'] ) ? array_map( function( $id ) {
|
||||
return \IPS\Member::load( $id );
|
||||
}, $data['additional']['author'] ) : NULL, FALSE, array( 'nullLang' => 'node_mass_move_anyone', 'multiple' => NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_date', isset( $data['additional']['date'] ) ? $data['additional']['date'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
if ( isset( $contentItemClass::$commentClass ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'node_move_comments', isset( $data['additional']['num_comments'] ) ? $data['additional']['num_comments'] : -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, NULL, 'node_move_comments_less' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_last_post', isset( $data['additional']['last_post'] ) ? $data['additional']['last_post'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Lockable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_state', isset( $data['additional']['state'] ) ? $data['additional']['state'] : 'any', FALSE, array( 'options' => array( 'locked' => 'locked', 'open' => 'unlocked', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Pinnable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_pinned', isset( $data['additional']['pinned'] ) ? $data['additional']['pinned'] : 'any', FALSE, array( 'options' => array( '1' => 'pinned', '0' => 'node_move_pinned_not_pinned', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Featurable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_featured', isset( $data['additional']['featured'] ) ? $data['additional']['featured'] : 'any', FALSE, array( 'options' => array( '1' => 'featured', '0' => 'node_move_pinned_not_featured', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
$form->addHeader('node_mass_move_delete_then');
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'node_move_content', isset( $data['moveTo'] ) ? call_user_func( array( $data['moveToClass'], 'load' ), $data['moveTo'] ) : 0, TRUE, array( 'class' => $nodeClass, 'disabled' => array( $node->_id ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
return array_key_exists( 'add', $node->permissionTypes() );
|
||||
} ) ) );
|
||||
/* Fetch the form to mass move content - abstracted so other apps can adjust if necessary */
|
||||
$form = new \IPS\Helpers\Form( 'delete_node_form', 'continue', $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id, 'subnode' => \IPS\Request::i()->subnode, '_step' => 'node_mass_content_form' ) ) );
|
||||
$form = $this->_buildMassMoveForm( $form, $data, $nodeClass, $node, $contentItemClass );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$data['deleteWhenDone'] = FALSE;
|
||||
$data['class'] = get_class( $node );
|
||||
$data['id'] = $node->_id;
|
||||
|
||||
if ( is_object( $values['node_move_content'] ) )
|
||||
{
|
||||
$data['moveToClass'] = get_class( $values['node_move_content'] );
|
||||
$data['moveTo'] = $values['node_move_content']->_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['moveToClass'] );
|
||||
unset( $data['moveTo'] );
|
||||
}
|
||||
|
||||
if ( count( $values['node_move_author'] ) )
|
||||
{
|
||||
$data['additional']['author'] = array_keys( $values['node_move_author'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['author'] );
|
||||
}
|
||||
|
||||
if ( $values['node_move_date'] )
|
||||
{
|
||||
$data['additional']['date'] = $values['node_move_date']->setTime( 23, 59, 59 )->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['date'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_comments'] ) and $values['node_move_comments'] > -1 )
|
||||
{
|
||||
$data['additional']['num_comments'] = $values['node_move_comments'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['num_comments'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_last_post'] ) and $values['node_move_last_post'] )
|
||||
{
|
||||
$data['additional']['last_post'] = $values['node_move_last_post']->setTime( 23, 59, 59 )->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['last_post'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_state'] ) and $values['node_move_state'] != 'any' )
|
||||
{
|
||||
$data['additional']['state'] = $values['node_move_state'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['state'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_pinned'] ) and $values['node_move_pinned'] != 'any' )
|
||||
{
|
||||
$data['additional']['pinned'] = $values['node_move_pinned'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['pinned'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_featured'] ) and $values['node_move_featured'] != 'any' )
|
||||
{
|
||||
$data['additional']['featured'] = $values['node_move_featured'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['featured'] );
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $this->_processMassMoveForm( $values, $data, $nodeClass, $node, $contentItemClass );
|
||||
}
|
||||
|
||||
/* Display Form */
|
||||
@@ -1438,33 +1365,185 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'node_mass_content_confirm' => function( $data ) use ( $node, $contentItemClass )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', $data );
|
||||
|
||||
if ( isset( $data['moveTo'] ) )
|
||||
{
|
||||
$newNode = $data['moveToClass']::load( $data['moveTo'] );
|
||||
\IPS\Session::i()->log( 'acplog__node_mass_move', array( $this->title => TRUE, $node->titleForLog() => FALSE, $newNode->titleForLog() => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'node_mass_content_moving' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__node_mass_delete', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'node_mass_content_deleting' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$number = $node->getContentItems( NULL, NULL, $node->massMoveorDeleteWhere( $data ), TRUE );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->nodeMoveDeleteContent( $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id ) ), \IPS\Member::loggedIn()->language()->addToStack( $contentItemClass::$title . '_pl_lc' ), $number, isset( $data['moveTo'] ) ? call_user_func( array( $data['moveToClass'], 'load' ), $data['moveTo'] ) : NULL );
|
||||
}
|
||||
return $this->_performMassMove( $data, $node, $contentItemClass );
|
||||
}
|
||||
),
|
||||
$this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id ) )
|
||||
$this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id, 'subnode' => \IPS\Request::i()->subnode ) )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form to mass move content
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form helper object
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
protected function _buildMassMoveForm( $form, $data, $nodeClass, $node, $contentItemClass )
|
||||
{
|
||||
$form->addHeader('node_mass_move_delete_if');
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'node_move_author', isset( $data['additional']['author'] ) ? array_map( function( $id ) {
|
||||
return \IPS\Member::load( $id );
|
||||
}, $data['additional']['author'] ) : NULL, FALSE, array( 'nullLang' => 'node_mass_move_anyone', 'multiple' => NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_date', isset( $data['additional']['date'] ) ? $data['additional']['date'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
if ( isset( $contentItemClass::$commentClass ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'node_move_comments', isset( $data['additional']['num_comments'] ) ? $data['additional']['num_comments'] : -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, NULL, 'node_move_comments_less' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'node_move_last_post', isset( $data['additional']['last_post'] ) ? $data['additional']['last_post'] : 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'node_mass_move_any_time' ) ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Lockable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_state', isset( $data['additional']['state'] ) ? $data['additional']['state'] : 'any', FALSE, array( 'options' => array( 'locked' => 'locked', 'open' => 'unlocked', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_pinned', isset( $data['additional']['pinned'] ) ? $data['additional']['pinned'] : 'any', FALSE, array( 'options' => array( '1' => 'pinned', '0' => 'node_move_pinned_not_pinned', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $contentItemClass ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'node_move_featured', isset( $data['additional']['featured'] ) ? $data['additional']['featured'] : 'any', FALSE, array( 'options' => array( '1' => 'featured', '0' => 'node_move_pinned_not_featured', 'any' => 'node_mass_move_either' ) ) ) );
|
||||
}
|
||||
$form->addHeader('node_mass_move_delete_then');
|
||||
$moveToClass = isset( $data['moveToClass'] ) ? $data['moveToClass'] : $nodeClass;
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'node_move_content', isset( $data['moveTo'] ) ? $moveToClass::load( $data['moveTo'] ) : 0, TRUE, array( 'class' => $nodeClass, 'disabledIds' => array( $node->_id ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
return array_key_exists( 'add', $node->permissionTypes() );
|
||||
} ) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the mass move form submission
|
||||
*
|
||||
* @param array $values Values from form submission
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return array Wizard helper data
|
||||
*/
|
||||
protected function _processMassMoveForm( $values, $data, $nodeClass, $node, $contentItemClass )
|
||||
{
|
||||
$data['deleteWhenDone'] = FALSE;
|
||||
$data['class'] = \get_class( $node );
|
||||
$data['id'] = $node->_id;
|
||||
|
||||
if ( \is_object( $values['node_move_content'] ) )
|
||||
{
|
||||
$data['moveToClass'] = \get_class( $values['node_move_content'] );
|
||||
$data['moveTo'] = $values['node_move_content']->_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['moveToClass'] );
|
||||
unset( $data['moveTo'] );
|
||||
}
|
||||
|
||||
if ( \count( $values['node_move_author'] ) )
|
||||
{
|
||||
$data['additional']['author'] = array_keys( $values['node_move_author'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['author'] );
|
||||
}
|
||||
|
||||
if ( $values['node_move_date'] )
|
||||
{
|
||||
$data['additional']['date'] = $values['node_move_date']->setTime( 23, 59, 59 )->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['date'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_comments'] ) and $values['node_move_comments'] > -1 )
|
||||
{
|
||||
$data['additional']['num_comments'] = $values['node_move_comments'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['num_comments'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_last_post'] ) and $values['node_move_last_post'] )
|
||||
{
|
||||
$data['additional']['last_post'] = $values['node_move_last_post']->setTime( 23, 59, 59 )->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['last_post'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_state'] ) and $values['node_move_state'] != 'any' )
|
||||
{
|
||||
$data['additional']['state'] = $values['node_move_state'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['state'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_pinned'] ) and $values['node_move_pinned'] != 'any' )
|
||||
{
|
||||
$data['additional']['pinned'] = $values['node_move_pinned'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['pinned'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['node_move_featured'] ) and $values['node_move_featured'] != 'any' )
|
||||
{
|
||||
$data['additional']['featured'] = $values['node_move_featured'];
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $data['additional']['featured'] );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually perform the mass move operation (called from the wizard helper)
|
||||
*
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param \IPS\Node\Mode $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _performMassMove( $data, $node, $contentItemClass )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', $data );
|
||||
|
||||
if ( isset( $data['moveTo'] ) )
|
||||
{
|
||||
$newNode = $data['moveToClass']::load( $data['moveTo'] );
|
||||
\IPS\Session::i()->log( 'acplog__node_mass_move', array( $this->title => TRUE, $node->titleForLog() => FALSE, $newNode->titleForLog() => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'node_mass_content_moving' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__node_mass_delete', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'node_mass_content_deleting' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$number = $node->getContentItems( NULL, NULL, $node->massMoveorDeleteWhere( $data ), TRUE );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->nodeMoveDeleteContent( $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id, 'subnode' => \IPS\Request::i()->subnode ) )->csrf(), \IPS\Member::loggedIn()->language()->addToStack( $contentItemClass::$title . '_pl_lc' ), $number, isset( $data['moveTo'] ) ? $data['moveToClass']::load( $data['moveTo'] ) : NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
|
||||
+557
-193
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Node;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Node;
|
||||
|
||||
/* 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;
|
||||
|
||||
Reference in new issue
Block a user