Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
@@ -300,4 +300,157 @@ class _entry extends \IPS\Content\Controller
|
||||
{
|
||||
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Move
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function move()
|
||||
{
|
||||
try
|
||||
{
|
||||
$item = \IPS\blog\Entry::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
if ( !$item->canMove() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
|
||||
$container = $item->container();
|
||||
|
||||
$wizard = new \IPS\Helpers\Wizard( array(
|
||||
'blog' => function( $data ) use ( $container ) {
|
||||
$data['item'] = \IPS\Request::i()->id;
|
||||
$item = \IPS\blog\Entry::loadAndCheckPerms( $data['item'] );
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to', NULL, TRUE, array(
|
||||
'class' => \get_class( $item->container() ),
|
||||
'permissionCheck' => function( $node ) use ( $item )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* If the item is in a club, only allow moving to other clubs that you moderate */
|
||||
if ( \IPS\IPS::classUsesTrait( $item->container(), 'IPS\Content\ClubContainer' ) and $item->container()->club() )
|
||||
{
|
||||
return $item::modPermission( 'move', \IPS\Member::loggedIn(), $node ) and $node->can( 'add' ) ;
|
||||
}
|
||||
|
||||
if ( $node->can( 'add' ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch( \OutOfBoundsException $e ) { }
|
||||
|
||||
return false;
|
||||
},
|
||||
'clubs' => TRUE
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$data['blog'] = $values['move_to'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $form;
|
||||
},
|
||||
'category' => function( $data ) {
|
||||
$item = \IPS\blog\Entry::loadAndCheckPerms( $data['item'] );
|
||||
$newBlog = $data['blog'];
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
$categories = \IPS\blog\Entry\Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $newBlog->id ) );
|
||||
$choiceOptions = array( 0 => 'entry_category_choice_new' );
|
||||
$choiceToggles = array( 0 => array( 'blog_entry_new_category' ) );
|
||||
|
||||
if( \count( $categories ) )
|
||||
{
|
||||
$choiceOptions[1] = 'entry_category_choice_existing';
|
||||
$choiceToggles[1] = array( 'entry_category_id' );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'entry_category_choice', 0, FALSE, array(
|
||||
'options' => $choiceOptions,
|
||||
'toggles' => $choiceToggles
|
||||
) ) );
|
||||
|
||||
if( \count( $categories ) )
|
||||
{
|
||||
$options = array();
|
||||
foreach ( $categories as $category )
|
||||
{
|
||||
$options[ $category->id ] = $category->name;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'entry_category_id', NULL, FALSE, array( 'options' => $options, 'parse' => 'normal' ), NULL, NULL, NULL, "entry_category_id" ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'blog_entry_new_category', NULL, TRUE, array(), NULL, NULL, NULL, "blog_entry_new_category" ) );
|
||||
$this->moderationAlertField( $form, $item );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( $data['blog'] === NULL OR !$data['blog']->can( 'add' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_move_invalid', '1S136/L', 403, '' );
|
||||
}
|
||||
|
||||
/* If this item is read, we need to re-mark it as such after moving */
|
||||
if( $item instanceof \IPS\Content\ReadMarkers )
|
||||
{
|
||||
$unread = $item->unread();
|
||||
}
|
||||
|
||||
$item->move( $data['blog'], FALSE );
|
||||
|
||||
|
||||
if( $values['entry_category_choice'] == 1 and $values['entry_category_id'] )
|
||||
{
|
||||
$item->category_id = $values['entry_category_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$newCategory = new \IPS\blog\Entry\Category;
|
||||
$newCategory->name = $values['blog_entry_new_category'];
|
||||
$newCategory->seo_name = \IPS\Http\Url\Friendly::seoTitle( $values['blog_entry_new_category'] );
|
||||
|
||||
$newCategory->blog_id = $item->blog_id;
|
||||
$newCategory->save();
|
||||
|
||||
$item->category_id = $newCategory->id;
|
||||
}
|
||||
|
||||
$item->save();
|
||||
|
||||
/* Mark it as read */
|
||||
if( $item instanceof \IPS\Content\ReadMarkers and $unread == 0 )
|
||||
{
|
||||
$item->markRead( NULL, NULL, NULL, TRUE );
|
||||
}
|
||||
|
||||
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'] )
|
||||
{
|
||||
$item->sendModerationAlert($values, $item);
|
||||
}
|
||||
|
||||
\IPS\Session::i()->modLog( 'modlog__action_move', array( $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped( 'title' ) ?: ( method_exists( $item, 'item' ) ? $item->item()->mapped( 'title' ) : NULL ) => FALSE ), $item );
|
||||
|
||||
\IPS\Output::i()->redirect( $item->url() );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
), $item->url()->setQueryString( array( 'do' => 'move' ) ) );
|
||||
|
||||
$this->_setBreadcrumbAndTitle( $item );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'move_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\blog\Entry::$title ) ) ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->box( $wizard, array( 'ipsPad' ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/D', 403, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user