Fix: bad path for photo and uniformize code

This commit is contained in:
Regis Houssin 2012-12-13 11:42:59 +01:00
parent 57742b347a
commit 5f41174cfa
4 changed files with 93 additions and 88 deletions

View File

@ -1025,7 +1025,7 @@ class Adherent extends CommonObject
$sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,"; $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,";
$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql.= " d.datec as datec,"; $sql.= " d.datec as datec,";
$sql.= " d.tms as datem,"; $sql.= " d.tms as datem,";
$sql.= " d.datefin as datefin,"; $sql.= " d.datefin as datefin,";
@ -1057,6 +1057,7 @@ class Adherent extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->entity = $obj->entity;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->civilite_id = $obj->civilite; $this->civilite_id = $obj->civilite;
@ -1084,8 +1085,10 @@ class Adherent extends CommonObject
$this->country_id = $obj->country_id; $this->country_id = $obj->country_id;
$this->country_code = $obj->country_code; $this->country_code = $obj->country_code;
if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code); if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)
else $this->country=$obj->country; $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code);
else
$this->country=$obj->country;
$this->pays_id = $obj->country_id; // deprecated $this->pays_id = $obj->country_id; // deprecated
$this->pays_code = $obj->country_code; // deprecated $this->pays_code = $obj->country_code; // deprecated
$this->pays = $this->country; // deprecated $this->pays = $this->country; // deprecated

View File

