Subversion Repositories Applications.bazar

Rev

Rev 328 | Rev 346 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 328 Rev 330
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: bazar.fonct.php,v 1.73 2007-10-24 13:27:00 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.php,v 1.74 2007-10-25 09:41:31 alexandre_tb Exp $
23
/**
23
/**
24
*
24
*
25
* Fonctions du module bazar
25
* Fonctions du module bazar
26
* 
26
* 
27
*
27
*
Line 29... Line 29...
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
*@author        Florian Schmitt <florian@ecole-et-nature.org>
31
*@author        Florian Schmitt <florian@ecole-et-nature.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.73 $ $Date: 2007-10-24 13:27:00 $
34
*@version       $Revision: 1.74 $ $Date: 2007-10-25 09:41:31 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 529... Line 529...
529
		if ($mode == BAZ_ACTION_MODIFIER) {
529
		if ($mode == BAZ_ACTION_MODIFIER) {
530
			if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
530
			if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
531
				$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER);
531
				$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER);
532
			} else {
532
			} else {
533
				$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER_V);
533
				$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER_V);
-
 
534
				if (isset ($_SESSION['_BAZAR_']['fichier'])) unset($_SESSION['_BAZAR_']['fichier']) ;
-
 
535
				if (isset ($_SESSION['_BAZAR_']['image'])) unset($_SESSION['_BAZAR_']['image']);
-
 
536
				if (isset ($_SESSION['_BAZAR_']['lien'])) unset($_SESSION['_BAZAR_']['lien']);
534
			}		
537
			}		
535
			$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
538
			$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
536
		}
539
		}
537
		if ($mode == BAZ_ACTION_MODIFIER_V) {
540
		if ($mode == BAZ_ACTION_MODIFIER_V) {
538
			$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER_V);
541
			$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER_V);
Line 950... Line 953...
950
* @global   integer L'identifiant de la fiche
953
* @global   integer L'identifiant de la fiche
951
* @return   void
954
* @return   void
952
*/
955
*/
953
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
956
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
954
	//requete d'insertion dans bazar_url
957
	//requete d'insertion dans bazar_url
-
 
958
	if (!isset($_SESSION['_BAZAR_']['lien'])) {
955
	$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
959
		$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
956
	$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
960
		$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
957
		   'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
961
			   'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
958
	
962
		
959
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
963
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
960
        if (DB::isError($resultat)) {
964
	    if (DB::isError($resultat)) {
961
            return $resultat->getMessage().$resultat->getDebugInfo() ;
965
	        return $resultat->getMessage().$resultat->getDebugInfo() ;
962
        }
966
	    }
-
 
967
	    $_SESSION['_BAZAR_']['lien'] = 1;
963
	return;
968
	    return; 
-
 
969
	}
964
}
970
}
Line 965... Line 971...
965
 
971
 
966
 
972
 
Line 973... Line 979...
973
*/
979
*/
974
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
980
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
975
	//verification de la presence de ce fichier 
981
	//verification de la presence de ce fichier 
976
	$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
982
	$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
977
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
983
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
984
    if (DB::isError($resultat)) {
-
 
985
        die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
986
    }
-
 
987
	if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
-
 
988
		if ($resultat->numRows()==0) {
-
 
989
			$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
-
 
990
			move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
-
 
991
			chmod ($chemin_destination, 0755);
-
 
992
		}
-
 
993
		$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
-
 
994
		$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
-
 
995
		           ', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
-
 
996
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
978
        if (DB::isError($resultat)) {
997
        if (DB::isError($resultat)) {
979
            die ($resultat->getMessage().$resultat->getDebugInfo()) ;
998
            return $resultat->getMessage().$resultat->getDebugInfo() ;
980
        }
999
        }
981
	if ($resultat->numRows()==0) {
-
 
982
		$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
-
 
983
		move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
-
 
984
		chmod ($chemin_destination, 0755);
-
 
985
	}
1000
	}
986
	$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
-
 
987
	$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
-
 
988
	           ', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
-
 
989
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1001
    $_SESSION['_BAZAR_']['fichier'] = 1;
990
        if (DB::isError($resultat)) {
-
 
991
            die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
992
        }
-
 
993
	return;
1002
	return;
994
}
1003
}
Line 995... Line 1004...
995
 
1004
 
Line 1009... Line 1018...
1009
	if ($resultat->numRows()==0) {
1018
	if ($resultat->numRows()==0) {
1010
		$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
1019
		$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
1011
		move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
1020
		move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
1012
		chmod ($chemin_destination, 0755);
1021
		chmod ($chemin_destination, 0755);
1013
	}
1022
	}
-
 
1023
	$_SESSION['_BAZAR_']['image'] = 1;
1014
	return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
1024
	return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
1015
}
1025
}
Line 1016... Line 1026...
1016
 
1026
 
Line 1386... Line 1396...
1386
}
1396
}
Line 1387... Line 1397...
1387
 
1397
 
1388
/* +--Fin du code ----------------------------------------------------------------------------------------+
1398
/* +--Fin du code ----------------------------------------------------------------------------------------+
1389
*
1399
*
-
 
1400
* $Log: not supported by cvs2svn $
-
 
1401
* Revision 1.73  2007-10-24 13:27:00  alexandre_tb
-
 
1402
* bug : double saisie d url
-
 
1403
* suppression de warning sur variable
1390
* $Log: not supported by cvs2svn $
1404
*
1391
* Revision 1.72  2007-10-22 10:09:21  florian
1405
* Revision 1.72  2007-10-22 10:09:21  florian
1392
* correction template
1406
* correction template
1393
*
1407
*
1394
* Revision 1.71  2007-10-22 09:18:39  alexandre_tb
1408
* Revision 1.71  2007-10-22 09:18:39  alexandre_tb