diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index 91c73943ae..7140044202 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -872,11 +872,15 @@ class ACL implements cache_cacheableInterface if ($row['order_master'] == '1') $this->_global_rights['order_master'] = true; - if ($row['time_limited'] == '1') + $row['limited_from'] = $row['limited_from'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_from']); + $row['limited_to'] = $row['limited_to'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_to']); + + if ($row['time_limited'] == '1' + && ($row['limited_from'] !== '' || $row['limited_to'] !== '')) { $this->_limited[$row['base_id']] = array( - 'dmin' => new DateTime($row['limited_from']) - , 'dmax' => new DateTime($row['limited_to']) + 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null + , 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null ); } @@ -1444,11 +1448,12 @@ class ACL implements cache_cacheableInterface { return false; } + + $lim_min = $this->_limited[$base_id]['dmin'] && $this->_limited[$base_id]['dmin'] > $datetime; - $ret = ($this->_limited[$base_id]['dmin'] > $datetime - || $this->_limited[$base_id]['dmax'] < $datetime); + $lim_max = $this->_limited[$base_id]['dmax'] && $this->_limited[$base_id]['dmax'] < $datetime; - return $ret; + return $lim_max || $lim_min; } public function get_limits($base_id) diff --git a/lib/classes/User/Query.class.php b/lib/classes/User/Query.class.php index 1aee467595..aa962ba946 100644 --- a/lib/classes/User/Query.class.php +++ b/lib/classes/User/Query.class.php @@ -23,96 +23,115 @@ class User_Query implements User_QueryInterface * @var appbox */ protected $appbox; + /** * * @var Array */ protected $results = array(); + /** * * @var Array */ protected $sort = array(); + /** * * @var Array */ protected $like_field = array(); + /** * * @var Array */ protected $have_rights; + /** * * @var Array */ protected $have_not_rights; + /** * * @var string */ protected $like_match = 'OR'; + /** * * @var string */ protected $get_inactives = ''; + /** * * @var int */ protected $total = 0; + /** * * @var Array */ protected $active_bases = array(); + /** * * @var Array */ protected $active_sbas = array(); + /** * * @var boolean */ protected $bases_restrictions = false; + /** * * @var boolean */ protected $sbas_restrictions = false; + /** * * @var boolean */ protected $include_templates = false; + /** * * @var boolean */ protected $only_templates = false; + /** * * @var Array */ protected $base_ids = array(); + /** * * @var Array */ protected $sbas_ids = array(); + /** * * @var int */ protected $page; + /** * * @var int */ protected $offset_start; + /** * * @var int @@ -124,9 +143,8 @@ class User_Query implements User_QueryInterface const ORD_ASC = 'asc'; const ORD_DESC = 'desc'; - - const SORT_FIRSTNAME= 'usr_prenom'; - const SORT_LASTNAME= 'usr_nom'; + const SORT_FIRSTNAME = 'usr_prenom'; + const SORT_LASTNAME = 'usr_nom'; const SORT_COMPANY = 'societe'; const SORT_LOGIN = 'usr_login'; const SORT_EMAIL = 'usr_mail'; @@ -134,15 +152,13 @@ class User_Query implements User_QueryInterface const SORT_CREATIONDATE = 'usr_creationdate'; const SORT_COUNTRY = 'pays'; const SORT_LASTMODEL = 'lastModel'; - - const LIKE_FIRSTNAME= 'usr_prenom'; - const LIKE_LASTNAME= 'usr_nom'; - const LIKE_NAME= 'name'; + const LIKE_FIRSTNAME = 'usr_prenom'; + const LIKE_LASTNAME = 'usr_nom'; + const LIKE_NAME = 'name'; const LIKE_COMPANY = 'societe'; const LIKE_LOGIN = 'usr_login'; const LIKE_EMAIL = 'usr_mail'; const LIKE_COUNTRY = 'pays'; - const LIKE_MATCH_AND = 'AND'; const LIKE_MATCH_OR = 'OR'; @@ -225,16 +241,13 @@ class User_Query implements User_QueryInterface else { $extra = $this->include_phantoms ? ' OR base_id IS NULL ' : ''; - if (count($this->active_bases) > count($this->base_ids)) + + $not_base_id = array_diff($this->active_bases, $this->base_ids); + + if (count($not_base_id) > 0 && count($not_base_id) < count($this->base_ids)) { $sql .= sprintf(' AND ((base_id != %s ) ' . $extra . ')' - , implode( - ' AND base_id != ' - , array_diff( - $this->active_bases - , $this->base_ids - ) - ) + , implode(' AND base_id != ', $not_base_id) ); } else @@ -246,7 +259,6 @@ class User_Query implements User_QueryInterface } - if (count($this->sbas_ids) == 0) { if ($this->sbas_restrictions) @@ -255,16 +267,13 @@ class User_Query implements User_QueryInterface else { $extra = $this->include_phantoms ? ' OR sbas_id IS NULL ' : ''; - if (count($this->active_sbas) > count($this->sbas_ids)) + + $not_sbas_id = array_diff($this->active_sbas, $this->sbas_ids); + + if (count($not_sbas_id) > 0 && count($not_sbas_id) < count($this->sbas_ids)) { $sql .= sprintf(' AND ((sbas_id != %s ) ' . $extra . ')' - , implode( - ' AND sbas_id != ' - , array_diff( - $this->active_sbas - , $this->sbas_ids - ) - ) + , implode(' AND sbas_id != ', $not_sbas_id) ); } else @@ -293,7 +302,7 @@ class User_Query implements User_QueryInterface } $sql_like = array(); - + foreach ($this->like_field as $like_field => $like_value) { switch ($like_field) @@ -366,6 +375,7 @@ class User_Query implements User_QueryInterface return $this; } + /** * * @param boolean $boolean @@ -479,7 +489,6 @@ class User_Query implements User_QueryInterface public function get_total() { if ($this->total) - return $this->total; $conn = $this->appbox->get_connection(); @@ -581,8 +590,8 @@ class User_Query implements User_QueryInterface */ public function like($like_field, $like_value) { - - if($like_field == self::LIKE_NAME) + + if ($like_field == self::LIKE_NAME) { $this->like_field[self::LIKE_FIRSTNAME] = trim($like_value); $this->like_field[self::LIKE_LASTNAME] = trim($like_value); @@ -591,7 +600,7 @@ class User_Query implements User_QueryInterface { $this->like_field[trim($like_field)] = trim($like_value); } - + $this->total = $this->page = null; return $this; @@ -628,11 +637,12 @@ class User_Query implements User_QueryInterface public function on_base_ids(Array $base_ids = null) { if (!$base_ids) - return $this; $this->bases_restrictions = true; + $this->include_phantoms(false); + if (count($this->base_ids) > 0) $this->base_ids = array_intersect($this->base_ids, $base_ids); else @@ -651,11 +661,12 @@ class User_Query implements User_QueryInterface public function on_sbas_ids(Array $sbas_ids = null) { if (!$sbas_ids) - return $this; $this->sbas_restrictions = true; + $this->include_phantoms(false); + if (count($this->sbas_ids) > 0) $this->sbas_ids = array_intersect($this->sbas_ids, $sbas_ids); else @@ -664,23 +675,6 @@ class User_Query implements User_QueryInterface $this->total = $this->page = null; return $this; -// $base_ids = array(); -// foreach ($sbas_ids as $sbas_id) -// { -// try -// { -// foreach ($this->appbox->get_databox($sbas_id)->get_collections() as $collection) -// $base_ids[] = $collection->get_base_id(); -// if(count($base_ids) > 0) -// $this->bases_restrictions; -// } -// catch (Exception $e) -// { -// -// } -// } -// -// return $this->on_base_ids($base_ids); } /** diff --git a/lib/classes/databox/cgu.class.php b/lib/classes/databox/cgu.class.php index 79d4adb25f..0ba6b99485 100644 --- a/lib/classes/databox/cgu.class.php +++ b/lib/classes/databox/cgu.class.php @@ -94,12 +94,16 @@ class databox_cgu $terms = array(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); - + + if(!$home) + { + $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); + } + foreach ($appbox->get_databoxes() as $databox) { try { - $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $cgus = $databox->get_cgus(); if (!isset($cgus[Session_Handler::get_locale()])) @@ -112,6 +116,10 @@ class databox_cgu if (!$home) { + if(!$user->ACL()->has_access_to_sbas($databox->get_sbas_id())); + { + continue; + } $userValidation = ($user->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== ''); } diff --git a/lib/classes/http/request.class.php b/lib/classes/http/request.class.php index 62b3bfe6c4..c83ee48623 100644 --- a/lib/classes/http/request.class.php +++ b/lib/classes/http/request.class.php @@ -93,6 +93,13 @@ class http_request return true; return false; } + + public function is_secure() + { + return ( + isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) + ); + } public function comes_from_flash() { diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 881bf3e520..5eb39c557c 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1747,14 +1747,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface echo $e->getMessage() . "\n"; } - if (!array_key_exists($subdefname, $record_subdefs)) + if (array_key_exists($subdefname, $record_subdefs)) { - continue; + $record_subdefs[$subdefname]->delete_data_from_cache(); } - $record_subdefs[$subdefname]->delete_data_from_cache(); - - $this->delete_data_from_cache(self::CACHE_SUBDEFS); try { $subdef = $this->get_subdef($subdefname); diff --git a/lib/classes/searchEngine/options.class.php b/lib/classes/searchEngine/options.class.php index ff8949c815..aaff7c25f6 100644 --- a/lib/classes/searchEngine/options.class.php +++ b/lib/classes/searchEngine/options.class.php @@ -353,7 +353,7 @@ class searchEngine_options implements Serializable { if (!is_null($min_date) && trim($min_date) !== '') { - $this->date_min = new DateTime($min_date); + $this->date_min = DateTime::createFromFormat('d/m/Y h:i:s', $min_date.' 00:00:00'); } return $this; @@ -377,7 +377,7 @@ class searchEngine_options implements Serializable { if (!is_null($max_date) && trim($max_date) !== '') { - $this->date_max = new DateTime($max_date); + $this->date_max = DateTime::createFromFormat('d/m/Y h:i:s', $max_date.' 23:59:59'); } return $this; diff --git a/templates/mobile/lightbox/index.twig b/templates/mobile/lightbox/index.twig index 3e2c140483..854bf0c8d8 100644 --- a/templates/mobile/lightbox/index.twig +++ b/templates/mobile/lightbox/index.twig @@ -66,7 +66,7 @@
Phraseanet Version {{core.getVersion().getName()}} - {{core.getVersion().getNumber()}}
License GNU GPL v3
diff --git a/templates/mobile/report/header.twig b/templates/mobile/report/header.twig index 225178a915..88c38e0320 100644 --- a/templates/mobile/report/header.twig +++ b/templates/mobile/report/header.twig @@ -26,7 +26,7 @@ dmax : '{{ dashboard_array.dmax_req }}' }; - + diff --git a/templates/web/admin/users.html b/templates/web/admin/users.html index 162ce53a65..bef6e1e9ac 100644 --- a/templates/web/admin/users.html +++ b/templates/web/admin/users.html @@ -220,8 +220,12 @@ - - + {% for sbas_id in parm.sbas_id %} + + {% endfor %} + {% for base_id in parm.base_id %} + + {% endfor %} diff --git a/templates/web/login/index.twig b/templates/web/login/index.twig index 3404edca5c..b5647271ac 100644 --- a/templates/web/login/index.twig +++ b/templates/web/login/index.twig @@ -46,8 +46,8 @@ {% endif %} {% if display_chrome_frame and session.get_cookie('gfc_box') == false %}