mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-07 18:14:35 +00:00
PHRAS-3754 admin - user detail - Record ACL tab (#4148)
* record acl tab in admin * fix email locked, limit record right to 200 * fix * add filter * update * feed element, basket element * feed list * feed entries * when not expand * some improvement
This commit is contained in:
@@ -16,16 +16,20 @@ use Alchemy\Phrasea\Controller\Controller;
|
||||
use Alchemy\Phrasea\Core\Response\CSVFileResponse;
|
||||
use Alchemy\Phrasea\Helper\User as UserHelper;
|
||||
use Alchemy\Phrasea\Model\Entities\AuthFailure;
|
||||
use Alchemy\Phrasea\Model\Entities\Feed;
|
||||
use Alchemy\Phrasea\Model\Entities\FtpCredential;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
|
||||
use Alchemy\Phrasea\Model\Manipulator\RegistrationManipulator;
|
||||
use Alchemy\Phrasea\Model\Manipulator\UserManipulator;
|
||||
use Alchemy\Phrasea\Model\NativeQueryProvider;
|
||||
use Alchemy\Phrasea\Model\Repositories\FeedEntryRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\FeedRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\RegistrationRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\UserRepository;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Goodby\CSV\Export\Protocol\ExporterInterface;
|
||||
use Goodby\CSV\Import\Standard\Interpreter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -39,7 +43,88 @@ class UserController extends Controller
|
||||
public function editRightsAction(Request $request)
|
||||
{
|
||||
$rights = $this->getUserEditHelper($request);
|
||||
return $this->render('admin/editusers.html.twig', $rights->get_users_rights());
|
||||
|
||||
return $this->render('admin/editusers.html.twig',
|
||||
array_merge($rights->get_user_records_rights(),
|
||||
$rights->getFeeds(),
|
||||
$rights->getBasketElements(),
|
||||
$rights->get_users_rights())
|
||||
);
|
||||
}
|
||||
|
||||
public function listRecordAcl(Request $request)
|
||||
{
|
||||
$rights = $this->getUserEditHelper($request);
|
||||
$results = $rights->get_user_records_rights($request->query->get('userId'), $request->query->get('databoxId'), $request->query->get('recordId'));
|
||||
|
||||
return $this->app->json([
|
||||
'content' => $this->render('admin/user/records_list.html.twig', ['records_acl' => $results['records_acl']]),
|
||||
'total_count' => $results['total_count'],
|
||||
'total_result' => count($results['records_acl'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteFeedEntry(Request $request)
|
||||
{
|
||||
/** @var EntityManager $manager */
|
||||
$manager = $this->app['orm.em'];
|
||||
/** @var FeedEntryRepository $feedEntryRepo */
|
||||
$feedEntryRepo = $this->app['repo.feed-entries'];
|
||||
|
||||
/** @var Feed|null $feed */
|
||||
$feedEntry = $feedEntryRepo->find($request->request->get('feedEntryId'));
|
||||
|
||||
if ($feedEntry == null) {
|
||||
return $this->app->json(['success' => false, 'message' => 'publication not found']);
|
||||
}
|
||||
|
||||
$manager->remove($feedEntry);
|
||||
$manager->flush();
|
||||
|
||||
return $this->app->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function listFeedEntry(Request $request)
|
||||
{
|
||||
/** @var UserRepository $userRepo */
|
||||
$userRepo = $this->app['repo.users'];
|
||||
$user = $userRepo->find($request->query->get('userId'));
|
||||
|
||||
// when not expand
|
||||
if ($request->query->get('feedId') == null) {
|
||||
return $this->app->json(['content' => '']);
|
||||
}
|
||||
|
||||
/** @var FeedRepository $feedsRepository */
|
||||
$feedsRepository = $this->app['repo.feeds'];
|
||||
/** @var Feed|null $feed */
|
||||
$feed = $feedsRepository->find($request->query->get('feedId'));
|
||||
|
||||
if ($feed == null || $user == null) {
|
||||
return $this->app->json(['content' => 'Give feed_id or user_id']);
|
||||
} else {
|
||||
/** @var FeedEntryRepository $feedEntryRepo */
|
||||
$feedEntryRepo = $this->app['repo.feed-entries'];
|
||||
$feedEntryRepo->getByUserAndFeed($user, $feed);
|
||||
|
||||
return $this->app->json(['content' => $this->render('admin/user/records_list.html.twig', [
|
||||
'feed_entries' => $feedEntryRepo->getByUserAndFeed($user, $feed)
|
||||
]),
|
||||
'feed_entries_count' => $feedEntryRepo->getByUserAndFeed($user, $feed, true)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function listRecordBasket(Request $request)
|
||||
{
|
||||
$rights = $this->getUserEditHelper($request);
|
||||
$results = $rights->getBasketElements($request->query->get('userId'), $request->query->get('databoxId'), $request->query->get('recordId'));
|
||||
|
||||
return $this->app->json([
|
||||
'content' => $this->render('admin/user/records_list.html.twig', ['basket_elements' => $results['basket_elements']]),
|
||||
'total_count' => $results['basket_elements_count'],
|
||||
'total_result' => count($results['basket_elements'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetRightsAction(Request $request)
|
||||
|
@@ -86,6 +86,10 @@ class Users implements ControllerProviderInterface, ServiceProviderInterface
|
||||
->bind('users_import_csv');
|
||||
$controllers->get('/import/example/rtf/', 'controller.admin.users:importRtfExampleAction')
|
||||
->bind('users_import_rtf');
|
||||
$controllers->get('/records-acl/', 'controller.admin.users:listRecordAcl');
|
||||
$controllers->get('/feed-entry/', 'controller.admin.users:listFeedEntry');
|
||||
$controllers->post('/feed-entry/delete/', 'controller.admin.users:deleteFeedEntry');
|
||||
$controllers->get('/records-basket/', 'controller.admin.users:listRecordBasket');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -15,8 +15,12 @@ use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Application\Helper\NotifierAware;
|
||||
use Alchemy\Phrasea\Core\LazyLocator;
|
||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Alchemy\Phrasea\Model\Entities\Feed;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Alchemy\Phrasea\Model\Manipulator\UserManipulator;
|
||||
use Alchemy\Phrasea\Model\Repositories\BasketElementRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\FeedEntryRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\FeedRepository;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
use Doctrine\DBAL\Connection;
|
||||
@@ -205,6 +209,133 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getFeeds($userId = null)
|
||||
{
|
||||
if (empty($userId)) {
|
||||
if (count($this->users) == 1) {
|
||||
$userId = current($this->users);
|
||||
} else {
|
||||
return [
|
||||
'feeds' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$user = $this->app['repo.users']->find($userId);
|
||||
|
||||
/** @var FeedRepository $feedsRepository */
|
||||
$feedsRepository = $this->app['repo.feeds'];
|
||||
$feeds = $feedsRepository->getUserFeed($user);
|
||||
|
||||
/** @var FeedEntryRepository $feedEntryRepo */
|
||||
$feedEntryRepo = $this->app['repo.feed-entries'];
|
||||
|
||||
$feedCount = [];
|
||||
/** @var Feed $feed */
|
||||
foreach ($feeds as $feed) {
|
||||
$feedCount[$feed->getId()] = $feedEntryRepo->getByUserAndFeed($user, $feed, true);
|
||||
}
|
||||
|
||||
return [
|
||||
'feeds' => $feedsRepository->getUserFeed($user),
|
||||
'feeds_count' => $feedCount
|
||||
];
|
||||
}
|
||||
|
||||
public function getBasketElements($userId = null, $databoxId = null, $recordId = null)
|
||||
{
|
||||
if (empty($userId)) {
|
||||
if (count($this->users) == 1) {
|
||||
$userId = current($this->users);
|
||||
} else {
|
||||
return [
|
||||
'basket_elements' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$user = $this->app['repo.users']->find($userId);
|
||||
|
||||
/** @var BasketElementRepository $basketElementRepository */
|
||||
$basketElementRepository = $this->app['repo.basket-elements'];
|
||||
|
||||
return [
|
||||
'basket_elements' => $basketElementRepository->getElements($user, $databoxId, $recordId),
|
||||
'basket_elements_count' => $basketElementRepository->getElementsCount($user, $databoxId, $recordId)
|
||||
];
|
||||
}
|
||||
|
||||
public function get_user_records_rights($userId = null, $databoxId = null, $recordId = null)
|
||||
{
|
||||
$rows = [];
|
||||
$totalCount = 0;
|
||||
|
||||
$databoxIds = array_map(function (\databox $databox) {
|
||||
return $databox->get_sbas_id();
|
||||
},
|
||||
$this->app->getApplicationBox()->get_databoxes()
|
||||
);
|
||||
|
||||
if (empty($userId)) {
|
||||
if (count($this->users) == 1) {
|
||||
$userId = current($this->users);
|
||||
} else {
|
||||
return [
|
||||
'records_acl' => $rows,
|
||||
'total_count' => $totalCount,
|
||||
'databoxIds' => $databoxIds
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$whereClause = "WHERE rr.usr_id = :usr_id";
|
||||
$params[':usr_id'] = $userId;
|
||||
|
||||
if (!empty($databoxId)) {
|
||||
$whereClause .= " AND rr.sbas_id= :databox_id";
|
||||
$params[':databox_id'] = $databoxId;
|
||||
}
|
||||
|
||||
if (!empty($recordId)) {
|
||||
$whereClause .= " AND rr.record_id= :record_id";
|
||||
$params[':record_id'] = $recordId;
|
||||
}
|
||||
|
||||
$sql = "SELECT rr.sbas_id, rr.record_id, rr.preview, rr.document, rr.`case` as type, \n"
|
||||
. "IF(TRIM(p.last_name)!='' OR TRIM(p.first_name)!='', \n"
|
||||
. " CONCAT_WS(' ', p.last_name, p.first_name),\n"
|
||||
. " IF(TRIM(p.email)!='', p.email, p.login)\n"
|
||||
. ") as pusher_name\n"
|
||||
. " FROM records_rights rr \n"
|
||||
. " INNER JOIN sbas ON sbas.sbas_id = rr.sbas_id\n"
|
||||
. " JOIN Users as p ON p.id = rr.pusher_usr_id\n"
|
||||
. $whereClause
|
||||
. " ORDER BY rr.id DESC limit 200 \n"
|
||||
;
|
||||
|
||||
$stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = "SELECT count(*) as nb \n"
|
||||
. " FROM records_rights rr \n"
|
||||
. " INNER JOIN sbas ON sbas.sbas_id = rr.sbas_id\n"
|
||||
. $whereClause
|
||||
;
|
||||
|
||||
$stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$totalCount = $stmt->fetchColumn();
|
||||
$stmt->closeCursor();
|
||||
|
||||
return [
|
||||
'records_acl' => $rows,
|
||||
'total_count' => $totalCount,
|
||||
'databoxIds' => $databoxIds
|
||||
];
|
||||
}
|
||||
|
||||
public function get_quotas()
|
||||
{
|
||||
$this->base_id = (int) $this->request->get('base_id');
|
||||
|
@@ -233,4 +233,50 @@ DQL;
|
||||
|
||||
return $builder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getElements(User $user, $databoxId = null, $recordId = null, $nbElement = 200)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('be');
|
||||
$qb->innerJoin('be.basket', 'b');
|
||||
|
||||
$qb->where($qb->expr()->eq('b.user', ':user'));
|
||||
$qb->setParameter(':user', $user);
|
||||
|
||||
if ($databoxId != null) {
|
||||
$qb->andWhere('be.sbas_id = :databoxId');
|
||||
$qb->setParameter(':databoxId', $databoxId);
|
||||
}
|
||||
|
||||
if ($recordId != null) {
|
||||
$qb->andWhere('be.record_id = :recordId');
|
||||
$qb->setParameter(':recordId', $recordId);
|
||||
}
|
||||
|
||||
$qb->orderBy('be.id', 'DESC');
|
||||
$qb->setMaxResults($nbElement);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getElementsCount(User $user, $databoxId = null, $recordId = null)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('be');
|
||||
$qb->select('count(be)');
|
||||
$qb->innerJoin('be.basket', 'b');
|
||||
|
||||
$qb->where($qb->expr()->eq('b.user', ':user'));
|
||||
$qb->setParameter(':user', $user);
|
||||
|
||||
if ($databoxId != null) {
|
||||
$qb->andWhere('be.sbas_id = :databoxId');
|
||||
$qb->setParameter(':databoxId', $databoxId);
|
||||
}
|
||||
|
||||
if ($recordId != null) {
|
||||
$qb->andWhere('be.record_id = :recordId');
|
||||
$qb->setParameter(':recordId', $recordId);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Model\Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Feed;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
@@ -64,4 +65,24 @@ class FeedEntryRepository extends EntityRepository
|
||||
|
||||
return $builder->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function getByUserAndFeed(User $user, Feed $feed, $isCount = false)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('fe');
|
||||
|
||||
$qb->innerJoin('fe.publisher', 'fp');
|
||||
$qb->where($qb->expr()->eq('fp.user', ':publisher'));
|
||||
$qb->setParameter(':publisher', $user);
|
||||
|
||||
$qb->andWhere($qb->expr()->eq('fe.feed', ':feed'));
|
||||
$qb->setParameter(':feed', $feed);
|
||||
|
||||
if ($isCount) {
|
||||
$qb->select('count(fe)');
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
} else {
|
||||
$qb->orderBy('fe.id', 'DESC');
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Model\Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedItem;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -103,4 +104,52 @@ class FeedItemRepository extends EntityRepository
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public function getItemsCount(User $user, $databoxId = null, $recordId = null)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('fi');
|
||||
$qb->select('count(fi)');
|
||||
$qb->innerjoin('fi.entry', 'fe');
|
||||
$qb->innerjoin('fe.publisher', 'fp');
|
||||
|
||||
$qb->where($qb->expr()->eq('fp.user', ':publisher'));
|
||||
$qb->setParameter(':publisher', $user);
|
||||
|
||||
if ($databoxId != null) {
|
||||
$qb->andWhere('fi.sbasId = :databoxId');
|
||||
$qb->setParameter(':databoxId', $databoxId);
|
||||
}
|
||||
|
||||
if ($recordId != null) {
|
||||
$qb->andWhere('fi.recordId = :recordId');
|
||||
$qb->setParameter(':recordId', $recordId);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function getLastItems(User $user, $databoxId = null, $recordId = null, $nbItems = 200)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('fi');
|
||||
$qb->innerjoin('fi.entry', 'fe');
|
||||
$qb->innerjoin('fe.publisher', 'fp');
|
||||
|
||||
$qb->where($qb->expr()->eq('fp.user', ':publisher'));
|
||||
$qb->setParameter(':publisher', $user);
|
||||
|
||||
if ($databoxId != null) {
|
||||
$qb->andWhere('fi.sbasId = :databoxId');
|
||||
$qb->setParameter(':databoxId', $databoxId);
|
||||
}
|
||||
|
||||
if ($recordId != null) {
|
||||
$qb->andWhere('fi.recordId = :recordId');
|
||||
$qb->setParameter(':recordId', $recordId);
|
||||
}
|
||||
|
||||
$qb->orderBy('fi.id', 'DESC');
|
||||
$qb->setMaxResults($nbItems);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Model\Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Feed;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
@@ -108,4 +109,14 @@ class FeedRepository extends EntityRepository
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getUserFeed(User $user)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('f');
|
||||
$qb->innerJoin('f.publishers', 'fp');
|
||||
$qb->where($qb->expr()->eq('fp.user', ':publisher'));
|
||||
$qb->setParameter(':publisher', $user);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@@ -472,7 +472,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
|
||||
}
|
||||
|
||||
public function updateStatusRunningToCanceledSinceCreated($hour = 0)
|
||||
|
@@ -80,6 +80,24 @@
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
#basket_tab table, #basket_tab th,
|
||||
#feed_tab table, #feed_tab th,
|
||||
#record_acl_tab table,
|
||||
#record_acl_tab th {
|
||||
border: 1px solid #a5a0a0;
|
||||
border-collapse: collapse;
|
||||
text-align: center;
|
||||
padding:0px 10px;
|
||||
}
|
||||
|
||||
#basket_tab td,
|
||||
#feed_tab td,
|
||||
#record_acl_tab td{
|
||||
border-right: 1px solid #a5a0a0;
|
||||
border-left: 1px solid #a5a0a0;
|
||||
padding:0px 10px;
|
||||
}
|
||||
|
||||
#api_tab th,
|
||||
#api_tab td,
|
||||
#auth_failure_tab th,
|
||||
@@ -92,6 +110,10 @@
|
||||
</style>
|
||||
|
||||
<div>
|
||||
{% if main_user is not empty %}
|
||||
<h4>{{ main_user.getDisplayName() ~ ' ( ' ~ main_user.getId() ~' )'}}</h4>
|
||||
{% endif %}
|
||||
|
||||
<div class="tabs PNB" style="bottom:40px;">
|
||||
<ul>
|
||||
<li>
|
||||
@@ -107,6 +129,15 @@
|
||||
<li>
|
||||
<a href="#auth_failure_tab">{{ 'admin::users: Auth failure' | trans }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#record_acl_tab">Record ACL</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#feed_tab">Publications</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#basket_tab">Baskets</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div id="rights_tab" class="" style="top:40px;">
|
||||
@@ -434,126 +465,129 @@
|
||||
|
||||
{% if main_user is not empty and main_user.isTemplate is empty and main_user.isSpecial is empty %}
|
||||
<div id="user_infos_tab" class="" style="top:40px;overflow:auto;">
|
||||
<form id="user_infos_form">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur identifiant' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="{{main_user.getLogin()}}" readonly="readonly" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur sexe' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<select name="gender">
|
||||
<option {% if main_user.getGender() == 0 %}selected="selected"{% endif %} value="0" >{{ 'admin::compte-utilisateur:sexe: mademoiselle' | trans }}</option>
|
||||
<option {% if main_user.getGender() == 1 %}selected="selected"{% endif %} value="1" >{{ 'admin::compte-utilisateur:sexe: madame' | trans }}</option>
|
||||
<option {% if main_user.getGender() == 2 %}selected="selected"{% endif %} value="2" >{{ 'admin::compte-utilisateur:sexe: monsieur' | trans }}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur prenom' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="first_name" value="{{main_user.getFirstName()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur nom' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="last_name" value="{{main_user.getLastName()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur email' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="email" value="{{main_user.getEmail()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur adresse' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="address" value="{{main_user.getAddress()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur code postal' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="zip" value="{{main_user.getZipCode()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur ville' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="{{ main_user.getGeonameId() }}" class="geoname_field" name="geonameid"
|
||||
autocomplete="false"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur poste' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="function" value="{{main_user.getJob()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur societe' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="company" value="{{main_user.getCompany()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur activite' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="activite" value="{{main_user.getActivity()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<form id="user_infos_form">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur identifiant' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="{{main_user.getLogin()}}" readonly="readonly" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur sexe' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<select name="gender">
|
||||
<option {% if main_user.getGender() == 0 %}selected="selected"{% endif %} value="0" >{{ 'admin::compte-utilisateur:sexe: mademoiselle' | trans }}</option>
|
||||
<option {% if main_user.getGender() == 1 %}selected="selected"{% endif %} value="1" >{{ 'admin::compte-utilisateur:sexe: madame' | trans }}</option>
|
||||
<option {% if main_user.getGender() == 2 %}selected="selected"{% endif %} value="2" >{{ 'admin::compte-utilisateur:sexe: monsieur' | trans }}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur prenom' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="first_name" value="{{main_user.getFirstName()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur nom' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="last_name" value="{{main_user.getLastName()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur email' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="email" value="{{main_user.getEmail()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur adresse' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="address" value="{{main_user.getAddress()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur code postal' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="zip" value="{{main_user.getZipCode()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur ville' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="{{ main_user.getGeonameId() }}" class="geoname_field" name="geonameid"
|
||||
autocomplete="false"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur poste' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="function" value="{{main_user.getJob()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur societe' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="company" value="{{main_user.getCompany()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur activite' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="activite" value="{{main_user.getActivity()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur telephone' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="telephone" value="{{main_user.getPhone()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur fax' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="fax" value="{{main_user.getFax()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur telephone' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="telephone" value="{{main_user.getPhone()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'admin::compte-utilisateur fax' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="fax" value="{{main_user.getFax()}}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<label class="checkbox" style="padding-left: 0px; margin-top:10px">
|
||||
<span class="mail-locked-label {% if not apiApplication.isMailLocked() %} hidden {% endif %}">{{ 'admin::users: mail is locked' | trans }}</span>
|
||||
<span class="mail-unlocked-label {% if apiApplication.isMailLocked() %} hidden {% endif %}">{{ 'admin::users: mail is unlocked' | trans }}</span>
|
||||
<input type="checkbox" id="mail_locked_activation" {% if apiApplication.isMailLocked() %} checked="checked" {% endif %} style="margin-left:10px; margin-right:10px;" />
|
||||
</label>
|
||||
<div>
|
||||
<label for="lock" style="margin-right: 20px;display:inline-block;">Email locked</label>
|
||||
<input type="radio" id="lock" name="email-locked" value="locked" style="margin-right: 10px;"
|
||||
{% if main_user.isMailLocked() %} checked {% endif %}>
|
||||
<input type="radio" id="unlock" name="email-locked" value="unlock" style="margin-left: 10px;"
|
||||
{% if not main_user.isMailLocked() %} checked {% endif %}>
|
||||
<label for="unlock" style="margin-left: 20px;display:inline-block;">Email unlocked</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
{% set usrProviders = app['repo.usr-auth-providers'].findByUser(main_user) %}
|
||||
@@ -701,6 +735,98 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="record_acl_tab">
|
||||
<h1>User record acl</h1>
|
||||
<div style="margin-bottom: 20px;">
|
||||
<select id="acl-databox-filter">
|
||||
<option value="">{{ 'button::choose databox' | trans }}</option>
|
||||
{% for databoxId in databoxIds %}
|
||||
<option value="{{ databoxId }}">{{ databoxId | sbas_labels(app) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<input type="number" id="acl-record-filter" placeholder="recordId" style="margin-bottom: 0px;margin-left: 30px;">
|
||||
</div>
|
||||
|
||||
<p> <span class="acl-result-count">{{ records_acl|length }} / {{ total_count }}</span> (last 200 rights displayed)</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>databox name</th>
|
||||
<th>record_id</th>
|
||||
<th>right on document</th>
|
||||
<th>right on subdef</th>
|
||||
<th>type</th>
|
||||
<th>pusher name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="record_acl_list">
|
||||
{% for r_a in records_acl %}
|
||||
<tr>
|
||||
<td>{{ r_a.sbas_id | sbas_labels(app) }}</td>
|
||||
<td>{{ r_a.record_id }}</td>
|
||||
<td>{{ r_a.document }}</td>
|
||||
<td>{{ r_a.preview }}</td>
|
||||
<td>{{ r_a.type }}</td>
|
||||
<td>{{ r_a.pusher_name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="feed_tab">
|
||||
<h1>{{ "User's publications in feeds" | trans}}</h1>
|
||||
<div id="feeds-list">
|
||||
{% for f in feeds %}
|
||||
<h6 style="max-width:400px; max-height: 30px; padding-bottom: 0px; padding-top: 0px;" data-feed="{{ f.id }}">
|
||||
{{ f.title }}
|
||||
{% if f.public %}<span style="margin-top: 1px;margin-left:15px;" class="badge badge-success pull-right">public</span>{% endif %}
|
||||
<span class="pull-right ">
|
||||
<span class="publication-count">{{ feeds_count[f.getId()] }} </span> publication(s)
|
||||
</span>
|
||||
</h6>
|
||||
<div data-feed="{{ f.id }}" class="feed-content" style="max-height: 300px; max-width:600px;"></div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="basket_tab">
|
||||
<h1>User basket</h1>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<select id="basket-databox-filter">
|
||||
<option value="">{{ 'button::choose databox' | trans }}</option>
|
||||
{% for databoxId in databoxIds %}
|
||||
<option value="{{ databoxId }}">{{ databoxId | sbas_labels(app) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<input type="number" id="basket-record-filter" placeholder="recordId" style="margin-bottom: 0px;margin-left: 30px;">
|
||||
</div>
|
||||
|
||||
<p> <span class="basket-result-count">{{ basket_elements|length }} / {{ basket_elements_count }}</span> (last 200 basket records displayed)</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>databox name</th>
|
||||
<th>record_id</th>
|
||||
<th>Basket name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="record_basket_list">
|
||||
{% for b_e in basket_elements %}
|
||||
<tr>
|
||||
<td>{{ b_e.getSbasId() | sbas_labels(app) }}</td>
|
||||
<td>{{ b_e.getRecordId() }}</td>
|
||||
<td>{{ b_e.basket.name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-actions" style="">
|
||||
@@ -1209,7 +1335,15 @@
|
||||
|
||||
ini_edit_usrs();
|
||||
|
||||
$('div.tabs').tabs();
|
||||
$('div.tabs').tabs({
|
||||
activate:function( event, ui ) {
|
||||
if (ui.newPanel.selector === '#rights_tab' || ui.newPanel.selector === '#user_infos_tab') {
|
||||
$("#right-ajax .form-actions").removeClass('hidden');
|
||||
} else {
|
||||
$("#right-ajax .form-actions").addClass('hidden');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#users_rights_form button#reset_rights').bind('click', function () {
|
||||
if (confirm("{{ 'Are you sure you want to reset rights?' | trans }}")) {
|
||||
@@ -1316,29 +1450,116 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#mail_locked_activation').on('click', function() {
|
||||
let $this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/admin/users/mail-locked/change/',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
user_id: {{ main_user.getId() }},
|
||||
action: $this.is(':checked') ? 'locked' : 'unlocked'
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.success == true) {
|
||||
if ($this.is(':checked')) {
|
||||
$('.mail-locked-label').removeClass('hidden');
|
||||
$('.mail-unlocked-label').addClass('hidden');
|
||||
} else {
|
||||
$('.mail-locked-label').addClass('hidden');
|
||||
$('.mail-unlocked-label').removeClass('hidden');
|
||||
}
|
||||
$('input[type=radio][name="email-locked"]').change( function() {
|
||||
let $this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/admin/users/mail-locked/change/',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
user_id: {{ main_user.getId() }},
|
||||
action: $this.val()
|
||||
},
|
||||
success: function (data) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function listRecordAcl() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/users/records-acl/",
|
||||
data: {
|
||||
databoxId : $("#acl-databox-filter").val(),
|
||||
recordId : $("#acl-record-filter").val(),
|
||||
userId: {{ main_user.getId() }}
|
||||
},
|
||||
success: function (data) {
|
||||
$("#record_acl_list").empty().html(data.content);
|
||||
$(".acl-result-count").empty().text(data.total_result + ' / ' + data.total_count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function listRecordBasket() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/users/records-basket/",
|
||||
data: {
|
||||
databoxId : $("#basket-databox-filter").val(),
|
||||
recordId : $("#basket-record-filter").val(),
|
||||
userId: {{ main_user.getId() }}
|
||||
},
|
||||
success: function (data) {
|
||||
$("#record_basket_list").empty().html(data.content);
|
||||
$(".basket-result-count").empty().text(data.total_result + ' / ' + data.total_count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function listFeedEntry(userId, feedId, dest) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/admin/users/feed-entry/',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
userId: userId,
|
||||
feedId: feedId
|
||||
},
|
||||
success: function (data) {
|
||||
dest.empty().html(data.content);
|
||||
dest.siblings('.ui-state-active').find(".publication-count").text(data.feed_entries_count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#acl-databox-filter").on('change', function() {
|
||||
listRecordAcl();
|
||||
});
|
||||
|
||||
$("#acl-record-filter").on('input', function() {
|
||||
listRecordAcl();
|
||||
});
|
||||
|
||||
$("#basket-databox-filter").on('change', function() {
|
||||
listRecordBasket();
|
||||
});
|
||||
|
||||
$("#basket-record-filter").on('input', function() {
|
||||
listRecordBasket();
|
||||
});
|
||||
|
||||
$("#feeds-list").accordion({
|
||||
active: false,
|
||||
heightStyle: 'content',
|
||||
collapsible: true,
|
||||
autoHeight: true,
|
||||
fillSpace: true,
|
||||
activate: function(){
|
||||
let dest = $(this).find('.ui-state-active').next('.feed-content');
|
||||
let feedId = $(this).find('.ui-state-active').attr('data-feed');
|
||||
|
||||
listFeedEntry({{ main_user.getId() }}, feedId, dest)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#feed_tab").on('click', '.delete-publication', function() {
|
||||
let feedId = $(this).closest('.feed-content').attr('data-feed');
|
||||
let dest = $(this).closest('.feed-content');
|
||||
if(confirm('This delete the publication "' + $(this).siblings('.publication-name').text() + '"')) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/admin/users/feed-entry/delete/",
|
||||
data: {
|
||||
feedEntryId : $(this).attr('data-feed-entry'),
|
||||
},
|
||||
success: function (data) {
|
||||
listFeedEntry({{ main_user.getId() }}, feedId, dest)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
|
34
templates/web/admin/user/records_list.html.twig
Normal file
34
templates/web/admin/user/records_list.html.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% for r_a in records_acl %}
|
||||
<tr>
|
||||
<td>{{ r_a.sbas_id | sbas_labels(app) }}</td>
|
||||
<td>{{ r_a.record_id }}</td>
|
||||
<td>{{ r_a.document }}</td>
|
||||
<td>{{ r_a.preview }}</td>
|
||||
<td>{{ r_a.type }}</td>
|
||||
<td>{{ r_a.pusher_name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% if feed_entries is defined %}
|
||||
{% if feed_entries | length > 0 %}
|
||||
<ul>
|
||||
{% for f_e in feed_entries %}
|
||||
<li style="line-height: 25px;">
|
||||
<span class="publication-name">{{ f_e.title }}</span>
|
||||
<span style="margin-left:15px;">({{ f_e.getItems() | length }} records)</span>
|
||||
<button data-feed-entry="{{ f_e.getId() }}" class="btn btn-danger btn-mini pull-right delete-publication" style="margin-left:30px;">Delete</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p> No publication</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for b_e in basket_elements %}
|
||||
<tr>
|
||||
<td>{{ b_e.getSbasId() | sbas_labels(app) }}</td>
|
||||
<td>{{ b_e.getRecordId() }}</td>
|
||||
<td>{{ b_e.basket.name }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
Reference in New Issue
Block a user