Update core.
[platal.git] / modules / profile.php
index e1c70c0..da3b414 100644 (file)
@@ -178,9 +178,9 @@ class ProfileModule extends PLModule
         } elseif (Env::v('suppr')) {
             S::assert_xsrf_token();
 
-            XDB::execute('DELETE FROM  photo
-                                WHERE  uid = {?}',
-                         S::v('uid'));
+            XDB::execute('DELETE FROM  profile_photos
+                                WHERE  pid = {?}',
+                         S::user()->profile()->id());
             XDB::execute('DELETE FROM  requests
                                 WHERE  user_id = {?} AND type="photo"',
                          S::v('uid'));
@@ -228,7 +228,6 @@ class ProfileModule extends PLModule
         // Now that we know this is the profile of an existing user, we can
         // switch to the appropriate template.
         $page->changeTpl('profile/profile.tpl', SIMPLE);
-        require_once 'user.func.inc.php';
 
         // Determines the access level at which the profile will be displayed.
         if (!S::logged() || Env::v('view') == 'public') {
@@ -586,7 +585,6 @@ class ProfileModule extends PLModule
 
     function handler_referent(&$page, $user)
     {
-        require_once 'user.func.inc.php';
         $page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
 
         $user = Profile::get($user);
@@ -643,7 +641,7 @@ class ProfileModule extends PLModule
         require_once "directory.enums.inc.php";
 
         // Retrieval of sector names
-        $sectors = DirEnum::getOptionsArray(DirEnum::SECTORS);
+        $sectors = DirEnum::getOptions(DirEnum::SECTORS);
         $sectors[''] = '';
         $page->assign_by_ref('sectors', $sectors);
 
@@ -747,7 +745,7 @@ class ProfileModule extends PLModule
         }
 
         $vcard = new VCard();
-        $vcard->addUser($x);
+        $vcard->addProfile(Profile::get($x));
         $vcard->show();
     }
 
@@ -763,8 +761,7 @@ class ProfileModule extends PLModule
 
         switch ($action) {
             case "original":
-                pl_cached_content_headers("image/jpeg");
-               readfile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg");
+                PlImage::fromFile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg", "image/jpeg")->send();
                 exit;
 
             case "new":
@@ -775,14 +772,14 @@ class ProfileModule extends PLModule
                $mimetype = substr($_FILES['userfile']['type'], 6);
                unlink($_FILES['userfile']['tmp_name']);
                 XDB::execute(
-                        "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
-                        $user->id(), $mimetype, $data, $x, $y);
+                        "REPLACE INTO profile_photos SET pid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
+                        $user->profile()->id(), $mimetype, $data, $x, $y);
                break;
 
             case "delete":
                 S::assert_xsrf_token();
 
-                XDB::execute('DELETE FROM photo WHERE uid = {?}', $user->id());
+                XDB::execute('DELETE FROM profile_photos WHERE pid = {?}', $user->profile()->id());
                 break;
         }
     }