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.= " 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.tms as datem,";
$sql.= " d.datefin as datefin,";
@ -1057,63 +1057,66 @@ class Adherent extends CommonObject
{
$obj = $this->db->fetch_object($resql);
$this->ref = $obj->rowid;
$this->id = $obj->rowid;
$this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname; // deprecated
$this->firstname = $obj->firstname;
$this->nom = $obj->lastname; // deprecated
$this->lastname = $obj->lastname;
$this->login = $obj->login;
$this->pass = $obj->pass;
$this->societe = $obj->societe;
$this->fk_soc = $obj->fk_soc;
$this->adresse = $obj->address; // deprecated
$this->address = $obj->address;
$this->cp = $obj->zip; // deprecated
$this->zip = $obj->zip;
$this->ville = $obj->town; // deprecated
$this->town = $obj->town;
$this->entity = $obj->entity;
$this->ref = $obj->rowid;
$this->id = $obj->rowid;
$this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname; // deprecated
$this->firstname = $obj->firstname;
$this->nom = $obj->lastname; // deprecated
$this->lastname = $obj->lastname;
$this->login = $obj->login;
$this->pass = $obj->pass;
$this->societe = $obj->societe;
$this->fk_soc = $obj->fk_soc;
$this->adresse = $obj->address; // deprecated
$this->address = $obj->address;
$this->cp = $obj->zip; // deprecated
$this->zip = $obj->zip;
$this->ville = $obj->town; // deprecated
$this->town = $obj->town;
$this->state_id = $obj->fk_departement;
$this->state_code = $obj->fk_departement?$obj->state_code:'';
$this->state = $obj->fk_departement?$obj->state:'';
$this->fk_departement = $obj->fk_departement; // deprecated
$this->departement_code = $obj->fk_departement?$obj->state_code:''; // deprecated
$this->departement = $obj->fk_departement?$obj->state:''; // deprecated
$this->state_id = $obj->fk_departement;
$this->state_code = $obj->fk_departement?$obj->state_code:'';
$this->state = $obj->fk_departement?$obj->state:'';
$this->fk_departement = $obj->fk_departement; // deprecated
$this->departement_code = $obj->fk_departement?$obj->state_code:''; // deprecated
$this->departement = $obj->fk_departement?$obj->state:''; // deprecated
$this->country_id = $obj->country_id;
$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);
else $this->country=$obj->country;
$this->pays_id = $obj->country_id; // deprecated
$this->pays_code = $obj->country_code; // deprecated
$this->pays = $this->country; // deprecated
$this->country_id = $obj->country_id;
$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);
else
$this->country=$obj->country;
$this->pays_id = $obj->country_id; // deprecated
$this->pays_code = $obj->country_code; // deprecated
$this->pays = $this->country; // deprecated
$this->phone = $obj->phone;
$this->phone_perso = $obj->phone_perso;
$this->phone_mobile = $obj->phone_mobile;
$this->email = $obj->email;
$this->phone = $obj->phone;
$this->phone_perso = $obj->phone_perso;
$this->phone_mobile = $obj->phone_mobile;
$this->email = $obj->email;
$this->photo = $obj->photo;
$this->statut = $obj->statut;
$this->public = $obj->public;
$this->photo = $obj->photo;
$this->statut = $obj->statut;
$this->public = $obj->public;
$this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->datem);
$this->datefin = $this->db->jdate($obj->datefin);
$this->datevalid = $this->db->jdate($obj->datev);
$this->naiss = $this->db->jdate($obj->datenaiss);
$this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->datem);
$this->datefin = $this->db->jdate($obj->datefin);
$this->datevalid = $this->db->jdate($obj->datev);
$this->naiss = $this->db->jdate($obj->datenaiss);
$this->note = $obj->note;
$this->morphy = $obj->morphy;
$this->note = $obj->note;
$this->morphy = $obj->morphy;
$this->typeid = $obj->fk_adherent_type;
$this->type = $obj->type;
$this->typeid = $obj->fk_adherent_type;
$this->type = $obj->type;
$this->need_subscription = ($obj->cotisation=='yes'?1:0);
$this->user_id = $obj->user_id;
$this->user_login = $obj->user_login;
$this->user_id = $obj->user_id;
$this->user_login = $obj->user_login;
// Load other properties
$result=$this->fetch_subscriptions();

View File

@ -3908,26 +3908,29 @@ class Form
{
global $conf;
$entity = (! empty($object->entity) ? $object->entity : $conf->entity);
$id = (! empty($object->id) ? $object->id : $object->rowid);
$ret='';$dir='';$file='';$altfile='';$email='';
if ($modulepart=='societe')
{
$dir=$conf->societe->multidir_output[$object->entity];
$dir=$conf->societe->multidir_output[$entity];
$smallfile=$object->logo;
$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')
{
$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
$email=$object->email;
}
else if ($modulepart=='memberphoto')
{
$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
$email=$object->email;
}
@ -3938,14 +3941,14 @@ class Form
if ($file && file_exists($dir."/".$file))
{
// TODO Link to large image
$ret.='<a href="'.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='.$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='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='</a>';
}
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.='<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.='<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='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
$ret.='</a>';
}
else

View File

@ -72,7 +72,7 @@ llxHeaderVierge($langs->trans("MemberCard"));
$extralabels=$extrafields->fetch_name_optionals_label('member');
if ($id > 0)
{
$res=$object->fetch($id,$ref);
$res=$object->fetch($id);
if ($res < 0) { dol_print_error($db,$object->error); exit; }
$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 '<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("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("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("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("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>';
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>';
if (isset($object->photo) && $object->photo !='')
{
$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){
// 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
*
* @return void
*/
* Show footer for member list
*
* @return void
*/
function llxFooterVierge()
{
printCommonFooter('public');
@ -88,8 +88,8 @@ $offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$filter=$_GET["filter"];
$statut=isset($_GET["statut"])?$_GET["statut"]:'';
$filter=GETPOST('filter');
$statut=GETPOST('statut');
if (! $sortorder) { $sortorder="ASC"; }
if (! $sortfield) { $sortfield="nom"; }
@ -101,8 +101,7 @@ if (! $sortfield) { $sortfield="nom"; }
llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"));
$sql = "SELECT rowid, prenom, nom, societe, cp, ville, email, naiss, photo";
$sql = "SELECT rowid, prenom, nom, societe, cp as zip, ville as town, email, naiss, photo";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent";
$sql.= " WHERE entity = ".$entity;
$sql.= " AND statut = 1";
@ -122,12 +121,14 @@ if ($result)
$param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
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 "<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_liste_field_titre($langs->trans("DateToBirth"),"public_list.php","naiss","",$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),"public_list.php","email","",$param,$sortfield,$sortorder);
print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=prenom">'.$langs->trans("Firstname").'</a>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'&sortorder=ASC&sortfield=nom">'.$langs->trans("Lastname").'</a>';
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("Town"),"public_list.php","ville","",$param,$sortfield,$sortorder);
print "<td>".$langs->trans("Photo")."</td>\n";
@ -139,14 +140,17 @@ if ($result)
$objp = $db->fetch_object($result);
$var=!$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>$objp->naiss</td>\n";
print "<td>$objp->email</td>\n";
print "<td>$objp->cp</td>\n";
print "<td>$objp->ville</td>\n";
if (isset($objp->photo) && $objp->photo!= '')
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"; // est-ce nécessaire ??
print '<td>'.$objp->email.'</td>'."\n";
print '<td>'.$objp->zip.'</td>'."\n";
print '<td>'.$objp->town.'</td>'."\n";
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
{