diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
index b47c916291..cc428cfabc 100644
--- a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
+++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
@@ -84,13 +84,13 @@ class Step35 implements DatasUpgraderInterface
try {
$this->updateMetadatas($record, $row['xml']);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$this->app['monolog']->addError(sprintf("Error while upgrading metadatas for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage()));
}
try {
$record->set_binary_status($row['status']);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$this->app['monolog']->addError(sprintf("Error while upgrading status for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage()));
}
unset($record);
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
index f9da5d13c9..14a0cdca95 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
@@ -74,9 +74,15 @@ class Users implements ControllerProviderInterface
try {
$rights = new UserHelper\Edit($app, $app['request']);
- $rights->apply_rights();
+
+ if (!$app['request']->request->get('reset_before_apply')) {
+ $rights->apply_rights();
+ }
if ($app['request']->request->get('template')) {
+ if ($app['request']->request->get('reset_before_apply')) {
+ $rights->resetRights();
+ }
$rights->apply_template();
}
@@ -200,6 +206,9 @@ class Users implements ControllerProviderInterface
$controllers->post('/apply_template/', function () use ($app) {
$users = new UserHelper\Edit($app, $app['request']);
+ if ($app['request']->request->get('reset_before_apply')) {
+ $users->resetRights();
+ }
$users->apply_template();
return $app->redirectPath('admin_users_search');
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php
index 0633c143f2..6c6a20c6a6 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Account.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php
@@ -323,7 +323,7 @@ class Account implements ControllerProviderInterface
return $app['twig']->render('account/account.html.twig', array(
'user' => $app['authentication']->getUser(),
'evt_mngr' => $app['events-manager'],
- 'notifications' => $app['events-manager']->list_notifications_available(),
+ 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()),
));
}
@@ -372,6 +372,7 @@ class Account implements ControllerProviderInterface
);
if (0 === count(array_diff($accountFields, array_keys($request->request->all())))) {
+
try {
$app['phraseanet.appbox']->get_connection()->beginTransaction();
@@ -403,7 +404,7 @@ class Account implements ControllerProviderInterface
$app['EM']->persist($ftpCredential);
$app['EM']->flush();
$app->addFlash('success', _('login::notification: Changements enregistres'));
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$app->addFlash('error', _('forms::erreurs lors de l\'enregistrement des modifications'));
$app['phraseanet.appbox']->get_connection()->rollBack();
}
@@ -411,15 +412,12 @@ class Account implements ControllerProviderInterface
$requestedNotifications = (array) $request->request->get('notifications', array());
- foreach ($app['events-manager']->list_notifications_available() as $notifications) {
+ foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()) as $notifications) {
foreach ($notifications as $notification) {
- $notifId = $notification['id'];
- $notifName = sprintf('notification_%s', $notifId);
-
- if (isset($requestedNotifications[$notifId])) {
- $app['authentication']->getUser()->setPrefs($notifName, '1');
+ if (isset($requestedNotifications[$notification['id']])) {
+ $app['authentication']->getUser()->set_notification_preference($app, $notification['id'], '1');
} else {
- $app['authentication']->getUser()->setPrefs($notifName, '0');
+ $app['authentication']->getUser()->set_notification_preference($app, $notification['id'], '0');
}
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
index e1e52e3762..5f150dc91b 100644
--- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
+++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
@@ -66,12 +66,12 @@ class Xmlhttp implements ControllerProviderInterface
$connbas = $databox->get_connection();
$domct = $databox->get_dom_cterms();
- if (!($domct instanceof DOMDocument)) {
+ if (!($domct instanceof \DOMDocument)) {
throw new \Exception('Unable to load cterms');
}
$domth = $databox->get_dom_thesaurus();
- if (!($domth instanceof DOMDocument)) {
+ if (!($domth instanceof \DOMDocument)) {
throw new \Exception('Unable to load thesaurus');
}
@@ -83,10 +83,6 @@ class Xmlhttp implements ControllerProviderInterface
$q = "/thesaurus//te[@id='" . $request->get("tid") . "']";
}
- if ($request->get("debug")) {
- printf("qth: %s
\n", $q);
- }
-
$parentnode = $xpathth->query($q)->item(0);
if (!$parentnode) {
throw new \Exception('Unable to find branch');
@@ -165,9 +161,6 @@ class Xmlhttp implements ControllerProviderInterface
if ($ct2->nodeType != XML_ELEMENT_NODE || $ct2->nodeName != 'sy') {
continue;
}
- if ($request->get('debug')) {
- printf("ct2:%s \n", var_export($ct2, true));
- }
$nid = $parentnode->getAttribute("nextid");
$parentnode->setAttribute("nextid", (int) $nid + 1);
@@ -526,10 +519,6 @@ class Xmlhttp implements ControllerProviderInterface
$xpath = $databox->get_xpath_thesaurus();
$q = "/thesaurus//sy[@id='" . $request->get('id') . "']";
- if ($request->get('debug')) {
- print("q:" . $q . "
\n");
- }
-
$nodes = $xpath->query($q);
if ($nodes->length > 0) {
$n2 = $nodes->item(0);
@@ -859,10 +848,6 @@ class Xmlhttp implements ControllerProviderInterface
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- if ($request->get('debug')) {
- printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
- }
-
foreach ($rs as $rowbas) {
$t_nrec[$thid] = $rowbas;
}
@@ -879,10 +864,6 @@ class Xmlhttp implements ControllerProviderInterface
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- if ($request->get('debug')) {
- printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
- }
-
foreach ($rs as $rowbas) {
$t_nrec[$thid . $rowbas['k']] = $rowbas;
}
@@ -900,10 +881,6 @@ class Xmlhttp implements ControllerProviderInterface
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- if ($request->get('debug')) {
- printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
- }
-
foreach ($rs as $rowbas) {
$t_nrec[$thid] = $rowbas;
}
@@ -920,19 +897,11 @@ class Xmlhttp implements ControllerProviderInterface
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- if ($request->get('debug')) {
- printf("/*\n thid=%s\n %s \n */\n", $thid, $sql);
- }
-
foreach ($rs as $rowbas) {
$t_nrec[$thid . '.' . $rowbas['k']] = $rowbas;
}
}
- if ($request->get('debug')) {
- printf("/* %s */\n", var_export($t_nrec, true));
- }
-
$databox = $app['phraseanet.appbox']->get_databox($sbid);
if ($request->get('type') == 'T') {
$xqroot = 'thesaurus';
@@ -953,9 +922,6 @@ class Xmlhttp implements ControllerProviderInterface
} else {
$q = '/' . $xqroot . '//te[@id=\'' . $thid . '\']';
}
- if ($request->get('debug')) {
- print("q:" . $q . "
\n");
- }
$nodes = $xpath->query($q);
if ($nodes->length > 0) {
@@ -1009,10 +975,6 @@ class Xmlhttp implements ControllerProviderInterface
}
}
- if ($request->get('debug')) {
- printf("tts(%s) :
%s
\n", $nts, var_export($tts, true));
- }
-
if ($nts > 0) {
$field0 = $node0->getAttribute('field');
if ($field0) {
@@ -1026,9 +988,6 @@ class Xmlhttp implements ControllerProviderInterface
} elseif ($request->get('type') == 'C') {
$tts = array_reverse($tts);
}
- if ($request->get('debug')) {
- printf("%s: type=%s : %s
\n", __LINE__, $request->get('type'), var_export($tts, true));
- }
foreach ($tts as $ts) {
$class = '';
@@ -1155,9 +1114,6 @@ class Xmlhttp implements ControllerProviderInterface
$xpath = $databox->get_xpath_thesaurus();
$q = '/thesaurus';
- if ($request->get('debug')) {
- print('q:' . $q . '
\n');
- }
if (($znode = $xpath->query($q)->item(0))) {
$q2 = '//sy';
if ($request->get('t')) {
@@ -1194,9 +1150,6 @@ class Xmlhttp implements ControllerProviderInterface
$html .= '';
}
}
- if ($request->get('debug')) {
- printf('zhtml=%s
\n', $html);
- }
}
return new Response($html);
@@ -1282,11 +1235,11 @@ class Xmlhttp implements ControllerProviderInterface
$ret->preserveWhiteSpace = false;
$root = $ret->appendChild($ret->createElement('result'));
$root->appendChild($ret->createCDATASection(var_export(array(
- 'bid' => $request->get('bid'),
- 't' => $request->get('t'),
- 'mod' => $request->get('mod'),
- 'debug' => $request->get('debug'),
- ), true)));
+ 'bid' => $request->get('bid'),
+ 't' => $request->get('t'),
+ 'mod' => $request->get('mod'),
+ 'debug' => $request->get('debug'),
+ ), true)));
$html = $root->appendChild($ret->createElement('html'));
@@ -1304,10 +1257,6 @@ class Xmlhttp implements ControllerProviderInterface
$xpath = $databox->get_xpath_thesaurus();
$q = '/thesaurus';
- if ($request->get('debug')) {
- print('q:' . $q . '
\n');
- }
-
if (($znode = $xpath->query($q)->item(0))) {
$q2 = '//sy';
if ($request->get('t')) {
@@ -1317,18 +1266,12 @@ class Xmlhttp implements ControllerProviderInterface
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
$q2 = '//sy[' . $q2 . ']';
}
- if ($request->get('debug')) {
- print('q2:' . $q2 . '
\n');
- }
$nodes = $xpath->query($q2, $znode);
if ($mod == 'TREE') {
for ($i = 0; $i < $nodes->length; $i++) {
$nodes->item($i)->setAttribute('bold', '1');
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
$n->setAttribute('open', '1');
- if ($request->get('debug')) {
- printf('opening node te id=%s
\n', $n->getAttribute('id'));
- }
}
}
@@ -1346,9 +1289,6 @@ class Xmlhttp implements ControllerProviderInterface
$zhtml .= '';
}
}
- if ($request->get('debug')) {
- printf('zhtml=%s
\n', $zhtml);
- }
$html->appendChild($ret->createTextNode($zhtml));
}
@@ -1434,10 +1374,6 @@ class Xmlhttp implements ControllerProviderInterface
$tsbas['b' . $sbas_id]['tids'][] = implode('.', $id);
}
- if ($request->get('debug')) {
- var_dump($tsbas);
- }
-
$appbox = $app['phraseanet.appbox'];
// first, count the number of records to update
@@ -1489,22 +1425,12 @@ class Xmlhttp implements ControllerProviderInterface
$stmt = $connbas->prepare($sql);
$stmt->execute();
- if ($request->get('debug')) {
- printf("(%d) sql: \n", __LINE__);
- var_dump($sql);
- }
-
$tsbas[$ksbas]['trids'] = $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
$stmt->closeCursor();
$ret['nRecsToUpdate'] += count($tsbas[$ksbas]['trids']);
}
- if ($request->get('debug')) {
- printf("(%d) nRecsToUpdate = %d \ntsbas: \n", __LINE__, $ret['nRecsToUpdate']);
- print_r($tsbas);
- }
-
if ($ret['nRecsToUpdate'] <= self::SEARCH_REPLACE_MAXREC) {
foreach ($tsbas as $sbas) {
@@ -1518,10 +1444,6 @@ class Xmlhttp implements ControllerProviderInterface
// fix caption of records
foreach ($sbas['trids'] as $rid) {
-
- if ($request->get('debug')) {
- printf("(%d) ======== working on record_id = %d ======= \n", __LINE__, $rid);
- }
try {
$record = $databox->get_record($rid);
@@ -1531,17 +1453,10 @@ class Xmlhttp implements ControllerProviderInterface
/* @var $field caption_field */
foreach ($record->get_caption()->get_fields(null, true) as $field) {
$meta_struct_id = $field->get_meta_struct_id();
- if ($request->get('debug')) {
- printf("(%d) field '%s' meta_struct_id=%s \n", __LINE__, $field->get_name(), $meta_struct_id);
- }
-
/* @var $v caption_Field_Value */
$fname = $field->get_name();
if (!array_key_exists($fname, $sbas['tvals'])) {
foreach ($field->get_values() as $v) {
- if ($request->get('debug')) {
- printf("(%d) ...v = '%s' (meta_id=%s) keep \n", __LINE__, $v->getValue(), $v->getId());
- }
$metadatask[] = array(
'meta_struct_id' => $meta_struct_id,
'meta_id' => $v->getId(),
@@ -1558,9 +1473,6 @@ class Xmlhttp implements ControllerProviderInterface
}
}
- if ($request->get('debug')) {
- printf("(%d) ...v = '%s' (meta_id=%s) %s \n", __LINE__, $v->getValue(), $v->getId(), ($keep ? '' : '!!! drop !!!'));
- }
if ($keep) {
$metadatask[] = array(
'meta_struct_id' => $meta_struct_id,
@@ -1578,13 +1490,6 @@ class Xmlhttp implements ControllerProviderInterface
}
}
- if ($request->get('debug')) {
- printf("(%d) metadatask: \n", __LINE__);
- var_dump($metadatask);
- printf("(%d) metadatasd: \n", __LINE__);
- var_dump($metadatasd);
- }
-
if (count($metadatasd) > 0) {
if (!$request->get('debug')) {
$record->set_metadatas($metadatasd, true);
@@ -1596,10 +1501,6 @@ class Xmlhttp implements ControllerProviderInterface
}
}
- // delete the branch from the cterms
- if ($request->get('debug')) {
- printf("cterms before :\n%s \n", $sbas['domct']->saveXML());
- }
foreach ($sbas['tvals'] as $tval) {
foreach ($tval as $sy) {
// remove candidate from cterms
@@ -1608,9 +1509,6 @@ class Xmlhttp implements ControllerProviderInterface
$ret['ctermsDeleted'][] = $sbas['sbas_id'] . '.' . $te->getAttribute('id');
}
}
- if ($request->get('debug')) {
- printf("cterms after :\n%s \n", $sbas['domct']->saveXML());
- }
if (!$request->get('debug')) {
$databox->saveCterms($sbas['domct']);
}
@@ -1669,21 +1567,13 @@ class Xmlhttp implements ControllerProviderInterface
if (($q !== null) && $domth) {
$xpath = new \DOMXPath($domth);
- if ($request->get('debug'))
- print('q:' . $q . "\n");
-
$t = $this->splitTermAndContext($request->get('t'));
$q2 = 'starts-with(@w, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[0])) . '\')';
if ($t[1])
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
$q2 = '//sy[' . $q2 . ' and @lng=\'' . $lng . '\']';
- if ($request->get('debug'))
- print('q2:' . $q2 . "\n");
-
$q .= $q2;
- if ($request->get('debug'))
- print('q:' . $q . "\n");
$nodes = $xpath->query($q);
@@ -1691,8 +1581,6 @@ class Xmlhttp implements ControllerProviderInterface
$nodes->item($i)->setAttribute('bold', '1');
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
$n->setAttribute('open', '1');
- if ($request->get('debug'))
- printf("opening node te id=%s \n", $n->getAttribute('id'));
}
}
diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
index 03b6081ea6..f5e2f2a497 100644
--- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
+++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
@@ -431,7 +431,7 @@ class PhraseaEngine implements SearchEngineInterface
$data['record_id'],
$resultNumber
));
- } catch (Exception $e) {
+ } catch (\Exception $e) {
}
$resultNumber++;
diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php
index 611c3677d5..9a72d64e9d 100644
--- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php
+++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php
@@ -506,7 +506,7 @@ class SphinxSearchEngine implements SearchEngineInterface
);
$results->add($record);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
}
$resultOffset++;
diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php
index 7603b5e060..cf49980ad9 100644
--- a/lib/classes/User/Adapter.php
+++ b/lib/classes/User/Adapter.php
@@ -69,7 +69,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
*
* @var array
*/
- protected static $def_values = array(
+ public static $def_values = array(
'view' => 'thumbs',
'images_per_page' => 20,
'images_size' => 120,
@@ -275,6 +275,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected $password;
+ protected $preferences_loaded = false;
+ protected $notifications_preferences_loaded = false;
+
/**
*
* @param Integer $id
@@ -1030,7 +1033,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_preferences()
{
- if ($this->_prefs) {
+ if ($this->preferences_loaded) {
return $this;
}
@@ -1051,42 +1054,49 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
}
$this->_prefs[$k] = $v;
- $this->update_pref($k, $v);
}
}
- $this->load_notifications_preferences($this->app);
+ $this->preferences_loaded = true;
return $this;
}
protected function load_notifications_preferences(Application $app)
{
- $notifications = $app['events-manager']->list_notifications_available();
+ $this->load_preferences();
+
+ $notifications = $app['events-manager']->list_notifications_available($this->id);
foreach ($notifications as $notification_group => $nots) {
foreach ($nots as $notification) {
if (!isset($this->_prefs['notification_' . $notification['id']])) {
$this->_prefs['notification_' . $notification['id']] = '1';
-
- $this->update_pref('notification_' . $notification['id'], '1');
}
}
}
+ $this->notification_preferences_loaded = true;
}
public function get_notifications_preference(Application $app, $notification_id)
{
- $this->load_preferences($app);
+ if (!$this->notifications_preferences_loaded)
+ $this->load_notifications_preferences($app);
- return isset($this->_prefs['notification_' . $notification_id]) ? $this->_prefs['notification_' . $notification_id] : null;
+ return isset($this->_prefs['notification_' . $notification_id]) ? $this->_prefs['notification_' . $notification_id] : '0';
}
public function set_notification_preference(Application $app, $notification_id, $value)
{
- $this->load_preferences($app);
+ if (!$this->notifications_preferences_loaded)
+ $this->load_notifications_preferences($app);
- return $this->_prefs['notification_' . $notification_id] = $value ? '1' : '0';
+ $prop = 'notification_' . $notification_id;
+ $value = $value ? '1' : '0';
+
+ $this->setPrefs($prop, $value);
+
+ return ;
}
public function get_display_name()
@@ -1172,15 +1182,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->_prefs[$prop];
}
- public function getPrefs($prop)
+ public function getPrefs($prop, $default = null)
{
$this->load_preferences();
- if (!isset($this->_prefs[$prop])) {
- $this->_prefs[$prop] = null;
- $this->update_pref($prop, null);
- }
- return $this->_prefs[$prop];
+ return array_key_exists($prop, $this->_prefs) ? $this->_prefs[$prop] : $default;
}
public static function get_sys_admins(Application $app)
diff --git a/lib/classes/eventsmanager/broker.php b/lib/classes/eventsmanager/broker.php
index 8a4436e420..977eaa4db2 100644
--- a/lib/classes/eventsmanager/broker.php
+++ b/lib/classes/eventsmanager/broker.php
@@ -56,7 +56,7 @@ class eventsmanager_broker
foreach ($this->pool_classes[$classname]->get_events() as $event)
$this->bind($event, $classname);
- if ($type === 'notify' && $this->pool_classes[$classname]->is_available())
+ if ($type === 'notify' && $this->pool_classes[$classname])
$this->notifications[] = $classname;
}
}
@@ -273,11 +273,14 @@ class eventsmanager_broker
return $this;
}
- public function list_notifications_available()
+ public function list_notifications_available($usr_id)
{
$personnal_notifications = array();
foreach ($this->notifications as $notification) {
+ if (!$this->pool_classes[$notification]->is_available($usr_id)) {
+ continue;
+ }
$group = $this->pool_classes[$notification]->get_group();
$group = $group === null ? _('Notifications globales') : $group;
diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php
index 185e22eec9..17a8c88177 100644
--- a/lib/classes/eventsmanager/notify/autoregister.php
+++ b/lib/classes/eventsmanager/notify/autoregister.php
@@ -214,21 +214,22 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
- $bool = false;
-
- if ( ! $this->app['authentication']->isAuthenticated() || ! $this->app['registration.enabled']) {
+ if (!$this->app['registration.enabled']) {
return false;
}
- if ($this->app['acl']->get($this->app['authentication']->getUser())->has_right('manageusers') === true) {
- $bool = true;
+ try {
+ $user = \User_Adapter::getInstance($usr_id, $this->app);
+ } catch (\Exception $e) {
+ return false;
}
- return $bool;
+ return $user->ACL()->has_right('manageusers');
}
}
diff --git a/lib/classes/eventsmanager/notify/bridgeuploadfail.php b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
index 4e062ee96c..692ab2ad54 100644
--- a/lib/classes/eventsmanager/notify/bridgeuploadfail.php
+++ b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
@@ -159,10 +159,11 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/downloadmailfail.php b/lib/classes/eventsmanager/notify/downloadmailfail.php
index 8ca9d55593..b73e55b5cd 100644
--- a/lib/classes/eventsmanager/notify/downloadmailfail.php
+++ b/lib/classes/eventsmanager/notify/downloadmailfail.php
@@ -144,10 +144,11 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php
index 5d1205e4fb..f566989653 100644
--- a/lib/classes/eventsmanager/notify/feed.php
+++ b/lib/classes/eventsmanager/notify/feed.php
@@ -176,10 +176,11 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php
index 4b41677299..6f29cc405c 100644
--- a/lib/classes/eventsmanager/notify/order.php
+++ b/lib/classes/eventsmanager/notify/order.php
@@ -182,20 +182,18 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
- $bool = false;
- if ( !$this->app['authentication']->isAuthenticated()) {
+ try {
+ $user = \User_Adapter::getInstance($usr_id, $this->app);
+ } catch (\Exception $e) {
return false;
}
- if ($this->app['acl']->get($this->app['authentication']->getUser())->has_right('order_master')) {
- $bool = true;
- }
-
- return $bool;
+ return $user->ACL()->has_right('order_master');
}
}
diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php
index 5ac5833779..ca41782a65 100644
--- a/lib/classes/eventsmanager/notify/orderdeliver.php
+++ b/lib/classes/eventsmanager/notify/orderdeliver.php
@@ -196,10 +196,11 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php
index bd92be9074..b555eedf07 100644
--- a/lib/classes/eventsmanager/notify/ordernotdelivered.php
+++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php
@@ -141,10 +141,11 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php
index cfad060a02..b9a2143ff7 100644
--- a/lib/classes/eventsmanager/notify/push.php
+++ b/lib/classes/eventsmanager/notify/push.php
@@ -162,10 +162,11 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/register.php b/lib/classes/eventsmanager/notify/register.php
index 96632a40e0..5fe9364239 100644
--- a/lib/classes/eventsmanager/notify/register.php
+++ b/lib/classes/eventsmanager/notify/register.php
@@ -193,21 +193,24 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
- $bool = false;
-
- if ( !$this->app['authentication']->isAuthenticated() || ! $this->app['registration.enabled']) {
+ if (!$this->app['registration.enabled']) {
return false;
}
+ try {
+ $user = \User_Adapter::getInstance($usr_id, $this->app);
+ } catch (\Exception $e) {
+ return false;
if ($this->app['acl']->get($this->app['authentication']->getUser())->has_right('manageusers')) {
$bool = true;
}
- return $bool;
+ return $user->ACL()->has_right('manageusers');
}
}
diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php
index a0fb5e4b76..186ceb687d 100644
--- a/lib/classes/eventsmanager/notify/uploadquarantine.php
+++ b/lib/classes/eventsmanager/notify/uploadquarantine.php
@@ -182,15 +182,18 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
- if (null !== $this->app['authentication']->getUser()) {
- return $this->app['acl']->get($this->app['authentication']->getUser())->has_right('addrecord');
+ try {
+ $user = \User_Adapter::getInstance($usr_id, $this->app);
+ } catch (\Exception $e) {
+ return false;
}
- return false;
+ return $user->ACL()->has_right('addrecord');
}
}
diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php
index 7a8d46d8ed..491836d52f 100644
--- a/lib/classes/eventsmanager/notify/validate.php
+++ b/lib/classes/eventsmanager/notify/validate.php
@@ -190,10 +190,11 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php
index a0742f5235..f8cde00545 100644
--- a/lib/classes/eventsmanager/notify/validationdone.php
+++ b/lib/classes/eventsmanager/notify/validationdone.php
@@ -178,21 +178,18 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return boolean
*/
- public function is_available()
+ public function is_available($usr_id)
{
- $bool = false;
-
- if ( ! $this->app['authentication']->isAuthenticated()) {
+ try {
+ $user = \User_Adapter::getInstance($usr_id, $this->app);
+ } catch (\Exception $e) {
return false;
}
- if ($this->app['acl']->get($this->app['authentication']->getUser())->has_right('push')) {
- $bool = true;
- }
-
- return $bool;
+ return $user->ACL()->has_right('push');
}
}
diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php
index 56f6908c98..b8b898134f 100644
--- a/lib/classes/eventsmanager/notify/validationreminder.php
+++ b/lib/classes/eventsmanager/notify/validationreminder.php
@@ -187,10 +187,11 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
}
/**
+ * @param integer $usr_id The id of the user to check
*
* @return string
*/
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/eventsmanager/notifyAbstract.php b/lib/classes/eventsmanager/notifyAbstract.php
index 272a7f82a3..2a7bb3372d 100644
--- a/lib/classes/eventsmanager/notifyAbstract.php
+++ b/lib/classes/eventsmanager/notifyAbstract.php
@@ -11,7 +11,7 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
abstract public function datas($datas, $unread);
- public function is_available()
+ public function is_available($usr_id)
{
return true;
}
diff --git a/lib/classes/patch/381alpha3a.php b/lib/classes/patch/381alpha3a.php
new file mode 100644
index 0000000000..4d391c529c
--- /dev/null
+++ b/lib/classes/patch/381alpha3a.php
@@ -0,0 +1,73 @@
+release;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function require_all_upgrades()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function concern()
+ {
+ return $this->concern;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply(base $appbox, Application $app)
+ {
+ $propSql = $propArgs = array();
+ $n = 0;
+
+ foreach (\User_Adapter::$def_values as $prop => $value) {
+ if ('start_page_query' === $prop) {
+ continue;
+ }
+ $propSql[] = '(prop = :prop_'.$n.' AND value = :value_'.$n.')';
+ $propArgs[':prop_'.$n] = $prop;
+ $propArgs[':value_'.$n] = $value;
+ $n++;
+ }
+
+ $sql = "DELETE FROM usr_settings
+ WHERE 1 AND (".implode(' OR ', $propSql)." OR value IS NULL OR (value = 1 AND prop LIKE 'notification_%'))";
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute($propArgs);
+ $stmt->closeCursor();
+
+ return true;
+ }
+}
diff --git a/lib/conf.d/minifyGroupsConfig.php b/lib/conf.d/minifyGroupsConfig.php
index 96917c9f49..727d5a35be 100644
--- a/lib/conf.d/minifyGroupsConfig.php
+++ b/lib/conf.d/minifyGroupsConfig.php
@@ -42,9 +42,11 @@ $groups = array(
, '//assets/jquery.ui/i18n/jquery-ui-i18n.js'
, '//include/jquery.kb-event.js'
, '//skins/admin/users.js'
+ , '//skins/admin/template-dialogs.js'
, '//skins/admin/editusers.js'
, '//include/jquery.common.js'
, '//include/jquery.tooltip.js'
+ , '//skins/prod/jquery.Dialog.js'
, '//include/jslibs/jquery.contextmenu_scroll.js'
, '//assets/blueimp-load-image/load-image.js'
, '//assets/jquery-file-upload/jquery.iframe-transport.js'
diff --git a/templates/web/account/account.html.twig b/templates/web/account/account.html.twig
index e23ff26884..4ee167d3dd 100644
--- a/templates/web/account/account.html.twig
+++ b/templates/web/account/account.html.twig
@@ -154,7 +154,7 @@
{% for notification in nots %}
diff --git a/templates/web/admin/index.html.twig b/templates/web/admin/index.html.twig
index 8fe1b82766..c188e0e518 100644
--- a/templates/web/admin/index.html.twig
+++ b/templates/web/admin/index.html.twig
@@ -18,10 +18,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-