mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +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/story/.*$ /prod/router.php last;
|
||||||
rewrite ^/prod/WorkZone/.*$ /prod/router.php last;
|
rewrite ^/prod/WorkZone/.*$ /prod/router.php last;
|
||||||
rewrite ^/prod/language/.*$ /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 ^/prod/$ /prod/router.php last;
|
||||||
|
|
||||||
rewrite ^/robots.txt$ /index.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('/baskets', new Controller\Basket());
|
||||||
$app->mount('/story', new Controller\Story());
|
$app->mount('/story', new Controller\Story());
|
||||||
$app->mount('/WorkZone', new Controller\WorkZone());
|
$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,8 +1487,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->load_preferences();
|
$this->load_preferences();
|
||||||
if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value)
|
if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value)
|
||||||
|
{
|
||||||
return $value;
|
return $this->_prefs[$prop];
|
||||||
|
}
|
||||||
|
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
RewriteRule ^prod/records/edit/.*$ /prod/router.php [L]
|
RewriteRule ^prod/records/edit/.*$ /prod/router.php [L]
|
||||||
RewriteRule ^prod/records/movecollection/.*$ /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/bridge/.*$ /prod/router.php [L]
|
||||||
RewriteRule ^prod/MustacheLoader/.*$ /prod/router.php [L]
|
RewriteRule ^prod/MustacheLoader/.*$ /prod/router.php [L]
|
||||||
RewriteRule ^prod/feeds/.*$ /prod/router.php [L]
|
RewriteRule ^prod/feeds/.*$ /prod/router.php [L]
|
||||||
|
@@ -304,12 +304,13 @@ function setPref(name,value)
|
|||||||
|
|
||||||
jQuery.data['pref_'+name] = $.ajax({
|
jQuery.data['pref_'+name] = $.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/prod/prodFeedBack.php",
|
url: "/prod/UserPreferences/save/",
|
||||||
data: {
|
data: {
|
||||||
action: "SAVEPREF",
|
action: "SAVEPREF",
|
||||||
prop:name,
|
prop:name,
|
||||||
value:value
|
value:value
|
||||||
},
|
},
|
||||||
|
dataType:'json',
|
||||||
timeout: function(){
|
timeout: function(){
|
||||||
jQuery.data['pref_'+name] = false;
|
jQuery.data['pref_'+name] = false;
|
||||||
},
|
},
|
||||||
@@ -317,6 +318,14 @@ function setPref(name,value)
|
|||||||
jQuery.data['pref_'+name] = false;
|
jQuery.data['pref_'+name] = false;
|
||||||
},
|
},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
|
if(data.success)
|
||||||
|
{
|
||||||
|
humane.info(data.message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
humane.error(data.message);
|
||||||
|
}
|
||||||
jQuery.data['pref_'+name] = false;
|
jQuery.data['pref_'+name] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -71,30 +71,6 @@ switch ($action)
|
|||||||
$parm = $request->get_parms('color');
|
$parm = $request->get_parms('color');
|
||||||
$output = $user->setPrefs('css', $color);
|
$output = $user->setPrefs('css', $color);
|
||||||
break;
|
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':
|
case 'SAVETEMPPREF':
|
||||||
$parm = $request->get_parms('prop', 'value');
|
$parm = $request->get_parms('prop', 'value');
|
||||||
@@ -113,11 +89,6 @@ switch ($action)
|
|||||||
$output = deleteRecord($parm['lst'], $parm['del_children']);
|
$output = deleteRecord($parm['lst'], $parm['del_children']);
|
||||||
break;
|
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':
|
case 'DENY_CGU':
|
||||||
$parm = $request->get_parms('sbas_id');
|
$parm = $request->get_parms('sbas_id');
|
||||||
$output = databox_cgu::denyCgus($parm['sbas_id']);
|
$output = databox_cgu::denyCgus($parm['sbas_id']);
|
||||||
|
Reference in New Issue
Block a user