Merge commit 'origin/master' into account
[platal.git] / modules / profile.php
index 58bce5f..e1c70c0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -89,36 +89,16 @@ class ProfileModule extends PLModule
         }
 
         // Retrieve the photo and its mime type.
-        $photo_data = null;
-        $photo_type = null;
-
         if ($req && S::logged()) {
             include 'validations.inc.php';
             $myphoto = PhotoReq::get_request($user->id());
-            if ($myphoto) {
-                $photo_data = $myphoto->data;
-                $photo_type = $myphoto->mimetype;
-            }
+            $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype);
         } else {
-            $res = XDB::query(
-                    "SELECT  attachmime, attach, pub
-                       FROM  photo
-                      WHERE  uid = {?}", $user->id());
-            list($photo_type, $photo_data, $photo_pub) = $res->fetchOneRow();
-            if ($photo_pub != 'public' && !S::logged()) {
-                $photo_type = $photo_data = null;
-            }
+            $photo = $user->profile()->getPhoto(true);
         }
 
         // Display the photo, or a default one when not available.
-        if ($photo_type && $photo_data != null) {
-            pl_cached_dynamic_content_headers("image/$photo_type");
-            echo $photo_data;
-        } else {
-            pl_cached_dynamic_content_headers("image/png");
-            echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
-        }
-        exit;
+        $photo->send();
     }
 
     function handler_medal(&$page, $mid)
@@ -205,6 +185,7 @@ class ProfileModule extends PLModule
                                 WHERE  user_id = {?} AND type="photo"',
                          S::v('uid'));
             $globals->updateNbValid();
+            $page->trigSuccess("Ta photo a bien été supprimée. Elle ne sera plus visible sur le site dans au plus une heure.");
         } elseif (Env::v('cancel')) {
             S::assert_xsrf_token();
 
@@ -360,8 +341,8 @@ class ProfileModule extends PLModule
 
         // Build the page
         $page->addJsLink('ajax.js');
-        $page->addJsLink('education.js');
-        $page->addJsLink('grades.js');
+        $page->addJsLink('education.js'); /* dynamic content */
+        $page->addJsLink('grades.js');    /* dynamic content */
         $page->addJsLink('profile.js');
         $page->addJsLink('jquery.autocomplete.js');
         $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true, false);
@@ -677,7 +658,7 @@ class ProfileModule extends PLModule
             require_once 'userset.inc.php';
             $ufc = $ufb->getUFC();
             $set = new ProfileSet($ufc);
-            $set->addMod('referent', 'Référents');
+            $set->addMod('mentor', 'Référents');
             $set->apply('referent/search', $page, $action, $subaction);
             if ($set->count() > 100) {
                 $page->assign('recherche_trop_large', true);
@@ -724,9 +705,9 @@ class ProfileModule extends PLModule
         $req = XDB::query('
             SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
                    COUNT(e.eid) AS events, mail_domain AS lists
-              FROM #groupex#.membres AS m
-        INNER JOIN #groupex#.asso AS a ON(m.asso_id = a.id)
-         LEFT JOIN #groupex#.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
+              FROM group_members AS m
+        INNER JOIN groups AS a ON(m.asso_id = a.id)
+         LEFT JOIN group_events AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
              WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S::i('uid'));
         $page->assign('assos', $req->fetchAllAssoc());
     }
@@ -738,7 +719,7 @@ class ProfileModule extends PLModule
         }
 
         $res = XDB::query('SELECT  logo, logo_mime
-                             FROM  #groupex#.asso
+                             FROM  groups
                             WHERE  id = {?}', $id);
         list($logo, $logo_mime) = $res->fetchOneRow();