merge some useful parts of SCore

git-svn-id: file:///home/shish/svn/shimmie2/trunk@1002 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish
2008-08-23 12:05:24 +00:00
parent a9c8d7c6ec
commit 1e4d7d1938
8 changed files with 123 additions and 64 deletions

View File

@@ -501,7 +501,6 @@ function send_event($event) {
ksort($my_event_listeners);
foreach($my_event_listeners as $listener) {
$listener->receive_event($event);
if($event->vetoed) break;
}
$_event_count++;
}
@@ -526,31 +525,6 @@ function _get_query_parts() {
$path = substr($path, 1);
}
/*
* Split post/list/fate//stay_night/1
* into post list fate/stay_night 1
*/
/*
$parts = array();
$n = 0;
$lastsplit = 0;
while($n<=strlen($path)) {
if(
$n == strlen($path) ||
(
$path[$n] == '/' &&
($n < strlen($path) && $path[$n+1] != '/')
&& ($n > 0 && $path[$n-1] != '/')
)
) {
$part = substr($path, $lastsplit, $n-$lastsplit);
$part = str_replace('//', '/', $part);
$parts[] = $part;
$lastsplit = $n+1;
}
$n++;
}
*/
$path = str_replace('/', '%%', $path);
$path = str_replace('%%%%', '/', $path);
$parts = split('%%', $path);
@@ -579,20 +553,17 @@ function _get_page_request($context) {
return new PageRequestEvent($context, $page_name, $args);
}
function _get_user() {
global $database;
global $config;
function _get_user($config, $database) {
$user = null;
if(isset($_COOKIE["shm_user"]) && isset($_COOKIE["shm_session"])) {
$tmp_user = $database->get_user_session($_COOKIE["shm_user"], $_COOKIE["shm_session"]);
$tmp_user = User::by_session($config, $database, $_COOKIE["shm_user"], $_COOKIE["shm_session"]);
if(!is_null($tmp_user)) {
$user = $tmp_user;
}
}
if(is_null($user)) {
$user = $database->get_user_by_id($config->get_int("anon_id", 0));
$user = User::by_id($config, $database, $config->get_int("anon_id", 0));
}
assert(!is_null($user));
return $user;