@ -3908,26 +3908,29 @@ class Form
{ {
global $conf; global $conf;
$entity = (! empty($object->entity) ? $object->entity : $conf->entity);
$id = (! empty($object->id) ? $object->id : $object->rowid);
$ret='';$dir='';$file='';$altfile='';$email=''; $ret='';$dir='';$file='';$altfile='';$email='';
if ($modulepart=='societe') if ($modulepart=='societe')
{ {
$dir=$conf->societe->multidir_output[$object->entity]; $dir=$conf->societe->multidir_output[$entity];
$smallfile=$object->logo; $smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile); $smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
if ($object->logo) $file=$object->id.'/logos/thumbs/'.$smallfile; if ($object->logo) $file=$id.'/logos/thumbs/'.$smallfile;
} }
else if ($modulepart=='userphoto') else if ($modulepart=='userphoto')
{ {
$dir=$conf->user->dir_output; $dir=$conf->user->dir_output;
if ($object->photo) $file=get_exdir($object->id,2).$object->photo; if ($object->photo) $file=get_exdir($id, 2).$object->photo;
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email; $email=$object->email;
} }
else if ($modulepart=='memberphoto') else if ($modulepart=='memberphoto')
{ {
$dir=$conf->adherent->dir_output; $dir=$conf->adherent->dir_output;
if ($object->photo) $file=get_exdir($object->id,2).'photos/'.$object->photo; if ($object->photo) $file=get_exdir($id, 2).'photos/'.$object->photo;
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email; $email=$object->email;
} }
@ -3938,14 +3941,14 @@ class Form
if ($file && file_exists($dir."/".$file)) if ($file && file_exists($dir."/".$file))
{ {
// TODO Link to large image // TODO Link to large image
$ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">'; $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">'; $ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='</a>'; $ret.='</a>';
} }
else if ($altfile && file_exists($dir."/".$altfile)) else if ($altfile && file_exists($dir."/".$altfile))
{ {
$ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">'; $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($altfile).'&cache='.$cache.'">'; $ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
$ret.='</a>'; $ret.='</a>';
} }
else else

View File

@ -72,7 +72,7 @@ llxHeaderVierge($langs->trans("MemberCard"));
$extralabels=$extrafields->fetch_name_optionals_label('member'); $extralabels=$extrafields->fetch_name_optionals_label('member');
if ($id > 0) if ($id > 0)
{ {
$res=$object->fetch($id,$ref); $res=$object->fetch($id);
if ($res < 0) { dol_print_error($db,$object->error); exit; } if ($res < 0) { dol_print_error($db,$object->error); exit; }
$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
@ -87,27 +87,22 @@ if ($id > 0)
print '<table class="border" cellspacing="0" width="100%" cellpadding="3">'; print '<table class="border" cellspacing="0" width="100%" cellpadding="3">';
print '<tr><td width="15%">'.$langs->trans("Type").'</td><td class="valeur">'.$object->type."</td></tr>\n"; print '<tr><td width="15%">'.$langs->trans("Type").'</td><td class="valeur">'.$object->type."</td></tr>\n";
print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$object->morphy.'</td></tr>'; print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$object->morphy.'</td></tr>';
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" width="35%">'.$object->firstname.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" width="35%">'.$object->firstname.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->lastname.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->lastname.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">'.nl2br($object->address).'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">'.nl2br($object->address).'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Zip").' '.$langs->trans("Town").'</td><td class="valeur">'.$object->zip.' '.$object->town.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Zip").' '.$langs->trans("Town").'</td><td class="valeur">'.$object->zip.' '.$object->town.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$object->pays.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$object->pays.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.$object->email.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.$object->email.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.$object->naiss.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.$object->naiss.'&nbsp;</td></tr>';
if (isset($object->photo) && $object->photo !=''){ if (isset($object->photo) && $object->photo !='')
print '<tr><td>URL Photo</td><td class="valeur">'."<A HREF=\"$object->photo\"><IMG SRC=\"$object->photo\"></A>".'&nbsp;</td></tr>'; {
$form = new Form($db);
print '<tr><td>URL Photo</td><td class="valeur">';
print $form->showphoto('memberphoto', $object, 64);
print '</td></tr>'."\n";
} }
// foreach($objecto->attribute_label as $key=>$value){ // foreach($objecto->attribute_label as $key=>$value){
// print "<tr><td>$value</td><td>".$object->array_options["options_$key"]."&nbsp;</td></tr>\n"; // print "<tr><td>$value</td><td>".$object->array_options["options_$key"]."&nbsp;</td></tr>\n";

View File

@ -67,10 +67,10 @@ function llxHeaderVierge($title, $head = "")
} }
/** /**
* Show footer for member list * Show footer for member list
* *
* @return void * @return void
*/ */
function llxFooterVierge() function llxFooterVierge()
{ {
printCommonFooter('public'); printCommonFooter('public');
@ -88,8 +88,8 @@ $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$filter=$_GET["filter"]; $filter=GETPOST('filter');
$statut=isset($_GET["statut"])?$_GET["statut"]:''; $statut=GETPOST('statut');
if (! $sortorder) { $sortorder="ASC"; } if (! $sortorder) { $sortorder="ASC"; }
if (! $sortfield) { $sortfield="nom"; } if (! $sortfield) { $sortfield="nom"; }
@ -101,8 +101,7 @@ if (! $sortfield) { $sortfield="nom"; }
llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers")); llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"));
$sql = "SELECT rowid, prenom, nom, societe, cp as zip, ville as town, email, naiss, photo";
$sql = "SELECT rowid, prenom, nom, societe, cp, ville, email, naiss, photo";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent";
$sql.= " WHERE entity = ".$entity; $sql.= " WHERE entity = ".$entity;
$sql.= " AND statut = 1"; $sql.= " AND statut = 1";
@ -122,12 +121,14 @@ if ($result)
$param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"; $param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, ''); print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, '');
print "<table class=\"noborder\" width=\"100%\">"; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td><a href=\"".$_SERVER["PHP_SELF"]."?page=$page&sortorder=ASC&sortfield=prenom\">".$langs->trans("Firstname")."</a> <a href=\"".$_SERVER['PHP_SELF']."?page=$page&sortorder=ASC&sortfield=nom\">".$langs->trans("Lastname")."</a> / <a href=\"".$_SERVER["PHP_SELF"]."?page=$page&sortorder=ASC&sortfield=societe\">".$langs->trans("Company")."</a></td>\n"; print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=prenom">'.$langs->trans("Firstname").'</a>';
print_liste_field_titre($langs->trans("DateToBirth"),"public_list.php","naiss","",$param,$sortfield,$sortorder); print ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'&sortorder=ASC&sortfield=nom">'.$langs->trans("Lastname").'</a>';
print_liste_field_titre($langs->trans("EMail"),"public_list.php","email","",$param,$sortfield,$sortorder); print ' / <a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></td>'."\n";
//print_liste_field_titre($langs->trans("DateToBirth"),"public_list.php","naiss",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
print_liste_field_titre($langs->trans("EMail"),"public_list.php","email",'',$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Zip"),"public_list.php","cp","",$param,$sortfield,$sortorder); print_liste_field_titre($langs->trans("Zip"),"public_list.php","cp","",$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),"public_list.php","ville","",$param,$sortfield,$sortorder); print_liste_field_titre($langs->trans("Town"),"public_list.php","ville","",$param,$sortfield,$sortorder);
print "<td>".$langs->trans("Photo")."</td>\n"; print "<td>".$langs->trans("Photo")."</td>\n";
@ -139,14 +140,17 @@ if ($result)
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td><a href=\"public_card.php?id=$objp->rowid\">".$objp->prenom." ".$objp->nom.($objp->societe?" / ".$objp->societe:"")."</a></TD>\n"; print '<td><a href="public_card.php?id='.$objp->rowid.'">'.$objp->prenom.' '.$objp->nom.($objp->societe?' / '.$objp->societe:'').'</a></td>'."\n";
print "<td>$objp->naiss</td>\n"; //print "<td>$objp->naiss</td>\n"; // est-ce nécessaire ??
print "<td>$objp->email</td>\n"; print '<td>'.$objp->email.'</td>'."\n";
print "<td>$objp->cp</td>\n"; print '<td>'.$objp->zip.'</td>'."\n";
print "<td>$objp->ville</td>\n"; print '<td>'.$objp->town.'</td>'."\n";
if (isset($objp->photo) && $objp->photo!= '') if (isset($objp->photo) && $objp->photo != '')
{ {
print "<td><a href=\"$objp->photo\"><img src=\"$objp->photo\" height=\"64\" width=\"64\"></a></td>\n"; $form = new Form($db);
print '<td>';
print $form->showphoto('memberphoto', $objp, 64);
print '</td>'."\n";
} }
else else
{ {