fgcf.install 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * Installer/uninstaller for FGCF module.
  6. */
  7. /**
  8. * Implementation of hook_install().
  9. */
  10. function fgcf_install() {
  11. $vocabulary = array(
  12. 'name' => 'FGCF Thème',
  13. 'description' => '',
  14. 'multiple' => 0,
  15. 'required' => 1,
  16. 'hierarchy' => 0,
  17. 'relations' => 1,
  18. 'module' => 'fgcf',
  19. 'weight' => 0,
  20. 'nodes' => array('fgcf_fiche' => 1),
  21. );
  22. taxonomy_save_vocabulary($vocabulary);
  23. $vocabulary = array(
  24. 'name' => 'FGCF Supports de cours',
  25. 'description' => 'Toute caractéristique de la formation, comme la présence de travaux pratiques, une évaluation, etc.',
  26. 'multiple' => 0,
  27. 'required' => 0,
  28. 'hierarchy' => 0,
  29. 'relations' => 1,
  30. 'module' => 'fgcf',
  31. 'weight' => 0,
  32. 'nodes' => array(),
  33. );
  34. taxonomy_save_vocabulary($vocabulary);
  35. $vocabulary = array(
  36. 'name' => 'FGCF Documents remis',
  37. 'description' => '',
  38. 'multiple' => 0,
  39. 'required' => 0,
  40. 'hierarchy' => 0,
  41. 'relations' => 1,
  42. 'module' => 'fgcf',
  43. 'weight' => 0,
  44. 'nodes' => array(),
  45. );
  46. taxonomy_save_vocabulary($vocabulary);
  47. $vocabulary = array(
  48. 'name' => 'FGCF Sanction',
  49. 'description' => '',
  50. 'multiple' => 1,
  51. 'required' => 0,
  52. 'hierarchy' => 0,
  53. 'relations' => 1,
  54. 'module' => 'fgcf',
  55. 'weight' => 0,
  56. 'nodes' => array(),
  57. );
  58. taxonomy_save_vocabulary($vocabulary);
  59. $vocabulary = array(
  60. 'name' => 'FGCF Public concerné',
  61. 'description' => '',
  62. 'multiple' => 0,
  63. 'required' => 0,
  64. 'hierarchy' => 0,
  65. 'relations' => 1,
  66. 'module' => 'fgcf',
  67. 'weight' => 0,
  68. 'nodes' => array(),
  69. );
  70. taxonomy_save_vocabulary($vocabulary);
  71. }
  72. /**
  73. * Rename "FGCF Thématique" vocabulary to "FGCF Thème", as per issue #642
  74. *
  75. * @return array
  76. */
  77. function fgcf_update_6101() {
  78. $sq = "UPDATE {vocabulary} SET name = 'FGCF Thème' WHERE name = 'FGCF Thématique'";
  79. $ret = array(update_sql($sq));
  80. return $ret;
  81. }
  82. /**
  83. * Rename "FGCF Public visé" vocabulary to "FGCF Public concerné", as per issue #642
  84. *
  85. * @return array
  86. */
  87. function fgcf_update_6102() {
  88. $sq = "UPDATE {vocabulary} SET name = 'FGCF Public concerné' WHERE name = 'FGCF Public visé'";
  89. $ret = array(update_sql($sq));
  90. return $ret;
  91. }
  92. /**
  93. * Deploy feature changes, as per issue #650.
  94. *
  95. * @return array
  96. */
  97. function fgcf_update_6103() {
  98. // Revert only the CCK field changes.
  99. features_revert(array('fgcf' => array('content')));
  100. // OR, to revert all components for all features :
  101. // features_revert();
  102. return array();
  103. }
  104. /**
  105. * Rename "FGCF Supports remis" and "FGCF Format de cours" vocabularies as per issue #642
  106. *
  107. * @return array
  108. */
  109. function fgcf_update_6104() {
  110. $ret = array();
  111. $sq = "UPDATE {vocabulary} SET name = 'FGCF Documents remis' WHERE name = 'FGCF Supports remis'";
  112. $ret[] = update_sql($sq);
  113. $sq = "UPDATE {vocabulary} SET name = 'FGCF Supports de cours' WHERE name = 'FGCF Format de cours'";
  114. $ret[] = update_sql($sq);
  115. $sq = "DELETE FROM {url_alias} WHERE src LIKE 'fgcf/%'";
  116. $ret[] = update_sql($sq);
  117. return $ret;
  118. }
  119. /**
  120. * Deploy feature changes for 'Thème' color banner on 'Formation' nodes, as per issue #653.
  121. *
  122. * @return array
  123. */
  124. function fgcf_update_6105() {
  125. features_revert();
  126. return array();
  127. }
  128. /**
  129. * Save color information in existing Thème nodes, as per issue #653.
  130. *
  131. * @return array
  132. */
  133. function fgcf_update_6106() {
  134. $ret = array();
  135. $colors = array(
  136. // Langue - Communication - Développement personnel
  137. 303 => '#4a4494', // or #b47829 ?
  138. // Santé - Sécurité- Permis
  139. 302 => '#f0bf02',
  140. // Informatique - Bureautique
  141. 301 => '#f0bf02',
  142. // Institution des courses
  143. 300 => '#004c37',
  144. // Droit - RH - Management
  145. 299 => '#444',
  146. // Corps de métiers
  147. 298 => '#00868c',
  148. // Espaces verts / Horticulture
  149. 297 => '#496213',
  150. );
  151. foreach ($colors as $nid => $color) {
  152. $node = node_load($nid);
  153. $node->field_fgcf_thematique_color = array(array('value' => $color));
  154. node_save($node);
  155. $ret[] = array('success' => TRUE, 'query' => t('Ajout de la couleur sur thème @title.', array('@title' => $node->title)));
  156. }
  157. return $ret;
  158. }