Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -13,6 +13,7 @@ namespace IPS\core\modules\admin\discovery;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\Content\Tag;
|
||||
use IPS\courses\Module as ModuleClass;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Helpers\Form;
|
||||
@@ -88,7 +89,10 @@ class tags extends Controller
|
||||
$start = $args[0][0] ?? 0;
|
||||
$limit = $args[0][1] ?? $this->_getRootsPerPage();
|
||||
|
||||
foreach( $nodeClass::roots( NULL, NULL, [], [ $start, $limit ] ) as $node )
|
||||
foreach( new ActiveRecordIterator(
|
||||
Db::i()->select( '*', Tag::$databaseTable, null, 'tag_recommended desc, tag_text', [ $start, $limit ] ),
|
||||
Tag::class
|
||||
) as $node )
|
||||
{
|
||||
$rows[ $node->_id ] = $this->_getRow($node);
|
||||
}
|
||||
@@ -248,7 +252,18 @@ class tags extends Controller
|
||||
'alphabetical' => true,
|
||||
'addTokenText' => Member::loggedIn()->language()->get( 'tags_optional' ),
|
||||
)
|
||||
] ) );
|
||||
], function( $val ){
|
||||
if( !empty( $val ) )
|
||||
{
|
||||
foreach( $val as $_v )
|
||||
{
|
||||
if( $_v == Request::i()->tag_merge_to )
|
||||
{
|
||||
throw new InvalidArgumentException( 'err__bad_tag_merge' );
|
||||
}
|
||||
}
|
||||
}
|
||||
} ) );
|
||||
|
||||
$form->add( new Text( 'tag_merge_to', null, true, [
|
||||
'autocomplete' => array(
|
||||
@@ -261,15 +276,7 @@ class tags extends Controller
|
||||
'maxItems' => 1,
|
||||
'addTokenText' => Member::loggedIn()->language()->get( 'tags_optional' ),
|
||||
)
|
||||
], function( $val ){
|
||||
if( $val )
|
||||
{
|
||||
if( in_array( $val, explode( "\n", Request::i()->tag_merge_from ) ) )
|
||||
{
|
||||
throw new InvalidArgumentException( 'err__bad_tag_merge' );
|
||||
}
|
||||
}
|
||||
} ) );
|
||||
] ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
@@ -284,10 +291,12 @@ class tags extends Controller
|
||||
$tag->totals = $data;
|
||||
$tag->save();
|
||||
|
||||
/* Queue the background task to update the tags */
|
||||
/* Queue the background task to update the tags */
|
||||
Task::queue( 'core', 'UpdateTaggedItems', [ 'tag' => $tag->text, 'new' => $values['tag_merge_to'], 'merge' => true ], 5, [ 'tag' ] );
|
||||
}
|
||||
|
||||
Session::i()->log( 'acplogs__tag_merge', [ implode( ", ", $values['tag_merge_from'] ) => false, $values['tag_merge_to'] => false ] );
|
||||
|
||||
Output::i()->redirect( $this->url, Member::loggedIn()->language()->addToStack( 'tag_merge_requested' ) );
|
||||
}
|
||||
|
||||
@@ -336,9 +345,31 @@ class tags extends Controller
|
||||
Tag::load( $tag, 'tag_text' )->delete();
|
||||
}
|
||||
|
||||
Session::i()->log( 'acplogs__tag_bulk_delete', [ implode( ", ", $values['tag_to_delete'] ) => false ] );
|
||||
|
||||
Output::i()->redirect( $this->url );
|
||||
}
|
||||
|
||||
Output::i()->output = (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark/unmark a tag as recommended
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function recommend() : void
|
||||
{
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$tag = Tag::load( Request::i()->id );
|
||||
$tag->recommended = !$tag->recommended;
|
||||
$tag->save();
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
|
||||
Output::i()->redirect( Url::internal( "app=core&module=discovery&controller=tags" ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user