mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00

Conflicts: lib/Alchemy/Phrasea/Command/Developer/JavascriptBuilder.php lib/Alchemy/Phrasea/Controller/Prod/Basket.php lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php lib/classes/Exception/Feed/ItemNotFound.php lib/classes/Exception/Feed/PublisherNotFound.php lib/classes/Feed/Abstract.php lib/classes/Feed/Adapter.php lib/classes/Feed/Aggregate.php lib/classes/Feed/Collection.php lib/classes/Feed/CollectionInterface.php lib/classes/Feed/Entry/Adapter.php lib/classes/Feed/Entry/Collection.php lib/classes/Feed/Entry/Interface.php lib/classes/Feed/Entry/Item.php lib/classes/Feed/Entry/ItemInterface.php lib/classes/Feed/Interface.php lib/classes/Feed/Link.php lib/classes/Feed/LinkInterface.php lib/classes/Feed/Publisher/Adapter.php lib/classes/Feed/Publisher/Interface.php lib/classes/Feed/Token.php lib/classes/Feed/TokenAggregate.php lib/classes/Feed/XML/Abstract.php lib/classes/Feed/XML/Atom.php lib/classes/Feed/XML/Cooliris.php lib/classes/Feed/XML/Interface.php lib/classes/Feed/XML/RSS.php lib/classes/Feed/XML/RSS/ImageInterface.php lib/classes/http/request.php lib/classes/module/console/schedulerStart.php lib/classes/module/console/schedulerState.php lib/classes/module/console/schedulerStop.php lib/classes/module/console/taskState.php lib/classes/module/console/tasklist.php lib/classes/module/console/taskrun.php lib/classes/registry.php lib/classes/registryInterface.php lib/classes/set/order.php lib/classes/system/url.php lib/classes/task/Scheduler.php lib/classes/task/appboxAbstract.php lib/classes/task/databoxAbstract.php lib/classes/task/manager.php lib/classes/task/period/RecordMover.php lib/classes/task/period/apibridge.php lib/classes/task/period/archive.php lib/classes/task/period/cindexer.php lib/classes/task/period/emptyColl.php lib/classes/task/period/ftp.php lib/classes/task/period/ftpPull.php lib/classes/task/period/subdef.php lib/classes/task/period/test.php lib/classes/task/period/writemeta.php lib/conf.d/PhraseaFixture/AbstractWZ.php lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php lib/conf.d/PhraseaFixture/Lazaret/LoadOneFile.php lib/conf.d/PhraseaFixture/Story/LoadOneStory.php lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php lib/conf.d/PhraseaFixture/UsrLists/UsrList.php lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php
117 lines
2.6 KiB
PHP
117 lines
2.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Vocabulary\ControlProvider;
|
|
|
|
use Alchemy\Phrasea\Application;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Alchemy\Phrasea\Vocabulary\Term;
|
|
|
|
class UserProvider implements ControlProviderInterface
|
|
{
|
|
|
|
private $app;
|
|
|
|
public function __construct(Application $app)
|
|
{
|
|
$this->app = $app;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public static function getType()
|
|
{
|
|
return 'User';
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return type
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->app['translator']->trans('Users');
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param string $query
|
|
* @param \User_Adapter $for_user
|
|
* @param \databox $on_databox
|
|
* @return \Doctrine\Common\Collections\ArrayCollection
|
|
*/
|
|
public function find($query, \User_Adapter $for_user, \databox $on_databox = null)
|
|
{
|
|
$user_query = new \User_Query($this->app);
|
|
|
|
$users = $user_query
|
|
->like(\User_Query::LIKE_EMAIL, $query)
|
|
->like(\User_Query::LIKE_NAME, $query)
|
|
->like(\User_Query::LIKE_LOGIN, $query)
|
|
->like_match(\User_Query::LIKE_MATCH_OR)
|
|
->include_phantoms(true)
|
|
->on_bases_where_i_am($this->app['acl']->get($for_user), ['canadmin'])
|
|
->limit(0, 50)
|
|
->execute()->get_results();
|
|
|
|
$results = new ArrayCollection();
|
|
|
|
foreach ($users as $user) {
|
|
$results->add(
|
|
new Term($user->get_display_name(), '', $this, $user->get_id())
|
|
);
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param mixed $id
|
|
* @return boolean
|
|
*/
|
|
public function validate($id)
|
|
{
|
|
try {
|
|
\User_Adapter::getInstance($id, $this->app);
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param mixed $id
|
|
* @return string
|
|
*/
|
|
public function getValue($id)
|
|
{
|
|
$user = \User_Adapter::getInstance($id, $this->app);
|
|
|
|
return $user->get_display_name();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param mixed $id
|
|
* @return string
|
|
*/
|
|
public function getRessource($id)
|
|
{
|
|
return \User_Adapter::getInstance($id, $this->app);
|
|
}
|
|
}
|