diff --git a/config/nginx.rewrite.rules b/config/nginx.rewrite.rules index ecbafe5bf0..36ece7295c 100644 --- a/config/nginx.rewrite.rules +++ b/config/nginx.rewrite.rules @@ -29,6 +29,7 @@ rewrite ^/prod/baskets/.*$ /prod/router.php last; rewrite ^/prod/story/.*$ /prod/router.php last; rewrite ^/prod/WorkZone/.*$ /prod/router.php last; rewrite ^/prod/language/.*$ /prod/router.php last; +rewrite ^/prod/UserPreferences/.*$ /prod/router.php last; rewrite ^/prod/$ /prod/router.php last; rewrite ^/robots.txt$ /index.php last; diff --git a/lib/Alchemy/Phrasea/Application/Prod.php b/lib/Alchemy/Phrasea/Application/Prod.php index b48b89ff9a..98e09c6240 100644 --- a/lib/Alchemy/Phrasea/Application/Prod.php +++ b/lib/Alchemy/Phrasea/Application/Prod.php @@ -39,6 +39,7 @@ return call_user_func(function() ); }); + $app->mount('/UserPreferences/', new Controller\UserPreferences()); $app->mount('/baskets', new Controller\Basket()); $app->mount('/story', new Controller\Story()); $app->mount('/WorkZone', new Controller\WorkZone()); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php new file mode 100644 index 0000000000..3e224ae144 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php @@ -0,0 +1,69 @@ +post('/save/', function(Application $app, Request $request) + { + $ret = array('success' => false, 'message' => _('Error while saving preference')); + + try + { + $user = $app['Core']->getAuthenticatedUser(); + + $ret = $user->setPrefs($request->get('prop'), $request->get('value')); + + if ($ret == $request->get('value')) + $output = "1"; + else + $output = "0"; + + $ret = array('success' => true, 'message' => _('Preference saved !')); + } + catch (\Exception $e) + { + + } + + $Serializer = $app['Core']['Serializer']; + $datas = $Serializer->serialize($ret, 'json'); + + return new Response($datas, 200, array('Content-Type' => 'application/json')); + }); + + return $controllers; + } + +} \ No newline at end of file diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 1f071314ec..bbb48927a3 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -1487,9 +1487,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $this->load_preferences(); if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value) - - return $value; - + { + return $this->_prefs[$prop]; + } + $ok = true; if (isset(self::$available_values[$prop])) diff --git a/www/.htaccess b/www/.htaccess index 8b1e4187a8..1f394eaab4 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -20,6 +20,7 @@ RewriteRule ^prod/records/edit/.*$ /prod/router.php [L] RewriteRule ^prod/records/movecollection/.*$ /prod/router.php [L] + RewriteRule ^prod/UserPreferences/.*$ /prod/router.php [L] RewriteRule ^prod/bridge/.*$ /prod/router.php [L] RewriteRule ^prod/MustacheLoader/.*$ /prod/router.php [L] RewriteRule ^prod/feeds/.*$ /prod/router.php [L] @@ -64,7 +65,7 @@ RewriteRule ^admin/test-h264$ admin/adminFeedback.php?action=APACHE&test=success [L] - + RewriteRule ^admin/test-rewrite$ admin/adminFeedback.php?action=APACHE&test=fail [L] RewriteRule ^admin/test-xsendfile$ admin/adminFeedback.php?action=APACHE&test=fail [L] RewriteRule ^admin/test-authtoken$ admin/adminFeedback.php?action=APACHE&test=fail [L] diff --git a/www/include/jquery.common.js b/www/include/jquery.common.js index 58667bf6b2..b32ec5d06f 100644 --- a/www/include/jquery.common.js +++ b/www/include/jquery.common.js @@ -6,14 +6,14 @@ $(document).ready(function(){ function(){$(this).removeClass('hover');} ); var locale = $.cookie('locale'); - + 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[jq_date]); @@ -23,7 +23,7 @@ $(document).ready(function(){ var cache = $('#mainMenu .helpcontextmenu'); $('.context-menu-item',cache).hover(function(){$(this).addClass('context-menu-item-hover');},function(){$(this).removeClass('context-menu-item-hover');}); - + $('#help-trigger').contextMenu('#mainMenu .helpcontextmenu',{openEvt:'click',dropDown:true,theme:'vista', dropDown:true, showTransition:'slideDown', hideTransition:'hide', @@ -42,14 +42,14 @@ $(document).ready(function(){ else { box.show(); - + fix_notification_height(); - + $(this).addClass('open'); read_notifications(); } }); - + $(this).bind('mousedown',function(){ var not_trigger = $('#notification_trigger'); if(not_trigger.hasClass('open')) @@ -58,12 +58,12 @@ $(document).ready(function(){ $('#notification_box').bind('mousedown',function(event){ event.stopPropagation(); }); - + $('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');}); $('#notification_box div.notification').live('mouseout',function(){$(this).removeClass('hover');}); - - + + $(this).bind('mousedown',function(){ var box = $('#notification_box'); if($('#notification_trigger').hasClass('open')) @@ -73,10 +73,10 @@ $(document).ready(function(){ clear_notifications(); } }); - + set_notif_position(); - - + + }); @@ -116,11 +116,11 @@ function fix_notification_height() var n = not.length; var not_t = $('.notification_title',box); var n_t = not_t.length; - + h = not.outerHeight() * n + not_t.outerHeight() * n_t; h = h > 350 ? 350 : h; - - box.stop().animate({height:h}); + + box.stop().animate({height:h}); } function set_notif_position() @@ -149,7 +149,7 @@ function print_notifications(page) if($('#notifications-dialog').length === 0) $('body').append('
'); - + $('#notifications-dialog') .dialog({ title:language.notifications, @@ -170,7 +170,7 @@ function print_notifications(page) } }).dialog('option','buttons',buttons) .dialog('open'); - + $.ajax({ type: "POST", @@ -194,7 +194,7 @@ function print_notifications(page) cont.empty(); else $('.notification_next',cont).remove(); - + for (i in data.notifications) { var id = 'notif_date_'+i; @@ -219,14 +219,14 @@ function print_notifications(page) date_cont.append(html); } } - + var next_ln = $.trim(data.next); - + if(next_ln !== '') { cont.append('
'+next_ln+'
'); } - + // '
'. // '
'. // ''. @@ -235,21 +235,21 @@ function print_notifications(page) // $data['text'].' '. // '
'. // '
' - - + + } }); - + } function read_notifications() { var notifications = []; - + $('#notification_box .unread').each(function(){ notifications.push($(this).attr('id').split('_').pop()); }); - + $.ajax({ type: "POST", url: "/prod/prodFeedBack.php", @@ -266,10 +266,10 @@ function read_notifications() function clear_notifications() { var unread = $('#notification_box .unread'); - + if(unread.length === 0) return; - + unread.removeClass('unread'); $('#notification_trigger .counter').css('visibility','hidden').empty(); } @@ -282,7 +282,7 @@ function clear_notifications() function getMyRss(renew) { - + $.ajax({ type: "POST", url: "/prod/prodFeedBack.php", @@ -291,7 +291,7 @@ function getMyRss(renew) success: function(data){ } }); - + } function setPref(name,value) @@ -304,12 +304,13 @@ function setPref(name,value) jQuery.data['pref_'+name] = $.ajax({ type: "POST", - url: "/prod/prodFeedBack.php", + url: "/prod/UserPreferences/save/", data: { action: "SAVEPREF", prop:name, value:value }, + dataType:'json', timeout: function(){ jQuery.data['pref_'+name] = false; }, @@ -317,6 +318,14 @@ function setPref(name,value) jQuery.data['pref_'+name] = false; }, success: function(data){ + if(data.success) + { + humane.info(data.message); + } + else + { + humane.error(data.message); + } jQuery.data['pref_'+name] = false; return; } @@ -349,7 +358,7 @@ function manageSession(data, showMessages) { if(typeof(showMessages) == "undefined") showMessages = false; - + if(data.status == 'disconnected' || data.status == 'session') { disconnected(); @@ -359,10 +368,10 @@ function manageSession(data, showMessages) { var box = $('#notification_box'); box.empty().append(data.notifications); - + if(box.is(':visible')) fix_notification_height(); - + if($('.notification.unread',box).length > 0) { var trigger = $('#notification_trigger') ; @@ -370,7 +379,7 @@ function manageSession(data, showMessages) .empty() .append($('.notification.unread',box).length); $('.counter',trigger).css('visibility','visible'); - + } else $('#notification_trigger .counter').css('visibility','hidden').empty(); @@ -437,7 +446,7 @@ function disconnected() } function showModal(cas, options){ - + var content = ''; var callback = null; var button = { @@ -449,7 +458,7 @@ function showModal(cas, options){ }}; var escape = true; var onClose = function(){}; - + switch (cas) { case 'timeout': content = language.serverTimeout; @@ -465,9 +474,9 @@ function showModal(cas, options){ default: break; } - + p4.Alerts(options.title, content, callback); - + return; } @@ -482,7 +491,7 @@ function showOverlay(n,appendto,callback, zIndex){ appendto = 'body'; $(appendto).append(''); } - + var css = { display: 'block', opacity: 0, @@ -493,10 +502,10 @@ function showOverlay(n,appendto,callback, zIndex){ zIndex:zIndex, left:0 }; - + if(parseInt(zIndex) > 0) css['zIndex'] = parseInt(zIndex); - + if(typeof(callback) != 'function') callback = function(){}; $('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();}); diff --git a/www/prod/prodFeedBack.php b/www/prod/prodFeedBack.php index aeed89942e..057177ac5a 100644 --- a/www/prod/prodFeedBack.php +++ b/www/prod/prodFeedBack.php @@ -71,30 +71,6 @@ switch ($action) $parm = $request->get_parms('color'); $output = $user->setPrefs('css', $color); break; - case 'MYRSS': - require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); - $parm = $request->get_parms('renew'); - - $url = $user->get_protected_rss_url(($parm['renew'] === 'true'))->get_url(); - - $output = p4string::jsonencode( - array( - 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') - . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

-
', - 'titre' => _('publications::votre rss personnel') - ) - ); - break; - - case 'SAVEPREF': - $parm = $request->get_parms('prop', 'value'); - $ret = $user->setPrefs($parm['prop'], $parm['value']); - if (isset($ret[$parm['prop']]) && $ret[$parm['prop']] = $parm['value']) - $output = "1"; - else - $output = "0"; - break; case 'SAVETEMPPREF': $parm = $request->get_parms('prop', 'value'); @@ -113,11 +89,6 @@ switch ($action) $output = deleteRecord($parm['lst'], $parm['del_children']); break; - case 'MAIL_REQ': - $parm = $request->get_parms('user', 'contrib', 'message', 'query'); - $output = query_phrasea::mail_request($parm['user'], $parm['contrib'], $parm['message'], $parm['query']); - break; - case 'DENY_CGU': $parm = $request->get_parms('sbas_id'); $output = databox_cgu::denyCgus($parm['sbas_id']);