mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Coding standards
This commit is contained in:
@@ -34,4 +34,4 @@ return call_user_func(
|
||||
});
|
||||
|
||||
return $app;
|
||||
});
|
||||
});
|
||||
|
@@ -58,6 +58,7 @@ return call_user_func(
|
||||
{
|
||||
$browser = Browser::getInstance();
|
||||
if (!$browser->isMobile())
|
||||
|
||||
return new Response('');
|
||||
|
||||
$twig = new supertwig();
|
||||
|
@@ -70,10 +70,11 @@ return call_user_func(function()
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
|
||||
}
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return $app;
|
||||
});
|
||||
});
|
||||
|
@@ -34,10 +34,13 @@ return call_user_func(function()
|
||||
{
|
||||
$browser = Browser::getInstance();
|
||||
if ($browser->isMobile())
|
||||
|
||||
return $app->redirect("/login/?redirect=/lightbox");
|
||||
elseif ($browser->isNewGeneration())
|
||||
|
||||
return $app->redirect("/login/?redirect=/prod");
|
||||
else
|
||||
|
||||
return $app->redirect("/login/?redirect=/client");
|
||||
});
|
||||
|
||||
@@ -70,6 +73,7 @@ return call_user_func(function()
|
||||
/**
|
||||
* Mount all aps
|
||||
*/
|
||||
|
||||
return $app;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@@ -49,8 +49,10 @@ return call_user_func(function()
|
||||
$app->get('/', function() use ($app)
|
||||
{
|
||||
if ($app['install'] === true)
|
||||
|
||||
return $app->redirect('/setup/installer/');
|
||||
if ($app['upgrade'] === true)
|
||||
|
||||
return $app->redirect('/setup/upgrader/');
|
||||
});
|
||||
|
||||
@@ -63,6 +65,7 @@ return call_user_func(function()
|
||||
$app->error(function($e) use ($app)
|
||||
{
|
||||
if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled)
|
||||
|
||||
return $app->redirect('/login');
|
||||
|
||||
return new Response(
|
||||
@@ -77,4 +80,4 @@ return call_user_func(function()
|
||||
});
|
||||
|
||||
return $app;
|
||||
});
|
||||
});
|
||||
|
@@ -77,6 +77,7 @@ class module_admin
|
||||
);
|
||||
|
||||
$twig = new supertwig();
|
||||
|
||||
return $twig->render('admin/tree.html.twig', $params);
|
||||
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ class module_admin_route_users
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function export(Symfony\Component\HttpFoundation\Request $request)
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
@@ -143,8 +143,8 @@ class module_admin_route_users
|
||||
if (is_null($v))
|
||||
$this->query_parms[$k] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$query = new User_Query($appbox);
|
||||
$templates = $query
|
||||
->only_templates(true)
|
||||
|
@@ -183,7 +183,7 @@ class module_admin_route_users_edit
|
||||
$templates = $query
|
||||
->only_templates(true)
|
||||
->execute()->get_results();
|
||||
|
||||
|
||||
$this->users_datas = $rs;
|
||||
$out = array(
|
||||
'datas' => $this->users_datas,
|
||||
@@ -543,7 +543,7 @@ class module_admin_route_users_edit
|
||||
}
|
||||
|
||||
$users = $this->users;
|
||||
|
||||
|
||||
$user = User_adapter::getInstance(array_pop($users), appbox::get_instance());
|
||||
|
||||
if ($user->is_template() || $user->is_special())
|
||||
@@ -594,29 +594,29 @@ class module_admin_route_users_edit
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$session = $appbox->get_session();
|
||||
|
||||
|
||||
$template = \User_adapter::getInstance($this->request->get('template'), $appbox);
|
||||
|
||||
if ($template->get_template_owner()->get_id() != $session->get_usr_id())
|
||||
{
|
||||
throw new \Exception_Forbidden('You are not the owner of the template');
|
||||
}
|
||||
|
||||
|
||||
$current_user = \User_adapter::getInstance($session->get_usr_id(), $appbox);
|
||||
$base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin')));
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
$user = \User_adapter::getInstance($usr_id, $appbox);
|
||||
|
||||
|
||||
if($user->is_template())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$user->ACL()->apply_model($template, $base_ids);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -338,7 +338,7 @@ return call_user_func(function()
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
|
||||
@@ -367,7 +367,7 @@ return call_user_func(function()
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new response(json_encode($result), 200, array("content-type" => "application/json"));
|
||||
@@ -387,7 +387,7 @@ return call_user_func(function()
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
|
||||
@@ -405,7 +405,7 @@ return call_user_func(function()
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
|
||||
@@ -430,4 +430,4 @@ return call_user_func(function()
|
||||
|
||||
|
||||
return $app;
|
||||
});
|
||||
});
|
||||
|
@@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
return call_user_func(function(){
|
||||
|
||||
|
||||
|
||||
$app = new Silex\Application();
|
||||
|
||||
@@ -42,7 +42,7 @@ $app["appbox"] = appbox::get_instance();
|
||||
$app['p4user'] = null;
|
||||
|
||||
/**
|
||||
* @var API_OAuth2_Token
|
||||
* @var API_OAuth2_Token
|
||||
*/
|
||||
$app['token'] = null;
|
||||
|
||||
@@ -121,6 +121,7 @@ $parseRoute = function ($route, Response $response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
|
||||
};
|
||||
|
||||
@@ -139,6 +140,7 @@ $app->before(function($request) use ($app)
|
||||
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
|
||||
|
||||
if ($session->is_authenticated())
|
||||
|
||||
return;
|
||||
if ($oauth2_adapter->has_ses_id())
|
||||
{
|
||||
@@ -150,7 +152,7 @@ $app->before(function($request) use ($app)
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
$auth = new Session_Authentication_None($app['p4user']);
|
||||
@@ -171,7 +173,7 @@ $app->after(function (Request $request, Response $response) use ($app, $parseRou
|
||||
$route = $parseRoute($pathInfo, $response);
|
||||
$log = API_V1_Log::create(
|
||||
$app["appbox"],
|
||||
$account,
|
||||
$account,
|
||||
$request->getMethod() . " " . $pathInfo,
|
||||
$response->getStatusCode(),
|
||||
$response->headers->get('content-type'),
|
||||
@@ -659,7 +661,7 @@ $app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
|
||||
*/
|
||||
$app->error(function (\Exception $e) use ($app)
|
||||
{
|
||||
|
||||
|
||||
if ($e instanceof API_V1_exception_methodnotallowed)
|
||||
$code = API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
elseif ($e instanceof Exception\MethodNotAllowedHttpException)
|
||||
@@ -745,4 +747,4 @@ $app->error(function (\Exception $e) use ($app)
|
||||
//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
|
||||
return $app;
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -46,14 +46,14 @@ class module_console_systemUpgrade extends Command
|
||||
|
||||
$output->writeln('This version of Phraseanet requires a config/config.inc');
|
||||
$output->writeln('Would you like it to be created based on your settings ?');
|
||||
|
||||
|
||||
$dialog = $this->getHelperSet()->get('dialog');
|
||||
do
|
||||
{
|
||||
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y'));
|
||||
}
|
||||
while (!in_array($continue, array('y', 'n')));
|
||||
|
||||
|
||||
if ($continue == 'y')
|
||||
{
|
||||
require __DIR__ . "/../../../../config/_GV.php";
|
||||
@@ -64,16 +64,16 @@ class module_console_systemUpgrade extends Command
|
||||
.'$debug=false;'."\n"
|
||||
.'$debug=true;'."\n"
|
||||
.'';
|
||||
|
||||
|
||||
file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
@@ -75,7 +75,7 @@ class module_prod
|
||||
else
|
||||
$dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name);
|
||||
}
|
||||
|
||||
|
||||
if (isset($fields[$name]))
|
||||
{
|
||||
$fields[$name]['sbas'][] = $sbas_id;
|
||||
|
@@ -244,7 +244,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
$_lst[$indice]['type'] = $record->get_type();
|
||||
}
|
||||
@@ -450,11 +450,12 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($request->get('mds')))
|
||||
|
||||
return $this;
|
||||
|
||||
$sbas_id = (int) $request->get('sbid');
|
||||
|
@@ -500,6 +500,7 @@ class module_report
|
||||
public function getOrder($k = false)
|
||||
{
|
||||
if ($k === false)
|
||||
|
||||
return $this->tab_order;
|
||||
return $this->tab_order[$k];
|
||||
}
|
||||
@@ -819,6 +820,7 @@ class module_report
|
||||
public function buildReport($tab = false, $groupby = false, $on = false)
|
||||
{
|
||||
if (sizeof($this->report) > 0)
|
||||
|
||||
return $this->report;
|
||||
$conn = connection::getPDOConnection($this->sbas_id);
|
||||
|
||||
|
@@ -935,7 +935,7 @@ class module_report_activity extends module_report
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
GROUP by ddate
|
||||
ORDER BY ddate ASC";
|
||||
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -951,7 +951,7 @@ class module_report_activity extends module_report
|
||||
{
|
||||
$res[$key] = number_format($act, 2, '.', '');
|
||||
}
|
||||
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1102,7 @@ class module_report_activity extends module_report
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
GROUP BY ddate
|
||||
ORDER BY activity ASC ";
|
||||
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -1112,6 +1112,7 @@ class module_report_activity extends module_report
|
||||
$date = new DateTime($row['ddate']);
|
||||
$result[$date->format(DATE_ATOM)] = $row['activity'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@@ -157,8 +157,10 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
|
||||
public function isValid()
|
||||
{
|
||||
if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
|
||||
|
||||
return true;
|
||||
else
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -348,11 +350,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -75,9 +75,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$tmp = new self($sbasid, $sbas_coll, $dmin, $dmax);
|
||||
|
||||
$appbox->set_data_to_cache($tmp, $cache_id);
|
||||
@@ -131,7 +131,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
||||
* @return <void>
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
//Get number of DLs
|
||||
@@ -250,8 +250,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -149,8 +149,10 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
|
||||
public function isValid()
|
||||
{
|
||||
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
|
||||
|
||||
return true;
|
||||
else
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -162,10 +164,11 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
|
||||
public function getTop($nbtop)
|
||||
{
|
||||
if (!is_int($nbtop))
|
||||
|
||||
return array();
|
||||
|
||||
|
||||
$tmp = array();
|
||||
|
||||
|
||||
if ($this->isValid())
|
||||
{
|
||||
foreach ($this->arraySorted as $k => $v)
|
||||
@@ -182,6 +185,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class module_report_download extends module_report
|
||||
'mime' => 'subdef.mime',
|
||||
'file' => 'subdef.file'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
|
@@ -603,10 +603,10 @@ class module_report_nav extends module_report
|
||||
, 'titre' => $record->get_title()
|
||||
, 'taille' => $document->get_size()
|
||||
);
|
||||
|
||||
|
||||
$this->setDisplayNav();
|
||||
$this->setReport();
|
||||
|
||||
|
||||
return $this->report;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user