Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
+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
|
||||
|
||||
Reference in new issue
Block a user