source: sipes/0.3-modules/continuarproyectosopplurianual/continuarproyectosopplurianual.install @ 66ea143

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

nueva version del modulo continuar proyectos plurianuales

  • Propiedad mode establecida a 100755
File size: 10.8 KB
Línea 
1<?php
2
3  /**
4  * Sistema Integral de Planificación y Presupuesto (SIPP)
5  * @file continuarproyectosopplurianual.install
6  * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP)
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 - Phd. Juan Vizcarrondo
24  * @date 2017-08-09 // (a&#241;o-mes-dia)
25  * @version 0.3 // (0.1)
26  *
27  */
28
29/*
30 * Implementation of hook_install()
31 */
32function continuarproyectosopplurianual_install() {
33  db_query("UPDATE {system} SET weight = 100 WHERE name = 'continuarproyectosopplurianual'");
34  // Notify content module when this module is uninstalled.
35  drupal_load('module', 'content');
36  content_notify('install', 'continuarproyectosopplurianual');
37}
38
39/*
40 * Implementation of hook_uninstall()
41 */
42function continuarproyectosopplurianual_uninstall() {
43  // Notify content module when this module is uninstalled.
44  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
45  _continuarproyectosopplurianual_install_type_remove_field();
46  content_notify('uninstall', 'continuarproyectosopplurianual');
47  db_query("DELETE FROM {variable} WHERE name LIKE '%s'", 'continuarproyectosopplurianual%');
48}
49
50/*
51 * Implementation of hook_enable()
52 */
53function continuarproyectosopplurianual_enable() {
54  // Notify content module when this module is uninstalled.
55  drupal_load('module', 'content');
56  content_notify('enable', 'continuarproyectosopplurianual');
57  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
58  _continuarproyectosopplurianual_install_type_create_field();
59}
60
61/*
62 * Implementation of hook_disable()
63 */
64function continuarproyectosopplurianual_disable() {
65  drupal_load('module', 'content');
66  content_notify('disable', 'continuarproyectosopplurianual');
67}
68
69/*
70 * _continuarproyectosopplurianual_install_type_remove_field
71 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
72 */
73function _continuarproyectosopplurianual_install_type_remove_field() {
74  // Load fields.
75  $proyectos_operativos_fields = _continuarproyectosopplurianual_load_fields();
76  $remove_field = FALSE;
77  if (count($proyectos_operativos_fields['fields'])) {
78    foreach ($proyectos_operativos_fields['fields'] as $proyectos_operativos_inserts) {
79      $instances = content_field_instance_read(array(
80        'field_name' => $proyectos_operativos_inserts['field_name'],
81        'type_name' => $proyectos_operativos_inserts['type_name']
82      ));
83      if (count($instances)) {
84        $remove_field = TRUE;
85        // Only add the field if it doesn't exist. Don't overwrite any changes.
86        content_field_instance_delete($proyectos_operativos_inserts['field_name'], $proyectos_operativos_inserts['type_name']);
87        drupal_set_message(t("Removed field %typefield in content type %typecontent", array('%typefield' => $proyectos_operativos_inserts['label'], '%typecontent' => $proyectos_operativos_inserts['type_name'])));
88      }
89    }
90  }
91  if ($remove_field) {
92    content_clear_type_cache(TRUE);
93    menu_rebuild();
94  }
95}
96
97/*
98 * _continuarproyectosopplurianual_install_type_create_field
99 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
100 */
101function _continuarproyectosopplurianual_install_type_create_field() {
102  // Load fields.
103  $proyectos_operativos_fields = _continuarproyectosopplurianual_load_fields();
104  $create_field = FALSE;
105  if (count($proyectos_operativos_fields['fields'])) {
106    foreach ($proyectos_operativos_fields['fields'] as $proyectos_operativos_inserts) {
107      $instances = content_field_instance_read(array(
108        'field_name' => $proyectos_operativos_inserts['field_name'],
109        'type_name' => $proyectos_operativos_inserts['type_name']
110      ));
111      if (count($instances) < 1) {
112        $create_field = TRUE;
113        // Only add the field if it doesn't exist. Don't overwrite any changes.
114        $field_create = content_field_instance_create($proyectos_operativos_inserts, FALSE);
115        drupal_set_message(t("Saved field %typefield in content type %typecontent", array('%typefield' => $proyectos_operativos_inserts['label'], '%typecontent' => $proyectos_operativos_inserts['type_name'])));
116      }
117    }
118  }
119  if ($create_field) {
120    content_clear_type_cache(TRUE);
121    menu_rebuild();
122  }
123}
124
125/*
126 * _continuarproyectosopplurianual_load_fields
127 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
128 */
129function _continuarproyectosopplurianual_load_fields() {
130  $content = array();
131  $content['fields'] = array();
132  $content['fields'][] = array (
133    'label' => 'Proyecto Plurianual',
134    'type_name' => 'proyectos_operativos',
135    'field_name' => 'field_proyecto_plurianualb',
136    'type' => 'nodereference',
137    'widget_type' => 'nodereference_autocomplete',
138    'change' => 'Cambiar información básica',
139    'weight' => '70',
140    'autocomplete_match' => 'contains',
141    'size' => '60',
142    'description' => '',
143    'default_value' =>
144    array (
145      0 =>
146      array (
147        'nid' => NULL,
148        '_error_element' => 'default_value_widget][field_proyecto_plurianualb][0][nid][nid',
149      ),
150    ),
151    'default_value_php' => '',
152    'default_value_widget' => NULL,
153    'group' => false,
154    'required' => 0,
155    'multiple' => '0',
156    'referenceable_types' =>
157    array (
158      'proyectos_operativos' => 'proyectos_operativos',
159      'accion_centralizada' => 0,
160      'accion_especifica' => 0,
161      'activity' => 0,
162      'ente_planificador' => 0,
163      'page' => 0,
164      'story' => 0,
165    ),
166    'advanced_view' => '--',
167    'advanced_view_args' => '',
168    'op' => 'Guardar configuraciones del campo',
169    'module' => 'nodereference',
170    'widget_module' => 'nodereference',
171    'columns' =>
172    array (
173      'nid' =>
174      array (
175        'type' => 'int',
176        'unsigned' => true,
177        'not null' => false,
178        'index' => true,
179      ),
180    ),
181    'display_settings' =>
182    array (
183      'label' =>
184      array (
185        'format' => 'above',
186        'exclude' => 0,
187      ),
188      'teaser' =>
189      array (
190        'format' => 'default',
191        'exclude' => 0,
192      ),
193      'full' =>
194      array (
195        'format' => 'default',
196        'exclude' => 0,
197      ),
198      4 =>
199      array (
200        'format' => 'default',
201        'exclude' => 0,
202      ),
203      'token' =>
204      array (
205        'format' => 'default',
206        'exclude' => 0,
207      ),
208    ),
209  );
210
211  $content['fields'][] = array (
212    'label' => 'Acción Especifica Plurianual',
213    'type_name' => 'accion_especifica',
214    'field_name' => 'field_ae_plurianualb',
215    'type' => 'nodereference',
216    'widget_type' => 'nodereference_autocomplete',
217    'change' => 'Cambiar información básica',
218    'weight' => '70',
219    'autocomplete_match' => 'contains',
220    'size' => '60',
221    'description' => '',
222    'default_value' =>
223    array (
224      0 =>
225      array (
226        'nid' => NULL,
227        '_error_element' => 'default_value_widget][field_ae_plurianualb][0][nid][nid',
228      ),
229    ),
230    'default_value_php' => '',
231    'default_value_widget' => NULL,
232    'group' => false,
233    'required' => 0,
234    'multiple' => '0',
235    'referenceable_types' =>
236    array (
237      'proyectos_operativos' => 0,
238      'accion_centralizada' => 0,
239      'accion_especifica' => 'accion_especifica',
240      'activity' => 0,
241      'ente_planificador' => 0,
242      'page' => 0,
243      'story' => 0,
244    ),
245    'advanced_view' => '--',
246    'advanced_view_args' => '',
247    'op' => 'Guardar configuraciones del campo',
248    'module' => 'nodereference',
249    'widget_module' => 'nodereference',
250    'columns' =>
251    array (
252      'nid' =>
253      array (
254        'type' => 'int',
255        'unsigned' => true,
256        'not null' => false,
257        'index' => true,
258      ),
259    ),
260    'display_settings' =>
261    array (
262      'label' =>
263      array (
264        'format' => 'above',
265        'exclude' => 0,
266      ),
267      'teaser' =>
268      array (
269        'format' => 'default',
270        'exclude' => 0,
271      ),
272      'full' =>
273      array (
274        'format' => 'default',
275        'exclude' => 0,
276      ),
277      4 =>
278      array (
279        'format' => 'default',
280        'exclude' => 0,
281      ),
282      'token' =>
283      array (
284        'format' => 'default',
285        'exclude' => 0,
286      ),
287    ),
288  );
289
290  $content['fields'][] = array (
291    'label' => 'Proyecto operativo Plurianual Base',
292    'type_name' => 'accion_especifica',
293    'field_name' => 'field_ae_proyectobase',
294    'type' => 'nodereference',
295    'widget_type' => 'nodereference_autocomplete',
296    'change' => 'Cambiar información básica',
297    'weight' => '70',
298    'autocomplete_match' => 'contains',
299    'size' => '60',
300    'description' => '',
301    'default_value' =>
302    array (
303      0 =>
304      array (
305        'nid' => NULL,
306        '_error_element' => 'default_value_widget][field_ae_proyectobase][0][nid][nid',
307      ),
308    ),
309    'default_value_php' => '',
310    'default_value_widget' => NULL,
311    'group' => false,
312    'required' => 0,
313    'multiple' => '0',
314    'referenceable_types' =>
315    array (
316      'proyectos_operativos' => 'proyectos_operativos',
317      'accion_centralizada' => 0,
318      'accion_especifica' => 0,
319      'activity' => 0,
320      'ente_planificador' => 0,
321      'page' => 0,
322      'story' => 0,
323    ),
324    'advanced_view' => '--',
325    'advanced_view_args' => '',
326    'op' => 'Guardar configuraciones del campo',
327    'module' => 'nodereference',
328    'widget_module' => 'nodereference',
329    'columns' =>
330    array (
331      'nid' =>
332      array (
333        'type' => 'int',
334        'unsigned' => true,
335        'not null' => false,
336        'index' => true,
337      ),
338    ),
339    'display_settings' =>
340    array (
341      'label' =>
342      array (
343        'format' => 'above',
344        'exclude' => 0,
345      ),
346      'teaser' =>
347      array (
348        'format' => 'default',
349        'exclude' => 0,
350      ),
351      'full' =>
352      array (
353        'format' => 'default',
354        'exclude' => 0,
355      ),
356      4 =>
357      array (
358        'format' => 'default',
359        'exclude' => 0,
360      ),
361      'token' =>
362      array (
363        'format' => 'default',
364        'exclude' => 0,
365      ),
366    ),
367  );
368  return $content;
369}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.