The photo is part of the profile.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 1 Mar 2010 21:15:01 +0000 (22:15 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 1 Mar 2010 21:15:01 +0000 (22:15 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/profile.php
modules/xnet.php

index 55f4099..fe1126e 100644 (file)
@@ -84,17 +84,17 @@ class ProfileModule extends PLModule
 
     function handler_photo(&$page, $x = null, $req = null)
     {
-        if (!$x || !($user = User::getSilent($x))) {
+        if (!$x || !($profile = Profile::get($x))) {
             return PL_NOT_FOUND;
         }
 
         // Retrieve the photo and its mime type.
         if ($req && S::logged()) {
             include 'validations.inc.php';
-            $myphoto = PhotoReq::get_request($user->id());
+            $myphoto = PhotoReq::get_request($profile->owner()->id());
             $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype);
         } else {
-            $photo = $user->profile()->getPhoto(true);
+            $photo = $profile->getPhoto(true);
         }
 
         // Display the photo, or a default one when not available.
index 2a03c39..7edb674 100644 (file)
@@ -38,24 +38,15 @@ class XnetModule extends PLModule
 
     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)