X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnet.php;h=136382c969a352784bbba5cb3f730f1487f10f2c;hb=035de9c1782e689f6cb6424ba6dc0525729fed55;hp=2a03c39b6f2a40cdf9252c72aff3fb8c9b948a7a;hpb=5d83c3be8d026adc67efc2ea1ac7fb37de8b2ccd;p=platal.git diff --git a/modules/xnet.php b/modules/xnet.php index 2a03c39..136382c 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -33,29 +33,22 @@ class XnetModule extends PLModule 'plan' => $this->make_hook('plan', AUTH_PUBLIC), 'photo' => $this->make_hook('photo', AUTH_MDP), 'autologin' => $this->make_hook('autologin', AUTH_MDP), + + 'Xnet' => $this->make_wiki_hook(), ); } function handler_photo(&$page, $x = null) { - if (is_null($x)) { + if (!$x || !($profile = Profile::get($x))) { return PL_NOT_FOUND; } - $res = XDB::query("SELECT pp.attachmime, pp.attach - FROM aliases AS a - INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.flags)) - INNER JOIN profile_photos AS pp ON (ap.pid = pp.pid) - WHERE a.alias = {?}", $x); - - if ((list($type, $data) = $res->fetchOneRow())) { - pl_cached_dynamic_content_headers("image/$type"); - echo $data; - } else { - pl_cached_dynamic_content_headers("image/png"); - echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png'); - } - exit; + // Retrieve the photo and its mime type. + $photo = $profile->getPhoto(true, true); + + // Display the photo, or a default one when not available. + $photo->send(); } function handler_index(&$page) @@ -124,7 +117,7 @@ class XnetModule extends PLModule XDB::execute('INSERT INTO groups (id, diminutif) VALUES (NULL, {?})', Post::v('diminutif')); - pl_redirect('../' . Post::v('diminutif') . '/edit'); + pl_redirect(Post::v('diminutif') . '/edit'); } else { $page->trigError('Le diminutif demandé est déjà pris.'); }