mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Add dedicated route for user preferences
This commit is contained in:
@@ -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;
|
||||
|
@@ -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());
|
||||
|
69
lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php
Normal file
69
lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Silex\Application,
|
||||
Silex\ControllerProviderInterface,
|
||||
Silex\ControllerCollection;
|
||||
use Symfony\Component\HttpFoundation\Request,
|
||||
Symfony\Component\HttpFoundation\Response,
|
||||
Symfony\Component\HttpFoundation\RedirectResponse,
|
||||
Symfony\Component\HttpKernel\Exception\HttpException,
|
||||
Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Alchemy\Phrasea\RouteProcessor\Basket as BasketRoute,
|
||||
Alchemy\Phrasea\Helper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class UserPreferences implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->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;
|
||||
}
|
||||
|
||||
}
|
@@ -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]))
|
||||
|
@@ -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 @@
|
||||
<IfModule mod_h264_streaming.c>
|
||||
RewriteRule ^admin/test-h264$ admin/adminFeedback.php?action=APACHE&test=success [L]
|
||||
</IfModule>
|
||||
|
||||
|
||||
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]
|
||||
|
@@ -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('<div id="notifications-dialog" class="loading"></div>');
|
||||
|
||||
|
||||
$('#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('<div class="notification_next">'+next_ln+'</div>');
|
||||
}
|
||||
|
||||
|
||||
// '<div style="position:relative;" id="notification_'.$row['id'].'" class="notification '.($row['unread'] == '1' ? 'unread':'').'">'.
|
||||
// '<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'.
|
||||
// '<img src="'.$this->pool_classes[$row['type']]->icon_url().'" style="vertical-align:middle;width:16px;margin:2px;" />'.
|
||||
@@ -235,21 +235,21 @@ function print_notifications(page)
|
||||
// $data['text'].' <span class="time"></span></div>'.
|
||||
// '</td></tr></table>'.
|
||||
// '</div>'
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
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('<div id="'+div+'" style="display:none;"> </div>');
|
||||
}
|
||||
|
||||
|
||||
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)();});
|
||||
|
@@ -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' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" style="width:100%" value="' . $url . '"/></div>',
|
||||
'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']);
|
||||
|
Reference in New Issue
Block a user