PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

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