Adapts orangisation to master and PhD and merges it into the main profile edition.
[platal.git] / modules / xnet.php
index 2a03c39..9ad297a 100644 (file)
@@ -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);
+
+        // Display the photo, or a default one when not available.
+        $photo->send();
     }
 
     function handler_index(&$page)