diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index ccd588066c..91c73943ae 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -321,7 +321,7 @@ class ACL implements cache_cacheableInterface $this->give_access_to_base($bas_to_acces); - foreach ($rights_to_give as $sbas_id => $rights) + foreach ($rights_to_give as $base_id => $rights) { $this->update_rights_to_base($base_id, $rights); } diff --git a/lib/classes/basket/adapter.class.php b/lib/classes/basket/adapter.class.php index fb65eb54ee..246415cd1d 100644 --- a/lib/classes/basket/adapter.class.php +++ b/lib/classes/basket/adapter.class.php @@ -24,121 +24,145 @@ class basket_adapter implements cache_cacheableInterface * @var string */ protected $name = false; + /** * * @var string */ protected $desc = false; + /** * * @var DateTime */ protected $created_on; + /** * * @var DateTime */ protected $updated_on; + /** * * @var User_Adapter */ protected $pusher; + /** * * @var boolean */ protected $noview = false; + /** * * @var string */ protected $instance_key; + /** * * @var mixed */ protected $valid = false; + /** * * @var boolean */ protected $is_grouping = false; + /** * * @var int */ protected $record_id; + /** * * @var boolean */ protected $is_mine = false; + /** * * @var int */ protected $usr_id; + /** * * @var array */ protected $elements; + /** * * @var int */ protected $ssel_id; + /** * * @var array */ protected $validating_users = array(); + /** * * @var boolean */ protected $validation_see_others = false; + /** * * @var boolean */ protected $validation_end_date = false; + /** * * @var boolean */ protected $validation_is_confirmed = false; + /** * * @var int */ protected $sbas_id; + /** * * @var int */ protected $coll_id; + /** * * @var int */ protected $base_id; + /** * * @var boolean */ protected $owner_changed = false; + /** * * @var array */ static $_regfields = null; + /** * * @var appbox */ protected $appbox; + /** * * @var boolean @@ -303,7 +327,6 @@ class basket_adapter implements cache_cacheableInterface public function get_first_element() { foreach ($this->get_elements() as $basket_element) - return $basket_element; return null; } @@ -315,7 +338,6 @@ class basket_adapter implements cache_cacheableInterface public function get_validation_end_date() { if (!$this->valid || !$this->validation_end_date) - return null; return $this->validation_end_date; } @@ -327,7 +349,6 @@ class basket_adapter implements cache_cacheableInterface public function is_validation_finished() { if (!$this->valid || !$this->validation_end_date) - return null; $now = new DateTime(); @@ -341,7 +362,6 @@ class basket_adapter implements cache_cacheableInterface public function is_confirmed() { if (!$this->valid) - return null; return $this->validation_is_confirmed; @@ -350,17 +370,14 @@ class basket_adapter implements cache_cacheableInterface public function is_releasable() { if (!$this->valid) - return false; if ($this->is_confirmed()) - return false; - foreach($this->get_elements() as $element) + foreach ($this->get_elements() as $element) { - if($element->get_my_agreement() == '0') - + if ($element->get_my_agreement() == '0') return false; } @@ -460,7 +477,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT s.pushFrom, n.id as noview, s.usr_id as owner, s.rid @@ -494,7 +511,6 @@ class basket_adapter implements cache_cacheableInterface $this->desc = $row['descript']; $this->created_on = new DateTime($row['date']); $this->updated_on = new DateTime($row['updater']); - $this->usr_id = (int) $row['owner']; $this->noview = !!$row['noview']; $this->is_mine = ($row['owner'] == $this->usr_id); @@ -526,7 +542,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -569,7 +585,6 @@ class basket_adapter implements cache_cacheableInterface public function sort($order) { if (!$this->valid || !in_array($order, array('asc', 'desc'))) - return; $this->load_elements(); @@ -615,7 +630,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception_Record_AdapterNotFound $e) { - + } catch (Exception $e) { @@ -730,7 +745,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -885,7 +900,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } } @@ -1001,7 +1016,6 @@ class basket_adapter implements cache_cacheableInterface public function set_read() { if (!$this->noview) - return true; $session = $this->appbox->get_session(); @@ -1112,19 +1126,15 @@ class basket_adapter implements cache_cacheableInterface if ($this->is_mine) { if ($this->is_validation_finished()) - return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); else - return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); } else { if ($this->validation_see_others) - return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); else - return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); } } @@ -1135,7 +1145,7 @@ class basket_adapter implements cache_cacheableInterface */ public function set_released() { - if(!$this->is_valid()) + if (!$this->is_valid()) throw new Exception('Not a validation basket'); $session = $this->appbox->get_session(); @@ -1164,12 +1174,26 @@ class basket_adapter implements cache_cacheableInterface if ($row) { + $expires = new DateTime('+10 days'); + $url = $this->appbox->get_registry()->get('GV_ServerName') + . 'lightbox/index.php?LOG=' . random::getUrlToken( + 'validate' + , $session->get_usr_id() + , $expires + , $this->get_ssel_id() + ); + + $to = $row['usr_id']; $params = array( 'ssel_id' => $this->ssel_id, 'from' => $session->get_usr_id(), + 'url' => $url, 'to' => $to ); + + + $evt_mngr->trigger('__VALIDATION_DONE__', $params); } @@ -1219,7 +1243,6 @@ class basket_adapter implements cache_cacheableInterface protected function load_elements() { if (!is_null($this->elements)) - return; $this->elements = array(); @@ -1246,7 +1269,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -1281,7 +1304,7 @@ class basket_adapter implements cache_cacheableInterface $stmt->closeCursor(); $this->name = $name; - + $this->delete_data_from_cache(); return $this; @@ -1301,7 +1324,7 @@ class basket_adapter implements cache_cacheableInterface $this->desc = $desc; $this->delete_data_from_cache(); - + return $this; } @@ -1344,7 +1367,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } return array('error' => true, 'status' => 0); @@ -1384,7 +1407,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $ret = array('error' => false, 'status' => 0); @@ -1497,14 +1520,11 @@ class basket_adapter implements cache_cacheableInterface public function remove_from_ssel($sselcont_id) { if (!$this->is_mine) - return array('error' => 'error', 'status' => 0); if ($this->is_grouping) - return $this->remove_grouping_elements($sselcont_id); else - return $this->remove_basket_elements($sselcont_id); } @@ -1521,14 +1541,14 @@ class basket_adapter implements cache_cacheableInterface foreach ($this->get_validating_users() as $user_data) { $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id(); - $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; - $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; + $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id() . '_' . self::CACHE_ELEMENTS; + $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id() . '_' . self::CACHE_VALIDATING_USERS; } } $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id(); - $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; - $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; + $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id() . '_' . self::CACHE_ELEMENTS; + $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id() . '_' . self::CACHE_VALIDATING_USERS; $this->appbox->delete_data_from_cache($keys); @@ -1844,7 +1864,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } return $appbox->delete_data_from_cache($ssel_ids); @@ -1872,7 +1892,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT id, usr_id, confirmed, can_agree, can_see_others diff --git a/lib/classes/basketCollection.class.php b/lib/classes/basketCollection.class.php index 7cdf161f9d..b4045de7e0 100644 --- a/lib/classes/basketCollection.class.php +++ b/lib/classes/basketCollection.class.php @@ -151,9 +151,8 @@ class basketCollection $appbox = appbox::get_instance(); $conn = $appbox->get_connection(); $session = $appbox->get_session(); - $sql = 'SELECT n.ssel_id FROM sselnew n, ssel s - WHERE s.ssel_id = n.ssel_id AND n.usr_id = :usr_id - AND n.usr_id = s.usr_id'; + $sql = 'SELECT n.ssel_id FROM sselnew n + WHERE n.usr_id = :usr_id '; $stmt = $conn->prepare($sql); $stmt->execute(array(':usr_id' => $session->get_usr_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -162,7 +161,17 @@ class basketCollection $baskets = array(); foreach($rs as $row) { - $baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); + try + { + $baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); + } + catch(Exception $e) + { + $sql = 'DELETE FROM sselnew WHERE ssel_id = :ssel_id AND usr_id = :usr_id'; + $stmt = $conn->prepare($sql); + $stmt->execute(array(':usr_id' => $session->get_usr_id(), ':ssel_id' => $row['ssel_id'])); + $stmt->closeCursor(); + } } return $baskets; diff --git a/lib/classes/eventsmanager/notify/validationdone.class.php b/lib/classes/eventsmanager/notify/validationdone.class.php index 107409993e..26ccf938e5 100644 --- a/lib/classes/eventsmanager/notify/validationdone.class.php +++ b/lib/classes/eventsmanager/notify/validationdone.class.php @@ -110,7 +110,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract 'name' => $user_from->get_display_name() ); - if (self::mail($to, $from, $params['ssel_id'])) + if (self::mail($to, $from, $params['ssel_id'], $params['url'])) $mailed = true; } @@ -189,7 +189,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract * @param int $ssel_id * @return boolean */ - function mail($to, $from, $ssel_id) + function mail($to, $from, $ssel_id, $url) { try { @@ -211,7 +211,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract $from['name'] ) . "\n"; - $body .= "
\n" . $this->registry->get('GV_ServerName') . 'lightbox/validate/' . $ssel_id; + $body .= "
\n" . $url; return mail::send_mail($subject, $body, $to, $from, array()); } diff --git a/lib/classes/gatekeeper.class.php b/lib/classes/gatekeeper.class.php index a0a47e72d6..97aa6996bb 100644 --- a/lib/classes/gatekeeper.class.php +++ b/lib/classes/gatekeeper.class.php @@ -76,7 +76,6 @@ class gatekeeper $session = $appbox->get_session(); if (http_request::is_command_line()) - return; if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) @@ -105,7 +104,7 @@ class gatekeeper } catch (Exception $e) { - + } } @@ -122,7 +121,6 @@ class gatekeeper if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') - return; phrasea::redirect('/login/?redirect=/thesaurus2'); break; @@ -131,7 +129,6 @@ class gatekeeper break; case 'admin': if ($this->_script_name === 'runscheduler.php') - return; phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); break; @@ -151,7 +148,6 @@ class gatekeeper return; case 'setup': if ($appbox->upgradeavailable()) - return; else phrasea::redirect('/login/'); @@ -161,7 +157,7 @@ class gatekeeper break; case 'lightbox': $this->token_access(); - if(!$session->is_authenticated()) + if (!$session->is_authenticated()) { phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); } @@ -268,13 +264,12 @@ class gatekeeper $parm = $request->get_parms('LOG'); if (is_null($parm["LOG"])) - return $this; try { - if($session->is_authenticated()) - $session->logout (); + if ($session->is_authenticated()) + $session->logout(); $auth = new Session_Authentication_Token($appbox, $parm['LOG']); $session->authenticate($auth); } @@ -286,10 +281,11 @@ class gatekeeper try { $datas = random::helloToken($parm['LOG']); + return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/"); } catch (Exception_NotFound $e) { - + } return $this; diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index 53cd339888..330e9e0edf 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -375,8 +375,14 @@ class record_preview extends record_adapter $tab[$hour][$site][$action] = array(); if (!isset($tab[$hour][$site][$action][$row['usr_id']])) + { $tab[$hour][$site][$action][$row['usr_id']] = - array('final' => array(), 'comment' => array()); + array( + 'final' => array() + , 'comment' => array() + , 'user' => \User_Adapter::getInstance($row['usr_id'], $appbox) + ); + } if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) $tab[$hour][$site][$action][$row['usr_id']]['final'][] = diff --git a/templates/web/prod/preview/short_history.html b/templates/web/prod/preview/short_history.html index 2292814be0..5386068f8f 100644 --- a/templates/web/prod/preview/short_history.html +++ b/templates/web/prod/preview/short_history.html @@ -3,7 +3,7 @@ {% for hour, sites in record.get_short_history() %} {% for site, actions in sites %} {% for action, users in actions %} - {% for current_user, done in users %} + {% for done in users %}
@@ -55,9 +55,9 @@ {% endif %} {% if user.ACL().has_right_on_base(record.get_base_id(), 'canreport') %} - {% set user_infos = user.getInfos(current_user) %} - {% if current_user != session.get_usr_id() and user_infos %} - {% trans %}report:: par {{user_infos}}{% endtrans %} + {% if done['user'].get_id() != session.get_usr_id() %} + {% set user_infos = done['user'].get_display_name() %} + {% trans %}report:: par {{ user_infos }}{% endtrans %} {% endif %} {% endif %} diff --git a/www/include/jquery.common.js b/www/include/jquery.common.js index a501b5858b..9b1135d7a9 100644 --- a/www/include/jquery.common.js +++ b/www/include/jquery.common.js @@ -366,7 +366,7 @@ function manageSession(data, showMessages) if($('.notification.unread',box).length > 0) { var trigger = $('#notification_trigger') ; - $('.counter div',trigger) + $('.counter',trigger) .empty() .append($('.notification.unread',box).length); $('.counter',trigger).css('visibility','visible');