Fix contact pdf (images and addresses). Close #1060
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 3 Jun 2010 16:49:19 +0000 (18:49 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jun 2010 12:24:11 +0000 (14:24 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/profilefields.inc.php
modules/carnet/contacts.pdf.inc.php

index 6d7a90c..e44a639 100644 (file)
@@ -295,6 +295,9 @@ class Address
 
     public function hasFlag($flag)
     {
+        if (!$this->flags instanceof PlFlagSet) {
+            $this->flags = new PlFlagSet($this->flags);
+        }
         return $this->flags->hasFlag($flag);
     }
 }
index 175cbc7..09ed3b4 100644 (file)
@@ -175,19 +175,19 @@ class ContactsPDF extends FPDF
 
     private function Address($a)
     {
-        if (!$a['text']) {
+        if (!$a->text) {
             return;
         }
         $l = "adresse\n";
-        if ($a['current']) {
+        if ($a->hasFlag('current')) {
             $l .= 'actuelle';
-        } elseif ($a['secondary']) {
+        } elseif ($a->hasFlag('secondary')) {
             $l .= 'secondaire';
         } else {
             $l .= 'principale';
         }
 
-        $r = utf8_decode($a['text']);
+        $r = utf8_decode($a->text);
 /*        $r = trim("$r\n".$a['adr1']);
         $r = trim("$r\n".$a['adr2']);
         $r = trim("$r\n".$a['adr3']);
@@ -283,7 +283,7 @@ class ContactsPDF extends FPDF
         $ok  = false;
 
         if ($wp) {
-            $photo = $profile->getPhoto(false);
+            $photo = $profile->getPhoto(false, true);
             if ($photo) {
                 $old2  = clone $self;
                 $width = $photo->width() * 20 / $photo->height();
@@ -291,8 +291,7 @@ class ContactsPDF extends FPDF
                 $_y = $self->getY();
                 $self->Cell(0, 20, '', '', 0, '', 1);
                 error_reporting(0);
-                $mime = explode('/', $photo->mimeType());
-                $self->Image($photo->path(), $_x, $_y, $width, 20, $mime[1]);
+                $self->Image($photo->path(), $_x, $_y, $width, 20, $photo->mimeType());
                 error_reporting($self->report);
 
                 if ($self->error) {