Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
+209
-11
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Node Controller
|
||||
* @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
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Node;
|
||||
@@ -121,12 +120,21 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $nodeClass::canAddRoot() )
|
||||
{
|
||||
return array( 'add' => array(
|
||||
$add = array(
|
||||
'icon' => 'plus',
|
||||
'title' => 'add',
|
||||
'link' => $this->url->setQueryString( 'do', 'form' ),
|
||||
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') ) : array() )
|
||||
) );
|
||||
);
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
return array( 'add' => $add );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['add'] = ( array( 'primary' => true ) + $add );
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
@@ -270,7 +278,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Load the node being edited */
|
||||
try
|
||||
{
|
||||
$node = call_user_func( "{$nodeClass}::load", \IPS\Request::i()->id );
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
\IPS\Output::i()->title = $node->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -368,7 +376,7 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
$new = !$node->_id;
|
||||
if ( $new and isset( $node::$databaseColumnOrder ) )
|
||||
if ( $new and isset( $node::$databaseColumnOrder ) AND $node::$automaticPositionDetermination === TRUE )
|
||||
{
|
||||
$orderColumn = $node::$databaseColumnOrder;
|
||||
$node->$orderColumn = \IPS\Db::i()->select( 'MAX(' . $node::$databasePrefix . $orderColumn . ')', $node::$databaseTable )->first() + 1;
|
||||
@@ -1181,10 +1189,10 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
/* Do we have any children or content? */
|
||||
if ( $node->hasChildren( NULL, NULL, TRUE ) or $node->showDeleteOrMoveForm() )
|
||||
{
|
||||
$form = $node->deleteOrMoveForm();
|
||||
$form = $node->deleteOrMoveForm( FALSE, TRUE );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$node->deleteOrMoveFormSubmit( $values, \IPS\Request::i()->deleteNode );
|
||||
$node->deleteOrMoveFormSubmit( $values );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
}
|
||||
else
|
||||
@@ -1221,6 +1229,196 @@ class _Controller extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass Move/Delete Content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function massManageContent()
|
||||
{
|
||||
/* Get node */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
try
|
||||
{
|
||||
$node = call_user_func( "{$nodeClass}::load", \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S101/X', 404, '' );
|
||||
}
|
||||
|
||||
/* Permission check */
|
||||
if( !$node->canMassManageContent() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '2S101/Y', 403, '' );
|
||||
}
|
||||
|
||||
/* Is there any content? */
|
||||
if ( !isset( $nodeClass::$contentItemClass ) or !$node->getContentItemCount() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_mass_content_none', '2S101/Z' );
|
||||
}
|
||||
$contentItemClass = $nodeClass::$contentItemClass;
|
||||
|
||||
/* Build Wizard */
|
||||
\IPS\Output::i()->title = $node->_title;
|
||||
\IPS\Output::i()->output = 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() );
|
||||
} ) ) );
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Display Form */
|
||||
return (string) $form;
|
||||
},
|
||||
'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 );
|
||||
}
|
||||
}
|
||||
),
|
||||
$this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id ) )
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user