diff --git a/check_cs.php b/check_cs.php index c9db549fc0..7c6e364a35 100755 --- a/check_cs.php +++ b/check_cs.php @@ -14,12 +14,10 @@ * */ -require_once __DIR__ . '/lib/Alchemy/Phrasea/Core.php'; +require_once __DIR__ . '/lib/bootstrap.php'; use Symfony\Component\Finder\Finder; -\Alchemy\Phrasea\Core::initAutoloads(); - $fix = isset($argv[1]) && 'fix' == $argv[1]; $finder = new Finder(); diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index 0d13086a42..fd3ca9eb08 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -121,6 +121,7 @@ class ACL implements cache_cacheableInterface $key = $record->get_serialize_key(); if (array_key_exists($key, $this->_rights_records_document)) + return true; return false; @@ -188,6 +189,7 @@ class ACL implements cache_cacheableInterface $key = $record->get_serialize_key(); if (array_key_exists($key, $this->_rights_records_preview)) + return true; return false; @@ -241,6 +243,7 @@ class ACL implements cache_cacheableInterface public function apply_model(User_Interface $template_user, Array $base_ids) { if (count($base_ids) == 0) + return $this; $sbas_ids = array(); @@ -382,6 +385,7 @@ class ACL implements cache_cacheableInterface $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; if ($this->is_limited($base_id)) @@ -469,6 +473,7 @@ class ACL implements cache_cacheableInterface $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; return $this->_rights_bas[$base_id]['restrict_dwnld']; @@ -485,6 +490,7 @@ class ACL implements cache_cacheableInterface $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; return (int) $this->_rights_bas[$base_id]['remain_dwnld']; @@ -502,6 +508,7 @@ class ACL implements cache_cacheableInterface $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; $this->_rights_bas[$base_id]['remain_dwnld'] = @@ -541,12 +548,14 @@ class ACL implements cache_cacheableInterface $this->load_rights_sbas(); if (!isset($this->_rights_sbas[$sbas_id])) + return false; if (!isset($this->_rights_sbas[$sbas_id][$right])) throw new Exception('This right does not exists'); if ($this->_rights_sbas[$sbas_id][$right] === true) + return true; return false; @@ -562,6 +571,7 @@ class ACL implements cache_cacheableInterface { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; return $this->_rights_bas[$base_id]['mask_and']; @@ -577,6 +587,7 @@ class ACL implements cache_cacheableInterface { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) + return false; return $this->_rights_bas[$base_id]['mask_xor']; @@ -620,21 +631,21 @@ class ACL implements cache_cacheableInterface { $this->load_rights_bas(); $ret = array(); - + foreach($this->appbox->get_databoxes() as $databox) { if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) { continue; } - + foreach ($databox->get_collections() as $collection) { $continue = false; if(!array_key_exists($collection->get_base_id(), $this->_rights_bas)) continue; - + $base_id = $collection->get_base_id(); $datas = $this->_rights_bas[$base_id]; @@ -702,7 +713,7 @@ class ACL implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -718,6 +729,7 @@ class ACL implements cache_cacheableInterface { if ($this->_rights_records_preview) + return $this; try @@ -730,7 +742,7 @@ class ACL implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT sbas_id, record_id, preview, document FROM records_rights WHERE usr_id = :usr_id'; @@ -771,6 +783,7 @@ class ACL implements cache_cacheableInterface { if ($this->_rights_sbas && $this->_global_rights) + return $this; try @@ -782,7 +795,7 @@ class ACL implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT sbasusr.* FROM sbasusr, sbas @@ -832,6 +845,7 @@ class ACL implements cache_cacheableInterface protected function load_rights_bas() { if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) + return $this; try @@ -844,7 +858,7 @@ class ACL implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT u.* FROM basusr u, bas b, sbas s @@ -1335,6 +1349,7 @@ class ACL implements cache_cacheableInterface $stmt->closeCursor(); if (!$row) + return $this; $this->give_access_to_base(array($base_id_dest)); @@ -1501,6 +1516,7 @@ class ACL implements cache_cacheableInterface { $this->load_rights_bas(); if (!isset($this->_limited[$base_id])) + return null; return ($this->_limited[$base_id]); } @@ -1509,18 +1525,18 @@ class ACL implements cache_cacheableInterface { if ($limit) { - $sql = 'UPDATE basusr + $sql = 'UPDATE basusr SET time_limited = 1 - , limited_from = :limited_from - , limited_to = :limited_to + , limited_from = :limited_from + , limited_to = :limited_to WHERE base_id = :base_id AND usr_id = :usr_id'; } else { - $sql = 'UPDATE basusr + $sql = 'UPDATE basusr SET time_limited = 0 - , limited_from = :limited_from - , limited_to = :limited_to + , limited_from = :limited_from + , limited_to = :limited_to WHERE base_id = :base_id AND usr_id = :usr_id'; } diff --git a/lib/classes/API/OAuth2/Adapter.class.php b/lib/classes/API/OAuth2/Adapter.class.php index ec5dcaddbd..ab3d8458d1 100644 --- a/lib/classes/API/OAuth2/Adapter.class.php +++ b/lib/classes/API/OAuth2/Adapter.class.php @@ -551,7 +551,7 @@ class API_OAuth2_Adapter extends OAuth2 return $account; } - + /** * * @param int $usr_id diff --git a/lib/classes/API/V1/Log.class.php b/lib/classes/API/V1/Log.class.php index 269efe547c..e562c4e143 100644 --- a/lib/classes/API/V1/Log.class.php +++ b/lib/classes/API/V1/Log.class.php @@ -71,7 +71,7 @@ class API_V1_Log /** * - * @var API_OAuth2_Account + * @var API_OAuth2_Account */ protected $account; @@ -85,7 +85,7 @@ class API_V1_Log * * @param appbox $appbox * @param Request $request - * @param API_OAuth2_Account $account + * @param API_OAuth2_Account $account */ public function __construct(appbox &$appbox, $log_id) { @@ -93,16 +93,16 @@ class API_V1_Log $this->id = (int) $log_id; $sql = ' - SELECT + SELECT api_log_id, api_account_id, api_log_route, - api_log_date, - api_log_status_code, - api_log_format, - api_log_ressource, - api_log_general, - api_log_aspect, + api_log_date, + api_log_status_code, + api_log_format, + api_log_ressource, + api_log_general, + api_log_aspect, api_log_action FROM api_logs @@ -172,7 +172,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -184,7 +184,7 @@ class API_V1_Log public function set_status_code($status_code) { $this->status_code = (int) $status_code; - + $sql = 'UPDATE api_log SET api_log_status_code = :code WHERE api_log_id = :log_id'; @@ -197,7 +197,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -208,12 +208,12 @@ class API_V1_Log public function set_format($format) { - + if (!in_array($format, array('json', 'jsonp', 'yaml', 'unknow'))) throw new Exception_InvalidArgument(); - + $this->format = $format; - + $sql = 'UPDATE api_log SET api_log_format = :format WHERE api_log_id = :log_id'; @@ -226,7 +226,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -239,9 +239,9 @@ class API_V1_Log { if (!in_array($format, array(self::DATABOXES_RESSOURCE,self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE))) throw new Exception_InvalidArgument(); - + $this->ressource = $ressource; - + $sql = 'UPDATE api_log SET api_log_ressource = :ressource WHERE api_log_id = :log_id'; @@ -254,7 +254,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -266,7 +266,7 @@ class API_V1_Log public function set_general($general) { $this->general = $general; - + $sql = 'UPDATE api_log SET api_log_general = :general WHERE api_log_id = :log_id'; @@ -279,7 +279,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -291,7 +291,7 @@ class API_V1_Log public function set_aspect($aspect) { $this->aspect = $aspect; - + $sql = 'UPDATE api_log SET api_log_aspect = :aspect WHERE api_log_id = :log_id'; @@ -304,7 +304,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -316,7 +316,7 @@ class API_V1_Log public function set_action($action) { $this->action = $action; - + $sql = 'UPDATE api_log SET api_log_action = :action WHERE api_log_id = :log_id'; @@ -329,7 +329,7 @@ class API_V1_Log $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); - + return $this; } @@ -338,8 +338,8 @@ class API_V1_Log return $this->account; } - - public static function create(appbox &$appbox, API_OAuth2_Account $account, $route, $status_code, $format, $ressource, $general = null, $aspect = null, $action = null) + + public static function create(appbox &$appbox, API_OAuth2_Account $account, $route, $status_code, $format, $ressource, $general = null, $aspect = null, $action = null) { $sql = ' INSERT INTO @@ -347,38 +347,38 @@ class API_V1_Log api_log_id, api_account_id, api_log_route, - api_log_date, - api_log_status_code, - api_log_format, - api_log_ressource, - api_log_general, - api_log_aspect, + api_log_date, + api_log_status_code, + api_log_format, + api_log_ressource, + api_log_general, + api_log_aspect, api_log_action ) VALUES ( null, :account_id, :route, - NOW(), - :status_code, - :format, - :ressource, - :general, - :aspect, + NOW(), + :status_code, + :format, + :ressource, + :general, + :aspect, :action )'; - + $params = array( ':account_id' => $account->get_id(), ':route' => $route, - ':status_code' => $status_code, - ':format' => $format, - ':ressource' => $ressource, - ':general' => $general, - ':aspect' => $aspect, - ':action' => $action + ':status_code' => $status_code, + ':format' => $format, + ':ressource' => $ressource, + ':general' => $general, + ':aspect' => $aspect, + ':action' => $action ); - + $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/classes/Bridge/Exception.class.php b/lib/classes/Bridge/Exception.class.php index d802d3e9f9..37a18a3af7 100644 --- a/lib/classes/Bridge/Exception.class.php +++ b/lib/classes/Bridge/Exception.class.php @@ -18,4 +18,4 @@ class Bridge_Exception extends Exception { -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Admin/Fields.class.php b/lib/classes/Controller/Admin/Fields.class.php index 9cb6895636..6b57acec60 100644 --- a/lib/classes/Controller/Admin/Fields.class.php +++ b/lib/classes/Controller/Admin/Fields.class.php @@ -68,4 +68,4 @@ class Controller_Admin_Fields implements ControllerProviderInterface return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Admin/Publications.class.php b/lib/classes/Controller/Admin/Publications.class.php index 3d0263331d..5fe10b997c 100644 --- a/lib/classes/Controller/Admin/Publications.class.php +++ b/lib/classes/Controller/Admin/Publications.class.php @@ -54,7 +54,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface $request = $app['request']; $feed = Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle')); - + if($request->get('public') == '1') $feed->set_public (true); elseif ($request->get('base_id')) @@ -93,6 +93,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); if (!$feed->is_owner($user)) + return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it')); $request = $app['request']; @@ -121,23 +122,29 @@ class Controller_Admin_Publications implements ControllerProviderInterface $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); if (!$feed->is_owner($user)) + return new Response('ERROR:you are not allowed'); if ($_FILES['Filedata']['error'] !== 0) + return new Response('ERROR:error while upload'); $file = new system_file($_FILES['Filedata']['tmp_name']); if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) + return new Response('ERROR:bad filetype'); if ($file->getSize() > 200000) + return new Response('ERROR:file too large'); $datas = $file->get_technical_datas(); if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT])) + return new Response('ERROR:file is not square'); if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT]) + return new Response('ERROR:file is not square'); $feed->set_icon($file); diff --git a/lib/classes/Controller/Admin/Users.class.php b/lib/classes/Controller/Admin/Users.class.php index 3c1c6a5336..a71c471422 100644 --- a/lib/classes/Controller/Admin/Users.class.php +++ b/lib/classes/Controller/Admin/Users.class.php @@ -260,7 +260,7 @@ class Controller_Admin_Users implements ControllerProviderInterface $response = new Response($CSVDatas, 200, array('Content-Type' => 'text/plain')); $response->headers->set('Content-Disposition', 'attachment; filename=export.txt'); - + return $response; } ); diff --git a/lib/classes/Controller/Prod/Records/Edit.class.php b/lib/classes/Controller/Prod/Records/Edit.class.php index 2f4cbfd0a2..a0215e928c 100644 --- a/lib/classes/Controller/Prod/Records/Edit.class.php +++ b/lib/classes/Controller/Prod/Records/Edit.class.php @@ -54,7 +54,7 @@ class Controller_Prod_Records_Edit implements ControllerProviderInterface return $twig->render($template, array('edit' => $editing, 'message' => '')); } ); - + return $controllers; } diff --git a/lib/classes/Controller/Prod/Records/MoveCollection.class.php b/lib/classes/Controller/Prod/Records/MoveCollection.class.php index 64ea944696..ce062387fd 100644 --- a/lib/classes/Controller/Prod/Records/MoveCollection.class.php +++ b/lib/classes/Controller/Prod/Records/MoveCollection.class.php @@ -57,4 +57,4 @@ class Controller_Prod_Records_MoveCollection implements ControllerProviderInterf return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Prod/Records/Tooltip.class.php b/lib/classes/Controller/Prod/Records/Tooltip.class.php index 4055c48fb3..372492752d 100644 --- a/lib/classes/Controller/Prod/Records/Tooltip.class.php +++ b/lib/classes/Controller/Prod/Records/Tooltip.class.php @@ -174,4 +174,4 @@ class Controller_Prod_Records_Tooltip implements ControllerProviderInterface return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/RSSFeeds.class.php b/lib/classes/Controller/RSSFeeds.class.php index 94d03d2ef6..7efe918ed0 100644 --- a/lib/classes/Controller/RSSFeeds.class.php +++ b/lib/classes/Controller/RSSFeeds.class.php @@ -44,17 +44,17 @@ class Controller_RSSFeeds implements ControllerProviderInterface { $content = new Feed_XML_RSS(); } - + if ($format == Feed_Adapter::FORMAT_ATOM) { $content = new Feed_XML_Atom(); } - + if($format == Feed_Adapter::FORMAT_COOLIRIS) { $content = new Feed_XML_Cooliris(); } - + if ($user instanceof User_Adapter) $link = $feed->get_user_link($registry, $user, $format, $page); else @@ -82,7 +82,7 @@ class Controller_RSSFeeds implements ControllerProviderInterface } foreach ($entries->get_entries() as $entry) $content->set_item($entry); - + $render = $content->render(); $response = new Response($render, 200, array('Content-Type' => $content->get_mimetype())); $response->setCharset('UTF-8'); @@ -176,8 +176,8 @@ class Controller_RSSFeeds implements ControllerProviderInterface return $display_feed($feed, Feed_Adapter::FORMAT_COOLIRIS , $page); }); - + return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Setup/Installer.class.php b/lib/classes/Controller/Setup/Installer.class.php index ebdb313203..078adea9d1 100644 --- a/lib/classes/Controller/Setup/Installer.class.php +++ b/lib/classes/Controller/Setup/Installer.class.php @@ -51,8 +51,8 @@ class Controller_Setup_Installer implements ControllerProviderInterface $request = $app['request']; $servername = $request->getScheme() . '://' . $request->getHttpHost() . '/'; setup::write_config($servername); - - + + $php_constraint = setup::check_php_version(); $writability_constraints = setup::check_writability(new Setup_Registry()); $extension_constraints = setup::check_php_extension(); @@ -89,11 +89,11 @@ class Controller_Setup_Installer implements ControllerProviderInterface return $app->redirect('/setup/installer/step2/'); } - + $ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); $loader = new Twig_Loader_Filesystem($ld_path); $twig = new Twig_Environment($loader); - + $html = $twig->render( '/setup/index.twig' , array_merge($constraints_coll, array( @@ -111,12 +111,12 @@ class Controller_Setup_Installer implements ControllerProviderInterface $controllers->get('/step2/', function() use ($app) { phrasea::use_i18n(Session_Handler::get_locale()); - + $ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); - + $loader = new Twig_Loader_Filesystem($ld_path); $twig = new Twig_Environment($loader); - + $twig->addExtension(new Twig_Extensions_Extension_I18n()); $request = $app['request']; @@ -303,4 +303,4 @@ class Controller_Setup_Installer implements ControllerProviderInterface return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Setup/Upgrader.class.php b/lib/classes/Controller/Setup/Upgrader.class.php index a3928baf45..2fcc4ea46c 100644 --- a/lib/classes/Controller/Setup/Upgrader.class.php +++ b/lib/classes/Controller/Setup/Upgrader.class.php @@ -86,4 +86,4 @@ class Controller_Setup_Upgrader implements ControllerProviderInterface return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/Controller/Utils/ConnectionTest.class.php b/lib/classes/Controller/Utils/ConnectionTest.class.php index 6622dfaec1..9707a09a70 100644 --- a/lib/classes/Controller/Utils/ConnectionTest.class.php +++ b/lib/classes/Controller/Utils/ConnectionTest.class.php @@ -50,7 +50,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface } catch (Exception $e) { - + } if ($dbname && $connection_ok === true) @@ -83,7 +83,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface } catch (Exception $e) { - + } } diff --git a/lib/classes/Controller/Utils/PathFileTest.class.php b/lib/classes/Controller/Utils/PathFileTest.class.php index b168a4771a..a36c345ce5 100644 --- a/lib/classes/Controller/Utils/PathFileTest.class.php +++ b/lib/classes/Controller/Utils/PathFileTest.class.php @@ -57,4 +57,4 @@ class Controller_Utils_PathFileTest implements ControllerProviderInterface return $controllers; } -} \ No newline at end of file +} diff --git a/lib/classes/DailymotionWithoutOauth2.php b/lib/classes/DailymotionWithoutOauth2.php index 007ffd0665..855b481d9b 100644 --- a/lib/classes/DailymotionWithoutOauth2.php +++ b/lib/classes/DailymotionWithoutOauth2.php @@ -14,8 +14,8 @@ require_once __DIR__ . '/../vendor/dailymotion-sdk-php/Dailymotion.php'; class DailymotionWithoutOauth2 extends Dailymotion { - - + + /** * Call a remote method. * @@ -37,7 +37,7 @@ class DailymotionWithoutOauth2 extends Dailymotion 'call' => $method, 'args' => $args, )); - + $status_code = null; try { @@ -45,7 +45,7 @@ class DailymotionWithoutOauth2 extends Dailymotion } catch (DailymotionAuthException $e) { - + if ($e->error === 'invalid_token') { throw new Bridge_Exception_ActionAuthNeedReconnect(); @@ -84,8 +84,8 @@ class DailymotionWithoutOauth2 extends Dailymotion return $result['result']; } - - + + /** * Upload a file on the Dailymotion servers and generate an URL to be used with API methods. * @@ -100,6 +100,7 @@ class DailymotionWithoutOauth2 extends Dailymotion $this->timeout = null; $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); $this->timeout = $timeout; + return $result['url']; } } diff --git a/lib/classes/Exception/Setup/FixBadEmailAddresses.class.php b/lib/classes/Exception/Setup/FixBadEmailAddresses.class.php index 659d857471..2625d4013a 100644 --- a/lib/classes/Exception/Setup/FixBadEmailAddresses.class.php +++ b/lib/classes/Exception/Setup/FixBadEmailAddresses.class.php @@ -10,12 +10,12 @@ */ /** - * + * * @package Exception * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ class Exception_Setup_FixBadEmailAddresses extends Exception { - -} \ No newline at end of file + +} diff --git a/lib/classes/Feed/Abstract.class.php b/lib/classes/Feed/Abstract.class.php index b9450c260d..0c976c98d1 100644 --- a/lib/classes/Feed/Abstract.class.php +++ b/lib/classes/Feed/Abstract.class.php @@ -26,7 +26,7 @@ abstract class Feed_Abstract */ const FORMAT_ATOM = 'atom'; /** - * + * */ const FORMAT_COOLIRIS = 'cooliris'; diff --git a/lib/classes/Feed/Adapter.class.php b/lib/classes/Feed/Adapter.class.php index 0a5a301ca8..9fdf9e5756 100644 --- a/lib/classes/Feed/Adapter.class.php +++ b/lib/classes/Feed/Adapter.class.php @@ -57,7 +57,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea const CACHE_ENTRY_NUMBER = 'entrynumber'; const CACHE_USER_TOKEN = 'usr_token'; - + const MAX_ENTRIES = 20; /** diff --git a/lib/classes/Feed/Entry/Adapter.class.php b/lib/classes/Feed/Entry/Adapter.class.php index ef7c035543..aa15389755 100644 --- a/lib/classes/Feed/Entry/Adapter.class.php +++ b/lib/classes/Feed/Entry/Adapter.class.php @@ -357,11 +357,11 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa return $this->publisher; } - + /** * * @param User_adapter $user - * @return boolean + * @return boolean */ public function is_publisher(User_adapter $user) { diff --git a/lib/classes/Feed/XML/Cooliris.class.php b/lib/classes/Feed/XML/Cooliris.class.php index 36d2f3830c..45d81183a0 100644 --- a/lib/classes/Feed/XML/Cooliris.class.php +++ b/lib/classes/Feed/XML/Cooliris.class.php @@ -370,9 +370,11 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface $medium = strtolower($content->get_record()->get_type()); if (!in_array($medium, array('image', 'audio', 'video'))) + return $this; if (!$preview_permalink || !$thumbnail_permalink) + return $this; //add item node to channel node diff --git a/lib/classes/Session/Handler.class.php b/lib/classes/Session/Handler.class.php index 662e0c6e93..d408aea3d5 100644 --- a/lib/classes/Session/Handler.class.php +++ b/lib/classes/Session/Handler.class.php @@ -324,7 +324,7 @@ class Session_Handler { if (!$this->phrasea_session instanceof Session_Phrasea) throw new \Exception('No phrasea session available'); - + $this->phrasea_session->open(); return $this; @@ -597,7 +597,7 @@ class Session_Handler 'ssel_id' => $row['ssel_id'], 'from' => $row['owner'], 'validate_id' => $row['validate_id'], - 'url' => $registry->get('GV_ServerName') + 'url' => $registry->get('GV_ServerName') . 'lightbox/validate/'.$row['ssel_id'].'/?LOG=' . $row['value'] ); diff --git a/lib/classes/Setup/Upgrade.class.php b/lib/classes/Setup/Upgrade.class.php index c8725b8a15..08209f2b34 100644 --- a/lib/classes/Setup/Upgrade.class.php +++ b/lib/classes/Setup/Upgrade.class.php @@ -55,14 +55,14 @@ class Setup_Upgrade { throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started'); } - + $this->appbox = $appbox; - + if(count(User_Adapter::get_wrong_email_users($appbox)) > 0) { throw new Exception_Setup_FixBadEmailAddresses('Please fix the database before starting'); } - + $this->write_lock(); return $this; diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 695984d96c..69522981dc 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -907,6 +907,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public static function get_usr_id_from_email($email) { if (is_null($email)) + return false; $conn = connection::getPDOConnection(); @@ -1255,7 +1256,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function get_applied_template() { - + return $this->applied_template; } @@ -1277,10 +1278,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface protected function load_preferences() { if ($this->_prefs) + return $this; - + $registry = \registry::get_instance(); - + $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute(array(':id' => $this->id)); @@ -1300,7 +1302,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $v = $registry->get('GV_defaultQuery'); } - + $this->_prefs[$k] = $v; $this->update_pref($k, $v); } @@ -1378,7 +1380,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface } catch (Exception $e) { - + } return $this; @@ -1573,6 +1575,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $this->load_preferences(); if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value) + return $value; $ok = true; @@ -1610,6 +1613,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $appbox = appbox::get_instance(); $session = $appbox->get_session(); if (!$session->is_authenticated()) + return; $ses_id = $session->get_ses_id(); @@ -1668,7 +1672,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface } catch (Exception $e) { - + } } } @@ -1732,7 +1736,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface } catch (Exception $e) { - + } return false; @@ -1818,7 +1822,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface } catch (Exception $e) { - + } return $locale; @@ -1884,6 +1888,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function get_nonce() { if ($this->nonce) + return $this->nonce; $nonce = false; diff --git a/lib/classes/User/Query.class.php b/lib/classes/User/Query.class.php index aa962ba946..18fcadf804 100644 --- a/lib/classes/User/Query.class.php +++ b/lib/classes/User/Query.class.php @@ -269,7 +269,7 @@ class User_Query implements User_QueryInterface $extra = $this->include_phantoms ? ' OR sbas_id IS NULL ' : ''; $not_sbas_id = array_diff($this->active_sbas, $this->sbas_ids); - + if (count($not_sbas_id) > 0 && count($not_sbas_id) < count($this->sbas_ids)) { $sql .= sprintf(' AND ((sbas_id != %s ) ' . $extra . ')' @@ -489,6 +489,7 @@ class User_Query implements User_QueryInterface public function get_total() { if ($this->total) + return $this->total; $conn = $this->appbox->get_connection(); @@ -637,6 +638,7 @@ class User_Query implements User_QueryInterface public function on_base_ids(Array $base_ids = null) { if (!$base_ids) + return $this; $this->bases_restrictions = true; @@ -661,6 +663,7 @@ class User_Query implements User_QueryInterface public function on_sbas_ids(Array $sbas_ids = null) { if (!$sbas_ids) + return $this; $this->sbas_restrictions = true; diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index 541f78b189..8e176f2fe1 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -215,7 +215,7 @@ class appbox extends base $stmt = $this->get_connection()->prepare($sqlupd); $stmt->execute(array(':ordre' => $ordre, ':base_id' => $collection->get_base_id())); $stmt->closeCursor(); - + $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS); return $this; diff --git a/lib/classes/basket/adapter.class.php b/lib/classes/basket/adapter.class.php index b3c419cbc8..3120d93ec8 100644 --- a/lib/classes/basket/adapter.class.php +++ b/lib/classes/basket/adapter.class.php @@ -327,6 +327,7 @@ class basket_adapter implements cache_cacheableInterface public function get_first_element() { foreach ($this->get_elements() as $basket_element) + return $basket_element; return null; } @@ -338,6 +339,7 @@ class basket_adapter implements cache_cacheableInterface public function get_validation_end_date() { if (!$this->valid || !$this->validation_end_date) + return null; return $this->validation_end_date; } @@ -349,6 +351,7 @@ class basket_adapter implements cache_cacheableInterface public function is_validation_finished() { if (!$this->valid || !$this->validation_end_date) + return null; $now = new DateTime(); @@ -362,6 +365,7 @@ class basket_adapter implements cache_cacheableInterface public function is_confirmed() { if (!$this->valid) + return null; return $this->validation_is_confirmed; @@ -370,14 +374,17 @@ class basket_adapter implements cache_cacheableInterface public function is_releasable() { if (!$this->valid) + return false; if ($this->is_confirmed()) + return false; foreach ($this->get_elements() as $element) { if ($element->get_my_agreement() == '0') + return false; } @@ -477,7 +484,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT s.pushFrom, n.id as noview, s.usr_id as owner, s.rid @@ -542,7 +549,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -585,6 +592,7 @@ class basket_adapter implements cache_cacheableInterface public function sort($order) { if (!$this->valid || !in_array($order, array('asc', 'desc'))) + return; $this->load_elements(); @@ -630,7 +638,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception_Record_AdapterNotFound $e) { - + } catch (Exception $e) { @@ -745,7 +753,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -900,7 +908,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } } @@ -1016,6 +1024,7 @@ class basket_adapter implements cache_cacheableInterface public function set_read() { if (!$this->noview) + return true; $session = $this->appbox->get_session(); @@ -1075,7 +1084,7 @@ class basket_adapter implements cache_cacheableInterface foreach ($this->get_elements() as $basket_element) { $basket_element->validate($me, $user, $insert_id, $can_hd); - + if ($can_hd && $me->ACL()->has_hd_grant($basket_element->get_record())) $user->ACL()->grant_hd_on($basket_element->get_record(), $me, 'validate'); else @@ -1131,15 +1140,19 @@ class basket_adapter implements cache_cacheableInterface if ($this->is_mine) { if ($this->is_validation_finished()) + return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); else + return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); } else { if ($this->validation_see_others) + return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); else + return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); } } @@ -1248,6 +1261,7 @@ class basket_adapter implements cache_cacheableInterface protected function load_elements() { if (!is_null($this->elements)) + return; $this->elements = array(); @@ -1274,7 +1288,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } } @@ -1372,7 +1386,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } return array('error' => true, 'status' => 0); @@ -1412,7 +1426,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $ret = array('error' => false, 'status' => 0); @@ -1525,11 +1539,14 @@ class basket_adapter implements cache_cacheableInterface public function remove_from_ssel($sselcont_id) { if (!$this->is_mine) + return array('error' => 'error', 'status' => 0); if ($this->is_grouping) + return $this->remove_grouping_elements($sselcont_id); else + return $this->remove_basket_elements($sselcont_id); } @@ -1869,7 +1886,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } return $appbox->delete_data_from_cache($ssel_ids); @@ -1897,7 +1914,7 @@ class basket_adapter implements cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT id, usr_id, confirmed, can_agree, can_see_others diff --git a/lib/classes/basket/element/adapter.class.php b/lib/classes/basket/element/adapter.class.php index c99fbbb324..ce97b34cd0 100644 --- a/lib/classes/basket/element/adapter.class.php +++ b/lib/classes/basket/element/adapter.class.php @@ -548,20 +548,20 @@ class basket_element_adapter implements cache_cacheableInterface } $this->delete_data_from_cache(); - + $sql = 'SELECT distinct v.usr_id FROM ssel s, validate v WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id'; - + $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(array(':ssel_id' => $this->get_ssel_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - + foreach($rs as $row) { $appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id); } - + try { $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); @@ -654,23 +654,23 @@ class basket_element_adapter implements cache_cacheableInterface $stmt->closeCursor(); $this->delete_data_from_cache(); - + $sql = 'SELECT distinct v.usr_id FROM ssel s, validate v WHERE v.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id'; - + $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(array(':ssel_id' => $this->get_ssel_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - + foreach($rs as $row) { $appbox->delete_data_from_cache('basket_element_' . $row['usr_id'] . '_' . $this->sselcont_id); } - + $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); $basket->delete_cache(); - + return $this; } diff --git a/lib/classes/basketCollection.class.php b/lib/classes/basketCollection.class.php index d85b4e44ee..6b170d7263 100644 --- a/lib/classes/basketCollection.class.php +++ b/lib/classes/basketCollection.class.php @@ -151,7 +151,7 @@ class basketCollection $appbox = appbox::get_instance(); $conn = $appbox->get_connection(); $session = $appbox->get_session(); - $sql = 'SELECT n.ssel_id FROM sselnew n + $sql = 'SELECT n.ssel_id FROM sselnew n WHERE n.usr_id = :usr_id '; $stmt = $conn->prepare($sql); $stmt->execute(array(':usr_id' => $session->get_usr_id())); @@ -164,12 +164,12 @@ class basketCollection try { $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); - + if ($basket->is_valid() && !$basket->is_my_valid() && $basket->is_validation_finished()) throw new Exception('Finished'); - + $baskets[] = $basket; - + } catch(Exception $e) { diff --git a/lib/classes/bootstrap.class.php b/lib/classes/bootstrap.class.php index 57febb4c58..dec45d34a8 100644 --- a/lib/classes/bootstrap.class.php +++ b/lib/classes/bootstrap.class.php @@ -154,7 +154,7 @@ class bootstrap Twig_Autoloader::register(); Twig_Extensions_Autoloader::register(); - + /** * Load symfony components needed */ diff --git a/lib/classes/cache/databox.class.php b/lib/classes/cache/databox.class.php index c219d071c1..6535e19b66 100644 --- a/lib/classes/cache/databox.class.php +++ b/lib/classes/cache/databox.class.php @@ -43,7 +43,7 @@ class cache_databox } catch (\Exception $e) { - + } if ($last_update) diff --git a/lib/classes/caption/field.class.php b/lib/classes/caption/field.class.php index 1b343b8e9f..d683df07fa 100644 --- a/lib/classes/caption/field.class.php +++ b/lib/classes/caption/field.class.php @@ -208,7 +208,7 @@ class caption_field implements cache_cacheableInterface { if(strlen($separator) > 1) $separator = $separator[0]; - + if (trim($separator) === '') $separator = ' '; else diff --git a/lib/classes/caption/record.class.php b/lib/classes/caption/record.class.php index c5073e43f2..43ac0636c6 100644 --- a/lib/classes/caption/record.class.php +++ b/lib/classes/caption/record.class.php @@ -60,6 +60,7 @@ class caption_record implements caption_interface, cache_cacheableInterface protected function retrieve_fields() { if (is_array($this->fields)) + return $this->fields; $fields = array(); @@ -96,7 +97,7 @@ class caption_record implements caption_interface, cache_cacheableInterface } catch (Exception $e) { - + } } $this->fields = $rec_fields; @@ -133,6 +134,7 @@ class caption_record implements caption_interface, cache_cacheableInterface { $fields = $this->retrieve_fields(); if (isset($this->dces_elements[$label])) + return $fields[$this->dces_elements[$label]]; return null; } diff --git a/lib/classes/collection.class.php b/lib/classes/collection.class.php index 8acf39bdcb..5312763e1c 100644 --- a/lib/classes/collection.class.php +++ b/lib/classes/collection.class.php @@ -200,9 +200,9 @@ class collection implements cache_cacheableInterface $stmt = $this->get_connection()->prepare($sql); $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); - + $this->pub_wm = $publi; - + $this->delete_data_from_cache(); } @@ -223,9 +223,9 @@ class collection implements cache_cacheableInterface $stmt->closeCursor(); $this->name = $name; - + $this->delete_data_from_cache(); - + phrasea::reset_baseDatas(); return $this; @@ -404,7 +404,7 @@ class collection implements cache_cacheableInterface $stmt = $this->get_connection()->prepare($sql); $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); - + $this->delete_data_from_cache(); return $this->prefs; diff --git a/lib/classes/connection.class.php b/lib/classes/connection.class.php index a57e1be46a..921505f04d 100755 --- a/lib/classes/connection.class.php +++ b/lib/classes/connection.class.php @@ -175,6 +175,7 @@ class connection self::$_PDO_instance[$name] = null; unset(self::$_PDO_instance[$name]); } + return; } diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 7ac6ee415f..4777e5fcb1 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -142,7 +142,7 @@ class databox extends base } catch (Exception $e) { - + } } @@ -157,7 +157,7 @@ class databox extends base } catch (Exception $e) { - + } $conn = connection::getPDOConnection(); @@ -451,6 +451,7 @@ class databox extends base $stmt->closeCursor(); if ($row) + return self::get_instance((int) $row['sbas_id']); try @@ -463,7 +464,7 @@ class databox extends base } catch (Exception $e) { - + } $sql = 'USE `' . $dbname . '`'; @@ -575,6 +576,7 @@ class databox extends base public function get_meta_structure() { if ($this->meta_struct) + return $this->meta_struct; try @@ -697,6 +699,7 @@ class databox extends base } } if ($n > $limit) + return true; return false; @@ -986,7 +989,7 @@ class databox extends base } catch (Exception $e) { - + } if (isset($field['regname'])) @@ -1220,6 +1223,7 @@ class databox extends base public function get_structure() { if ($this->structure) + return $this->structure; $this->structure = $this->retrieve_structure(); @@ -1234,7 +1238,7 @@ class databox extends base } catch (Exception $e) { - + } $structure = null; @@ -1260,6 +1264,7 @@ class databox extends base public function get_cterms() { if ($this->cterms) + return $this->cterms; $sql = "SELECT value FROM pref WHERE prop='cterms'"; @@ -1426,6 +1431,7 @@ class databox extends base public function get_cgus() { if ($this->cgus) + return $this->cgus; $this->load_cgus(); @@ -1443,7 +1449,7 @@ class databox extends base } catch (Exception $e) { - + } $sql = 'SELECT value, locale, updated_on FROM pref WHERE prop ="ToU"'; diff --git a/lib/classes/databox/cgu.class.php b/lib/classes/databox/cgu.class.php index 0ba6b99485..1c701dd382 100644 --- a/lib/classes/databox/cgu.class.php +++ b/lib/classes/databox/cgu.class.php @@ -94,12 +94,12 @@ class databox_cgu $terms = array(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); - + if(!$home) { $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); } - + foreach ($appbox->get_databoxes() as $databox) { try diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index 7f36cab930..0a04a48bd4 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -554,7 +554,7 @@ class databox_field implements cache_cacheableInterface { if (strpos($separator, ';') === false) $separator .= ';'; - + $this->separator = $separator; return $this; diff --git a/lib/classes/databox/status.class.php b/lib/classes/databox/status.class.php index 48626b874e..88a3b1cfa3 100644 --- a/lib/classes/databox/status.class.php +++ b/lib/classes/databox/status.class.php @@ -159,13 +159,13 @@ class databox_status $statuses = array(); $sbas_ids = $user->ACL()->get_granted_sbas(); - + $see_all = array(); foreach ($sbas_ids as $databox) { $see_all[$databox->get_sbas_id()] = false; - + foreach($databox->get_collections() as $collection) { if($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) @@ -193,7 +193,7 @@ class databox_status if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) $see_this = true; - + foreach ($status as $bit => $props) { @@ -491,7 +491,7 @@ class databox_status $conn = connection::getPDOConnection(); $status = '0'; - + if(substr($stat1, 0, 2) === '0x') { $stat1 = self::hex2bin(substr($stat1, 2)); @@ -530,7 +530,7 @@ class databox_status { $stat2 = self::hex2bin(substr($stat2, 2)); } - + $sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result'; $stmt = $conn->prepare($sql); @@ -560,7 +560,7 @@ class databox_status { $stat2 = self::hex2bin(substr($stat2, 2)); } - + $sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result'; $stmt = $conn->prepare($sql); @@ -579,12 +579,12 @@ class databox_status public static function dec2bin($status) { $status = (string) $status; - + if(!ctype_digit($status)) { throw new \Exception('Non-decimal value'); } - + $conn = connection::getPDOConnection(); $sql = 'select bin(' . $status . ') as result'; @@ -595,7 +595,7 @@ class databox_status $stmt->closeCursor(); $status = '0'; - + if ($row) { $status = $row['result']; @@ -611,12 +611,12 @@ class databox_status { $status = substr($status, 2); } - + if(!ctype_xdigit($status)) { throw new \Exception('Non-hexadecimal value'); } - + $conn = connection::getPDOConnection(); $sql = 'select BIN( CAST( 0x'.trim($status).' AS UNSIGNED ) ) as result'; @@ -627,7 +627,7 @@ class databox_status $stmt->closeCursor(); $status = '0'; - + if ($row) { $status = $row['result']; diff --git a/lib/classes/gatekeeper.class.php b/lib/classes/gatekeeper.class.php index 97aa6996bb..240310e931 100644 --- a/lib/classes/gatekeeper.class.php +++ b/lib/classes/gatekeeper.class.php @@ -76,6 +76,7 @@ class gatekeeper $session = $appbox->get_session(); if (http_request::is_command_line()) + return; if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) @@ -104,7 +105,7 @@ class gatekeeper } catch (Exception $e) { - + } } @@ -121,6 +122,7 @@ class gatekeeper if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') + return; phrasea::redirect('/login/?redirect=/thesaurus2'); break; @@ -129,6 +131,7 @@ class gatekeeper break; case 'admin': if ($this->_script_name === 'runscheduler.php') + return; phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); break; @@ -148,6 +151,7 @@ class gatekeeper return; case 'setup': if ($appbox->upgradeavailable()) + return; else phrasea::redirect('/login/'); @@ -264,6 +268,7 @@ class gatekeeper $parm = $request->get_parms('LOG'); if (is_null($parm["LOG"])) + return $this; try @@ -281,11 +286,12 @@ class gatekeeper try { $datas = random::helloToken($parm['LOG']); + return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/"); } catch (Exception_NotFound $e) { - + } return $this; diff --git a/lib/classes/geonames.class.php b/lib/classes/geonames.class.php index 561f46de94..4d4859eba7 100644 --- a/lib/classes/geonames.class.php +++ b/lib/classes/geonames.class.php @@ -33,7 +33,7 @@ class geonames { return ''; } - + $registry = registry::get_instance(); $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/') . 'get_name.php?geonameid=' @@ -94,6 +94,7 @@ class geonames $cityName = self::clean_input($cityName); if (strlen($cityName) === 0) + return $output; $registry = registry::get_instance(); @@ -134,6 +135,7 @@ class geonames public function find_geoname_from_ip($ip) { if (array_key_exists($ip, $this->cache_ips)) + return $this->cache_ips[$ip]; $output = array( diff --git a/lib/classes/http/request.class.php b/lib/classes/http/request.class.php index c83ee48623..622228dc60 100644 --- a/lib/classes/http/request.class.php +++ b/lib/classes/http/request.class.php @@ -93,7 +93,7 @@ class http_request return true; return false; } - + public function is_secure() { return ( diff --git a/lib/classes/lazaretFile.class.php b/lib/classes/lazaretFile.class.php index 3a4c0646a4..6df683398c 100644 --- a/lib/classes/lazaretFile.class.php +++ b/lib/classes/lazaretFile.class.php @@ -138,7 +138,7 @@ class lazaretFile $record = new record_adapter($sbas_id, $record_id); $record->substitute_subdef('document', new system_file($pathfile)); - + $this->delete(); return $this; diff --git a/lib/classes/module/Admin.php b/lib/classes/module/Admin.php index 83a60be9dd..8e960d684f 100644 --- a/lib/classes/module/Admin.php +++ b/lib/classes/module/Admin.php @@ -34,4 +34,4 @@ return call_user_func( }); return $app; - }); \ No newline at end of file + }); diff --git a/lib/classes/module/Lightbox.php b/lib/classes/module/Lightbox.php index 0c7a362ad4..8d90286f57 100644 --- a/lib/classes/module/Lightbox.php +++ b/lib/classes/module/Lightbox.php @@ -58,6 +58,7 @@ return call_user_func( { $browser = Browser::getInstance(); if (!$browser->isMobile()) + return new Response(''); $twig = new supertwig(); diff --git a/lib/classes/module/Prod.php b/lib/classes/module/Prod.php index 6bb8b650ca..4cef7878a3 100644 --- a/lib/classes/module/Prod.php +++ b/lib/classes/module/Prod.php @@ -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; - }); \ No newline at end of file + }); diff --git a/lib/classes/module/Root.php b/lib/classes/module/Root.php index 5d94ac1ee9..17c30348aa 100644 --- a/lib/classes/module/Root.php +++ b/lib/classes/module/Root.php @@ -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; } -); \ No newline at end of file +); diff --git a/lib/classes/module/Setup.php b/lib/classes/module/Setup.php index 015e558e48..b35443710e 100644 --- a/lib/classes/module/Setup.php +++ b/lib/classes/module/Setup.php @@ -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; - }); \ No newline at end of file + }); diff --git a/lib/classes/module/admin.class.php b/lib/classes/module/admin.class.php index 423c180973..a84bc63058 100644 --- a/lib/classes/module/admin.class.php +++ b/lib/classes/module/admin.class.php @@ -77,6 +77,7 @@ class module_admin ); $twig = new supertwig(); + return $twig->render('admin/tree.html.twig', $params); } diff --git a/lib/classes/module/admin/route/users.class.php b/lib/classes/module/admin/route/users.class.php index 94f74fda6a..7485d45023 100644 --- a/lib/classes/module/admin/route/users.class.php +++ b/lib/classes/module/admin/route/users.class.php @@ -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) diff --git a/lib/classes/module/admin/route/users/edit.class.php b/lib/classes/module/admin/route/users/edit.class.php index 227d775242..973ed90a33 100644 --- a/lib/classes/module/admin/route/users/edit.class.php +++ b/lib/classes/module/admin/route/users/edit.class.php @@ -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; } diff --git a/lib/classes/module/api/OAuthv2.php b/lib/classes/module/api/OAuthv2.php index bc6939d4b9..e27cdc31ee 100644 --- a/lib/classes/module/api/OAuthv2.php +++ b/lib/classes/module/api/OAuthv2.php @@ -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; - }); \ No newline at end of file + }); diff --git a/lib/classes/module/api/V1.php b/lib/classes/module/api/V1.php index 2205e54f9c..be3a7fbb68 100644 --- a/lib/classes/module/api/V1.php +++ b/lib/classes/module/api/V1.php @@ -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; -}); \ No newline at end of file +}); diff --git a/lib/classes/module/console/systemUpgrade.class.php b/lib/classes/module/console/systemUpgrade.class.php index 22d62f2a66..553ddd32ea 100644 --- a/lib/classes/module/console/systemUpgrade.class.php +++ b/lib/classes/module/console/systemUpgrade.class.php @@ -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, '' . _('Create automatically') . ' (Y/n)', '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'; diff --git a/lib/classes/module/prod.class.php b/lib/classes/module/prod.class.php index 9f07050663..6d010026b2 100644 --- a/lib/classes/module/prod.class.php +++ b/lib/classes/module/prod.class.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; diff --git a/lib/classes/module/prod/route/records/edit.class.php b/lib/classes/module/prod/route/records/edit.class.php index 372f2e943d..4ad2758525 100644 --- a/lib/classes/module/prod/route/records/edit.class.php +++ b/lib/classes/module/prod/route/records/edit.class.php @@ -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'); diff --git a/lib/classes/module/report.class.php b/lib/classes/module/report.class.php index 4d4eb62210..d052c83597 100644 --- a/lib/classes/module/report.class.php +++ b/lib/classes/module/report.class.php @@ -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); diff --git a/lib/classes/module/report/activity.class.php b/lib/classes/module/report/activity.class.php index 97b0e31bc2..6411fc531d 100644 --- a/lib/classes/module/report/activity.class.php +++ b/lib/classes/module/report/activity.class.php @@ -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; } diff --git a/lib/classes/module/report/dashboard.class.php b/lib/classes/module/report/dashboard.class.php index 17c525625b..96a6c6fcac 100644 --- a/lib/classes/module/report/dashboard.class.php +++ b/lib/classes/module/report/dashboard.class.php @@ -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; } diff --git a/lib/classes/module/report/dashboard/feed.class.php b/lib/classes/module/report/dashboard/feed.class.php index 24373e673a..5d244a262f 100644 --- a/lib/classes/module/report/dashboard/feed.class.php +++ b/lib/classes/module/report/dashboard/feed.class.php @@ -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 */ 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; } diff --git a/lib/classes/module/report/dashboard/sort.class.php b/lib/classes/module/report/dashboard/sort.class.php index 40eb57f882..94c2f2418a 100644 --- a/lib/classes/module/report/dashboard/sort.class.php +++ b/lib/classes/module/report/dashboard/sort.class.php @@ -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; } diff --git a/lib/classes/module/report/download.class.php b/lib/classes/module/report/download.class.php index da9475b17b..b53cebf137 100644 --- a/lib/classes/module/report/download.class.php +++ b/lib/classes/module/report/download.class.php @@ -38,7 +38,7 @@ class module_report_download extends module_report 'mime' => 'subdef.mime', 'file' => 'subdef.file' ); - + /** * constructor * diff --git a/lib/classes/module/report/nav.class.php b/lib/classes/module/report/nav.class.php index afcd27c8d5..89232dd429 100644 --- a/lib/classes/module/report/nav.class.php +++ b/lib/classes/module/report/nav.class.php @@ -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; } diff --git a/lib/classes/patch/320f.class.php b/lib/classes/patch/320f.class.php index 5031e58803..7777e680cb 100644 --- a/lib/classes/patch/320f.class.php +++ b/lib/classes/patch/320f.class.php @@ -55,7 +55,7 @@ class patch_320f implements patchInterface function apply(base &$appbox) { $feeds = array(); - + try { $sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"'; @@ -65,9 +65,9 @@ class patch_320f implements patchInterface } catch(Exception $e) { - + } - + $sql = 'SELECT ssel_id, usr_id, name, descript, pub_date , updater, pub_restrict, homelink FROM ssel WHERE (public = "1" or homelink="1") and migrated = 0'; @@ -123,7 +123,7 @@ class patch_320f implements patchInterface } } - $sql = 'UPDATE ssel SET deleted = "1", migrated="1" + $sql = 'UPDATE ssel SET deleted = "1", migrated="1" WHERE ssel_id = :ssel_id'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(array(':ssel_id' => $row['ssel_id'])); diff --git a/lib/classes/random.class.php b/lib/classes/random.class.php index d547875033..24a615b66f 100644 --- a/lib/classes/random.class.php +++ b/lib/classes/random.class.php @@ -202,8 +202,8 @@ class random self::cleanTokens(); $conn = connection::getPDOConnection(); - $sql = 'SELECT * FROM tokens - WHERE value = :token + $sql = 'SELECT * FROM tokens + WHERE value = :token AND (expire_on > NOW() OR expire_on IS NULL)'; $stmt = $conn->prepare($sql); $stmt->execute(array(':token' => $token)); diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 731dec4918..8eba74d921 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -180,7 +180,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $connbas = $this->databox->get_connection(); @@ -530,7 +530,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } return null; @@ -580,7 +580,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $sql = 'SELECT BIN(status) as status FROM record WHERE record_id = :record_id'; @@ -617,6 +617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface throw new Exception_Media_SubdefNotFound (); if (isset($this->subdefs[$name])) + return $this->subdefs[$name]; if (!$this->subdefs) @@ -657,7 +658,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $connbas = $this->get_databox()->get_connection(); @@ -756,8 +757,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface if ($data) { if (isset($this->technical_datas[$data])) + return $this->technical_datas[$data]; else + return false; } @@ -860,7 +863,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface ); } - $sql = 'UPDATE record + $sql = 'UPDATE record SET originalname = :originalname WHERE record_id = :record_id'; $params = array( @@ -1114,7 +1117,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $this->delete_data_from_cache(self::CACHE_SUBDEFS); @@ -1340,7 +1343,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $this->delete_data_from_cache(self::CACHE_STATUS); @@ -1355,6 +1358,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface public function get_reg_name() { if (!$this->is_grouping()) + return false; $balisename = ''; @@ -1551,6 +1555,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface { $hd = $this->get_subdef('document'); if ($hd->is_physically_present()) + return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return null; } @@ -1773,7 +1778,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } $this->delete_data_from_cache(self::CACHE_SUBDEFS); } @@ -1803,16 +1808,16 @@ class record_adapter implements record_Interface, cache_cacheableInterface public function get_data_from_cache($option = null) { \cache_databox::refresh($this->get_sbas_id()); - + $databox = $this->get_databox(); - + return $databox->get_data_from_cache($this->get_cache_key($option)); } public function set_data_to_cache($value, $option = null, $duration = 0) { $databox = $this->get_databox(); - + return $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration); } @@ -1830,7 +1835,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface break; } $databox = $this->get_databox(); - + \cache_databox::update($this->get_sbas_id(), 'record', $this->get_record_id()); return $databox->delete_data_from_cache($this->get_cache_key($option)); @@ -1871,7 +1876,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } catch (Exception $e) { - + } } @@ -1891,6 +1896,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface public function get_container_baskets() { if ($this->container_basket) + return $this->container_basket; $appbox = appbox::get_instance(); diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index d30ef62779..3d025bac91 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -205,6 +205,7 @@ class record_preview extends record_adapter public function get_train($pos = 0, $query='', searchEngine_adapter $search_engine=null) { if ($this->train) + return $this->train; switch ($this->env) @@ -267,10 +268,11 @@ class record_preview extends record_adapter public function get_title($highlight = '', searchEngine_adapter $search_engine=null) { if ($this->title) + return $this->title; - + $this->title = collection::getLogo($this->get_base_id()) . ' '; - + switch ($this->env) { @@ -323,6 +325,7 @@ class record_preview extends record_adapter public function get_short_history() { if (!is_null($this->short_history)) + return $this->short_history; $tab = array(); @@ -376,14 +379,14 @@ class record_preview extends record_adapter if (!isset($tab[$hour][$site][$action][$row['usr_id']])) { $user = null; - + try { $user = \User_Adapter::getInstance($row['usr_id'], $appbox); } catch (Exception $e) { - + } $tab[$hour][$site][$action][$row['usr_id']] = @@ -415,6 +418,7 @@ class record_preview extends record_adapter public function get_view_popularity() { if (!is_null($this->view_popularity)) + return $this->view_popularity; $appbox = appbox::get_instance(); $session = $appbox->get_session(); @@ -512,6 +516,7 @@ class record_preview extends record_adapter public function get_refferer_popularity() { if (!is_null($this->refferer_popularity)) + return $this->refferer_popularity; $appbox = appbox::get_instance(); $session = $appbox->get_session(); @@ -598,6 +603,7 @@ class record_preview extends record_adapter { if (!is_null($this->download_popularity)) + return $this->download_popularity; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index e8c13dfd3b..71c2b8eed8 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -131,8 +131,10 @@ class registry implements registryInterface $this->load(); if(!$this->cache->is_set($key) && !is_null($defaultvalue)) + return $defaultvalue; else + return $this->cache->get($key); } diff --git a/lib/classes/searchEngine/adapter/phrasea/engine.class.php b/lib/classes/searchEngine/adapter/phrasea/engine.class.php index 416f5f0446..b8ae74692e 100644 --- a/lib/classes/searchEngine/adapter/phrasea/engine.class.php +++ b/lib/classes/searchEngine/adapter/phrasea/engine.class.php @@ -143,7 +143,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract public function set_options(searchEngine_options $options) { $this->options = $options; - + $this->opt_search_type = (int) $options->get_search_type(); $this->opt_bases = $options->get_bases(); $this->opt_fields = $options->get_fields(); @@ -397,7 +397,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract $total_time = 0; $sort = ''; - + if($this->options->get_sortby()) { switch($this->options->get_sortord()) @@ -412,7 +412,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract } $sort .= '0' . $this->options->get_sortby(); } - + foreach ($this->queries as $sbas_id => $qry) { $this->results[$sbas_id] = phrasea_query2( @@ -651,7 +651,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract { $val = $field['value']; } - + $ret[] = $val; } diff --git a/lib/classes/searchEngine/adapter/sphinx/engine.class.php b/lib/classes/searchEngine/adapter/sphinx/engine.class.php index 0967d8e8d2..048236b7d9 100644 --- a/lib/classes/searchEngine/adapter/sphinx/engine.class.php +++ b/lib/classes/searchEngine/adapter/sphinx/engine.class.php @@ -752,9 +752,9 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i 'before_match' => "", 'after_match' => "" ); - + $fields_to_send = array(); - + foreach($fields as $k=>$f) { $fields_to_send[$k] = $f['value']; diff --git a/lib/classes/searchEngine/options.class.php b/lib/classes/searchEngine/options.class.php index 62acbde8b1..78c179d7f9 100644 --- a/lib/classes/searchEngine/options.class.php +++ b/lib/classes/searchEngine/options.class.php @@ -454,13 +454,13 @@ class searchEngine_options implements Serializable { $tmpvalue = (array) $value; $value = array(); - + foreach($tmpvalue as $k=>$data) { $k = ctype_digit($k) ? (int) $k : $k; $value[$k] = $data; } - + } $this->$key = $value; diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php index 85e2bffc03..f98c3519f5 100644 --- a/lib/classes/set/export.class.php +++ b/lib/classes/set/export.class.php @@ -475,7 +475,7 @@ class set_export extends set_abstract $sd = $download_element->get_subdefs(); foreach ($download_element->get_downloadable() as $name => $properties) - { + { if ($properties === false || !in_array($name, $subdefs)) { continue; @@ -758,6 +758,7 @@ class set_export extends set_abstract return false; } if (isset($list['complete']) && $list['complete'] === true) + return; @@ -989,13 +990,13 @@ class set_export extends set_abstract else { /** - * + * * Header "Pragma: public" SHOULD be present. * In case it is not present, download on IE 8 and previous over HTTPS * will fail. - * + * * @todo : merge this shitty fix with Response object. - * + * */ if (!headers_sent()) { @@ -1007,6 +1008,7 @@ class set_export extends set_abstract $response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";"); $response->headers->set('Content-Length', filesize($file)); $response->setContent(file_get_contents($file)); + return $response; } } @@ -1057,7 +1059,7 @@ class set_export extends set_abstract $user = false; if ($anonymous) { - + } else { diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 97f8c5e6d2..ef37cd54ff 100644 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -53,7 +53,7 @@ class task_Scheduler { self::$connection = new connection_pdo ('appbox', $hostname, $port, $user, $password, $dbname); } - + return self::$connection; } diff --git a/lib/classes/task/manager.class.php b/lib/classes/task/manager.class.php index 51767999d7..6783b59049 100644 --- a/lib/classes/task/manager.class.php +++ b/lib/classes/task/manager.class.php @@ -112,7 +112,7 @@ class task_manager return $row; } - + public static function getAvailableTasks() { $registry = registry::get_instance(); @@ -150,6 +150,7 @@ class task_manager closedir($hdir); } } + return $tasks; } } diff --git a/lib/classes/task/period/ftp.class.php b/lib/classes/task/period/ftp.class.php index ed092c21a7..a021fbc3d2 100644 --- a/lib/classes/task/period/ftp.class.php +++ b/lib/classes/task/period/ftp.class.php @@ -459,7 +459,7 @@ class task_period_ftp extends task_appboxAbstract if (in_array(trim($basefolder), array('.', './', ''))) $basefolder = '/'; - + foreach ($ftp_export['files'] as $fileid => $file) { $base_id = $file["base_id"]; @@ -567,7 +567,7 @@ class task_period_ftp extends task_appboxAbstract { if($this->debug) echo "\nlogfile \n"; - + $date = new DateTime(); $remote_file = $date->format('U'); @@ -575,12 +575,12 @@ class task_period_ftp extends task_appboxAbstract FROM ftp_export_elements WHERE ftp_export_id = :ftp_export_id AND error = "0" AND done="1"'; - + $stmt = $conn->prepare($sql); $stmt->execute(array(':ftp_export_id'=>$id)); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - + $buffer = '#transfert finished '.$date->format(DATE_ATOM)."\n\n"; foreach ($rs as $row) @@ -602,7 +602,7 @@ class task_period_ftp extends task_appboxAbstract $ftp_client->chdir($ftp_export["destfolder"]); $ftp_client->put($remotefile, $tmpfile); - + unlink($tmpfile); } @@ -766,7 +766,7 @@ class task_period_ftp extends task_appboxAbstract _('task::ftp:Status about your FTP transfert from %1$s to %2$s') , $registry->get('GV_homeTitle'), $ftp_server ); - + mail::ftp_sent($sendermail, $subject, $sender_message); mail::ftp_receive($mail, $receiver_message); diff --git a/lib/classes/task/period/outofdate.class.php b/lib/classes/task/period/outofdate.class.php index 58eaef71f0..6b06967ed2 100644 --- a/lib/classes/task/period/outofdate.class.php +++ b/lib/classes/task/period/outofdate.class.php @@ -162,6 +162,7 @@ class task_period_outofdate extends task_abstract parent.calcSQL(); ..."; for(i in data.date_fields) html += "\n"; @@ -308,12 +310,13 @@ class task_period_outofdate extends task_abstract for(fld=0; fld<=2; fld++) $("#status"+fld).html(html); } - }); + }); + return; } - - - + + + 0 ? $nchanged : 'NORECSTODO'); + return($ret); } - - - + + + /* function doRecords() { @@ -911,9 +915,9 @@ class task_period_outofdate extends task_abstract private function calcSQL($sxTaskSettings) { $ret = array(); - + $this->sxTaskSettings = $sxTaskSettings; - + $date1 = $date2 = NULL; $field1 = $field2 = ''; @@ -1007,7 +1011,7 @@ class task_period_outofdate extends task_abstract SET " . $sqlset[0] . " WHERE " . $w; // printf("%d : %s \n%s", __LINE__, $sql, var_export($params, true)); - + $ret[] = array('sql'=>$sql, 'params'=>$params); // $stmt = $this->connbas->prepare($sql); @@ -1274,7 +1278,7 @@ class task_period_outofdate extends task_abstract } catch(Exception $e) { - + } } break; diff --git a/lib/classes/task/period/upgradetov32.class.php b/lib/classes/task/period/upgradetov32.class.php index f63f6bfc29..c3d1138b6c 100644 --- a/lib/classes/task/period/upgradetov32.class.php +++ b/lib/classes/task/period/upgradetov32.class.php @@ -68,6 +68,7 @@ class task_period_upgradetov32 extends task_abstract { printf("sbas_id '" . $this->sbas_id . "' invalide\n"); $this->return_value = self::RETURNSTATUS_STOPPED; + return; } @@ -241,7 +242,7 @@ class task_period_upgradetov32 extends task_abstract } catch (Exception $e) { - + } } @@ -369,11 +370,13 @@ class task_period_upgradetov32 extends task_abstract if ($n_done >= 5000) { $this->return_value = task_abstract::RETURNSTATUS_TORESTART; + return; - } + } if ($memory > 100) { $this->return_value = task_abstract::RETURNSTATUS_TORESTART; + return; } } @@ -408,9 +411,9 @@ class task_period_upgradetov32 extends task_abstract $stmt->closeCursor(); $this->setProgress(0, 0); - + $this->return_value = self::RETURNSTATUS_TODELETE; - + flush(); return; diff --git a/lib/classes/task/period/writemeta.class.php b/lib/classes/task/period/writemeta.class.php index 3e87a4193b..726aa92278 100644 --- a/lib/classes/task/period/writemeta.class.php +++ b/lib/classes/task/period/writemeta.class.php @@ -307,7 +307,7 @@ class task_period_writemeta extends task_databoxAbstract $fields = $record->get_caption()->get_fields(); $subCMD = ''; - + if ($record->get_uuid()) { $subCMD .= '-XMP-exif:ImageUniqueID='; @@ -315,7 +315,7 @@ class task_period_writemeta extends task_databoxAbstract $subCMD .= '-IPTC:UniqueDocumentID='; $subCMD .= escapeshellarg($record->get_uuid()); } - + foreach ($fields as $field) { $meta = $field->get_databox_field(); @@ -326,23 +326,23 @@ class task_period_writemeta extends task_databoxAbstract $multi = $meta->is_multi(); $type = $meta->get_type(); $datas = $field->get_value(); - + if ($multi) { $datas = $field->get_value(); foreach ($datas as $value) { $value = $this->format_value($type, $value); - - $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; + + $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; $subCMD .= escapeshellarg($value).' '; } } else { $datas = $this->format_value($type, $datas); - - $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; + + $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'='; $subCMD .= escapeshellarg($datas).' '; } } @@ -355,17 +355,18 @@ class task_period_writemeta extends task_databoxAbstract $cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original '); if ($name != 'document' || $this->clear_doc) $cmd .= '-all:all= '; - + $cmd .= ' -codedcharacterset=utf8 '; - + $cmd .= $subCMD.' '.escapeshellarg($file); - + $this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name)); $s = trim(shell_exec($cmd)); $this->log("\t" . $s); } + return $this; } diff --git a/lib/unitTest/ACLTest.php b/lib/unitTest/ACLTest.php index 4f0c802b59..e4b3fb4df1 100644 --- a/lib/unitTest/ACLTest.php +++ b/lib/unitTest/ACLTest.php @@ -655,48 +655,48 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testis_limited() { $appbox = appbox::get_instance(); - + $found = false; - + foreach ($appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - + if(!self::$user->ACL()->has_access_to_base($base_id)) continue; - + $this->assertFalse(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, true, new DateTime('-1 day'), new DateTime('+1 day')); - + $this->assertFalse(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, false, new DateTime('-1 day'), new DateTime('+1 day')); - + $this->assertFalse(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, true, new DateTime('+1 day'), new DateTime('+2 day')); - + $this->assertTrue(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('-1 day')); - + $this->assertTrue(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, true, new DateTime('-2 day'), new DateTime('+2 day')); - + $this->assertFalse(self::$user->ACL()->is_limited($base_id)); - + self::$user->ACL()->set_limits($base_id, false, new DateTime('-2 day'), new DateTime('+2 day')); - + $this->assertFalse(self::$user->ACL()->is_limited($base_id)); - + $found = true; } } - + if(!$found) $this->fail ('Unable to test'); } @@ -704,50 +704,50 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testget_limits() { $appbox = appbox::get_instance(); - + $found = false; - + foreach ($appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - + if(!self::$user->ACL()->has_access_to_base($base_id)) continue; - + $minusone = new DateTime('-1 day'); - + $plusone = new DateTime('+1 day'); - + self::$user->ACL()->set_limits($base_id, true, $minusone, $plusone); - + $limits = self::$user->ACL()->get_limits($base_id); - + $this->assertEquals($limits['dmin'], $minusone); - + $this->assertEquals($limits['dmax'], $plusone); - + $minustwo = new DateTime('-2 day'); - + $plustwo = new DateTime('-2 day'); - + self::$user->ACL()->set_limits($base_id, true, $minustwo, $plustwo); - + $limits = self::$user->ACL()->get_limits($base_id); $this->assertEquals($limits['dmin'], $minustwo); - + $this->assertEquals($limits['dmax'], $plustwo); - + self::$user->ACL()->set_limits($base_id, false); - + $this->assertNull(self::$user->ACL()->get_limits($base_id)); - + $found = true; } } - + if(!$found) $this->fail ('Unable to test'); } diff --git a/lib/unitTest/Bridge/Bridge_datas.inc b/lib/unitTest/Bridge/Bridge_datas.inc index 52c8194079..934aa3e087 100644 --- a/lib/unitTest/Bridge/Bridge_datas.inc +++ b/lib/unitTest/Bridge/Bridge_datas.inc @@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../bootstrap.php'; */ /** - * + * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com @@ -25,17 +25,17 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface public function __construct() { - + } public function get_created_on() { - + } public function get_description() { - + } public function get_id() @@ -45,12 +45,12 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface public function get_thumbnail($width = 120, $height = 90) { - + } public function get_title() { - + } public function get_type() @@ -60,12 +60,12 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface public function get_updated_on() { - + } public function get_url() { - + } } @@ -78,27 +78,27 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface public function __construct() { - + } public function get_category() { - + } public function get_created_on() { - + } public function get_description() { - + } public function get_duration() { - + } public function get_id() @@ -108,17 +108,17 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface public function get_rating() { - + } public function get_thumbnail() { - + } public function get_title() { - + } public function get_type() @@ -128,22 +128,22 @@ class Bridge_Api_Apitest_Element implements Bridge_Api_ElementInterface public function get_updated_on() { - + } public function get_url() { - + } public function get_view_count() { - + } public function is_private() { - + } } @@ -159,17 +159,17 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter protected function initialize_transport() { - + } protected function set_auth_params() { - + } protected function set_transport_authentication_params() { - + } public function get_terms_url() @@ -178,7 +178,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter } /** - * + * * @return Array */ public function connect() @@ -188,7 +188,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter /** * - * @return Bridge_Api_Interface + * @return Bridge_Api_Interface */ public function reconnect() { @@ -197,7 +197,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter /** * - * @return Bridge_Api_Interface + * @return Bridge_Api_Interface */ public function disconnect() { @@ -206,7 +206,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter /** * - * @return boolean + * @return boolean */ public function is_connected() { @@ -214,16 +214,16 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter } /** - * - * @return Bridge_Api_Interface + * + * @return Bridge_Api_Interface */ public function set_locale($locale) { - + } /** - * + * * @return string */ public function get_name() @@ -232,39 +232,39 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter } /** - * + * * @return string */ public function get_icon_url() { - + } /** - * + * * @return string */ public function get_image_url() { - + } /** - * + * * @return string */ public function get_url() { - + } /** - * + * * @return string */ public function get_infos() { - + } public function get_object_class_from_type($type) @@ -292,12 +292,12 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter public function get_element_types() { - + } public function get_container_types() { - + } public function get_element_from_id($element_id, $object) @@ -305,6 +305,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter $element = new Bridge_Api_Apitest_Element(); $element->id = $element_id; $element->type = $object; + return $element; } @@ -313,12 +314,13 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter $container = new Bridge_Api_Apitest_Containers(); $container->id = $element_id; $container->type = $object; + return $container; } public function get_category_list() { - + } public function get_user_name() @@ -340,6 +342,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter $element_collection->add_element(new Bridge_Api_Apitest_Element()); $i++; } + return $element_collection; } @@ -352,61 +355,62 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter $container_collection->add_element(new Bridge_Api_Apitest_Containers()); $i++; } + return $container_collection; } public function update_element($object, $object_id, Array $datas) { - + } public function create_container($container_type, Request $request) { - + } public function add_element_to_container($element_type, $element_id, $destination, $container_id) { - + } public function delete_object($object, $object_id) { - + } /** - * + * * @return Closure */ public function acceptable_records() { - + } public function get_element_status(Bridge_Element $element) { - + } public function map_connector_to_element_status($status) { - + } public function get_error_message_from_status($connector_status) { - + } public function upload(record_adapter &$record, array $options = array()) { - + } public function is_valid_object_id($object_id) { - + } public function is_configured() @@ -416,27 +420,27 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter public function check_upload_constraints(array $datas, record_adapter $record) { - + } public function get_upload_datas(Request $request, record_adapter $record) { - + } public function is_multiple_upload() { - + } public function check_update_constraints(Array $datas) { - + } public function get_update_datas(Request $request) { - + } } @@ -446,12 +450,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap public function connect($param) { - + } public function parse_request_token() { - + } public function reconnect() @@ -476,12 +480,12 @@ class Bridge_Api_Auth_None extends Bridge_Api_Auth_Abstract implements Bridge_Ap public function get_auth_signatures() { - + } public function set_parameters(Array $parameters) { - + } -} \ No newline at end of file +} diff --git a/lib/unitTest/FeedValidator.inc b/lib/unitTest/FeedValidator.inc index ceea8f0227..f32e70533b 100644 --- a/lib/unitTest/FeedValidator.inc +++ b/lib/unitTest/FeedValidator.inc @@ -1,8 +1,8 @@ getMessage(); } - * + * */ /** @@ -30,7 +30,7 @@ */ class W3CFeedValidatorException extends Exception { - + } /** @@ -55,7 +55,7 @@ class W3CFeedUrlValidator extends W3CFeedValidator /** * The URL of the document to validate - * @var string + * @var string */ private $url; @@ -88,12 +88,13 @@ class W3CFeedUrlValidator extends W3CFeedValidator { throw new W3CFeedValidatorException("Unable to request W3C API"); } + return new W3CFeedValidatorResponse($response); } /** * Check if an url is valid - * @param string $url + * @param string $url * @return boolean */ private function isValidUrl($url) @@ -112,14 +113,14 @@ class W3CFeedRawValidator extends W3CFeedValidator /** * The source of the document to validate - * @var string + * @var string */ private $rawData; /** * Constructor * Init instance which the specified data to validate - * @param string $rawData + * @param string $rawData */ public function __construct($rawData) { @@ -151,6 +152,7 @@ class W3CFeedRawValidator extends W3CFeedValidator { throw new W3CFeedValidatorException("Unable to request W3C API"); } + return new W3CFeedValidatorResponse($response); } @@ -209,36 +211,40 @@ class W3CFeedValidatorResponse $string .= $name . "=>" . $detail . "\n"; } } + return $string; } /** - * Check if the XML is valid - * @return boolean + * Check if the XML is valid + * @return boolean */ public function isValid() { $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity"; + return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false"; } /** * Check for errors - * @return boolean + * @return boolean */ public function hasError() { $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount"; + return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; } /** * check fro warnings - * @return boolean + * @return boolean */ public function hasWarning() { $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount"; + return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; } @@ -271,8 +277,8 @@ class W3CFeedValidatorResponse * 1 => etc .. * } * } - * - * @return array + * + * @return array */ public function getWarnings() { @@ -286,12 +292,13 @@ class W3CFeedValidatorResponse $warnings[] = $this->domNodeToArray($warning); } } + return $warnings; } /** * Get an array with all errors as follow - * @return array + * @return array */ public function getErrors() { @@ -305,14 +312,15 @@ class W3CFeedValidatorResponse $errors[] = $this->domNodeToArray($error); } } + return $errors; } /** * @source http://www.ermshaus.org/2010/12/php-transform-domnode-to-array - * + * * Transforms the contents of a DOMNode to an associative array - * + * * XML node names become array keys, attributes will be discarded. If $node * doesn't contain child nodes, a string will be returned. * diff --git a/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc b/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc index aa0ff88600..13e9d7286a 100644 --- a/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc +++ b/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc @@ -10,7 +10,7 @@ */ /** - * + * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com @@ -29,7 +29,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase const USER_AGENT_IPHONE = 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F137 Safari/525.20'; /** * - * @var Symfony\Component\HttpKernel\Client + * @var Symfony\Component\HttpKernel\Client */ protected $client; @@ -330,7 +330,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase /** * - * @var collection + * @var collection */ protected static $collection; protected static $time_start; @@ -340,7 +340,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase { if (!self::$time_start) self::$time_start = microtime(true); - + if(!setup::is_installed()) exit("Phraseanet is not set up\n"); @@ -431,12 +431,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $basket_coll = new basketCollection($appbox, self::$user->get_id()); $baskets = $basket_coll->get_baskets(); - + foreach($baskets['baskets'] as $basket) { $basket->delete(); } - + basket_adapter::create($appbox, 'TEST', self::$user); $appbox->get_session()->authenticate(new Session_Authentication_None(self::$user)); @@ -919,11 +919,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase { return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date); } - + protected function set_user_agent($user_agent) { $browser = Browser::getInstance(); $browser->setUserAgent($user_agent); } -} \ No newline at end of file +} diff --git a/lib/unitTest/PhraseanetPHPUnitAuthenticatedAbstract.class.inc b/lib/unitTest/PhraseanetPHPUnitAuthenticatedAbstract.class.inc index cdab589f41..f46b7bc5b1 100644 --- a/lib/unitTest/PhraseanetPHPUnitAuthenticatedAbstract.class.inc +++ b/lib/unitTest/PhraseanetPHPUnitAuthenticatedAbstract.class.inc @@ -10,7 +10,7 @@ */ /** - * + * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com @@ -40,7 +40,7 @@ abstract class PhraseanetPHPUnitAuthenticatedAbstract extends PhraseanetPHPUnitA $session->logout(); parent::tearDown(); } - + // public static function setUpBeforeClass() // { // parent::setUpBeforeClass(); @@ -55,4 +55,4 @@ abstract class PhraseanetPHPUnitAuthenticatedAbstract extends PhraseanetPHPUnitA // parent::tearDownAfterClass(); // } -} \ No newline at end of file +} diff --git a/lib/unitTest/PhraseanetWebTestCaseAbstract.class.inc b/lib/unitTest/PhraseanetWebTestCaseAbstract.class.inc index 6bd22c5732..cdf310d726 100644 --- a/lib/unitTest/PhraseanetWebTestCaseAbstract.class.inc +++ b/lib/unitTest/PhraseanetWebTestCaseAbstract.class.inc @@ -10,7 +10,7 @@ */ /** - * + * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com @@ -34,4 +34,4 @@ abstract class PhraseanetWebTestCaseAbstract extends PhraseanetPHPUnitAbstract $this->app = $this->createApplication(); } -} \ No newline at end of file +} diff --git a/lib/unitTest/PhraseanetWebTestCaseAuthenticatedAbstract.class.inc b/lib/unitTest/PhraseanetWebTestCaseAuthenticatedAbstract.class.inc index ff111cd776..c18910c0cb 100644 --- a/lib/unitTest/PhraseanetWebTestCaseAuthenticatedAbstract.class.inc +++ b/lib/unitTest/PhraseanetWebTestCaseAuthenticatedAbstract.class.inc @@ -10,7 +10,7 @@ */ /** - * + * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com @@ -35,4 +35,4 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU $this->app = $this->createApplication(); } -} \ No newline at end of file +} diff --git a/lib/unitTest/databox/databox_statusTest.php b/lib/unitTest/databox/databox_statusTest.php index b13cc8f8bc..2ab4e6689d 100644 --- a/lib/unitTest/databox/databox_statusTest.php +++ b/lib/unitTest/databox/databox_statusTest.php @@ -153,13 +153,13 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract public function testDec2bin() { $this->assertEquals('1010', databox_status::dec2bin('10')); - + try { } catch(Exception $e) { - + } } @@ -167,7 +167,7 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract { $this->assertEquals('10100001', databox_status::hex2bin('0x0A1')); $this->assertEquals('10100001', databox_status::hex2bin('0A1')); - + try { databox_status::hex2bin('G1'); @@ -175,7 +175,7 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract } catch(Exception $e) { - + } } diff --git a/lib/unitTest/module/prod/overviewAppTest.php b/lib/unitTest/module/prod/overviewAppTest.php index 00d861f243..4edccc6573 100644 --- a/lib/unitTest/module/prod/overviewAppTest.php +++ b/lib/unitTest/module/prod/overviewAppTest.php @@ -117,7 +117,7 @@ class Feed_overviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract $crawler = $this->client->request('GET', $url); $response = $this->client->getResponse(); - + if (self::$record_1->get_preview()->get_baseurl() !== '') { $this->assertEquals(302, $response->getStatusCode()); diff --git a/lib/unitTest/module/prod/route/record/feedApplicatonTest.php b/lib/unitTest/module/prod/route/record/feedApplicatonTest.php index 5ab1a096c8..7d2e878d67 100644 --- a/lib/unitTest/module/prod/route/record/feedApplicatonTest.php +++ b/lib/unitTest/module/prod/route/record/feedApplicatonTest.php @@ -64,6 +64,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated public function createApplication() { $app = require __DIR__ . '/../../../../../classes/module/Prod.php'; + return $app; } @@ -211,7 +212,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated // } // catch (Exception $e) // { -// +// // } // } // diff --git a/lib/unitTest/module/rssFeedTest.php b/lib/unitTest/module/rssFeedTest.php index ef5aa855bd..1175c2bcb3 100644 --- a/lib/unitTest/module/rssFeedTest.php +++ b/lib/unitTest/module/rssFeedTest.php @@ -163,9 +163,9 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract /** * XML is not verified due to Validator Service bug */ - + return; - + try { $validator = new W3CFeedRawValidator($xml); @@ -253,7 +253,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $offset_start = ($offset_start++) * $n_entries; $collection = $feed->get_entries($offset_start, $n_entries); $entries = $collection->get_entries(); - if (sizeof($entries) == 0) //no more + if (sizeof($entries) == 0) //no more break; } $feed_entry = array_shift($entries); @@ -331,6 +331,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract { $current_attributes[$attribute->name] = $attribute->value; } + return $current_attributes; } @@ -470,7 +471,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract ) ); - + foreach ($fields as $key_field => $field) { if ($field["media_field"]["name"] == $node->nodeName) @@ -516,6 +517,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract unset($item_entries[$key]); //remove } }; + return $remove; } @@ -562,7 +564,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $offset_start = ($offset_start++) * $n_entries; $collection = $feed->get_entries($offset_start, $n_entries); $entries = $collection->get_entries(); - if (sizeof($entries) == 0) //no more + if (sizeof($entries) == 0) //no more break; } $feed_entry = array_shift($entries); @@ -642,4 +644,4 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract } } -} \ No newline at end of file +} diff --git a/lib/unitTest/report/dashboardTest.php b/lib/unitTest/report/dashboardTest.php index 494e67b8c5..b223a97fca 100644 --- a/lib/unitTest/report/dashboardTest.php +++ b/lib/unitTest/report/dashboardTest.php @@ -100,7 +100,7 @@ class dashboardTest extends PhraseanetPHPUnitAbstract { if ($key == 'activity_added') { - + } $this->assertLessThanOrEqual($nbDay, count($dash)); } @@ -119,7 +119,7 @@ class dashboardTest extends PhraseanetPHPUnitAbstract } catch (Exception $e) { - + } } diff --git a/lib/unitTest/searchEngine_optionsTest.php b/lib/unitTest/searchEngine_optionsTest.php index 11e9e47e3d..8bda9cb974 100644 --- a/lib/unitTest/searchEngine_optionsTest.php +++ b/lib/unitTest/searchEngine_optionsTest.php @@ -29,7 +29,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract */ public function tearDown() { - + } /** diff --git a/lib/unitTest/userTest.php b/lib/unitTest/userTest.php index 4bcc3d3912..d9b00f75c0 100644 --- a/lib/unitTest/userTest.php +++ b/lib/unitTest/userTest.php @@ -23,8 +23,8 @@ require_once dirname(__FILE__) . '/PhraseanetPHPUnitAbstract.class.inc'; class userTest extends PhraseanetPHPUnitAbstract { - - + + public function testMail() { $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); @@ -32,10 +32,10 @@ class userTest extends PhraseanetPHPUnitAbstract { $appbox = appbox::get_instance(); - self::$user->set_email(null); + self::$user->set_email(null); $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); - self::$user->set_email(''); + self::$user->set_email(''); $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); self::$user->set_email('noone@example.com'); $this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noone@example.com')); @@ -46,14 +46,14 @@ class userTest extends PhraseanetPHPUnitAbstract } try { - + self::$user->set_email('noonealt1@example.com'); $this->fail('A user already got this address'); } catch(Exception $e) { - + } $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); } -} \ No newline at end of file +} diff --git a/templates/web/admin/editusers.twig b/templates/web/admin/editusers.twig index 37cda2aed5..af17fbfc4a 100644 --- a/templates/web/admin/editusers.twig +++ b/templates/web/admin/editusers.twig @@ -124,7 +124,7 @@ {% if main_user is not empty %} - + {% if main_user.is_special is not empty %} {% if main_user.get_login() == 'invite' %} {% trans 'Reglages:: reglages d acces guest' %} @@ -199,7 +199,7 @@ {% endif %} - + {{rights['sbas_id']|sbas_name}} @@ -556,7 +556,7 @@ {% endif %}
- + {% trans 'boutton::retour' %}
diff --git a/templates/web/admin/editusers_timelimit.twig b/templates/web/admin/editusers_timelimit.twig index f02348863f..8a9ce7f0f1 100644 --- a/templates/web/admin/editusers_timelimit.twig +++ b/templates/web/admin/editusers_timelimit.twig @@ -21,13 +21,13 @@ - {% trans 'De' %} + {% trans 'De' %} - {% trans 'A' %} + {% trans 'A' %} diff --git a/templates/web/admin/index.html.twig b/templates/web/admin/index.html.twig index 5f151845ee..c75f103587 100644 --- a/templates/web/admin/index.html.twig +++ b/templates/web/admin/index.html.twig @@ -94,7 +94,7 @@ } }) }; - + function activeTree(click) { $('#FNDR').treeview({ @@ -142,7 +142,7 @@ activeTree(true); } ); - + function refreshBaskets() { return; diff --git a/templates/web/admin/tree.html.twig b/templates/web/admin/tree.html.twig index 7a2deacee3..d0ce68c69a 100644 --- a/templates/web/admin/tree.html.twig +++ b/templates/web/admin/tree.html.twig @@ -32,7 +32,7 @@ {% endif %}
  • - + {% trans 'admin::utilisateurs: utilisateurs connectes' %} @@ -40,13 +40,13 @@ {% if user.ACL().has_right('manageusers') %}
  • - + {% trans 'admin::utilisateurs: utilisateurs' %}
  • - + {% trans 'admin::utilisateurs: demandes en cours' %} @@ -64,7 +64,7 @@ {% if user.ACL().has_right('taskmanager') %}
  • - + {% trans 'admin::utilisateurs: gestionnaire de taches' %} @@ -73,7 +73,7 @@
  • \ No newline at end of file + diff --git a/templates/web/common/menubar.twig b/templates/web/common/menubar.twig index d825b55d38..ea020127eb 100644 --- a/templates/web/common/menubar.twig +++ b/templates/web/common/menubar.twig @@ -32,7 +32,7 @@ {% endif %} {% endif %}
  • - + {% if browser.isNewGeneration and registry.get('GV_thesaurus') == true and user.ACL.has_access_to_module('thesaurus') %}
  • @@ -42,8 +42,8 @@
  • {% endif %} - - + + {# MODULE #} {% if user.ACL.has_access_to_module('admin') %}
  • @@ -104,20 +104,20 @@
  • {% endif %} - + {% endif %}
      - + {% if module == "client" or module == "prod" %}
    1. {% trans 'Notifications' %} - +
      {% if events.get_unread_notifications_number > 0 %} @@ -191,4 +191,4 @@ \ No newline at end of file +
      diff --git a/templates/web/setup/step2.twig b/templates/web/setup/step2.twig index 1fdf08b240..2dc388378c 100644 --- a/templates/web/setup/step2.twig +++ b/templates/web/setup/step2.twig @@ -122,7 +122,7 @@ setTimeout("$('form#create_admin').submit();",500); }; } - + if($current.hasClass('appbox_settings')) { test_connection_appbox(callback); @@ -195,7 +195,7 @@ var password_input = $('input[name="ab_password"]', appbox_scope); var dbname_input = $('input[name="db_name"]', databox_scope); - + var user = user_input.val(); var password = password_input.val(); var dbname = dbname_input.val(); diff --git a/www/admin/cgus.php b/www/admin/cgus.php index 646bf4cc77..371d4d64ad 100644 --- a/www/admin/cgus.php +++ b/www/admin/cgus.php @@ -83,7 +83,7 @@ $TOU = $databox->get_cgus();

      - +
      diff --git a/www/admin/databases.php b/www/admin/databases.php index 689562885c..76e7434de5 100644 --- a/www/admin/databases.php +++ b/www/admin/databases.php @@ -90,7 +90,7 @@ phrasea::headers(); { $error[] = _('Database name can not contains special characters'); } - + if (count($error) === 0) { try @@ -117,7 +117,7 @@ phrasea::headers(); } } } - elseif ($parm['new_settings'] && $parm['new_hostname'] && $parm['new_port'] + elseif ($parm['new_settings'] && $parm['new_hostname'] && $parm['new_port'] && $parm['new_user'] && $parm['new_password'] && $parm['new_dbname'] && $parm['new_data_template']) { @@ -126,7 +126,7 @@ phrasea::headers(); { $error[] = _('Database name can not contains special characters'); } - + if (count($error) === 0) { @@ -226,7 +226,7 @@ phrasea::headers(); } catch (Exception $e) { - + } } ?> @@ -254,7 +254,7 @@ if ($createBase || $mountBase) ?> - diff --git a/www/admin/demand.php b/www/admin/demand.php index 40fa02aa5e..dd1ab96346 100644 --- a/www/admin/demand.php +++ b/www/admin/demand.php @@ -117,7 +117,7 @@ if (!is_null($templates) || !is_null($parm['deny']) || !is_null($parm['accept']) $done[$usr][$base_id] = true; } - $sql = "DELETE FROM demand + $sql = "DELETE FROM demand WHERE usr_id = :usr_id AND (base_id = ".implode(' OR base_id = ', $base_ids).")"; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(array(':usr_id' => $usr)); diff --git a/www/admin/description.php b/www/admin/description.php index b70f803d02..00d6002cdc 100644 --- a/www/admin/description.php +++ b/www/admin/description.php @@ -138,7 +138,7 @@ if (!empty($_POST)) } catch (Exception $e) { - + } } } diff --git a/www/admin/taskmanager.php b/www/admin/taskmanager.php index 072d56e1f5..c6eac115be 100644 --- a/www/admin/taskmanager.php +++ b/www/admin/taskmanager.php @@ -351,9 +351,10 @@ foreach ($tasks as $t) { if(window.console) console.log('No task like this'); + return(false); } - + switch(T_task[tid]) { case "stopped_0": // normal diff --git a/www/client/answer.php b/www/client/answer.php index ed9542c717..6883af0ffa 100644 --- a/www/client/answer.php +++ b/www/client/answer.php @@ -72,6 +72,7 @@ $qrySbas = array(); if (is_null($parm['bas'])) { echo 'vous devez selectionner des collections dans lesquelles chercher'; + return; } @@ -178,7 +179,7 @@ $ACL = $user->ACL(); $history = queries::history(); echo ''; - + $nbanswers = $result->get_count_available_results(); $longueur = strlen($parm['qry']); @@ -363,7 +364,7 @@ $npages = $result->get_total_pages(); $sd = $record->get_subdefs(); - + $isImage = false; $isDocument = false; if (!$isVideo && !$isAudio) @@ -470,7 +471,7 @@ $npages = $result->get_total_pages(); diff --git a/www/include/jslibs/yui2.8/examples/imagecropper/assets/exampleslib.inc b/www/include/jslibs/yui2.8/examples/imagecropper/assets/exampleslib.inc index 4d751666dd..901f95df75 100644 --- a/www/include/jslibs/yui2.8/examples/imagecropper/assets/exampleslib.inc +++ b/www/include/jslibs/yui2.8/examples/imagecropper/assets/exampleslib.inc @@ -1,16 +1,16 @@ diff --git a/www/login/register.php b/www/login/register.php index ac21ab9d64..0e08727a6e 100644 --- a/www/login/register.php +++ b/www/login/register.php @@ -175,7 +175,7 @@ if ($request->has_post_datas()) ->set_company($parm['form_company']) ->set_position($parm['form_activity']) ->set_geonameid($parm['form_geonameid']); - + $newid = $user->get_id(); $demandOK = array(); @@ -183,9 +183,9 @@ if ($request->has_post_datas()) if ($registry->get('GV_autoregister')) { $template_user_id = User_Adapter::get_usr_id_from_login('autoregister'); - + $template_user = User_Adapter::getInstance($template_user_id, appbox::get_instance()); - + $user->ACL()->apply_model($template_user, array_keys($inscOK[$base_id])); } @@ -220,6 +220,7 @@ if ($request->has_post_datas()) if ($newUsrEmail) { $user->set_mail_locked(true); + return phrasea::redirect('/login/sendmail-confirm.php?usr_id=' . $newid); } diff --git a/www/thesaurus2/thesaurus.php b/www/thesaurus2/thesaurus.php index 9ec547e088..6d9d5a6d78 100644 --- a/www/thesaurus2/thesaurus.php +++ b/www/thesaurus2/thesaurus.php @@ -337,7 +337,7 @@ $jsFlags = '{ ' . $jsFlags . ' }'; document.body.oncontextmenu = function(){ return false; } - + tFlags = ; myGUI = new GUI("myGUI", "desktop", "FR"); @@ -705,7 +705,7 @@ $jsFlags = '{ ' . $jsFlags . ' }'; { case "RMOUSEDOWN": if(o = eventObj.Src0) - { + { // alert(o.id.substr(0, 4)); switch(o.id.substr(0, 4)) {