From d0fc37b957e71660f27b1b5ec7c73b7d3eb54b29 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 30 Dec 2011 11:40:21 +0100 Subject: [PATCH 01/20] Fix #134 : browsing a story --- lib/classes/basketCollection.class.php | 4 +++- lib/classes/record/preview.class.php | 3 +-- templates/web/prod/basket_element.twig | 2 +- templates/web/prod/results/record.html | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/classes/basketCollection.class.php b/lib/classes/basketCollection.class.php index 82f254b2ff..7cdf161f9d 100644 --- a/lib/classes/basketCollection.class.php +++ b/lib/classes/basketCollection.class.php @@ -151,7 +151,9 @@ class basketCollection $appbox = appbox::get_instance(); $conn = $appbox->get_connection(); $session = $appbox->get_session(); - $sql = 'SELECT ssel_id FROM sselnew WHERE usr_id = :usr_id'; + $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'; $stmt = $conn->prepare($sql); $stmt->execute(array(':usr_id' => $session->get_usr_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index 5f5cf88dc2..53cd339888 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -112,8 +112,7 @@ class record_preview extends record_adapter break; case "REG": $contId = explode('_', $contId); - $base_id = $contId[0]; - $sbas_id = phrasea::sbasFromBas($base_id); + $sbas_id = $contId[0]; $record_id = $contId[1]; $this->container = new record_adapter($sbas_id, $record_id); diff --git a/templates/web/prod/basket_element.twig b/templates/web/prod/basket_element.twig index c89927913d..cd3edcfebf 100644 --- a/templates/web/prod/basket_element.twig +++ b/templates/web/prod/basket_element.twig @@ -9,7 +9,7 @@ {% import 'common/thumbnail.html' as thumbnail %} {% set record = basket_element.get_record() %} -
{% if user.getPrefs('basket_title_display') == '1' %} diff --git a/templates/web/prod/results/record.html b/templates/web/prod/results/record.html index 14ed145861..92971c7475 100644 --- a/templates/web/prod/results/record.html +++ b/templates/web/prod/results/record.html @@ -13,7 +13,7 @@
+ onDblClick="openPreview('REG','0','{{record.get_serialize_key()}}');"> {% else %}
Date: Fri, 30 Dec 2011 11:59:31 +0100 Subject: [PATCH 02/20] Fix #135 : substitution of a story image --- lib/classes/media/subdef.class.php | 4 ++++ lib/classes/module/prod/route/records/edit.class.php | 4 ++-- lib/classes/record/adapter.class.php | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/classes/media/subdef.class.php b/lib/classes/media/subdef.class.php index d11a7ea94e..dae599d315 100644 --- a/lib/classes/media/subdef.class.php +++ b/lib/classes/media/subdef.class.php @@ -192,6 +192,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'deleted.png'; $this->is_physically_present = false; + $this->is_substituted = true; } if (!$row || !file_exists($this->path . $this->file)) { @@ -204,6 +205,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = 'regroup_thumb.png'; + $this->is_substituted = true; } else { @@ -217,6 +219,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = str_replace('+', '%20', $mime) . '.png'; + $this->is_substituted = true; } $this->is_physically_present = false; if (!file_exists($this->path . $this->file)) @@ -225,6 +228,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'substitution.png'; + $this->is_substituted = true; } } diff --git a/lib/classes/module/prod/route/records/edit.class.php b/lib/classes/module/prod/route/records/edit.class.php index 926be31d8e..c7dd2df9f0 100644 --- a/lib/classes/module/prod/route/records/edit.class.php +++ b/lib/classes/module/prod/route/records/edit.class.php @@ -436,7 +436,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract try { $reg_record = $this->get_grouping_head(); - $reg_sbas_id = $reg_record->get_base_id(); + $reg_sbas_id = $reg_record->get_sbas_id(); $newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent')); @@ -452,7 +452,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract } catch (Exception $e) { - + } } diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 0614dd0f32..da8f587071 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -968,6 +968,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface try { $value = $this->get_subdef($name); + + if ($value->is_substituted()) + { + throw new Exception('Cannot replace a substitution'); + } + $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file(); unlink($original_file); } From ea0a54456754873a6d10ae46d1a92718274c7d5b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 30 Dec 2011 12:45:52 +0100 Subject: [PATCH 03/20] Removed bit.ly --- lib/classes/record/Interface.class.php | 2 - lib/classes/record/adapter.class.php | 48 ---------------------- templates/web/prod/preview/popularity.html | 8 ---- www/prod/share.php | 3 +- 4 files changed, 1 insertion(+), 60 deletions(-) diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php index 1730c36fe7..a97c859d17 100644 --- a/lib/classes/record/Interface.class.php +++ b/lib/classes/record/Interface.class.php @@ -97,8 +97,6 @@ interface record_Interface public function get_reg_name(); - public function get_bitly_link(); - public function get_hd_file(); public function delete(); diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index da8f587071..9a8673306d 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1294,54 +1294,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $regname; } - /** - * - * @return string - */ - public function get_bitly_link() - { - - $registry = registry::get_instance(); - - if ($this->bitly_link !== null) - return $this->bitly_link; - - $this->bitly_link = false; - - if (trim($registry->get('GV_bitly_user')) == '' - && trim($registry->get('GV_bitly_key')) == '') - return $this->bitly_link; - - try - { - $short = new PHPShortener(); - $bitly = $short->encode($url . 'view/', 'bit.ly', $registry); - - if (preg_match('/^(http:\/\/)?(www\.)?([^\/]*)\/(.*)$/', $bitly, $results)) - { - if ($results[3] && $results[4]) - { - $hash = 'http://bit.ly/' . $results[4]; - $sql = 'UPDATE record SET bitly = :hash WHERE record_id = :record_id'; - - $connbas = connection::getPDOConnection($this->get_sbas_id()); - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':hash' => $hash, ':record_id' => $this->get_record_id())); - $stmt->closeCursor(); - - $this->bitly_link = 'http://bit.ly/' . $hash; - } - } - } - catch (Exception $e) - { - unset($e); - } - $this->delete_data_from_cache(); - - return $this->bitly_link; - } - /** * * @param collection $collection diff --git a/templates/web/prod/preview/popularity.html b/templates/web/prod/preview/popularity.html index 86b56bd55d..b66e47694c 100644 --- a/templates/web/prod/preview/popularity.html +++ b/templates/web/prod/preview/popularity.html @@ -1,12 +1,4 @@ - {% if record.get_bitly_link() and user.ACL().has_right_on_base(record.get_base_id(), 'canreport') %} -
- {% trans 'preview::statistiques pour le lien' %} - - http://bit.ly/{{record.get_bitly_link()}}
- {% endif %} - {% if record.get_view_popularity() %}
{% trans 'preview::statistiques de visualisation pour le lien' %} diff --git a/www/prod/share.php b/www/prod/share.php index 01e7f6245b..da0ac5b38f 100644 --- a/www/prod/share.php +++ b/www/prod/share.php @@ -67,7 +67,6 @@ if (!$right) $sha256 = $record->get_sha256(); $type = $record->get_type(); -$bitly = $record->get_bitly_link(); $url = ''; @@ -114,7 +113,7 @@ if ($url != '') ?>
From 6c9812da7e116040293a511d1a0c32861dc968ec Mon Sep 17 00:00:00 2001 From: jygaulier Date: Fri, 30 Dec 2011 18:07:15 +0100 Subject: [PATCH 04/20] add attribute ldap_created + get/set --- lib/classes/User/Adapter.class.php | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index d16b15e780..8061239e92 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -222,6 +222,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface */ protected $is_admin; + /** + * + * @var boolean + */ + protected $ldap_created; + /** * * @var boolean @@ -587,6 +593,23 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return $this; } + /** + * + * @param boolean $boolean + * @return User_Adapter + */ + public function set_ldap_created($boolean) + { + $value = $boolean ? '1' : '0'; + $sql = 'UPDATE usr SET ldap_created = :ldap_created WHERE usr_id = :usr_id'; + $stmt = $this->appbox->get_connection()->prepare($sql); + $stmt->execute(array(':ldap_created' => $value, ':usr_id' => $this->get_id())); + $stmt->closeCursor(); + $this->ldap_created = $boolean; + + return $this; + } + /** * * @param string $address @@ -838,7 +861,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id())); $stmt->closeCursor(); - + $this->set_ftp_address('') ->set_activeftp(false) ->set_city('') @@ -1020,7 +1043,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface */ public function load($id) { - $sql = 'SELECT usr_id, create_db, usr_login, usr_nom, activite, + $sql = 'SELECT usr_id, ldap_created, create_db, usr_login, usr_nom, activite, usr_prenom, usr_sexe as gender, usr_mail, adresse, usr_creationdate, usr_modificationdate, ville, cpostal, tel, fax, fonction, societe, geonameid, lastModel, invite, defaultftpdatasent, mail_notifications, activeftp, addrftp, loginftp, @@ -1036,6 +1059,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $this->id = (int) $row['usr_id']; $this->email = $row['usr_mail']; $this->login = $row['usr_login']; + + $this->ldap_created = $row['ldap_created']; $this->defaultftpdatas = $row['defaultftpdatasent']; $this->mail_notifications = $row['mail_notifications']; @@ -1115,6 +1140,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return $this->id; } + public function get_ldap_created() + { + return $this->ldap_created; + } + public function is_guest() { return $this->is_guest; From 37d8fc26e9db3663bc6e6800410baa3f749ba03f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Jan 2012 16:26:06 +0100 Subject: [PATCH 05/20] Removed bas_manage right --- lib/classes/ACL.class.php | 2 -- lib/classes/User/Adapter.class.php | 1 - lib/classes/collection.class.php | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index 26949a568f..ccd588066c 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -1325,8 +1325,6 @@ class ACL implements cache_cacheableInterface $rights['manage'] = true; if ($row['modify_struct']) $rights['modify_struct'] = true; - if ($row['bas_manage']) - $rights['bas_manage'] = true; $this->update_rights_to_base($base_id_dest, $rights); diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 1680b2176e..3124d68bdc 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -1746,7 +1746,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface , 'imgtools' => '1' , 'manage' => '1' , 'modify_struct' => '1' - , 'bas_manage' => '1' , 'bas_modify_struct' => '1' ); diff --git a/lib/classes/collection.class.php b/lib/classes/collection.class.php index cdcd17fd83..53f4ec6df6 100644 --- a/lib/classes/collection.class.php +++ b/lib/classes/collection.class.php @@ -533,8 +533,7 @@ class collection implements cache_cacheableInterface "chgstatus" => "1", "imgtools" => "1", "manage" => "1", - "modify_struct" => "1", - "bas_manage" => "1" + "modify_struct" => "1" ); $user->ACL()->update_rights_to_base($base_id, $rights); From a8a8f57052fa00fa0d2ac24c1b56ec1a09fce76a Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Jan 2012 16:27:06 +0100 Subject: [PATCH 06/20] Bimp to version 3.5.6 --- lib/version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/version.inc b/lib/version.inc index 104f48509f..7113a41042 100644 --- a/lib/version.inc +++ b/lib/version.inc @@ -15,5 +15,5 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -define('GV_version', '3.5.5.0'); +define('GV_version', '3.5.6.0'); define('GV_version_name', 'Baobab'); From 008b1d66f656cb0be6e588ed3e6e4666108f0fd9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 11:27:03 +0100 Subject: [PATCH 07/20] Fix #140 : bad calendar in english --- www/include/jquery.common.js | 12 +++++++++--- www/prod/page0.js | 29 +++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/www/include/jquery.common.js b/www/include/jquery.common.js index 0324842e42..a501b5858b 100644 --- a/www/include/jquery.common.js +++ b/www/include/jquery.common.js @@ -1,15 +1,21 @@ +var p4 = p4 || {}; + $(document).ready(function(){ - $('input.input-button').hover( function(){$(this).addClass('hover');}, function(){$(this).removeClass('hover');} ); var locale = $.cookie('locale'); - p4.lng = locale !== null ? locale.split('_').reverse().pop() : 'en'; + var jq_date = p4.lng = locale !== null ? locale.split('_').reverse().pop() : 'en'; + + if(jq_date == 'en') + { + jq_date = 'en-GB'; + } $.datepicker.setDefaults({showMonthAfterYear: false}); - $.datepicker.setDefaults($.datepicker.regional[p4.lng]); + $.datepicker.setDefaults($.datepicker.regional[jq_date]); $('a.infoDialog,div.infoDialog').live('click',function(event){ infoDialog($(this)); diff --git a/www/prod/page0.js b/www/prod/page0.js index 1cca969b0a..96ad4d2e2c 100644 --- a/www/prod/page0.js +++ b/www/prod/page0.js @@ -1,6 +1,6 @@ document.getElementById('loader_bar').style.width = '30%'; -var p4 = {}; +var p4 = p4 || {}; var baskAjax,baskAjaxrunning; baskAjaxrunning = false; @@ -1398,24 +1398,21 @@ $(document).ready(function(){ $('#loader_bar').stop().animate({ width:'70%' },450); - p4 = { - preview :{ + p4.preview = { open:false, current:false - }, - currentViewMode:'classic', - nbNoview:0, - reg_delete:true, - lng:'', - sel:[], - baskSel:[], - edit:{}, - thesau:{ + }; + p4.currentViewMode = 'classic'; + p4.nbNoview = 0; + p4.reg_delete = true; + p4.sel = []; + p4.baskSel = []; + p4.edit = {}; + p4.thesau = { tabs:null - }, - active_zone:false, - next_bask_scroll: false - }; + }; + p4.active_zone = false; + p4.next_bask_scroll = false; $('#backcolorpickerHolder').ColorPicker({ From de91fc5c0e630eaa5200bd64358794e9eabc9847 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:39:20 +0100 Subject: [PATCH 08/20] Fix status conversion --- lib/classes/databox/status.class.php | 57 ++++++++++++++++++--- lib/unitTest/databox/databox_statusTest.php | 56 +++++++++++--------- 2 files changed, 84 insertions(+), 29 deletions(-) diff --git a/lib/classes/databox/status.class.php b/lib/classes/databox/status.class.php index 5dee255c3b..ed3262c244 100644 --- a/lib/classes/databox/status.class.php +++ b/lib/classes/databox/status.class.php @@ -479,6 +479,15 @@ class databox_status $conn = connection::getPDOConnection(); $status = '0'; + + if(substr($stat1, 0, 2) === '0x') + { + $stat1 = self::hex2bin(substr($stat1, 2)); + } + if(substr($stat2, 0, 2) === '0x') + { + $stat2 = self::hex2bin(substr($stat2, 2)); + } $sql = 'select bin(0b' . trim($stat1) . ' & 0b' . trim($stat2) . ') as result'; @@ -501,6 +510,15 @@ class databox_status $status = '0'; + if(substr($stat1, 0, 2) === '0x') + { + $stat1 = self::hex2bin(substr($stat1, 2)); + } + if(substr($stat2, 0, 2) === '0x') + { + $stat2 = self::hex2bin(substr($stat2, 2)); + } + $sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result'; $stmt = $conn->prepare($sql); @@ -522,6 +540,15 @@ class databox_status $status = '0'; + if(substr($stat1, 0, 2) === '0x') + { + $stat1 = self::hex2bin(substr($stat1, 2)); + } + if(substr($stat2, 0, 2) === '0x') + { + $stat2 = self::hex2bin(substr($stat2, 2)); + } + $sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result'; $stmt = $conn->prepare($sql); @@ -539,17 +566,24 @@ class databox_status public static function dec2bin($status) { + $status = (string) $status; + + if(!ctype_digit($status)) + { + throw new \Exception('Non-decimal value'); + } + $conn = connection::getPDOConnection(); - $status = '0'; - - $sql = 'select bin(' . ((int) $status) . ') as result'; + $sql = 'select bin(' . $status . ') as result'; $stmt = $conn->prepare($sql); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); + $status = '0'; + if ($row) { $status = $row['result']; @@ -560,17 +594,28 @@ class databox_status public static function hex2bin($status) { + $status = (string) $status; + if(substr($status, 0, 2) === '0x') + { + $status = substr($status, 2); + } + + if(!ctype_xdigit($status)) + { + throw new \Exception('Non-hexadecimal value'); + } + $conn = connection::getPDOConnection(); - $status = '0'; - - $sql = 'select bin(0x' . trim($status) . ') as result'; + $sql = 'select BIN( CAST( 0x'.trim($status).' AS UNSIGNED ) ) as result'; $stmt = $conn->prepare($sql); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); + $status = '0'; + if ($row) { $status = $row['result']; diff --git a/lib/unitTest/databox/databox_statusTest.php b/lib/unitTest/databox/databox_statusTest.php index 7f3d5cdd0a..b13cc8f8bc 100644 --- a/lib/unitTest/databox/databox_statusTest.php +++ b/lib/unitTest/databox/databox_statusTest.php @@ -14,6 +14,7 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract */ protected $object; protected $databox; + protected static $need_records = 1; public function setUp() { @@ -119,10 +120,10 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract */ public function testOperation_and() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals('0', databox_status::operation_and('0x001','0x010')); + $this->assertEquals('1', databox_status::operation_and('01','11')); + $this->assertEquals('0', databox_status::operation_and('01','10')); + $this->assertEquals('10', databox_status::operation_and('11','10')); } /** @@ -130,10 +131,11 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract */ public function testOperation_and_not() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals('0', databox_status::operation_and_not('0x001','0x011')); + $this->assertEquals('0', databox_status::operation_and_not('01','11')); + $this->assertEquals('1', databox_status::operation_and_not('01','10')); + $this->assertEquals('1', databox_status::operation_and_not('11','10')); + $this->assertEquals('10', databox_status::operation_and_not('10','01')); } /** @@ -141,10 +143,8 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract */ public function testOperation_or() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals('10001', databox_status::operation_or('0x001','0x011')); + $this->assertEquals('11', databox_status::operation_or('01','11')); } /** @@ -152,21 +152,31 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract */ public function testDec2bin() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals('1010', databox_status::dec2bin('10')); + + try + { + } + catch(Exception $e) + { + + } } - /** - * @todo Implement testHex2bin(). - */ public function testHex2bin() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals('10100001', databox_status::hex2bin('0x0A1')); + $this->assertEquals('10100001', databox_status::hex2bin('0A1')); + + try + { + databox_status::hex2bin('G1'); + $this->fail('Should raise an exception'); + } + catch(Exception $e) + { + + } } } From a2c0a7dbd4e55ef53709681ee5b57484222d512f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:45:21 +0100 Subject: [PATCH 09/20] Fix#143 : auto-authentication --- lib/classes/gatekeeper.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/classes/gatekeeper.class.php b/lib/classes/gatekeeper.class.php index 8cd4184f66..a0a47e72d6 100644 --- a/lib/classes/gatekeeper.class.php +++ b/lib/classes/gatekeeper.class.php @@ -161,7 +161,10 @@ class gatekeeper break; case 'lightbox': $this->token_access(); -// phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); + if(!$session->is_authenticated()) + { + phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); + } break; } } From 06887a068d41797391a4e1cefe42a7f3a6fa2dc9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:45:44 +0100 Subject: [PATCH 10/20] Basket should'nt load if empty --- lib/classes/module/Lightbox.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/classes/module/Lightbox.php b/lib/classes/module/Lightbox.php index 0e848d2b6a..0c7a362ad4 100644 --- a/lib/classes/module/Lightbox.php +++ b/lib/classes/module/Lightbox.php @@ -193,7 +193,8 @@ return call_user_func( if ($basket->is_valid()) { - $basket->get_first_element()->load_users_infos(); + if($basket->get_first_element() instanceof basket_element_adapter) + $basket->get_first_element()->load_users_infos(); } $twig = new supertwig(); From a8faa8ceef89bf57185c4d7744de6c1fb3564dfe Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:47:32 +0100 Subject: [PATCH 11/20] Fix #142 : add default user sort to date desc --- lib/classes/module/admin/route/users.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/classes/module/admin/route/users.class.php b/lib/classes/module/admin/route/users.class.php index eefd77e8a8..d2107c6e08 100644 --- a/lib/classes/module/admin/route/users.class.php +++ b/lib/classes/module/admin/route/users.class.php @@ -59,8 +59,8 @@ class module_admin_route_users , 'like_value' => $request->get('like_value') , 'sbas_id' => $request->get('sbas_id') , 'base_id' => $request->get('base_id') - , 'srt' => $request->get("srt") - , 'ord' => $request->get("ord") + , 'srt' => $request->get("srt", User_Query::SORT_CREATIONDATE) + , 'ord' => $request->get("ord", User_Query::ORD_DESC) , 'per_page' => $results_quantity , 'offset_start' => $offset_start ); @@ -68,14 +68,14 @@ class module_admin_route_users $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $query = new User_Query($appbox); - if (is_array($request->get('base_id'))) - $query->on_base_ids($request->get('base_id')); - elseif (is_array($request->get('sbas_id'))) - $query->on_sbas_ids($request->get('sbas_id')); + if (is_array($this->query_parms['base_id'])) + $query->on_base_ids($this->query_parms['base_id']); + elseif (is_array($this->query_parms['sbas_id'])) + $query->on_sbas_ids($this->query_parms['sbas_id']); - $this->results = $query->sort_by($request->get("srt"), $request->get("ord")) - ->like($request->get('like_field'), $request->get('like_value')) - ->get_inactives($request->get('inactives')) + $this->results = $query->sort_by($this->query_parms["srt"], $this->query_parms["ord"]) + ->like($this->query_parms['like_field'], $this->query_parms['like_value']) + ->get_inactives($this->query_parms['inactives']) ->include_templates(true) ->on_bases_where_i_am($user->ACL(), array('canadmin')) ->limit($offset_start, $results_quantity) From 9c15b5d9001c02afc3a3626d051a7ab873e7c0db Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:48:06 +0100 Subject: [PATCH 12/20] Add check before opening phrasea session --- lib/classes/Session/Handler.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/classes/Session/Handler.class.php b/lib/classes/Session/Handler.class.php index 901accc362..46dfd229be 100644 --- a/lib/classes/Session/Handler.class.php +++ b/lib/classes/Session/Handler.class.php @@ -322,6 +322,9 @@ class Session_Handler */ public function open_phrasea_session() { + if (!$this->phrasea_session instanceof Session_Phrasea) + throw new \Exception('No phrasea session available'); + $this->phrasea_session->open(); return $this; From 745d27b821a1513cde25723cef7ec566af0ad632 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:49:13 +0100 Subject: [PATCH 13/20] Fix #142 : add ability to apply template from user rights view --- lib/classes/Controller/Admin/Users.class.php | 8 ++- .../module/admin/route/users/edit.class.php | 8 ++- templates/web/admin/editusers.twig | 50 ++++++++++++------- www/admin/editusers.js | 12 +++++ 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/lib/classes/Controller/Admin/Users.class.php b/lib/classes/Controller/Admin/Users.class.php index 7f76233759..6ea71eb53a 100644 --- a/lib/classes/Controller/Admin/Users.class.php +++ b/lib/classes/Controller/Admin/Users.class.php @@ -88,6 +88,12 @@ class Controller_Admin_Users implements ControllerProviderInterface $request = $app['request']; $rights = new module_admin_route_users_edit($request); $rights->apply_rights(); + + if ($app['request']->get('template')) + { + $rights->apply_template(); + } + $rights->apply_infos(); $datas = array('error' => false); @@ -198,7 +204,7 @@ class Controller_Admin_Users implements ControllerProviderInterface { $request = $app['request']; $users = new module_admin_route_users_edit($request); - + $users->apply_template(); return new Symfony\Component\HttpFoundation\RedirectResponse('/admin/users/search/'); diff --git a/lib/classes/module/admin/route/users/edit.class.php b/lib/classes/module/admin/route/users/edit.class.php index b9161d94ae..e876a18e27 100644 --- a/lib/classes/module/admin/route/users/edit.class.php +++ b/lib/classes/module/admin/route/users/edit.class.php @@ -179,13 +179,19 @@ class module_admin_route_users_edit } } + $query = new User_Query($appbox); + $templates = $query + ->only_templates(true) + ->execute()->get_results(); + $this->users_datas = $rs; $out = array( 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, - 'main_user' => null + 'main_user' => null, + 'templates'=>$templates ); if (count($this->users) == 1) diff --git a/templates/web/admin/editusers.twig b/templates/web/admin/editusers.twig index dd36b33274..db2cd0be98 100644 --- a/templates/web/admin/editusers.twig +++ b/templates/web/admin/editusers.twig @@ -106,35 +106,46 @@
-
+
-
-

