Overview
Comment: | Corrections pour namespaces |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9c4927d404951091ae8ddbf72226b9c3 |
User & Date: | bohwaz on 2012-12-23 03:13:18 |
Other Links: | manifest | tags |
Context
2012-12-23
| ||
03:15 | Utilisation d'une page du wiki comme page d'accueil à la connexion check-in: 1e79f6cd3b user: bohwaz tags: trunk | |
03:13 | Corrections pour namespaces check-in: 9c4927d404 user: bohwaz tags: trunk | |
02:36 | Mise à jour pour namespaces check-in: 920b18bf61 user: bohwaz tags: trunk | |
Changes
Modified include/class.compta_import.php from [d5f3d8c89a] to [819e0a1300].
︙ | ︙ | |||
63 64 65 66 67 68 69 | return true; } public function fromCitizen($path) { if (!file_exists($path) || !is_readable($path)) { | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | return true; } public function fromCitizen($path) { if (!file_exists($path) || !is_readable($path)) { throw new \RuntimeException('Fichier inconnu : '.$path); } $fp = fopen($path, 'r'); if (!$fp) { return false; |
︙ | ︙ |
Modified include/class.config.php from [55a84f4045] to [4f8bb78056].
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 'categorie_dons' => $int, 'categorie_cotisations' => $int, 'champs_modifiables_membre' => $array, 'accueil_wiki' => $string, 'version' => $string, ); $db = DB::getInstance(); $this->config = $db->simpleStatementFetchAssoc('SELECT cle, valeur FROM config ORDER BY cle;'); foreach ($this->config as $key=>&$value) { if (!array_key_exists($key, $this->fields_types)) { | > | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 'categorie_dons' => $int, 'categorie_cotisations' => $int, 'champs_modifiables_membre' => $array, 'accueil_wiki' => $string, 'accueil_connexion' => $string, 'version' => $string, ); $db = DB::getInstance(); $this->config = $db->simpleStatementFetchAssoc('SELECT cle, valeur FROM config ORDER BY cle;'); foreach ($this->config as $key=>&$value) { if (!array_key_exists($key, $this->fields_types)) { throw new \OutOfBoundsException('Le champ "'.$key.'" est inconnu.'); } if (is_array($this->fields_types[$key])) { $value = explode(',', $value); } else |
︙ | ︙ | |||
114 115 116 117 118 119 120 | return true; } public function get($key) { if (!array_key_exists($key, $this->config)) { | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | return true; } public function get($key) { if (!array_key_exists($key, $this->config)) { throw new \OutOfBoundsException('Ce champ est inconnu.'); } return $this->config[$key]; } public function getVersion() { |
︙ | ︙ | |||
145 146 147 148 149 150 151 | return true; } public function set($key, $value) { if (!array_key_exists($key, $this->fields_types)) { | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | return true; } public function set($key, $value) { if (!array_key_exists($key, $this->fields_types)) { throw new \OutOfBoundsException('Ce champ est inconnu.'); } if (is_array($this->fields_types[$key])) { $value = !empty($value) ? (array) $value : array(); } elseif (is_int($this->fields_types[$key])) |
︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 | if (!trim($value)) { throw new UserException('Le nom de l\'association ne peut rester vide.'); } break; } case 'accueil_wiki': { if (!trim($value)) { | > > | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | if (!trim($value)) { throw new UserException('Le nom de l\'association ne peut rester vide.'); } break; } case 'accueil_wiki': case 'accueil_connexion': { if (!trim($value)) { $key = str_replace('accueil_', '', $key); throw new UserException('Le nom de la page d\'accueil ' . $key . ' ne peut rester vide.'); } break; } case 'email_asso': case 'email_envoi_automatique': { if (!filter_var($value, FILTER_VALIDATE_EMAIL)) |
︙ | ︙ |
Modified include/class.db.php from [92c22689a2] to [f7a224e087].
︙ | ︙ | |||
101 102 103 104 105 106 107 | */ $aMatchInfo = (string) func_get_arg(0); $nPhrase = ord(substr($aMatchInfo, 0, $iSize)); $nCol = ord(substr($aMatchInfo, $iSize, $iSize)); if (func_num_args() > (1 + $nCol)) { | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | */ $aMatchInfo = (string) func_get_arg(0); $nPhrase = ord(substr($aMatchInfo, 0, $iSize)); $nCol = ord(substr($aMatchInfo, $iSize, $iSize)); if (func_num_args() > (1 + $nCol)) { throw new \Exception("Invalid number of arguments : ".$nCol); } // Iterate through each phrase in the users query. // for ($iPhrase = 0; $iPhrase < $nPhrase; $iPhrase++) { $iCol = (int) 0; // Current column // |
︙ | ︙ | |||
161 162 163 164 165 166 167 | elseif (is_null($arg)) return SQLITE3_NULL; elseif (is_string($arg)) return SQLITE3_TEXT; elseif (is_object($arg) && $arg instanceof SQLite3_instruction) return SQLITE3_INSTRUCTION; else | | | | | | | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | elseif (is_null($arg)) return SQLITE3_NULL; elseif (is_string($arg)) return SQLITE3_TEXT; elseif (is_object($arg) && $arg instanceof SQLite3_instruction) return SQLITE3_INSTRUCTION; else throw new \InvalidArgumentException('Argument '.$name.' is of invalid type '.gettype($arg)); } public function simpleStatement($query, $args = array()) { $statement = $this->prepare($query); $nb = $statement->paramCount(); if (count($args) == 1 && is_array($args[0])) { if (count($args[0]) != $nb) { throw new \LengthException('Only '.count($args[0]).' arguments in array, but '.$nb.' are required by query.'); } foreach ($args[0] as $key=>$value) { if (is_int($key)) { throw new \InvalidArgumentException(__FUNCTION__ . ' requires second argument to be a named-associative array, but key '.$key.' is an integer.'); } $statement->bindValue(':'.$key, $value, $this->_getArgType($value, $key)); } } else { if (count($args) != $nb) { throw new \LengthException('Only '.count($args).' arguments, but '.$nb.' are required by query.'); } for ($i = 1; $i <= count($args); $i++) { $arg = $args[$i - 1]; $statement->bindValue($i, $arg, $this->_getArgType($arg, $i)); } } return $statement->execute(); } public function simpleStatementFetch($query, $mode = SQLITE3_BOTH) { if ($mode != SQLITE3_BOTH && $mode != SQLITE3_ASSOC && $mode != SQLITE3_NUM) { throw new \InvalidArgumentException('Mode argument should be either SQLITE3_BOTH, SQLITE3_ASSOC or SQLITE3_NUM.'); } $args = array_slice(func_get_args(), 2); return $this->_fetchResult($this->simpleStatement($query, $args), $mode); } public function simpleStatementFetchAssoc($query) { $args = array_slice(func_get_args(), 1); return $this->_fetchResultAssoc($this->simpleStatement($query, $args)); } public function simpleStatementFetchAssocKey($query, $mode = SQLITE3_BOTH) { if ($mode != SQLITE3_BOTH && $mode != SQLITE3_ASSOC && $mode != SQLITE3_NUM) { throw new \InvalidArgumentException('Mode argument should be either SQLITE3_BOTH, SQLITE3_ASSOC or SQLITE3_NUM.'); } $args = array_slice(func_get_args(), 2); return $this->_fetchResultAssocKey($this->simpleStatement($query, $args), $mode); } public function escapeAuto($value, $name = '') |
︙ | ︙ | |||
263 264 265 266 267 268 269 | if (count($args) == 1 && is_array($args[0])) { preg_match_all('/:[a-z_]+/', $query, $matches); $nb = count(array_unique($matches[0])); if (count($args[0]) < $nb) { | | | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | if (count($args) == 1 && is_array($args[0])) { preg_match_all('/:[a-z_]+/', $query, $matches); $nb = count(array_unique($matches[0])); if (count($args[0]) < $nb) { throw new \LengthException('Only '.count($args[0]).' arguments in array, but '.$nb.' are required by query.'); } foreach ($args[0] as $key=>$value) { if (is_int($key)) { throw new \InvalidArgumentException(__FUNCTION__ . ' requires second argument to be a named-associative array, but key '.$key.' is an integer.'); } $value = preg_replace('#(?<!\\\\)(\\$|\\\\)#', '\\\\$1', $this->escapeAuto($value, $key)); $query = preg_replace('/:'.$key.'(?![a-z])/', $value, $query); } } else { $nb = substr_count($query, '?'); if (count($args) != $nb) { throw new \LengthException('Only '.count($args).' arguments, but '.$nb.' are required by query.'); } for ($i = 1; $i <= count($args); $i++) { $arg = $args[$i - 1]; $arg = $this->escapeAuto($arg, $i); |
︙ | ︙ |
Modified include/class.membres.php from [9a3079c5de] to [2b67cfeb4e].
︙ | ︙ | |||
206 207 208 209 210 211 212 | return $_SESSION['storage'][$key]; } public function sendMessage($dest, $sujet, $message, $copie = false) { if (!$this->isLogged()) { | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | return $_SESSION['storage'][$key]; } public function sendMessage($dest, $sujet, $message, $copie = false) { if (!$this->isLogged()) { throw new \LogicException('Cette fonction ne peut être appelée que par un utilisateur connecté.'); } $from = $this->getLoggedUser(); $from = $from['email']; // Uniquement adresse email pour le moment car faudrait trouver comment // indiquer le nom mais qu'il soit correctement échappé FIXME |
︙ | ︙ |
Modified include/class.wiki.php from [6ab6597ecc] to [35826ce07e].
︙ | ︙ | |||
214 215 216 217 218 219 220 | $db = DB::getInstance(); $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id); // ?! L'ID fournit ne correspond à rien ? if ($revision === false) { | | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | $db = DB::getInstance(); $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id); // ?! L'ID fournit ne correspond à rien ? if ($revision === false) { throw new \RuntimeException('La page demandée n\'existe pas.'); } // Pas de révision if ($revision == 0 && !trim($data['contenu'])) { return true; } // Il faut obligatoirement fournir un ID d'auteur if (empty($data['id_auteur'])) { throw new \BadMethodCallException('Aucun ID auteur de fourni.'); } $contenu = $db->simpleQuerySingle('SELECT contenu FROM wiki_revisions WHERE revision = ? AND id_page = ?;', false, (int)$revision, (int)$id); // Pas de changement au contenu, pas la peine d'enregistrer une nouvelle révision if (trim($contenu) == trim($data['contenu'])) { |
︙ | ︙ | |||
288 289 290 291 292 293 294 | return true; } protected function _getLectureClause($prefix = '') { if (is_null($this->restriction_categorie)) { | | | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | return true; } protected function _getLectureClause($prefix = '') { if (is_null($this->restriction_categorie)) { throw new \UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.'); } if ($this->restriction_droit == Membres::DROIT_AUCUN) { throw new UserException('Vous n\'avez pas accès au wiki.'); } if ($this->restriction_droit == Membres::DROIT_ADMIN) return '1'; return '('.$prefix.'droit_lecture = '.self::LECTURE_NORMAL.' OR '.$prefix.'droit_lecture = '.self::LECTURE_PUBLIC.' OR '.$prefix.'droit_lecture = '.(int)$this->restriction_categorie.')'; } public function canReadPage($lecture) { if (is_null($this->restriction_categorie)) { throw new \UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.'); } if ($this->restriction_droit < Membres::DROIT_ACCES) { return false; } if ($this->restriction_droit == Membres::DROIT_ADMIN || $lecture == self::LECTURE_NORMAL || $lecture == self::LECTURE_PUBLIC || $lecture == $this->restriction_categorie) return true; return false; } public function canWritePage($ecriture) { if (is_null($this->restriction_categorie)) { throw new \UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.'); } if ($this->restriction_droit < Membres::DROIT_ECRITURE) { return false; } |
︙ | ︙ |
Modified include/lib.static_cache.php from [7c8d502706] to [9e4c6fda87].
︙ | ︙ | |||
8 9 10 11 12 13 14 | const CLEAN_EXPIRE = 86400; // 1 day protected static $cache_dir = null; protected static function _getCacheDir() { if (is_null(self::$cache_dir)) { | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | const CLEAN_EXPIRE = 86400; // 1 day protected static $cache_dir = null; protected static function _getCacheDir() { if (is_null(self::$cache_dir)) { throw new \RuntimeException('Cache dir not set.'); } return self::$cache_dir; } protected static function _getCachePath($id) { $id = 'cache_' . sha1($id); return self::_getCacheDir() . '/' . $id; } public static function setCacheDir($dir) { if (substr($dir, -1) == '/') { $dir = substr($dir, 0, -1); } if (!is_readable($dir) || !is_writable($dir)) { throw new \RuntimeException('Cache dir is not readable or writeable.'); } self::$cache_dir = $dir; return true; } static public function store($id, $content) |
︙ | ︙ |
Modified include/template.php from [2a741f1d56] to [ac46cd6b28].
︙ | ︙ | |||
181 182 183 184 185 186 187 | return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">'; }, $str); } function tpl_pagination($params) { if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total'])) | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">'; }, $str); } function tpl_pagination($params) { if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total'])) throw new \BadFunctionCallException("Paramètre manquant pour pagination"); if ($params['total'] == -1) return ''; $pagination = utils::getGenericPagination($params['page'], $params['total'], $params['bypage']); if (empty($pagination)) |
︙ | ︙ |