summaryrefslogtreecommitdiff
path: root/lib/Minz
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-31 16:57:11 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-31 16:57:11 +0100
commit54479a5027d83b5dc8deee5e2795c9d89c732ba0 (patch)
tree7ae55930f3ab6d5e2a548784e4d7561809f7c68c /lib/Minz
parentcff8636e770b2072a41928cd918b37654c0dafbb (diff)
parent724e13f0a6419b046b33da71e66058e279551edd (diff)
Merge branch 'dev' into beta
Conflicts: CHANGELOG README.fr.md README.md app/Controllers/feedController.php app/Controllers/indexController.php app/i18n/en.php app/i18n/fr.php app/views/helpers/view/normal_view.phtml app/views/stats/index.phtml app/views/stats/repartition.phtml constants.php p/scripts/main.js
Diffstat (limited to 'lib/Minz')
-rw-r--r--lib/Minz/Configuration.php50
-rw-r--r--lib/Minz/FrontController.php4
-rw-r--r--lib/Minz/ModelPdo.php12
-rw-r--r--lib/Minz/Request.php7
-rw-r--r--lib/Minz/View.php12
5 files changed, 71 insertions, 14 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 4e9da58b4..6cbc9fc0b 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -60,6 +60,15 @@ class Minz_Configuration {
'prefix' => '',
);
+ const MAX_SMALL_INT = 16384;
+ private static $limits = array(
+ 'cache_duration' => 800, //SimplePie cache duration in seconds
+ 'timeout' => 10, //SimplePie timeout in seconds
+ 'max_inactivity' => PHP_INT_MAX, //Time in seconds after which a user who has not used the account is considered inactive (no auto-refresh of feeds).
+ 'max_feeds' => Minz_Configuration::MAX_SMALL_INT,
+ 'max_categories' => Minz_Configuration::MAX_SMALL_INT,
+ );
+
/*
* Getteurs
*/
@@ -97,12 +106,12 @@ class Minz_Configuration {
public static function dataBase () {
return self::$db;
}
+ public static function limits() {
+ return self::$limits;
+ }
public static function defaultUser () {
return self::$default_user;
}
- public static function isAdmin($currentUser) {
- return $currentUser === self::$default_user;
- }
public static function allowAnonymous() {
return self::$allow_anonymous;
}
@@ -181,6 +190,7 @@ class Minz_Configuration {
'api_enabled' => self::$api_enabled,
'unsafe_autologin_enabled' => self::$unsafe_autologin_enabled,
),
+ 'limits' => self::$limits,
'db' => self::$db,
);
@rename(DATA_PATH . self::CONF_PATH_NAME, DATA_PATH . self::CONF_PATH_NAME . '.bak.php');
@@ -294,6 +304,40 @@ class Minz_Configuration {
);
}
+ if (isset($ini_array['limits'])) {
+ $limits = $ini_array['limits'];
+ if (isset($limits['cache_duration'])) {
+ $v = intval($limits['cache_duration']);
+ if ($v > 0) {
+ self::$limits['cache_duration'] = $v;
+ }
+ }
+ if (isset($limits['timeout'])) {
+ $v = intval($limits['timeout']);
+ if ($v > 0) {
+ self::$limits['timeout'] = $v;
+ }
+ }
+ if (isset($limits['max_inactivity'])) {
+ $v = intval($limits['max_inactivity']);
+ if ($v > 0) {
+ self::$limits['max_inactivity'] = $v;
+ }
+ }
+ if (isset($limits['max_feeds'])) {
+ $v = intval($limits['max_feeds']);
+ if ($v > 0 && $v < Minz_Configuration::MAX_SMALL_INT) {
+ self::$limits['max_feeds'] = $v;
+ }
+ }
+ if (isset($limits['max_categories'])) {
+ $v = intval($limits['max_categories']);
+ if ($v > 0 && $v < Minz_Configuration::MAX_SMALL_INT) {
+ self::$limits['max_categories'] = $v;
+ }
+ }
+ }
+
// Base de données
if (isset ($ini_array['db'])) {
$db = $ini_array['db'];
diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php
index f13882801..e95c56bf3 100644
--- a/lib/Minz/FrontController.php
+++ b/lib/Minz/FrontController.php
@@ -46,7 +46,7 @@ class Minz_FrontController {
);
Minz_Request::forward ($url);
} catch (Minz_Exception $e) {
- Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
+ Minz_Log::error($e->getMessage());
$this->killApp ($e->getMessage ());
}
@@ -85,7 +85,7 @@ class Minz_FrontController {
$this->dispatcher->run();
} catch (Minz_Exception $e) {
try {
- Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
+ Minz_Log::error($e->getMessage());
} catch (Minz_PermissionDeniedException $e) {
$this->killApp ($e->getMessage ());
}
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index b4bfca746..6198cd85c 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -16,6 +16,8 @@ class Minz_ModelPdo {
public static $useSharedBd = true;
private static $sharedBd = null;
private static $sharedPrefix;
+ private static $has_transaction = false;
+ private static $sharedCurrentUser;
protected static $sharedDbType;
/**
@@ -23,6 +25,7 @@ class Minz_ModelPdo {
*/
protected $bd;
+ protected $current_user;
protected $prefix;
public function dbType() {
@@ -37,6 +40,7 @@ class Minz_ModelPdo {
if (self::$useSharedBd && self::$sharedBd != null && $currentUser === null) {
$this->bd = self::$sharedBd;
$this->prefix = self::$sharedPrefix;
+ $this->current_user = self::$sharedCurrentUser;
return;
}
@@ -45,6 +49,8 @@ class Minz_ModelPdo {
if ($currentUser === null) {
$currentUser = Minz_Session::param('currentUser', '_');
}
+ $this->current_user = $currentUser;
+ self::$sharedCurrentUser = $currentUser;
try {
$type = $db['type'];
@@ -91,12 +97,18 @@ class Minz_ModelPdo {
public function beginTransaction() {
$this->bd->beginTransaction();
+ self::$has_transaction = true;
+ }
+ public function hasTransaction() {
+ return self::$has_transaction;
}
public function commit() {
$this->bd->commit();
+ self::$has_transaction = false;
}
public function rollBack() {
$this->bd->rollBack();
+ self::$has_transaction = false;
}
public static function clean() {
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index f7a24c026..4b97a3caf 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -45,6 +45,13 @@ class Minz_Request {
public static function defaultActionName() {
return self::$default_action_name;
}
+ public static function currentRequest() {
+ return array(
+ 'c' => self::$controller_name,
+ 'a' => self::$action_name,
+ 'params' => self::$params,
+ );
+ }
/**
* Setteurs
diff --git a/lib/Minz/View.php b/lib/Minz/View.php
index a0dec1824..b40448491 100644
--- a/lib/Minz/View.php
+++ b/lib/Minz/View.php
@@ -71,9 +71,7 @@ class Minz_View {
*/
public function render () {
if ((include($this->view_filename)) === false) {
- Minz_Log::record ('File not found: `'
- . $this->view_filename . '`',
- Minz_Log::NOTICE);
+ Minz_Log::notice('File not found: `' . $this->view_filename . '`');
}
}
@@ -87,9 +85,7 @@ class Minz_View {
. $part . '.phtml';
if ((include($fic_partial)) === false) {
- Minz_Log::record ('File not found: `'
- . $fic_partial . '`',
- Minz_Log::WARNING);
+ Minz_Log::warning('File not found: `' . $fic_partial . '`');
}
}
@@ -103,9 +99,7 @@ class Minz_View {
. $helper . '.phtml';
if ((include($fic_helper)) === false) {;
- Minz_Log::record ('File not found: `'
- . $fic_helper . '`',
- Minz_Log::WARNING);
+ Minz_Log::warning('File not found: `' . $fic_helper . '`');
}
}