- {% if main_user is not empty %} - {% set display_name = main_user.get_display_name() %} - {% trans %} - Edition des droits de {{ display_name }} - {% endtrans %} - {% else %} - {% set number = users|length %} - {% trans %} - Edition des droits de {{ number }} utilisateurs - {% endtrans %} - {% endif %} -

-
+ + + + + +
+ {% if main_user is not empty %} + {% set display_name = main_user.get_display_name() %} + {% trans %} + Edition des droits de {{ display_name }} + {% endtrans %} + {% else %} + {% set number = users|length %} + {% trans %} + Edition des droits de {{ number }} utilisateurs + {% endtrans %} + {% endif %} + + {% trans 'Apply a template' %} + +
@@ -521,6 +532,7 @@ {% endif %}
- + + {% trans 'boutton::retour' %}
diff --git a/www/admin/editusers.js b/www/admin/editusers.js index a9721ef94e..5e7dfdaa35 100644 --- a/www/admin/editusers.js +++ b/www/admin/editusers.js @@ -78,6 +78,7 @@ function ini_edit_usrs(){ var datas = { users:$('#users_rights_form input[name="users"]').val(), values:$('#users_rights_form').serialize(), + template:$('#users_rights_form select[name="template"]').val(), user_infos:$('#user_infos_form').serialize() }; $.ajax({ @@ -94,6 +95,17 @@ function ini_edit_usrs(){ }); return false; }); + + $('#right-ajax .users_rights_cancel').bind('click', function(){ + var $this = $(this); + $('#right-ajax').empty().addClass('loading').parent().show(); + $('#right').hide(); + $.get($this.attr('href'), function(data) { + $('#right-ajax').removeClass('loading').html(data); + }); + + return false; + }); var time_buttons = { 'Ok':function(){ From 2818211b2adcbc281e2f6988b2cefc431caf0c22 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 13:50:34 +0100 Subject: [PATCH 14/20] Fix #139 : unable to change status --- www/prod/chgstatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/prod/chgstatus.php b/www/prod/chgstatus.php index 22427b8c97..3659dc18ce 100644 --- a/www/prod/chgstatus.php +++ b/www/prod/chgstatus.php @@ -112,7 +112,7 @@ if ($parm["act"] == "START" || $parm["act"] == "WORK") $status = databox_status::operation_or($status, $msko[$basrec[0]]); $record->set_binary_status($status); - $session->get_logger($databox) + $session->get_logger($record->get_databox()) ->log($record, Session_Logger::EVENT_STATUS, '', ''); basket_adapter::revoke_baskets_record($record, $appbox); From 654ca168c73bb78545f1fb42c59e69620ba3bcbd Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 14:21:13 +0100 Subject: [PATCH 15/20] Removed invite and autoregister links from dashboard --- www/admin/sitestruct.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/www/admin/sitestruct.php b/www/admin/sitestruct.php index 6963f31d8c..665a5a2802 100644 --- a/www/admin/sitestruct.php +++ b/www/admin/sitestruct.php @@ -213,33 +213,6 @@ if ($parm['flush_cache'] && $registry->get('GV_cache_server_type') !== 'nocache'


- -
- -
-

From dfa31dc3b8545bbbbd3a4bbd5bb6da0478196eb7 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 14:22:06 +0100 Subject: [PATCH 16/20] Add link to autoregister setup --- templates/web/admin/editusers.twig | 21 +++++++++++++++------ templates/web/admin/users.html | 7 +++++++ www/admin/users.js | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/templates/web/admin/editusers.twig b/templates/web/admin/editusers.twig index db2cd0be98..871438a121 100644 --- a/templates/web/admin/editusers.twig +++ b/templates/web/admin/editusers.twig @@ -111,7 +111,7 @@
  • {% trans 'Rights' %}
  • - {% if main_user is not empty and main_user.is_template is empty %} + {% if main_user is not empty and main_user.is_template is empty and main_user.is_special is empty %}
  • {% trans 'Infos' %}
  • @@ -124,10 +124,19 @@
    {% if main_user is not empty %} - {% set display_name = main_user.get_display_name() %} - {% trans %} - Edition des droits de {{ display_name }} - {% endtrans %} + + {% if main_user.is_special is not empty %} + {% if main_user.get_login() == 'invite' %} + {% trans 'Reglages:: reglages d acces guest' %} + {% elseif main_user.get_login() == 'autoregister' %} + {% trans 'Reglages:: reglages d inscitpition automatisee' %} + {% endif %} + {% else %} + {% set display_name = main_user.get_display_name() %} + {% trans %} + Edition des droits de {{ display_name }} + {% endtrans %} + {% endif %} {% else %} {% set number = users|length %} {% trans %} @@ -413,7 +422,7 @@ - {% if main_user is not empty and main_user.is_template is empty %} + {% if main_user is not empty and main_user.is_template is empty and main_user.is_special is empty %}
    diff --git a/templates/web/admin/users.html b/templates/web/admin/users.html index 47c1ea5099..162ce53a65 100644 --- a/templates/web/admin/users.html +++ b/templates/web/admin/users.html @@ -34,6 +34,13 @@ + + + + {% trans 'Reglages:: reglages d inscitpition automatisee' %} + + +

    diff --git a/www/admin/users.js b/www/admin/users.js index a64db944b0..6eecde8195 100644 --- a/www/admin/users.js +++ b/www/admin/users.js @@ -362,7 +362,7 @@ $(document).ready(function(){ }); return false; }); - $('#users_page .invite_modifier').live('click', function(){ + $('#users_page .invite_modifier, #users_page .autoregister_modifier').live('click', function(){ var users = $(this).next('input').val(); if($.trim(users) === '') From 732301fba26023bbc52e6c1eab1a5e9620cd55ac Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 14:22:44 +0100 Subject: [PATCH 17/20] Add User_Adapter::is_special method --- lib/classes/User/Adapter.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 1c0843b44a..dc7b48fe13 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -893,6 +893,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { return $this->is_template; } + + public function is_special() + { + return in_array($this->login, array('invite', 'autoregister')); + } public function get_template_owner() { From e288fb01894c758afea404fd8dcdb0cb955f9f40 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 14:56:50 +0100 Subject: [PATCH 18/20] Fix #141 : wrong report datas --- lib/classes/module/report/sqlfilter.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/classes/module/report/sqlfilter.class.php b/lib/classes/module/report/sqlfilter.class.php index 6a7878e200..a38e3531b0 100644 --- a/lib/classes/module/report/sqlfilter.class.php +++ b/lib/classes/module/report/sqlfilter.class.php @@ -46,7 +46,7 @@ class module_report_sqlfilter $coll_filter = array(); foreach (explode(',', $list_coll_id) as $val) { - $coll_filter [] = " position('," . (int) $val . ",' in concat(',' ,coll_list, ',')) > 0 "; + $coll_filter [] = " position('," . phrasea::collFromBas($val) . ",' in concat(',' ,coll_list, ',')) > 0 "; } $ret['sql'] = implode(' OR ', $coll_filter); @@ -207,7 +207,7 @@ class module_report_sqlfilter { foreach ($tab as $val) { - $coll_filter[] = " position('," . (int) $val . ",' in concat(',' ,coll_list, ',')) > 0 "; + $coll_filter[] = " position('," . phrasea::collFromBas($val) . ",' in concat(',' ,coll_list, ',')) > 0 "; } $this->filter['collection'] = array('sql' => implode(' OR ', $coll_filter), 'params' => array()); } @@ -226,7 +226,7 @@ class module_report_sqlfilter foreach ($tab as $val) { $dl_coll_filter[] = "record.coll_id = :record_fil" . $n; - $params[":record_fil" . $n] = $val; + $params[":record_fil" . $n] = phrasea::collFromBas($val); $n++; } $this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params); From 74bb32cb8befb6904d437a4d276d9a4248fcfcb8 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 3 Jan 2012 14:57:52 +0100 Subject: [PATCH 19/20] Fix #136 : untranslated strings --- templates/web/prod/index.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/web/prod/index.html b/templates/web/prod/index.html index d6c4d0d7d6..e7603784a4 100644 --- a/templates/web/prod/index.html +++ b/templates/web/prod/index.html @@ -616,9 +616,7 @@ - +