source: sipes/0.3-modules/politicas_proyectos/politicas_proyectos.install @ 616e50e

stable
Last change on this file since 616e50e was 84211f4, checked in by Sipes Apn <root@…>, 7 años ago

se agrego el modulo de politicas de proyectos

  • Propiedad mode establecida a 100644
File size: 17.3 KB
Línea 
1<?php
2
3  /**
4  * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana
5  * @file politicas_proyectos.install
6  * Drupal part Module to code ente planificador module
7  * Copyright 2017 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  * @author Cenditel Merida - Msc. Juan Vizcarrondo
24  * @date 2017-18-15 // (a&#241;o-mes-dia)
25  * @version 0.3 // (0.3)
26  *
27  */
28
29/*
30 * Implementation of hook_install()
31 */
32function politicas_proyectos_install() {
33  // Notify content module when this module is uninstalled.
34  drupal_load('module', 'content');
35  content_notify('install', 'politicas_proyectos');
36}
37
38/*
39 * Implementation of hook_uninstall()
40 */
41function politicas_proyectos_uninstall() {
42  // Notify content module when this module is uninstalled.
43  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
44  _politicas_proyectos_install_type_remove_field();
45  content_notify('uninstall', 'politicas_proyectos');
46}
47
48/*
49 * Implementation of hook_enable()
50 */
51function politicas_proyectos_enable() {
52  // Notify content module when this module is uninstalled.
53  drupal_load('module', 'content');
54  content_notify('enable', 'politicas_proyectos');
55  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
56  //se elimina el campo field_proyecto_mcti
57  $instances = content_field_instance_read(array(
58    'field_name' => 'field_proyecto_mcti',
59    'type_name' => 'proyectos_operativos',
60  ));
61  if (count($instances) && $instances[0]['type'] != 'nodereference') {
62    content_field_instance_delete('field_proyecto_mcti', 'proyectos_operativos');
63  }
64  _politicas_proyectos_install_type_create_field();
65}
66
67/*
68 * Implementation of hook_disable()
69 */
70function politicas_proyectos_preliminar_disable() {
71  drupal_load('module', 'content');
72  content_notify('disable', 'politicas_proyectos');
73}
74
75/*
76 * _politicas_direccionales_install_type_remove_field
77 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
78 */
79function _politicas_proyectos_install_type_remove_field() {
80  // Load fields.
81  $politicas_proyectos_fields = _politicas_direccionales_load_fields();
82  $remove_field = FALSE;
83  foreach ($politicas_proyectos_fields['fields'] as $politicas_proyectos_inserts) {
84    $instances = content_field_instance_read(array(
85      'field_name' => $politicas_proyectos_inserts['field_name'],
86      'type_name' => $politicas_proyectos_inserts['type_name']
87    ));
88    if (count($instances)) {
89      $remove_field = TRUE;
90      // Only remove the field if it exist.
91      content_field_instance_delete($politicas_proyectos_inserts['field_name'], $politicas_proyectos_inserts['type_name']);
92      drupal_set_message(
93        t("Removed field %typefield in content type %typecontent",
94        array(
95          '%typefield' => $politicas_proyectos_inserts['label'],
96          '%typecontent' => $politicas_proyectos_inserts['type_name']
97        )
98      ));
99    }
100  }
101  if ($remove_field) {
102    content_clear_type_cache(TRUE);
103    menu_rebuild();
104  }
105}
106
107
108/*
109 *  _politicas_proyectos_install_type_create_field
110 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
111 */
112function _politicas_proyectos_install_type_create_field() {
113  // Load fields.
114  $politicas_proyectos_fields = _politicas_proyectos_load_fields();
115  $create_field = FALSE;
116  foreach ($politicas_proyectos_fields['fields'] as $politicas_proyectos_inserts) {
117    $instances = content_field_instance_read(array(
118      'field_name' => $politicas_proyectos_inserts['field_name'],
119      'type_name' => $politicas_proyectos_inserts['type_name']
120    ));
121    if (count($instances) < 1) {
122      $create_field = TRUE;
123      // Only add the field if it doesn't exist. Don't overwrite any changes.
124      content_field_instance_create($politicas_proyectos_inserts);
125      drupal_set_message(
126        t("Saved field %typefield in content type %typecontent",
127        array(
128          '%typefield' => $politicas_proyectos_inserts['label'],
129          '%typecontent' => $politicas_proyectos_inserts['type_name']
130        )
131      ));
132    }
133  }
134  if ($create_field) {
135    content_clear_type_cache(TRUE);
136    menu_rebuild();
137  }
138}
139
140
141/*
142 * _politicas_direccionales_load_fields
143 * Fields definitions
144 */
145function _politicas_proyectos_load_fields() {
146  $content = array();
147  $content['fields'] = array();
148  //SE AGREGAN LOS CAMPOS DE SITUACION ACTUAL A PROYECTOS
149
150  $content['fields'][] = array (
151    'label' => 'Política Direccional',
152    'type_name' => 'proyectos_operativos',
153    'field_name' => 'field_proyecto_mcti',
154    'type' => 'nodereference',
155    'widget_type' => 'politicas_direccionales_select',
156    'change' => 'Cambiar información básica',
157    'weight' => '31',
158    'autocomplete_match' => 'contains',
159    'size' => 60,
160    'description' => '',
161    'default_value' =>
162    array (
163      0 =>
164      array (
165        'nid' => '',
166      ),
167    ),
168    'default_value_php' => '',
169    'default_value_widget' => NULL,
170    'required' => 1,
171    'multiple' => 1,
172    'referenceable_types' =>
173    array (
174      'causas' => 0,
175      'situacion_ideal' => 0,
176      'ente_planificador' => 0,
177      'page' => 0,
178      'politicas_direccionales' => 'politicas_direccionales',
179      'direccionales' => 0,
180      'descriptores' => 0,
181      'story' => 0,
182      'situacion_actual_preliminar' => 0,
183      'webform' => 0,
184      'estrategia' => false,
185    ),
186    'advanced_view' => '--',
187    'advanced_view_args' => '',
188    'op' => 'Guardar opciones de campo',
189    'module' => 'nodereference',
190    'widget_module' => 'nodereference',
191    'columns' =>
192    array (
193      'nid' =>
194      array (
195        'type' => 'int',
196        'unsigned' => true,
197        'not null' => false,
198        'index' => true,
199      ),
200    ),
201    'display_settings' =>
202    array (
203      'weight' => '31',
204      'parent' => '',
205      'label' =>
206      array (
207        'format' => 'above',
208      ),
209      'teaser' =>
210      array (
211        'format' => 'default',
212        'exclude' => 0,
213      ),
214      'full' =>
215      array (
216        'format' => 'plain',
217        'exclude' => 0,
218      ),
219      4 =>
220      array (
221        'format' => 'default',
222        'exclude' => 0,
223      ),
224      'modal' =>
225      array (
226        'format' => 'default',
227        'exclude' => 0,
228      ),
229      'inline' =>
230      array (
231        'format' => 'default',
232        'exclude' => 0,
233      ),
234      'token' =>
235      array (
236        'format' => 'default',
237        'exclude' => 0,
238      ),
239    ),
240  );
241  $content['fields'][] = array (
242    'label' => 'Descriptores',
243    'type_name' => 'proyectos_operativos',
244    'field_name' => 'field_proyectos_descript',
245    'type' => 'nodereference',
246    'widget_type' => 'nodereference_select',
247    'change' => 'Cambiar información básica',
248    'weight' => '31',
249    'autocomplete_match' => 'contains',
250    'size' => 60,
251    'description' => '',
252    'default_value' =>
253    array (
254      0 =>
255      array (
256        'nid' => '',
257      ),
258    ),
259    'default_value_php' => '',
260    'default_value_widget' => NULL,
261    'required' => 1,
262    'multiple' => '1',
263    'referenceable_types' =>
264    array (
265      'causas' => 0,
266      'situacion_ideal' => 0,
267      'ente_planificador' => 0,
268      'page' => 0,
269      'politicas_direccionales' => 0,
270      'direccionales' => 0,
271      'descriptores' => 'descriptores',
272      'story' => 0,
273      'situacion_actual_preliminar' => 0,
274      'webform' => 0,
275      'estrategia' => false,
276    ),
277    'advanced_view' => '--',
278    'advanced_view_args' => '',
279    'op' => 'Guardar opciones de campo',
280    'module' => 'nodereference',
281    'widget_module' => 'nodereference',
282    'columns' =>
283    array (
284      'nid' =>
285      array (
286        'type' => 'int',
287        'unsigned' => true,
288        'not null' => false,
289        'index' => true,
290      ),
291    ),
292    'display_settings' =>
293    array (
294      'weight' => '31',
295      'parent' => '',
296      'label' =>
297      array (
298        'format' => 'above',
299      ),
300      'teaser' =>
301      array (
302        'format' => 'default',
303        'exclude' => 0,
304      ),
305      'full' =>
306      array (
307        'format' => 'plain',
308        'exclude' => 0,
309      ),
310      4 =>
311      array (
312        'format' => 'default',
313        'exclude' => 0,
314      ),
315      'modal' =>
316      array (
317        'format' => 'default',
318        'exclude' => 0,
319      ),
320      'inline' =>
321      array (
322        'format' => 'default',
323        'exclude' => 0,
324      ),
325      'token' =>
326      array (
327        'format' => 'default',
328        'exclude' => 0,
329      ),
330    ),
331  );
332
333
334  $content['fields'][] = array (
335    'label' => 'Causas Críticas',
336    'type_name' => 'proyectos_operativos',
337    'field_name' => 'field_proyectos_causasc',
338    'type' => 'nodereference',
339    'widget_type' => 'nodereference_select',
340    'change' => 'Cambiar información básica',
341    'weight' => '31',
342    'autocomplete_match' => 'contains',
343    'size' => 60,
344    'description' => '',
345    'default_value' =>
346    array (
347      0 =>
348      array (
349        'nid' => '',
350      ),
351    ),
352    'default_value_php' => '',
353    'default_value_widget' => NULL,
354    'required' => 1,
355    'multiple' => '1',
356    'referenceable_types' =>
357    array (
358      'causas' => 'causas',
359      'situacion_ideal' => 0,
360      'ente_planificador' => 0,
361      'page' => 0,
362      'politicas_direccionales' => 0,
363      'direccionales' => 0,
364      'descriptores' => 0,
365      'story' => 0,
366      'situacion_actual_preliminar' => 0,
367      'webform' => 0,
368      'estrategia' => false,
369    ),
370    'advanced_view' => '--',
371    'advanced_view_args' => '',
372    'op' => 'Guardar opciones de campo',
373    'module' => 'nodereference',
374    'widget_module' => 'nodereference',
375    'columns' =>
376    array (
377      'nid' =>
378      array (
379        'type' => 'int',
380        'unsigned' => true,
381        'not null' => false,
382        'index' => true,
383      ),
384    ),
385    'display_settings' =>
386    array (
387      'weight' => '31',
388      'parent' => '',
389      'label' =>
390      array (
391        'format' => 'above',
392      ),
393      'teaser' =>
394      array (
395        'format' => 'default',
396        'exclude' => 0,
397      ),
398      'full' =>
399      array (
400        'format' => 'plain',
401        'exclude' => 0,
402      ),
403      4 =>
404      array (
405        'format' => 'default',
406        'exclude' => 0,
407      ),
408      'modal' =>
409      array (
410        'format' => 'default',
411        'exclude' => 0,
412      ),
413      'inline' =>
414      array (
415        'format' => 'default',
416        'exclude' => 0,
417      ),
418      'token' =>
419      array (
420        'format' => 'default',
421        'exclude' => 0,
422      ),
423    ),
424  );
425  $content['fields'][] = array (
426    'label' => 'Cambios en la situación Actual',
427    'type_name' => 'proyectos_operativos',
428    'field_name' => 'field_proyectos_cambios',
429    'type' => 'nodereference',
430    'widget_type' => 'nodereference_select',
431    'change' => 'Cambiar información básica',
432    'weight' => '31',
433    'autocomplete_match' => 'contains',
434    'size' => 60,
435    'description' => '',
436    'default_value' =>
437    array (
438      0 =>
439      array (
440        'nid' => '',
441      ),
442    ),
443    'default_value_php' => '',
444    'default_value_widget' => NULL,
445    'required' => 1,
446    'multiple' => '1',
447    'referenceable_types' =>
448    array (
449      'cambios' => 'cambios',
450      'causas' => 0,
451      'situacion_ideal' => 0,
452      'ente_planificador' => 0,
453      'page' => 0,
454      'politicas_direccionales' => 0,
455      'direccionales' => 0,
456      'descriptores' => 0,
457      'story' => 0,
458      'situacion_actual_preliminar' => 0,
459      'webform' => 0,
460      'estrategia' => 0,
461    ),
462    'advanced_view' => '--',
463    'advanced_view_args' => '',
464    'op' => 'Guardar opciones de campo',
465    'module' => 'nodereference',
466    'widget_module' => 'nodereference',
467    'columns' =>
468    array (
469      'nid' =>
470      array (
471        'type' => 'int',
472        'unsigned' => true,
473        'not null' => false,
474        'index' => true,
475      ),
476    ),
477    'display_settings' =>
478    array (
479      'weight' => '31',
480      'parent' => '',
481      'label' =>
482      array (
483        'format' => 'above',
484      ),
485      'teaser' =>
486      array (
487        'format' => 'default',
488        'exclude' => 0,
489      ),
490      'full' =>
491      array (
492        'format' => 'plain',
493        'exclude' => 0,
494      ),
495      4 =>
496      array (
497        'format' => 'default',
498        'exclude' => 0,
499      ),
500      'modal' =>
501      array (
502        'format' => 'default',
503        'exclude' => 0,
504      ),
505      'inline' =>
506      array (
507        'format' => 'default',
508        'exclude' => 0,
509      ),
510      'token' =>
511      array (
512        'format' => 'default',
513        'exclude' => 0,
514      ),
515    ),
516  );
517  //posibles formas de solucion
518  $content['fields'][] = array (
519    'label' => 'Posibles formas de solución a la causa',
520    'type_name' => 'proyectos_operativos',
521    'field_name' => 'field_proyectos_solucion',
522    'type' => 'text',
523    'widget_type' => 'text_textarea',
524    'change' => 'Change basic information',
525    'weight' => '41',
526    'rows' => '5',
527    'size' => 60,
528    'description' => 'Descripción de las posibles formas de solución a los hechos problemáticos indicados en los descriptores de la causa',
529    'default_value' =>
530    array (
531      0 =>
532      array (
533        'value' => '',
534        '_error_element' => 'default_value_widget][field_proyectos_solucion][0][value',
535      ),
536    ),
537    'default_value_php' => '',
538    'default_value_widget' =>
539    array (
540      'field_causa_solucion' =>
541      array (
542        0 =>
543        array (
544          'value' => '',
545          '_error_element' => 'default_value_widget][field_proyectos_solucion][0][value',
546        ),
547      ),
548    ),
549    'required' => '1',
550    'multiple' => '1',
551    'text_processing' => '0',
552    'max_length' => '',
553    'allowed_values' => '',
554    'allowed_values_php' => '',
555    'op' => 'Guardar configuraciones del campo',
556    'module' => 'text',
557    'widget_module' => 'text',
558    'columns' =>
559    array (
560      'value' =>
561      array (
562        'type' => 'text',
563        'size' => 'big',
564        'not null' => false,
565        'sortable' => true,
566        'views' => true,
567      ),
568    ),
569    'display_settings' =>
570    array (
571      'label' =>
572      array (
573        'format' => 'above',
574        'exclude' => 0,
575      ),
576      'teaser' =>
577      array (
578        'format' => 'default',
579        'exclude' => 0,
580      ),
581      'full' =>
582      array (
583        'format' => 'default',
584        'exclude' => 0,
585      ),
586      4 =>
587      array (
588        'format' => 'default',
589        'exclude' => 0,
590      ),
591      'modal' =>
592      array (
593        'format' => 'default',
594        'exclude' => 0,
595      ),
596      'inline' =>
597      array (
598        'format' => 'default',
599        'exclude' => 0,
600      ),
601      'token' =>
602      array (
603        'format' => 'default',
604        'exclude' => 0,
605      ),
606    ),
607  );
608
609
610
611  $carabobo = variable_get('situacion_actual_preliminar_plan_carab', 0);
612  //plan carabobo
613  $content['fields'][] = array (
614    'label' => 'Plan Campaña Carabobo',
615    'type_name' => 'proyectos_operativos',
616    'field_name' => 'field_proyectos_carabobo',
617    'type' => 'content_taxonomy',
618    'widget_type' => 'content_taxonomy_select',
619    'change' => 'Change basic information',
620    'weight' => '40',
621    'show_depth' => 1,
622    'group_parent' => '0',
623    'description' => '',
624    'default_value' =>
625    array (
626      0 =>
627      array (
628        'value' => '',
629      ),
630    ),
631    'default_value_php' => '',
632    'default_value_widget' =>
633    array (
634      'field_proyectos_carabobo' =>
635      array (
636        'value' => '',
637      ),
638    ),
639    'required' => 1,
640    'multiple' => 1,
641    'save_term_node' => 1,
642    'vid' => $carabobo,
643    'parent' => '0',
644    'parent_php_code' => '',
645    'depth' => '',
646    'op' => 'Save field settings',
647    'module' => 'content_taxonomy',
648    'widget_module' => 'content_taxonomy_options',
649    'columns' =>
650    array (
651      'value' =>
652      array (
653        'type' => 'int',
654        'not null' => false,
655        'sortable' => false,
656      ),
657    ),
658    'display_settings' =>
659    array (
660      'label' =>
661      array (
662        'format' => 'above',
663        'exclude' => 0,
664      ),
665      'teaser' =>
666      array (
667        'format' => 'default',
668        'exclude' => 0,
669      ),
670      'full' =>
671      array (
672        'format' => 'default',
673        'exclude' => 0,
674      ),
675      4 =>
676      array (
677        'format' => 'default',
678        'exclude' => 0,
679      ),
680      'inline' =>
681      array (
682        'format' => 'default',
683        'exclude' => 0,
684      ),
685      'modal' =>
686      array (
687        'format' => 'default',
688        'exclude' => 0,
689      ),
690      'token' =>
691      array (
692        'format' => 'default',
693        'exclude' => 0,
694      ),
695    ),
696  );
697
698
699
700  return $content;
701}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.