PageRenderTime 188ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/_plugins_/tickets/branches/v1.1/tickets_fonctions.php

https://bitbucket.org/pombredanne/spip-zone-treemap
PHP | 270 lines | 195 code | 26 blank | 49 comment | 25 complexity | 76bd3ed1886c4292fd8cbe2f920c7aff MD5 | raw file
  1. <?php
  2. if (!defined("_ECRIRE_INC_VERSION")) return;
  3. /**
  4. * <BOUCLE(TICKETS)>
  5. */
  6. function boucle_TICKETS_dist($id_boucle, &$boucles) {
  7. $boucle = &$boucles[$id_boucle];
  8. $id_table = $boucle->id_table;
  9. $mstatut = $id_table .'.statut';
  10. // Restreindre aux elements considérés comme publiés soit pas en :
  11. // -* poubelle (poubelle)
  12. // -* en cours de rédac (redac)
  13. if (!isset($boucle->modificateur['criteres']['statut']) OR !isset($boucle->modificateur['criteres']['tout'])) {
  14. array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'ouvert\\',\\'resolu\\',\\'ferme\\',\\'redac\\')'"));
  15. }
  16. if(function_exists('lire_config')){
  17. $desactiver_public = lire_config('tickets/general/desactiver_public','off');
  18. if(($desactiver_public == 'on') && !test_espace_prive()){
  19. array_unshift($boucle->where,array("'='", "'$mstatut'", "'(\\'none\\')'"));
  20. }
  21. }
  22. return calculer_boucle($id_boucle, $boucles);
  23. }
  24. /**
  25. * Crée la liste des options du select des champs :
  26. * -* jalon
  27. * -* version
  28. * -* projet
  29. * -* composant
  30. *
  31. * @param string $nom
  32. */
  33. function tickets_champ_optionnel_actif($nom){
  34. $constante = '_TICKETS_LISTE_' . strtoupper($nom);
  35. if (!defined($constante) && !lire_config('tickets/general/'.$nom)) {
  36. return false;
  37. }
  38. if(defined($constante))
  39. $liste = constant($constante);
  40. else
  41. $liste = lire_config('tickets/general/'.$nom,'');
  42. if ($liste == '') return false;
  43. return array_map('trim',explode(':', $liste));
  44. }
  45. // Creation de la liste des options du select d'assignation
  46. /**
  47. *
  48. * Crée la liste des options du champ select d'assignation de ticket
  49. * Prend deux arguments optionnels :
  50. * -* $en_cours qui est l'id_auteur que l'on souhaite préselectionner
  51. * -* $format qui permet de choisir le format que la fonction renvoit :
  52. * -** rien ou autre chose que 'array' renverra les options d'un select
  53. * -** 'array' renverra un array des auteurs possibles
  54. *
  55. * @param int $en_cours
  56. * @param string $format
  57. * @return multitype:array|string
  58. */
  59. function tickets_select_assignation($en_cours='0',$format='select'){
  60. $options = NULL;
  61. $liste_assignables=array();
  62. include_spip('inc/tickets_autoriser');
  63. $select = array('nom','id_auteur');
  64. $from = array('spip_auteurs AS t1');
  65. $autorises = definir_autorisations_tickets('assigner');
  66. if ($autorises['statut'])
  67. $where = array(sql_in('t1.statut', $autorises['statut']), 't1.email LIKE '.sql_quote('%@%'));
  68. else
  69. $where = array(sql_in('t1.id_auteur', $autorises['auteur']), 't1.email LIKE '.sql_quote('%@%'));
  70. $query_auteurs = sql_select($select, $from, $where);
  71. while ($row_auteur = sql_fetch($query_auteurs)) {
  72. $liste_assignables[$row_auteur["id_auteur"]] = $row_auteur["nom"];
  73. $selected = ($row_auteur["id_auteur"] == $en_cours) ? ' selected="selected"' : '';
  74. $options .= '<option value="' . $row_auteur["id_auteur"] . '"' . $selected . '>' . $row_auteur["nom"] . '</option>';
  75. }
  76. if($format=='array'){
  77. return $liste_assignables;
  78. }
  79. return $options;
  80. }
  81. // Affichage de la page des tickets classes par jalon
  82. function tickets_classer_par_jalon($bidon) {
  83. $page = NULL;
  84. if (defined('_TICKETS_LISTE_JALONS') OR lire_config()) {
  85. $liste = explode(":", _TICKETS_LISTE_JALONS);
  86. $i = 0;
  87. foreach($liste as $_jalon) {
  88. $i += 1;
  89. $page .= recuperer_fond('prive/contenu/inc_liste_detaillee',
  90. array_merge($_GET, array('titre' => _T('tickets:champ_jalon').' '.$_jalon, 'statut' => 'ouvert', 'jalon' => $_jalon, 'bloc' => "_bloc$i")),
  91. array('ajax'=>true));
  92. }
  93. }
  94. return $page;
  95. }
  96. // Affichage des blocs de liste depliables et ajaxes
  97. function tickets_debut_block_depliable($deplie,$id=""){
  98. include_spip('inc/layer');
  99. return debut_block_depliable($deplie,$id);
  100. }
  101. function tickets_fin_block() {
  102. include_spip('inc/layer');
  103. return fin_block();
  104. }
  105. function tickets_bouton_block_depliable($texte,$deplie,$page="",$ids=""){
  106. include_spip('inc/layer');
  107. if ($page)
  108. return bouton_block_depliable(afficher_plus(generer_url_ecrire($page)).$texte,$deplie,$ids);
  109. else
  110. return bouton_block_depliable($texte,$deplie,$ids);
  111. }
  112. // creation des fonction de selection de texte
  113. // encore en truc a reprendre !
  114. foreach (array('severite', 'tracker', 'statut', 'navigateur') as $nom){
  115. eval("function tickets_texte_$nom(\$valeur) {
  116. \$type = tickets_liste_$nom();
  117. if (isset(\$type[\$valeur])) {
  118. return \$type[\$valeur];
  119. }
  120. }");
  121. }
  122. function tickets_icone_statut ($niveau,$full=false) {
  123. $img = array(
  124. "redac" => "puce-blanche.gif",
  125. "ouvert" => "puce-orange.gif",
  126. "resolu" => "puce-verte.gif",
  127. "ferme" => "puce-poubelle.gif",
  128. "poubelle" => "puce-poubelle.gif"
  129. );
  130. if($full)
  131. return '<img src="'.find_in_path('prive/images/'.$img[$niveau]).'" alt="'.tickets_texte_statut($niveau).'" />';
  132. else
  133. return $img[$niveau];
  134. }
  135. function tickets_icone_severite ($niveau,$full=false) {
  136. $img = array(
  137. 1 => "puce-rouge-breve.gif",
  138. 2 => "puce-orange-breve.gif",
  139. 3 => "puce-verte-breve.gif",
  140. 4 => "puce-poubelle-breve.gif"
  141. );
  142. if($full)
  143. return '<img src="'.find_in_path('prive/images/'.$img[$niveau]).'" alt="'.tickets_texte_severite($niveau).'" />';
  144. else
  145. return $img[$niveau];
  146. }
  147. function tickets_liste_statut($connecte = true){
  148. $statuts = array(
  149. "redac" => _T("tickets:statut_redac"),
  150. "ouvert" => _T("tickets:statut_ouvert"),
  151. "resolu" => _T("tickets:statut_resolu"),
  152. "ferme" => _T("tickets:statut_ferme"),
  153. "poubelle" => _T("tickets:statut_poubelle")
  154. );
  155. if (!$connecte) {
  156. unset($statuts['redac']);
  157. }
  158. return $statuts;
  159. }
  160. function tickets_liste_tracker($id_ticket = null){
  161. $trackers = array(
  162. 1 => _T("tickets:type_probleme"),
  163. 2 => _T("tickets:type_amelioration"),
  164. 3 => _T("tickets:type_tache"),
  165. );
  166. return $trackers;
  167. }
  168. function tickets_liste_severite($id_ticket = null){
  169. $severites = array(
  170. 1 => _T("tickets:severite_bloquant"),
  171. 2 => _T("tickets:severite_important"),
  172. 3 => _T("tickets:severite_normal"),
  173. 4 => _T("tickets:severite_peu_important"),
  174. );
  175. return $severites;
  176. }
  177. if(!function_exists('barre_typo')){
  178. function barre_typo(){
  179. return;
  180. }
  181. }
  182. /**
  183. *
  184. * Fonction de génération d'url privée de tickets
  185. *
  186. * @param int $id
  187. * @param string $args
  188. * @param string $ancre
  189. * @param string $statut
  190. * @param string $connect
  191. */
  192. function generer_url_ecrire_ticket($id, $args='', $ancre='', $statut='', $connect='') {
  193. $a = "id_ticket=" . intval($id);
  194. if (!$statut) {
  195. $statut = sql_getfetsel('statut', 'spip_tickets', $a,'','','','',$connect);
  196. }
  197. $h = generer_url_ecrire('ticket_afficher', $a . ($args ? "&$args" : ''))
  198. . ($ancre ? "#$ancre" : '');
  199. return $h;
  200. }
  201. /**
  202. * Liste des navigateurs possibles
  203. */
  204. function tickets_liste_navigateur($nav=false){
  205. $navs = array(
  206. 'tous' => _T('tickets:option_navigateur_tous'),
  207. 'android4' => 'Android 4.x',
  208. 'firefox3' => 'Firefox 3.x',
  209. 'firefox4' => 'Firefox 4.x',
  210. 'firefox5' => 'Firefox 5.x',
  211. 'firefox6' => 'Firefox 6.x',
  212. 'chrome9' => 'Google Chrome 9.x',
  213. 'chrome11' => 'Google Chrome 11.x',
  214. 'chrome12' => 'Google Chrome 12.x',
  215. 'chrome13' => 'Google Chrome 13.x',
  216. 'chrome14' => 'Google Chrome 14.x',
  217. 'ie6' => 'Internet Explorer 6',
  218. 'ie7' => 'Internet Explorer 7',
  219. 'ie8' => 'Internet Explorer 8',
  220. 'ie9' => 'Internet Explorer 9',
  221. 'opera11' => 'Opera 11.x',
  222. 'opera12' => 'Opera 12.x',
  223. 'safari4' => 'Safari 4.x',
  224. 'safari5' => 'Safari 5.x',
  225. 'autre' => _T('tickets:option_navigateur_autre')
  226. );
  227. return $navs;
  228. }
  229. // Balise #NOM_AUTEUR
  230. // Permet de retrouver le nom d'un auteur
  231. // d'après le id_assigne et le id_auteur de tickets
  232. function balise_NOM_AUTEUR($p) {
  233. $id_auteur = interprete_argument_balise (1, $p);
  234. $p->code = "trouve_nom(".$id_auteur.")";
  235. $p->statut = 'php';
  236. return $p;
  237. }
  238. function trouve_nom($id_auteur) {
  239. $nom = sql_getfetsel("nom","spip_auteurs", "id_auteur=" . intval($id_auteur));
  240. if (!empty($nom))
  241. return $nom;
  242. return '';
  243. }
  244. ?>