Subversion Repositories Applications.bazar

Rev

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

Rev 148 Rev 152
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.54 2006-09-14 15:11:23 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.php,v 1.55 2006-09-21 14:19:39 florian 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.54 $ $Date: 2006-09-14 15:11:23 $
34
*@version       $Revision: 1.55 $ $Date: 2006-09-21 14:19:39 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 718... Line 718...
718
		//cas des wikinis
718
		//cas des wikinis
719
		elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST['action']==BAZ_ACTION_NOUVEAU_V ) {
719
		elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST['action']==BAZ_ACTION_NOUVEAU_V ) {
720
			//on appelle les pages des apis et de l'integrateur wikini
720
			//on appelle les pages des apis et de l'integrateur wikini
721
			include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
721
			include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
722
			include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
722
			include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
723
			include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
723
			include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;			
724
			$requete_nom_wiki= 'SELECT '.BAZ_CHAMPS_NOM_WIKI.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$GLOBALS['id_user'];		
-
 
725
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete_nom_wiki) ;			
-
 
726
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
727
        		$nom_wiki=$ligne[BAZ_CHAMPS_NOM_WIKI];        		
-
 
728
        	}
-
 
729
        	
-
 
730
        	$requete_nombre_projet = 'SELECT max('.$tableau[$i]['nom_bdd'].') FROM bazar_fiche WHERE bf_ce_utilisateur='.$GLOBALS['id_user'];
-
 
731
        	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete_nombre_projet) ;
-
 
732
        	if ($resultat->numRows()>0) {
-
 
733
        		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
734
        			echo 'valeur du max: ';var_dump($ligne);
-
 
735
        			//on rajoute un au projet de plus haut identifiant, pour le projet suivant
724
			//génération du titre du wiki, sous la forme id-titre du projet
736
        			$id_wiki_projet=$ligne[0]+1;
725
			$titre=baz_titre_wiki($valeur["bf_titre"]);						
737
        		} 
-
 
738
        	}       	        
-
 
739
        	else $id_wiki_projet=1;
726
			//création du wiki
740
			$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$nom_wiki.$id_wiki_projet, "page"=>"AccueiL", "bdd_hote"=> "",
727
			$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$titre, "page"=>"AccueiL", "bdd_hote"=> "",
741
			        "bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$nom_wiki.$id_wiki_projet, "valider"=> "Valider");
728
			        "bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$titre, "valider"=> "Valider");			
742
			var_dump($valeur);
-
 
743
			$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
729
			$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
744
			$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;			
-
 
745
		}		
730
		}		
746
	}			
731
	}			
747
	$requete.=' bf_date_maj_fiche=NOW()';	
732
	$requete.=' bf_date_maj_fiche=NOW()';	
748
	return $requete;
733
	return $requete;
749
}
734
}
Line 864... Line 849...
864
*
849
*
865
* @global   L'identifiant de la fiche a supprimer
850
* @global   L'identifiant de la fiche a supprimer
866
* @return   void
851
* @return   void
867
*/
852
*/
868
function baz_suppression() {
853
function baz_suppression() {
-
 
854
	$valeurs=baz_valeurs_fiche($_GET['id_fiche']);	
-
 
855
	 
869
	//suppression dans bazar_fiche
856
	//suppression des wikinis associes		
-
 
857
	//génération du titre du wiki, sous la forme id-titre du projet
-
 
858
	$titre=baz_titre_wiki($valeurs["bf_titre"]);	
870
	$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
859
	$requete = 'SELECT gewi_id_wikini FROM gen_wikini WHERE gewi_code_alpha_wikini = "'.$titre.'"';
871
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
860
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
872
	if (DB::isError($resultat)) {
861
	if ($resultat->numRows()>0) {
873
		die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
862
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
863
			$id_wikini=$ligne['gewi_id_wikini'];
874
	}
864
		}
875
	//TODO: verifier si wikini est associee a la fiche 
865
		include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
876
	//suppression des wikinis associes
-
 
877
	/*
-
 
878
	include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/gestion_wikini.class.php' ;
866
		include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
879
	include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
867
		include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
880
	$id_wikini='';
-
 
881
	adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);				
868
		adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);
882
	*/
869
	}					
-
 
870
	
883
	// suppression des valeurs des listes et des cases à cocher
871
	// suppression des valeurs des listes et des cases à cocher
884
	$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
872
	$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
885
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
873
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
886
	if (DB::isError($resultat)) {
874
	if (DB::isError($resultat)) {
887
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
875
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
Line 905... Line 893...
905
	}
893
	}
906
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
894
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
907
		baz_suppression_fichier($ligne['bfj_id_fichier']);
895
		baz_suppression_fichier($ligne['bfj_id_fichier']);
908
	}
896
	}
Line -... Line 897...
-
 
897
		
-
 
898
	//suppression dans bazar_fiche
-
 
899
	$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
-
 
900
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
901
	if (DB::isError($resultat)) {
-
 
902
		die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
909
		
903
	}
910
	return ;
904
	return ;
Line 911... Line 905...
911
}
905
}
Line 1132... Line 1126...
1132
            	$val .= $result[0];
1126
            	$val .= $result[0];
1133
            	$nb++;
1127
            	$nb++;
1134
            }
1128
            }
1135
     		$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
1129
     		$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
1136
     	}
1130
     	}
1137
     	elseif ($tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') {
1131
     	elseif ($tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' || $tableau[$i]['type']=='wikini') {
1138
     		$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
1132
     		$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
1139
     	}	     
1133
     	}	     
1140
	}
1134
	}
1141
	return $valeurs_fiche;
1135
	return $valeurs_fiche;
1142
}
1136
}
Line 1200... Line 1194...
1200
	}
1194
	}
1201
	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
1195
	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
1202
	return $ligne->maxi + 1 ;
1196
	return $ligne->maxi + 1 ;
1203
}
1197
}
Line -... Line 1198...
-
 
1198
 
-
 
1199
/** function baz_titre_wiki () Renvoie la chaine de caractere sous une forme compatible avec wikini
-
 
1200
*
-
 
1201
*   @param  string  mot à transformer (enlever accents, espaces)
-
 
1202
*
-
 
1203
*   return  string  mot transformé
-
 
1204
*/
-
 
1205
function baz_titre_wiki($nom) {
-
 
1206
	$titre=trim($nom);
-
 
1207
	for ($j = 0; $j < strlen ($titre); $j++) {
-
 
1208
		if (!preg_match ('/[a-zA-Z0-9]/', $titre[$j])) {
-
 
1209
			$titre[$j] = '_' ;
-
 
1210
		}
-
 
1211
	}
-
 
1212
	return $titre;
-
 
1213
}
1204
 
1214
 
1205
/* +--Fin du code ----------------------------------------------------------------------------------------+
1215
/* +--Fin du code ----------------------------------------------------------------------------------------+
1206
*
1216
*
-
 
1217
* $Log: not supported by cvs2svn $
-
 
1218
* Revision 1.54  2006/09/14 15:11:23  alexandre_tb
-
 
1219
* suppression temporaire de la gestion des wikinis
1207
* $Log: not supported by cvs2svn $
1220
*
1208
* Revision 1.53  2006/07/25 13:24:44  florian
1221
* Revision 1.53  2006/07/25 13:24:44  florian
1209
* correction bug image
1222
* correction bug image
1210
*
1223
*
1211
* Revision 1.52  2006/07/25 13:05:00  alexandre_tb
1224
* Revision 1.52  2006/07/25 13:05:00  alexandre_tb