New file |
0,0 → 1,250 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Herbier. | |
// | | |
// | Foobar is free software; you can redistribute it and/or modify | |
// | it under the terms of the GNU General Public License as published by | |
// | the Free Software Foundation; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
// | GNU General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: hb_organisation.class.php,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $ |
/** |
* Classe H_organisation |
* |
* Classe permettant de récupérer les données concernant les organisations de la base de données. |
* |
*@package Herbier |
*@subpackage Classes |
//Auteur original : |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@clapas.org> |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class H_organisation() |
* |
* class H_organisation contient la structure nécessaire pour |
* représenter une table HERBIERS_ORGANISATION dont voici |
* la structure |
* @package herbiers |
*/ |
class H_organisation { |
/** @var integer l'identifiant de l'organisation.*/ |
var $id; |
/** @var string contient le nom de l'organisation.*/ |
var $nom; |
/** @var string contient l'adrese de l'organisation.*/ |
var $adresse; |
/** @var string contient l'adrese 01 de l'organisation.*/ |
var $adresse_02; |
/** @var H_collection un objet de type H_collection{@link H_collection}.*/ |
var $collections; |
/** @var string contiendra l'intitulé du pays.*/ |
var $pays; |
/** @var array contient un tableau d'objet equipe appartenant à l'organisation.*/ |
var $equipe_liste; |
|
/** |
* Constructeur de H_organisation |
* |
* @param aucun |
* @return void |
* @access public |
*/ |
function H_organisation($id_organisation = null) |
{ |
if (!is_null($id_organisation)) { |
$this->setId($id_organisation); |
$this->setNom($this->recupererNomOrganisation($id_organisation)); |
} |
$collections = array(); |
$equipe_liste = array(); |
$organisation_utilisateur = array(); |
} |
/** Accesseur getId() - Retourner l'id de l'organisation. |
* |
* @return integer l'identifiant de l'organisation. |
* @access public |
*/ |
function getId() |
{ |
return $this->id; |
} |
/** Accesseur setId() - Attribuer un id à l'organisation. |
* |
* @param integer l'identifiant de l'organisation. |
* @return void l'identifiant est ajouté à l'objet. |
* @access public |
*/ |
function setId($id) |
{ |
$this->id = $id; |
} |
/** Accesseur setNom() - Attribuer un nom à l'organisation. |
* |
* @param string le nom de l'organisation. |
* @return void le nom est ajouté à l'objet. |
* @access public |
*/ |
function setNom($nom) |
{ |
$this->nom = $nom; |
} |
/** Accesseur getNom() - Retourner le nom de l'organisation. |
* |
* @return string le nom de l'organisation. |
* @access public |
*/ |
function getNom() |
{ |
return $this->nom; |
} |
|
/** |
* Méthode getFromSQL() - Initialise objet H_organisation |
* |
* Initialise un objet H_organisation dont les propriétés |
* contiennent l'information rataché à une organisation |
* caractérisé par son $id (un entier positif) qui correspond |
* à la clé primaire ID_ORG de la table HERBIERS_ORGANISATION |
* |
* @param int la clé primaire de la table HERBIERS_ORGANISATION |
* @return void |
* @access public |
*/ |
function getFromSQL($id) |
{ |
$requete = 'SELECT * '. |
'FROM '.HB_BDD_NOM.'.HERBIERS_ORGANISATION '. |
'WHERE ID_ORG='.$id.' '. |
'ORDER BY TOWN'; |
$resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$ligne = mysql_fetch_object($resultat); |
foreach (get_object_vars($ligne) as $cle => $valeur) { |
$this->$cle = $valeur; |
} |
|
// Récupération des collections |
$requete_02 = 'SELECT ID '. |
'FROM '.HB_BDD_NOM.'.HERBIERS_COLLECTION '. |
'WHERE PARENT_ID = '.$id; |
|
$resultat_02 = mysql_query($requete_02) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_02)); |
while ($ligne_02 = mysql_fetch_object($resultat_02)) { |
$temp_coll = new H_collection() ; |
$this->collections[] = $temp_coll->getFromSQL($ligne_02->ID); |
unset($temp_coll); |
} |
$this->pays = getCountryName($this->COUNTRY_CODE); |
unset($this->COUNTRY_CODE); |
|
// Récupération de l'équipe |
$requete_03 = 'SELECT * '. |
'FROM '.HB_BDD_NOM.'.HERBIERS_ont_un_staff '. |
'WHERE ID_ORG = '.$id; |
$resultat_03 = mysql_query($requete_03) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_03)); |
|
while ($ligne_03 = mysql_fetch_object($resultat_03)) { |
$temp_equipe = new H_equipe(); |
$this->equipe_liste[] = $temp_equipe->getFromSQL($ligne_03->ID_STAFF); |
unset($temp_equipe); |
} |
|
// Recherche de l'auteur de la saisie |
$requete_saisie = 'SELECT U_NAME, U_SURNAME '. |
'FROM '.HB_BDD_NOM_ANNUAIRE.'.annuaire_tela, '.HB_BDD_NOM.'.HERBIERS_ADMINISTRER, '.HB_BDD_NOM.'.HERBIERS_ORGANISATION '. |
'WHERE HERBIERS_ADMINISTRER.HA_ID_ORG = '.$id.' '. |
'AND HERBIERS_ADMINISTRER.HA_ID_ANNUAIRE = annuaire_tela.U_ID'; |
$resultat_saisie = mysql_query($requete_saisie) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_saisie)); |
$ligne_saisie = mysql_fetch_object($resultat_saisie); |
$this->U_NAME = $ligne_saisie->U_NAME; |
$this->U_SURNAME = $ligne_saisie->U_SURNAME; |
|
//$this = H_Herbier::remplacerEsperluette($this); |
foreach (get_object_vars(H_Herbier::remplacerEsperluette($this)) as $key => $value) { |
$this->$key = $value; |
} |
} |
|
/** |
* Méthode recupererNomOrganisation() - Retourne le nom d'une organisation. |
* |
* Permet de récupérer dans la base de données le nom d'une organisation dont on passe l'identifiant |
* en paramêtre. |
* |
* @param integer l'identifiant d'une organisation. |
* @return string le nom de l'institution. |
* @access public |
*/ |
function recupererNomOrganisation($id_organisation) |
{ |
$requete = 'SELECT INSTITUTION_NAME '. |
'FROM HERBIERS_ORGANISATION '. |
'WHERE ID_ORG = "'.$id_organisation.'"'; |
$resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$ligne = mysql_fetch_object($resultat); |
$organisation_nom = $ligne->INSTITUTION_NAME; |
mysql_free_result($resultat); |
return $organisation_nom; |
} |
|
/** |
* Méthode insererMembreEquipe() - Insère un nouveau membre dans l'organisation. |
* |
* Permet d'insérer dans la base de données un lien entre une organisation et un membre d'équipe. |
* |
* @param integer l'identifiant d'un membre d'une équipe. |
* @return void |
* @access public |
*/ |
function insererMembreEquipe($id_equipe) |
{ |
$requete = 'INSERT INTO HERBIERS_ont_un_staff '. |
'SET ID_ORG = '.$this->getId().', ID_STAFF = '.$id_equipe; |
$resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
} |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2005/04/06 13:29:17 jpm |
* Ajout et modifications des objets représentant la base de données Herbier. |
* |
* Revision 1.2 2005/03/09 15:57:33 jpm |
* Modification de la forme. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |