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 2013 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 2015-03-09 // (año-mes-dia) |
---|
25 | * @version 0.2 // (0.1) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /* |
---|
30 | * Implementation of hook_install() |
---|
31 | */ |
---|
32 | function continuarproyectosopplurianual_install() { |
---|
33 | // Notify content module when this module is uninstalled. |
---|
34 | drupal_load('module', 'content'); |
---|
35 | content_notify('install', 'continuarproyectosopplurianual'); |
---|
36 | } |
---|
37 | |
---|
38 | /* |
---|
39 | * Implementation of hook_uninstall() |
---|
40 | */ |
---|
41 | function continuarproyectosopplurianual_uninstall() { |
---|
42 | // Notify content module when this module is uninstalled. |
---|
43 | include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc'); |
---|
44 | _continuarproyectosopplurianual_install_type_remove_field(); |
---|
45 | content_notify('uninstall', 'continuarproyectosopplurianual'); |
---|
46 | db_query("DELETE FROM {variable} WHERE name LIKE '%s'", 'continuarproyectosopplurianual%'); |
---|
47 | } |
---|
48 | |
---|
49 | /* |
---|
50 | * Implementation of hook_enable() |
---|
51 | */ |
---|
52 | function continuarproyectosopplurianual_enable() { |
---|
53 | // Notify content module when this module is uninstalled. |
---|
54 | drupal_load('module', 'content'); |
---|
55 | content_notify('enable', 'continuarproyectosopplurianual'); |
---|
56 | include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc'); |
---|
57 | _continuarproyectosopplurianual_install_type_create_field(); |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * Implementation of hook_disable() |
---|
62 | */ |
---|
63 | function continuarproyectosopplurianual_disable() { |
---|
64 | drupal_load('module', 'content'); |
---|
65 | content_notify('disable', 'continuarproyectosopplurianual'); |
---|
66 | } |
---|
67 | |
---|
68 | /* |
---|
69 | * _continuarproyectosopplurianual_install_type_remove_field |
---|
70 | * Crear los tipos de contenidos necesarios para el funcionamiento del modulo |
---|
71 | */ |
---|
72 | function _continuarproyectosopplurianual_install_type_remove_field() { |
---|
73 | // Load fields. |
---|
74 | $proyectos_operativos_fields = _continuarproyectosopplurianual_load_fields(); |
---|
75 | $remove_field = FALSE; |
---|
76 | if (count($proyectos_operativos_fields['fields'])) { |
---|
77 | foreach ($proyectos_operativos_fields['fields'] as $proyectos_operativos_inserts) { |
---|
78 | $instances = content_field_instance_read(array( |
---|
79 | 'field_name' => $proyectos_operativos_inserts['field_name'], |
---|
80 | 'type_name' => $proyectos_operativos_inserts['type_name'] |
---|
81 | )); |
---|
82 | if (count($instances)) { |
---|
83 | $remove_field = TRUE; |
---|
84 | // Only add the field if it doesn't exist. Don't overwrite any changes. |
---|
85 | content_field_instance_delete($proyectos_operativos_inserts['field_name'], $proyectos_operativos_inserts['type_name']); |
---|
86 | drupal_set_message(t("Removed field %typefield in content type %typecontent", array('%typefield' => $proyectos_operativos_inserts['label'], '%typecontent' => $proyectos_operativos_inserts['type_name']))); |
---|
87 | } |
---|
88 | } |
---|
89 | } |
---|
90 | if ($remove_field) { |
---|
91 | content_clear_type_cache(TRUE); |
---|
92 | menu_rebuild(); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | /* |
---|
97 | * _continuarproyectosopplurianual_install_type_create_field |
---|
98 | * Crear los tipos de contenidos necesarios para el funcionamiento del modulo |
---|
99 | */ |
---|
100 | function _continuarproyectosopplurianual_install_type_create_field() { |
---|
101 | // Load fields. |
---|
102 | $proyectos_operativos_fields = _continuarproyectosopplurianual_load_fields(); |
---|
103 | $create_field = FALSE; |
---|
104 | if (count($proyectos_operativos_fields['fields'])) { |
---|
105 | foreach ($proyectos_operativos_fields['fields'] as $proyectos_operativos_inserts) { |
---|
106 | $instances = content_field_instance_read(array( |
---|
107 | 'field_name' => $proyectos_operativos_inserts['field_name'], |
---|
108 | 'type_name' => $proyectos_operativos_inserts['type_name'] |
---|
109 | )); |
---|
110 | if (count($instances) < 1) { |
---|
111 | $create_field = TRUE; |
---|
112 | // Only add the field if it doesn't exist. Don't overwrite any changes. |
---|
113 | $field_create = content_field_instance_create($proyectos_operativos_inserts, FALSE); |
---|
114 | drupal_set_message(t("Saved field %typefield in content type %typecontent", array('%typefield' => $proyectos_operativos_inserts['label'], '%typecontent' => $proyectos_operativos_inserts['type_name']))); |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | if ($create_field) { |
---|
119 | content_clear_type_cache(TRUE); |
---|
120 | menu_rebuild(); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | /* |
---|
125 | * _continuarproyectosopplurianual_load_fields |
---|
126 | * Crear los tipos de contenidos necesarios para el funcionamiento del modulo |
---|
127 | */ |
---|
128 | function _continuarproyectosopplurianual_load_fields() { |
---|
129 | $content = array(); |
---|
130 | $content['fields'] = array(); |
---|
131 | $content['fields'][] = array ( |
---|
132 | 'label' => 'Proyecto Plurianual', |
---|
133 | 'type_name' => 'proyectos_operativos', |
---|
134 | 'field_name' => 'field_proyecto_plurianualb', |
---|
135 | 'type' => 'nodereference', |
---|
136 | 'widget_type' => 'nodereference_autocomplete', |
---|
137 | 'change' => 'Cambiar información básica', |
---|
138 | 'weight' => '70', |
---|
139 | 'autocomplete_match' => 'contains', |
---|
140 | 'size' => '60', |
---|
141 | 'description' => '', |
---|
142 | 'default_value' => |
---|
143 | array ( |
---|
144 | 0 => |
---|
145 | array ( |
---|
146 | 'nid' => NULL, |
---|
147 | '_error_element' => 'default_value_widget][field_proyecto_plurianualb][0][nid][nid', |
---|
148 | ), |
---|
149 | ), |
---|
150 | 'default_value_php' => '', |
---|
151 | 'default_value_widget' => NULL, |
---|
152 | 'group' => false, |
---|
153 | 'required' => 0, |
---|
154 | 'multiple' => '0', |
---|
155 | 'referenceable_types' => |
---|
156 | array ( |
---|
157 | 'proyectos_operativos' => 'proyectos_operativos', |
---|
158 | 'accion_centralizada' => 0, |
---|
159 | 'accion_especifica' => 0, |
---|
160 | 'activity' => 0, |
---|
161 | 'ente_planificador' => 0, |
---|
162 | 'page' => 0, |
---|
163 | 'story' => 0, |
---|
164 | ), |
---|
165 | 'advanced_view' => '--', |
---|
166 | 'advanced_view_args' => '', |
---|
167 | 'op' => 'Guardar configuraciones del campo', |
---|
168 | 'module' => 'nodereference', |
---|
169 | 'widget_module' => 'nodereference', |
---|
170 | 'columns' => |
---|
171 | array ( |
---|
172 | 'nid' => |
---|
173 | array ( |
---|
174 | 'type' => 'int', |
---|
175 | 'unsigned' => true, |
---|
176 | 'not null' => false, |
---|
177 | 'index' => true, |
---|
178 | ), |
---|
179 | ), |
---|
180 | 'display_settings' => |
---|
181 | array ( |
---|
182 | 'label' => |
---|
183 | array ( |
---|
184 | 'format' => 'above', |
---|
185 | 'exclude' => 0, |
---|
186 | ), |
---|
187 | 'teaser' => |
---|
188 | array ( |
---|
189 | 'format' => 'default', |
---|
190 | 'exclude' => 0, |
---|
191 | ), |
---|
192 | 'full' => |
---|
193 | array ( |
---|
194 | 'format' => 'default', |
---|
195 | 'exclude' => 0, |
---|
196 | ), |
---|
197 | 4 => |
---|
198 | array ( |
---|
199 | 'format' => 'default', |
---|
200 | 'exclude' => 0, |
---|
201 | ), |
---|
202 | 'token' => |
---|
203 | array ( |
---|
204 | 'format' => 'default', |
---|
205 | 'exclude' => 0, |
---|
206 | ), |
---|
207 | ), |
---|
208 | ); |
---|
209 | return $content; |
---|
210 | } |
---|