X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnet.php;h=9ad297aa5e8002b99f1433e79913a213c4f6e462;hb=8cf886dcfce33830ea734835a668bfd636548ea6;hp=0d11b05cd7e1d19ab2caf5a179b50f8162bde6bb;hpb=e14069654a64b00afcec4d312c81c827d3c5f411;p=platal.git diff --git a/modules/xnet.php b/modules/xnet.php index 0d11b05..9ad297a 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -1,6 +1,6 @@ $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 attachmime, attach - FROM aliases - INNER JOIN photo ON(id = uid) - WHERE 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); + + // Display the photo, or a default one when not available. + $photo->send(); } function handler_index(&$page)