@@ -46,39 +46,39 @@ |
||
46 | 46 | * Contributor(s): ______________________________________.. |
47 | 47 | ********************************************************************************/ |
48 | 48 | $fields_array['Relationship'] = array ('column_fields' => Array( |
49 | - 'id', |
|
50 | - 'relationship_name', |
|
51 | - 'lhs_module', |
|
52 | - 'lhs_table', |
|
53 | - 'lhs_key', |
|
54 | - 'rhs_module', |
|
55 | - 'rhs_table', |
|
56 | - 'rhs_key', |
|
57 | - 'join_table', |
|
58 | - 'join_key_lhs', |
|
59 | - 'join_key_rhs', |
|
60 | - 'relationship_type', |
|
61 | - 'relationship_role_column', |
|
62 | - 'relationship_role_column_value', |
|
63 | - 'reverse', |
|
64 | - ), |
|
49 | + 'id', |
|
50 | + 'relationship_name', |
|
51 | + 'lhs_module', |
|
52 | + 'lhs_table', |
|
53 | + 'lhs_key', |
|
54 | + 'rhs_module', |
|
55 | + 'rhs_table', |
|
56 | + 'rhs_key', |
|
57 | + 'join_table', |
|
58 | + 'join_key_lhs', |
|
59 | + 'join_key_rhs', |
|
60 | + 'relationship_type', |
|
61 | + 'relationship_role_column', |
|
62 | + 'relationship_role_column_value', |
|
63 | + 'reverse', |
|
64 | + ), |
|
65 | 65 | 'list_fields' => Array( |
66 | - 'id', |
|
67 | - 'relationship_name', |
|
68 | - 'lhs_module', |
|
69 | - 'lhs_table', |
|
70 | - 'lhs_key', |
|
71 | - 'rhs_module', |
|
72 | - 'rhs_table', |
|
73 | - 'rhs_key', |
|
74 | - 'join_table', |
|
75 | - 'join_key_lhs', |
|
76 | - 'join_key_rhs', |
|
77 | - 'relationship_type', |
|
78 | - 'relationship_role_column', |
|
79 | - 'relationship_role_column_value', |
|
80 | - 'reverse', |
|
81 | - ), |
|
66 | + 'id', |
|
67 | + 'relationship_name', |
|
68 | + 'lhs_module', |
|
69 | + 'lhs_table', |
|
70 | + 'lhs_key', |
|
71 | + 'rhs_module', |
|
72 | + 'rhs_table', |
|
73 | + 'rhs_key', |
|
74 | + 'join_table', |
|
75 | + 'join_key_lhs', |
|
76 | + 'join_key_rhs', |
|
77 | + 'relationship_type', |
|
78 | + 'relationship_role_column', |
|
79 | + 'relationship_role_column_value', |
|
80 | + 'reverse', |
|
81 | + ), |
|
82 | 82 | 'required_fields' => array("relationship_name"=>1), |
83 | 83 | ); |
84 | 84 | ?> |
85 | 85 | \ No newline at end of file |
@@ -48,30 +48,30 @@ discard block |
||
48 | 48 | |
49 | 49 | class RelationshipHandler extends Relationship { |
50 | 50 | |
51 | - var $db; //Database link by reference |
|
51 | + var $db; //Database link by reference |
|
52 | 52 | |
53 | - var $base_module; //name of module |
|
54 | - var $base_bean; //actual object |
|
55 | - var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
53 | + var $base_module; //name of module |
|
54 | + var $base_bean; //actual object |
|
55 | + var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
56 | 56 | |
57 | - var $rel1_module; //name of related module |
|
58 | - var $rel1_bean; //actual related object |
|
59 | - var $rel1_relationship_name; //Relationship name between base and rel1 |
|
60 | - var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
61 | - var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
57 | + var $rel1_module; //name of related module |
|
58 | + var $rel1_bean; //actual related object |
|
59 | + var $rel1_relationship_name; //Relationship name between base and rel1 |
|
60 | + var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
61 | + var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
62 | 62 | |
63 | - var $rel2_module; //name of related related module |
|
64 | - var $rel2_bean; //actual related related object |
|
65 | - var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
66 | - var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
63 | + var $rel2_module; //name of related related module |
|
64 | + var $rel2_bean; //actual related related object |
|
65 | + var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
66 | + var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
67 | 67 | |
68 | 68 | |
69 | - var $base_array; //Info array |
|
70 | - var $rel1_array; //Info array |
|
71 | - var $rel2_array; //Info array |
|
69 | + var $base_array; //Info array |
|
70 | + var $rel1_array; //Info array |
|
71 | + var $rel2_array; //Info array |
|
72 | 72 | |
73 | 73 | |
74 | - /* |
|
74 | + /* |
|
75 | 75 | |
76 | 76 | info arrays contain: |
77 | 77 | |
@@ -85,33 +85,33 @@ discard block |
||
85 | 85 | |
86 | 86 | ///////////////////////////Setup and populate functions////////////////////////////// |
87 | 87 | |
88 | - function RelationshipHandler(& $db, $base_module=""){ |
|
88 | + function RelationshipHandler(& $db, $base_module=""){ |
|
89 | 89 | |
90 | - $this->db = $db; |
|
91 | - $this->base_module = $base_module; |
|
90 | + $this->db = $db; |
|
91 | + $this->base_module = $base_module; |
|
92 | 92 | |
93 | - //end function RelationshipHandler |
|
94 | - } |
|
93 | + //end function RelationshipHandler |
|
94 | + } |
|
95 | 95 | |
96 | - function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){ |
|
96 | + function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){ |
|
97 | 97 | |
98 | - $this->base_vardef_field = $base_vardef_field; |
|
99 | - $this->rel1_vardef_field = $rel1_vardef_field; |
|
98 | + $this->base_vardef_field = $base_vardef_field; |
|
99 | + $this->rel1_vardef_field = $rel1_vardef_field; |
|
100 | 100 | |
101 | - //end function set_rel_vardef_fields |
|
102 | - } |
|
101 | + //end function set_rel_vardef_fields |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - function set_rel_relationship_names($build_rel2=false){ |
|
105 | + function set_rel_relationship_names($build_rel2=false){ |
|
106 | 106 | |
107 | - $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship']; |
|
107 | + $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship']; |
|
108 | 108 | |
109 | - if($build_rel2==true){ |
|
110 | - $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship']; |
|
111 | - } |
|
109 | + if($build_rel2==true){ |
|
110 | + $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship']; |
|
111 | + } |
|
112 | 112 | |
113 | - //end function set_rel_relationship_names |
|
114 | - } |
|
113 | + //end function set_rel_relationship_names |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | |
@@ -119,131 +119,131 @@ discard block |
||
119 | 119 | ///////////////////////////////END Setup and populate functions///////////////////// |
120 | 120 | |
121 | 121 | |
122 | - /* |
|
122 | + /* |
|
123 | 123 | set the build_rel2 to true if you want the rel2 info array as well |
124 | 124 | This function will build all the relationship info it can based on values set in the setup functions |
125 | 125 | When you use the info arrays (rel1_array) or (rel2_array), make sure you always check for empty values |
126 | 126 | */ |
127 | - function build_info($build_rel2=false){ |
|
128 | - if($this->base_bean == null){ |
|
129 | - $this->base_bean = get_module_info($this->base_module); |
|
130 | - } |
|
127 | + function build_info($build_rel2=false){ |
|
128 | + if($this->base_bean == null){ |
|
129 | + $this->base_bean = get_module_info($this->base_module); |
|
130 | + } |
|
131 | 131 | |
132 | - if(empty($this->rel1_bean)){ |
|
133 | - $this->build_rel1_info(); |
|
134 | - $this->rel1_module = $this->rel1_bean->module_dir; |
|
135 | - } |
|
132 | + if(empty($this->rel1_bean)){ |
|
133 | + $this->build_rel1_info(); |
|
134 | + $this->rel1_module = $this->rel1_bean->module_dir; |
|
135 | + } |
|
136 | 136 | |
137 | - if($build_rel2==true && $this->rel2_bean==""){ |
|
138 | - $this->build_rel2_info(); |
|
139 | - $this->rel2_module = $this->rel2_bean->module_dir; |
|
140 | - } |
|
137 | + if($build_rel2==true && $this->rel2_bean==""){ |
|
138 | + $this->build_rel2_info(); |
|
139 | + $this->rel2_module = $this->rel2_bean->module_dir; |
|
140 | + } |
|
141 | 141 | |
142 | - //translate the module titles to the proper language |
|
143 | - $this->build_module_labels($build_rel2); |
|
142 | + //translate the module titles to the proper language |
|
143 | + $this->build_module_labels($build_rel2); |
|
144 | 144 | |
145 | - //end function build_info |
|
146 | - } |
|
145 | + //end function build_info |
|
146 | + } |
|
147 | 147 | |
148 | - function build_rel1_info(){ |
|
148 | + function build_rel1_info(){ |
|
149 | 149 | |
150 | - $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field); |
|
150 | + $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field); |
|
151 | 151 | |
152 | - //end function build_rel1_info |
|
153 | - } |
|
152 | + //end function build_rel1_info |
|
153 | + } |
|
154 | 154 | |
155 | - function build_rel2_info(){ |
|
155 | + function build_rel2_info(){ |
|
156 | 156 | |
157 | - $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field); |
|
157 | + $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field); |
|
158 | 158 | |
159 | - //end function build_rel1_info |
|
160 | - } |
|
159 | + //end function build_rel1_info |
|
160 | + } |
|
161 | 161 | |
162 | - /* |
|
162 | + /* |
|
163 | 163 | Translates the module names to their singular and plural label and puts them in |
164 | 164 | the info arrays. Does it for base, rel1, and rel2 if specified |
165 | 165 | */ |
166 | 166 | |
167 | - function build_module_labels($build_rel2=false){ |
|
168 | - global $app_list_strings; |
|
169 | - |
|
170 | - ///Base Module Labels |
|
171 | - if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){ |
|
172 | - $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir]; |
|
173 | - } else { |
|
174 | - $this->base_array['plabel'] = $this->base_bean->module_dir; |
|
175 | - } |
|
176 | - if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){ |
|
177 | - $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir]; |
|
178 | - } else { |
|
179 | - $this->base_array['slabel'] = $this->base_bean->object_name; |
|
180 | - } |
|
181 | - |
|
182 | - ///Rel1 Module Labels |
|
183 | - if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){ |
|
184 | - $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir]; |
|
185 | - } else { |
|
186 | - $this->rel1_array['plabel'] = $this->rel1_bean->module_dir; |
|
187 | - } |
|
167 | + function build_module_labels($build_rel2=false){ |
|
168 | + global $app_list_strings; |
|
169 | + |
|
170 | + ///Base Module Labels |
|
171 | + if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){ |
|
172 | + $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir]; |
|
173 | + } else { |
|
174 | + $this->base_array['plabel'] = $this->base_bean->module_dir; |
|
175 | + } |
|
176 | + if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){ |
|
177 | + $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir]; |
|
178 | + } else { |
|
179 | + $this->base_array['slabel'] = $this->base_bean->object_name; |
|
180 | + } |
|
181 | + |
|
182 | + ///Rel1 Module Labels |
|
183 | + if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){ |
|
184 | + $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir]; |
|
185 | + } else { |
|
186 | + $this->rel1_array['plabel'] = $this->rel1_bean->module_dir; |
|
187 | + } |
|
188 | 188 | |
189 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){ |
|
190 | - $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir]; |
|
191 | - } else { |
|
192 | - $this->rel1_array['slabel'] = $this->rel1_bean->object_name; |
|
193 | - } |
|
189 | + if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){ |
|
190 | + $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir]; |
|
191 | + } else { |
|
192 | + $this->rel1_array['slabel'] = $this->rel1_bean->object_name; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | - //Rel2 Module Labels |
|
197 | - if($build_rel2==true){ |
|
196 | + //Rel2 Module Labels |
|
197 | + if($build_rel2==true){ |
|
198 | 198 | |
199 | - if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){ |
|
200 | - $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir]; |
|
201 | - } else { |
|
202 | - $this->rel2_array['plabel'] = $this->rel2_bean->module_dir; |
|
203 | - } |
|
204 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){ |
|
205 | - $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir]; |
|
206 | - } else { |
|
207 | - $this->rel2_array['slabel'] = $this->rel2_bean->module_dir; |
|
208 | - } |
|
209 | - //end if build_rel2 is true |
|
210 | - } |
|
199 | + if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){ |
|
200 | + $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir]; |
|
201 | + } else { |
|
202 | + $this->rel2_array['plabel'] = $this->rel2_bean->module_dir; |
|
203 | + } |
|
204 | + if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){ |
|
205 | + $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir]; |
|
206 | + } else { |
|
207 | + $this->rel2_array['slabel'] = $this->rel2_bean->module_dir; |
|
208 | + } |
|
209 | + //end if build_rel2 is true |
|
210 | + } |
|
211 | 211 | |
212 | - //end function buld_module_lables |
|
213 | - } |
|
212 | + //end function buld_module_lables |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | 216 | |
217 | 217 | |
218 | 218 | |
219 | - function build_related_list($type="base"){ |
|
220 | - //type can be base, rel1 |
|
219 | + function build_related_list($type="base"){ |
|
220 | + //type can be base, rel1 |
|
221 | 221 | |
222 | - $target_list = ""; |
|
222 | + $target_list = ""; |
|
223 | 223 | |
224 | - if($type=="base"){ |
|
225 | - $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name); |
|
226 | - //Possibility exists that this is a new relationship, so capture via relationship fields |
|
227 | - if(empty($target_list)){ |
|
228 | - $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field); |
|
229 | - //end if the target list is empty |
|
230 | - } |
|
231 | - } |
|
224 | + if($type=="base"){ |
|
225 | + $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name); |
|
226 | + //Possibility exists that this is a new relationship, so capture via relationship fields |
|
227 | + if(empty($target_list)){ |
|
228 | + $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field); |
|
229 | + //end if the target list is empty |
|
230 | + } |
|
231 | + } |
|
232 | 232 | |
233 | - if($type=="rel1"){ |
|
234 | - $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name); |
|
233 | + if($type=="rel1"){ |
|
234 | + $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name); |
|
235 | 235 | |
236 | - //Possibility exists that this is a new relationship, so capture via relationship fields |
|
237 | - if(empty($target_list)){ |
|
238 | - $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field); |
|
239 | - //end if the target list is empty |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - return $target_list; |
|
236 | + //Possibility exists that this is a new relationship, so capture via relationship fields |
|
237 | + if(empty($target_list)){ |
|
238 | + $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field); |
|
239 | + //end if the target list is empty |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + return $target_list; |
|
244 | 244 | |
245 | - //end function build_related_list |
|
246 | - } |
|
245 | + //end function build_related_list |
|
246 | + } |
|
247 | 247 | |
248 | 248 | |
249 | 249 | |
@@ -252,92 +252,92 @@ discard block |
||
252 | 252 | |
253 | 253 | function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false){ |
254 | 254 | |
255 | - $target_module_name = $target_bean->module_dir; |
|
256 | - $current_module_name = $this->base_module; |
|
255 | + $target_module_name = $target_bean->module_dir; |
|
256 | + $current_module_name = $this->base_module; |
|
257 | 257 | |
258 | - //Look for downstream connection |
|
259 | - $rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db); |
|
258 | + //Look for downstream connection |
|
259 | + $rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db); |
|
260 | 260 | |
261 | 261 | |
262 | - //Does a downstream relationship exist |
|
263 | - if($rel_array!=null){ |
|
264 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
265 | - $target_bean->$rel_array['join_key_lhs'] = $this->base_bean->id; |
|
266 | - if($rel_array['relationship_role_column']!=""){ |
|
267 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
268 | - } |
|
269 | - //end if many-to-many |
|
270 | - } |
|
262 | + //Does a downstream relationship exist |
|
263 | + if($rel_array!=null){ |
|
264 | + if($rel_array['relationship_type']=="many-to-many"){ |
|
265 | + $target_bean->$rel_array['join_key_lhs'] = $this->base_bean->id; |
|
266 | + if($rel_array['relationship_role_column']!=""){ |
|
267 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
268 | + } |
|
269 | + //end if many-to-many |
|
270 | + } |
|
271 | 271 | |
272 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
273 | - $target_bean->$rel_array['rhs_key'] = $this->base_bean->id; |
|
274 | - if($rel_array['relationship_role_column']!=""){ |
|
275 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
276 | - } |
|
277 | - //end if one-to-many |
|
278 | - } |
|
272 | + if($rel_array['relationship_type']=="one-to-many"){ |
|
273 | + $target_bean->$rel_array['rhs_key'] = $this->base_bean->id; |
|
274 | + if($rel_array['relationship_role_column']!=""){ |
|
275 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
276 | + } |
|
277 | + //end if one-to-many |
|
278 | + } |
|
279 | 279 | |
280 | - return; |
|
281 | - //end if downstream relationship exists |
|
282 | - } |
|
280 | + return; |
|
281 | + //end if downstream relationship exists |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | |
286 | - //Look for upstream connection |
|
287 | - $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db); |
|
286 | + //Look for upstream connection |
|
287 | + $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db); |
|
288 | 288 | |
289 | - //Does an upstream relationship exist |
|
290 | - if($rel_array!=null){ |
|
291 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
292 | - $target_bean->$rel_array['join_key_rhs'] = $this->base_bean->id; |
|
293 | - if($rel_array['relationship_role_column']!=""){ |
|
294 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
295 | - } |
|
296 | - //end if many-to-many |
|
297 | - } |
|
289 | + //Does an upstream relationship exist |
|
290 | + if($rel_array!=null){ |
|
291 | + if($rel_array['relationship_type']=="many-to-many"){ |
|
292 | + $target_bean->$rel_array['join_key_rhs'] = $this->base_bean->id; |
|
293 | + if($rel_array['relationship_role_column']!=""){ |
|
294 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
295 | + } |
|
296 | + //end if many-to-many |
|
297 | + } |
|
298 | 298 | |
299 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
300 | - $this->$rel_array['rhs_key'] = $this->base_bean->id; |
|
301 | - if($rel_array['relationship_role_column']!=""){ |
|
302 | - $this->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
303 | - } |
|
304 | - //end if one-to-many |
|
305 | - } |
|
299 | + if($rel_array['relationship_type']=="one-to-many"){ |
|
300 | + $this->$rel_array['rhs_key'] = $this->base_bean->id; |
|
301 | + if($rel_array['relationship_role_column']!=""){ |
|
302 | + $this->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
303 | + } |
|
304 | + //end if one-to-many |
|
305 | + } |
|
306 | 306 | |
307 | 307 | |
308 | - ///Fill additional id field if necessary |
|
309 | - if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){ |
|
310 | - $target_bean->$id_name = $this->base_bean->id; |
|
308 | + ///Fill additional id field if necessary |
|
309 | + if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){ |
|
310 | + $target_bean->$id_name = $this->base_bean->id; |
|
311 | 311 | if($get_upstream_rel_field_name) { |
312 | 312 | $target_bean->new_rel_relname = $id_name; |
313 | 313 | $target_bean->new_rel_id = $this->base_bean->id; |
314 | 314 | } |
315 | - } |
|
315 | + } |
|
316 | 316 | |
317 | - //end if an upstream relationship exists |
|
318 | - } |
|
317 | + //end if an upstream relationship exists |
|
318 | + } |
|
319 | 319 | |
320 | 320 | //end function get_relationship_information |
321 | 321 | } |
322 | 322 | |
323 | 323 | function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){ |
324 | - $id_name = null; |
|
324 | + $id_name = null; |
|
325 | 325 | |
326 | - //returns name of variable to store id in |
|
327 | - //if none exists, then returns null |
|
328 | - foreach($target_bean->field_defs as $field_array){ |
|
326 | + //returns name of variable to store id in |
|
327 | + //if none exists, then returns null |
|
328 | + foreach($target_bean->field_defs as $field_array){ |
|
329 | 329 | |
330 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){ |
|
330 | + if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){ |
|
331 | 331 | |
332 | - $id_name = $this->get_id_name($target_bean, $field_array['name']); |
|
333 | - return $id_name; |
|
334 | - //end if rel name match |
|
335 | - } |
|
332 | + $id_name = $this->get_id_name($target_bean, $field_array['name']); |
|
333 | + return $id_name; |
|
334 | + //end if rel name match |
|
335 | + } |
|
336 | 336 | |
337 | - //end foreach field def |
|
338 | - } |
|
337 | + //end foreach field def |
|
338 | + } |
|
339 | 339 | |
340 | - return null; |
|
340 | + return null; |
|
341 | 341 | |
342 | 342 | //end function traverse_rel_meta |
343 | 343 | } |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | |
346 | 346 | function get_id_name(& $target_bean, $field_name){ |
347 | 347 | |
348 | - foreach($target_bean->relationship_fields as $target_id => $rel_name){ |
|
348 | + foreach($target_bean->relationship_fields as $target_id => $rel_name){ |
|
349 | 349 | |
350 | - if($rel_name == $field_name){ |
|
351 | - //relationship id found |
|
352 | - return $target_id; |
|
353 | - //end if match |
|
354 | - } |
|
355 | - //end foreach |
|
356 | - } |
|
357 | - |
|
358 | - return null; |
|
350 | + if($rel_name == $field_name){ |
|
351 | + //relationship id found |
|
352 | + return $target_id; |
|
353 | + //end if match |
|
354 | + } |
|
355 | + //end foreach |
|
356 | + } |
|
357 | + |
|
358 | + return null; |
|
359 | 359 | //end function get_id_name |
360 | 360 | } |
361 | 361 | |
@@ -364,27 +364,27 @@ discard block |
||
364 | 364 | |
365 | 365 | function process_by_rel_bean($rel1_module){ |
366 | 366 | |
367 | - $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db); |
|
368 | - $this->rel1_module = $rel1_module; |
|
369 | - $this->rel1_bean = get_module_info($this->rel1_module); |
|
367 | + $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db); |
|
368 | + $this->rel1_module = $rel1_module; |
|
369 | + $this->rel1_bean = get_module_info($this->rel1_module); |
|
370 | 370 | |
371 | 371 | //end function process_by_rel_bean |
372 | 372 | } |
373 | 373 | |
374 | 374 | |
375 | 375 | function get_rel1_vardef_field_base($field_defs){ |
376 | - foreach($field_defs as $field_array){ |
|
376 | + foreach($field_defs as $field_array){ |
|
377 | 377 | |
378 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){ |
|
378 | + if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){ |
|
379 | 379 | |
380 | - $this->rel1_vardef_field_base = $field_array['name']; |
|
381 | - //end if rel name match |
|
382 | - } |
|
380 | + $this->rel1_vardef_field_base = $field_array['name']; |
|
381 | + //end if rel name match |
|
382 | + } |
|
383 | 383 | |
384 | - //end foreach field def |
|
385 | - } |
|
384 | + //end foreach field def |
|
385 | + } |
|
386 | 386 | |
387 | - return null; |
|
387 | + return null; |
|
388 | 388 | |
389 | 389 | |
390 | 390 | //end get_rel1_vardef_field_base |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | |
394 | 394 | function get_farthest_reach(){ |
395 | 395 | |
396 | - if($this->rel1_vardef_field!=""){ |
|
397 | - //the farthest reach is rel2 |
|
398 | - $this->build_info(true); |
|
399 | - return $this->rel2_bean; |
|
400 | - } |
|
396 | + if($this->rel1_vardef_field!=""){ |
|
397 | + //the farthest reach is rel2 |
|
398 | + $this->build_info(true); |
|
399 | + return $this->rel2_bean; |
|
400 | + } |
|
401 | 401 | |
402 | - //the farthest reach is rel1 |
|
403 | - $this->build_info(false); |
|
404 | - return $this->rel1_bean; |
|
402 | + //the farthest reach is rel1 |
|
403 | + $this->build_info(false); |
|
404 | + return $this->rel1_bean; |
|
405 | 405 | |
406 | 406 | //end function get_farthest_reach |
407 | 407 | } |
@@ -49,115 +49,115 @@ discard block |
||
49 | 49 | |
50 | 50 | class Relationship extends SugarBean { |
51 | 51 | |
52 | - var $object_name='Relationship'; |
|
53 | - var $module_dir = 'Relationships'; |
|
54 | - var $new_schema = true; |
|
55 | - var $table_name = 'relationships'; |
|
56 | - |
|
57 | - var $id; |
|
58 | - var $relationship_name; |
|
59 | - var $lhs_module; |
|
60 | - var $lhs_table; |
|
61 | - var $lhs_key; |
|
62 | - var $rhs_module; |
|
63 | - var $rhs_table; |
|
64 | - var $rhs_key; |
|
65 | - var $join_table; |
|
66 | - var $join_key_lhs; |
|
67 | - var $join_key_rhs; |
|
68 | - var $relationship_type; |
|
69 | - var $relationship_role_column; |
|
70 | - var $relationship_role_column_value; |
|
71 | - var $reverse; |
|
72 | - |
|
73 | - var $_self_referencing; |
|
74 | - |
|
75 | - function Relationship() { |
|
76 | - parent::SugarBean(); |
|
77 | - } |
|
78 | - |
|
79 | - /*returns true if the relationship is self referencing. equality check is performed for both table and |
|
52 | + var $object_name='Relationship'; |
|
53 | + var $module_dir = 'Relationships'; |
|
54 | + var $new_schema = true; |
|
55 | + var $table_name = 'relationships'; |
|
56 | + |
|
57 | + var $id; |
|
58 | + var $relationship_name; |
|
59 | + var $lhs_module; |
|
60 | + var $lhs_table; |
|
61 | + var $lhs_key; |
|
62 | + var $rhs_module; |
|
63 | + var $rhs_table; |
|
64 | + var $rhs_key; |
|
65 | + var $join_table; |
|
66 | + var $join_key_lhs; |
|
67 | + var $join_key_rhs; |
|
68 | + var $relationship_type; |
|
69 | + var $relationship_role_column; |
|
70 | + var $relationship_role_column_value; |
|
71 | + var $reverse; |
|
72 | + |
|
73 | + var $_self_referencing; |
|
74 | + |
|
75 | + function Relationship() { |
|
76 | + parent::SugarBean(); |
|
77 | + } |
|
78 | + |
|
79 | + /*returns true if the relationship is self referencing. equality check is performed for both table and |
|
80 | 80 | * key names. |
81 | 81 | */ |
82 | - function is_self_referencing() { |
|
83 | - if (empty($this->_self_referencing)) { |
|
84 | - $this->_self_referencing=false; |
|
82 | + function is_self_referencing() { |
|
83 | + if (empty($this->_self_referencing)) { |
|
84 | + $this->_self_referencing=false; |
|
85 | 85 | |
86 | - //is it self referencing, both table and key name from lhs and rhs should be equal. |
|
87 | - if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) { |
|
88 | - $this->_self_referencing=true; |
|
89 | - } |
|
90 | - } |
|
91 | - return $this->_self_referencing; |
|
92 | - } |
|
86 | + //is it self referencing, both table and key name from lhs and rhs should be equal. |
|
87 | + if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) { |
|
88 | + $this->_self_referencing=true; |
|
89 | + } |
|
90 | + } |
|
91 | + return $this->_self_referencing; |
|
92 | + } |
|
93 | 93 | |
94 | - /*returns true if a relationship with provided name exists*/ |
|
95 | - static function exists($relationship_name,&$db) { |
|
96 | - $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
97 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
98 | - $row = $db->fetchByAssoc($result); |
|
99 | - if ($row != null) { |
|
100 | - return true; |
|
101 | - } |
|
94 | + /*returns true if a relationship with provided name exists*/ |
|
95 | + static function exists($relationship_name,&$db) { |
|
96 | + $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
97 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
98 | + $row = $db->fetchByAssoc($result); |
|
99 | + if ($row != null) { |
|
100 | + return true; |
|
101 | + } |
|
102 | 102 | |
103 | - return false; |
|
104 | - } |
|
103 | + return false; |
|
104 | + } |
|
105 | 105 | |
106 | - static function delete($relationship_name,&$db) { |
|
106 | + static function delete($relationship_name,&$db) { |
|
107 | 107 | |
108 | - $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
109 | - $result = $db->query($query,true," Error updating relationships table for ".$relationship_name); |
|
108 | + $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
109 | + $result = $db->query($query,true," Error updating relationships table for ".$relationship_name); |
|
110 | 110 | |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - function get_other_module($relationship_name, $base_module, &$db){ |
|
115 | - //give it the relationship_name and base module |
|
116 | - //it will return the module name on the other side of the relationship |
|
114 | + function get_other_module($relationship_name, $base_module, &$db){ |
|
115 | + //give it the relationship_name and base module |
|
116 | + //it will return the module name on the other side of the relationship |
|
117 | 117 | |
118 | - $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
119 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
120 | - $row = $db->fetchByAssoc($result); |
|
121 | - if ($row != null) { |
|
118 | + $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
119 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
120 | + $row = $db->fetchByAssoc($result); |
|
121 | + if ($row != null) { |
|
122 | 122 | |
123 | - if($row['rhs_module']==$base_module){ |
|
124 | - return $row['lhs_module']; |
|
125 | - } |
|
126 | - if($row['lhs_module']==$base_module){ |
|
127 | - return $row['rhs_module']; |
|
128 | - } |
|
129 | - } |
|
123 | + if($row['rhs_module']==$base_module){ |
|
124 | + return $row['lhs_module']; |
|
125 | + } |
|
126 | + if($row['lhs_module']==$base_module){ |
|
127 | + return $row['rhs_module']; |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - return false; |
|
131 | + return false; |
|
132 | 132 | |
133 | 133 | |
134 | - //end function get_other_module |
|
135 | - } |
|
134 | + //end function get_other_module |
|
135 | + } |
|
136 | 136 | |
137 | - function retrieve_by_sides($lhs_module, $rhs_module, &$db){ |
|
138 | - //give it the relationship_name and base module |
|
139 | - //it will return the module name on the other side of the relationship |
|
137 | + function retrieve_by_sides($lhs_module, $rhs_module, &$db){ |
|
138 | + //give it the relationship_name and base module |
|
139 | + //it will return the module name on the other side of the relationship |
|
140 | 140 | |
141 | - $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'"; |
|
142 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
143 | - $row = $db->fetchByAssoc($result); |
|
144 | - if ($row != null) { |
|
141 | + $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'"; |
|
142 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
143 | + $row = $db->fetchByAssoc($result); |
|
144 | + if ($row != null) { |
|
145 | 145 | |
146 | - return $row; |
|
146 | + return $row; |
|
147 | 147 | |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | - return null; |
|
150 | + return null; |
|
151 | 151 | |
152 | 152 | |
153 | - //end function retrieve_by_sides |
|
154 | - } |
|
153 | + //end function retrieve_by_sides |
|
154 | + } |
|
155 | 155 | |
156 | - static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){ |
|
157 | - //give it the relationship_name and base module |
|
158 | - //it will return the module name on the other side of the relationship |
|
156 | + static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){ |
|
157 | + //give it the relationship_name and base module |
|
158 | + //it will return the module name on the other side of the relationship |
|
159 | 159 | |
160 | - $query = " SELECT * FROM relationships |
|
160 | + $query = " SELECT * FROM relationships |
|
161 | 161 | WHERE deleted=0 |
162 | 162 | AND ( |
163 | 163 | (lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."') |
@@ -165,113 +165,113 @@ discard block |
||
165 | 165 | (lhs_module = '".$rhs_module."' AND rhs_module = '".$lhs_module."') |
166 | 166 | ) |
167 | 167 | "; |
168 | - if(!empty($type)){ |
|
169 | - $query .= " AND relationship_type='$type'"; |
|
170 | - } |
|
171 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
172 | - $row = $db->fetchByAssoc($result); |
|
173 | - if ($row != null) { |
|
168 | + if(!empty($type)){ |
|
169 | + $query .= " AND relationship_type='$type'"; |
|
170 | + } |
|
171 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
172 | + $row = $db->fetchByAssoc($result); |
|
173 | + if ($row != null) { |
|
174 | 174 | |
175 | - return $row['relationship_name']; |
|
175 | + return $row['relationship_name']; |
|
176 | 176 | |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - return null; |
|
179 | + return null; |
|
180 | 180 | |
181 | 181 | |
182 | - //end function retrieve_by_sides |
|
183 | - } |
|
182 | + //end function retrieve_by_sides |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | - function retrieve_by_name($relationship_name) { |
|
186 | + function retrieve_by_name($relationship_name) { |
|
187 | 187 | |
188 | - if (empty($GLOBALS['relationships'])) { |
|
189 | - $this->load_relationship_meta(); |
|
190 | - } |
|
188 | + if (empty($GLOBALS['relationships'])) { |
|
189 | + $this->load_relationship_meta(); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | // _ppd($GLOBALS['relationships']); |
193 | 193 | |
194 | - if (array_key_exists($relationship_name, $GLOBALS['relationships'])) { |
|
195 | - |
|
196 | - foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
197 | - { |
|
198 | - $this->$field = $value; |
|
199 | - } |
|
200 | - } |
|
201 | - else { |
|
202 | - $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name); |
|
203 | - return false; |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - function load_relationship_meta() { |
|
208 | - if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) { |
|
209 | - $this->build_relationship_cache(); |
|
210 | - } |
|
211 | - include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only()); |
|
212 | - $GLOBALS['relationships']=$relationships; |
|
213 | - } |
|
214 | - |
|
215 | - function build_relationship_cache() { |
|
216 | - $query="SELECT * from relationships where deleted=0"; |
|
217 | - $result=$this->db->query($query); |
|
218 | - |
|
219 | - while (($row=$this->db->fetchByAssoc($result))!=null) { |
|
220 | - $relationships[$row['relationship_name']] = $row; |
|
221 | - } |
|
194 | + if (array_key_exists($relationship_name, $GLOBALS['relationships'])) { |
|
195 | + |
|
196 | + foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
197 | + { |
|
198 | + $this->$field = $value; |
|
199 | + } |
|
200 | + } |
|
201 | + else { |
|
202 | + $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name); |
|
203 | + return false; |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + function load_relationship_meta() { |
|
208 | + if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) { |
|
209 | + $this->build_relationship_cache(); |
|
210 | + } |
|
211 | + include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only()); |
|
212 | + $GLOBALS['relationships']=$relationships; |
|
213 | + } |
|
214 | + |
|
215 | + function build_relationship_cache() { |
|
216 | + $query="SELECT * from relationships where deleted=0"; |
|
217 | + $result=$this->db->query($query); |
|
218 | + |
|
219 | + while (($row=$this->db->fetchByAssoc($result))!=null) { |
|
220 | + $relationships[$row['relationship_name']] = $row; |
|
221 | + } |
|
222 | 222 | |
223 | - sugar_mkdir($this->cache_file_dir(), null, true); |
|
223 | + sugar_mkdir($this->cache_file_dir(), null, true); |
|
224 | 224 | $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";"; |
225 | 225 | sugar_file_put_contents_atomic(Relationship::cache_file_dir() . '/' . Relationship::cache_file_name_only(), $out); |
226 | 226 | |
227 | 227 | require_once("data/Relationships/RelationshipFactory.php"); |
228 | 228 | SugarRelationshipFactory::deleteCache(); |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | - public static function cache_file_dir() { |
|
233 | - return sugar_cached("modules/Relationships"); |
|
234 | - } |
|
235 | - public static function cache_file_name_only() { |
|
236 | - return 'relationships.cache.php'; |
|
237 | - } |
|
232 | + public static function cache_file_dir() { |
|
233 | + return sugar_cached("modules/Relationships"); |
|
234 | + } |
|
235 | + public static function cache_file_name_only() { |
|
236 | + return 'relationships.cache.php'; |
|
237 | + } |
|
238 | 238 | |
239 | - public static function delete_cache() { |
|
240 | - $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
241 | - if (file_exists($filename)) { |
|
242 | - unlink($filename); |
|
243 | - } |
|
239 | + public static function delete_cache() { |
|
240 | + $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
241 | + if (file_exists($filename)) { |
|
242 | + unlink($filename); |
|
243 | + } |
|
244 | 244 | require_once("data/Relationships/RelationshipFactory.php"); |
245 | 245 | SugarRelationshipFactory::deleteCache(); |
246 | - } |
|
246 | + } |
|
247 | 247 | |
248 | 248 | |
249 | - function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
|
250 | - global $beanList; |
|
251 | - global $dictionary; |
|
249 | + function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
|
250 | + global $beanList; |
|
251 | + global $dictionary; |
|
252 | 252 | |
253 | - $temp_module = get_module_info($base_module); |
|
253 | + $temp_module = get_module_info($base_module); |
|
254 | 254 | |
255 | - $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship']; |
|
256 | - $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); |
|
257 | - $rel_module1_bean = get_module_info($rel_module1); |
|
255 | + $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship']; |
|
256 | + $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); |
|
257 | + $rel_module1_bean = get_module_info($rel_module1); |
|
258 | 258 | |
259 | - if($rel_module2_name!=""){ |
|
260 | - if($rel_module2_name == 'ProjectTask'){ |
|
261 | - $rel_module2_name = strtolower($rel_module2_name); |
|
262 | - } |
|
263 | - $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; |
|
264 | - $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db); |
|
265 | - $rel_module2_bean = get_module_info($rel_module2); |
|
266 | - return $rel_module2_bean; |
|
259 | + if($rel_module2_name!=""){ |
|
260 | + if($rel_module2_name == 'ProjectTask'){ |
|
261 | + $rel_module2_name = strtolower($rel_module2_name); |
|
262 | + } |
|
263 | + $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; |
|
264 | + $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db); |
|
265 | + $rel_module2_bean = get_module_info($rel_module2); |
|
266 | + return $rel_module2_bean; |
|
267 | 267 | |
268 | - } else { |
|
269 | - //no rel_module2, so return rel_module2 bean |
|
270 | - return $rel_module1_bean; |
|
271 | - } |
|
268 | + } else { |
|
269 | + //no rel_module2, so return rel_module2 bean |
|
270 | + return $rel_module1_bean; |
|
271 | + } |
|
272 | 272 | |
273 | - //end function trace_relationship_module |
|
274 | - } |
|
273 | + //end function trace_relationship_module |
|
274 | + } |
|
275 | 275 | |
276 | 276 | |
277 | 277 |
@@ -11,21 +11,21 @@ discard block |
||
11 | 11 | |
12 | 12 | if (!empty($_REQUEST['cron'])) { |
13 | 13 | |
14 | - require_once('modules/jjwg_Maps/jjwg_Maps.php'); |
|
15 | - require_once('modules/jjwg_Maps/controller.php'); |
|
16 | - /* |
|
14 | + require_once('modules/jjwg_Maps/jjwg_Maps.php'); |
|
15 | + require_once('modules/jjwg_Maps/controller.php'); |
|
16 | + /* |
|
17 | 17 | * This script can be used as an entry point for a cron |
18 | 18 | * job to run the address geocoding on a regular basis. |
19 | 19 | * index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1&limit=2500 |
20 | 20 | */ |
21 | - $controller = new jjwg_MapsController(); |
|
22 | - $controller->action_geocode_addresses(); |
|
21 | + $controller = new jjwg_MapsController(); |
|
22 | + $controller->action_geocode_addresses(); |
|
23 | 23 | |
24 | - exit; |
|
24 | + exit; |
|
25 | 25 | |
26 | 26 | } else { |
27 | 27 | |
28 | - /* |
|
28 | + /* |
|
29 | 29 | * This script is also used to pass selected records from |
30 | 30 | * a module list view to the Maps Module (jjwg_Maps). |
31 | 31 | * |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | * 4.) Parameter Search - Checked Records - Map |
46 | 46 | * Uses 'uid'(s) parameter to define search |
47 | 47 | */ |
48 | - //echo 'Test:<pre>'."\n"; |
|
49 | - //foreach (array_keys($_REQUEST) as $key) { |
|
50 | - // echo 'Name: '.htmlspecialchars($key).' Value: '.htmlspecialchars($_REQUEST[$key])."\n"; |
|
51 | - //} |
|
48 | + //echo 'Test:<pre>'."\n"; |
|
49 | + //foreach (array_keys($_REQUEST) as $key) { |
|
50 | + // echo 'Name: '.htmlspecialchars($key).' Value: '.htmlspecialchars($_REQUEST[$key])."\n"; |
|
51 | + //} |
|
52 | 52 | |
53 | - // Redirect parameters to view/action using Javascript form post. |
|
54 | - echo '<html><head></head><body>'; |
|
55 | - echo '<form name="redirect" action="index.php" method="POST">'."\n"; |
|
56 | - echo '<input type="hidden" name="module" value="jjwg_Maps">'."\n"; |
|
57 | - echo '<input type="hidden" name="action" value="map_display">'."\n"; |
|
58 | - foreach (array_keys($_REQUEST) as $key) { |
|
53 | + // Redirect parameters to view/action using Javascript form post. |
|
54 | + echo '<html><head></head><body>'; |
|
55 | + echo '<form name="redirect" action="index.php" method="POST">'."\n"; |
|
56 | + echo '<input type="hidden" name="module" value="jjwg_Maps">'."\n"; |
|
57 | + echo '<input type="hidden" name="action" value="map_display">'."\n"; |
|
58 | + foreach (array_keys($_REQUEST) as $key) { |
|
59 | 59 | if (!in_array($key, array('action','module','entryPoint','display_module', 'quick_address'))) { |
60 | - echo '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($_REQUEST[$key]).'">'."\n"; |
|
60 | + echo '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($_REQUEST[$key]).'">'."\n"; |
|
61 | 61 | } |
62 | - } |
|
63 | - echo '<input type="hidden" name="display_module" value="'.htmlspecialchars($_REQUEST['display_module']).'">'."\n"; |
|
64 | - echo '</form>'."\n"; |
|
65 | - echo '<script language="javascript" type="text/javascript">document.redirect.submit();</script>'."\n"; |
|
66 | - echo '</body></html>'; |
|
62 | + } |
|
63 | + echo '<input type="hidden" name="display_module" value="'.htmlspecialchars($_REQUEST['display_module']).'">'."\n"; |
|
64 | + echo '</form>'."\n"; |
|
65 | + echo '<script language="javascript" type="text/javascript">document.redirect.submit();</script>'."\n"; |
|
66 | + echo '</body></html>'; |
|
67 | 67 | |
68 | - exit; |
|
68 | + exit; |
|
69 | 69 | } |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | class Jjwg_MapsViewGeocoding_Test extends SugarView { |
6 | 6 | |
7 | - function Jjwg_MapsViewGeocoding_Test() { |
|
8 | - parent::SugarView(); |
|
9 | - } |
|
7 | + function Jjwg_MapsViewGeocoding_Test() { |
|
8 | + parent::SugarView(); |
|
9 | + } |
|
10 | 10 | |
11 | - function display() { |
|
11 | + function display() { |
|
12 | 12 | |
13 | 13 | if (!isset($_REQUEST['geocoding_address'])) $_REQUEST['geocoding_address'] = ''; |
14 | 14 | ?> |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | <?php |
31 | 31 | if (!empty($_REQUEST['process_trigger'])) { |
32 | 32 | |
33 | - echo '<br /><br /><pre>'; |
|
34 | - print_r($this->bean->geocoding_results); |
|
35 | - echo '</pre><br /><br />'; |
|
33 | + echo '<br /><br /><pre>'; |
|
34 | + print_r($this->bean->geocoding_results); |
|
35 | + echo '</pre><br /><br />'; |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | - } |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | ?> |
43 | 43 | \ No newline at end of file |
@@ -4,18 +4,18 @@ discard block |
||
4 | 4 | |
5 | 5 | class Jjwg_MapsViewQuick_Radius_Display extends SugarView { |
6 | 6 | |
7 | - function Jjwg_MapsViewQuick_Radius_Display() { |
|
7 | + function Jjwg_MapsViewQuick_Radius_Display() { |
|
8 | 8 | parent::SugarView(); |
9 | - } |
|
9 | + } |
|
10 | 10 | |
11 | - function display() { |
|
11 | + function display() { |
|
12 | 12 | |
13 | 13 | $url = 'index.php?module='.$GLOBALS['currentModule'].'&action=map_markers'; |
14 | 14 | foreach (array_keys($_REQUEST) as $key) { |
15 | - // Exclude certain request parameters |
|
16 | - if (!in_array($key, array('action', 'module', 'entryPoint', 'record', 'relate_id'))) { |
|
15 | + // Exclude certain request parameters |
|
16 | + if (!in_array($key, array('action', 'module', 'entryPoint', 'record', 'relate_id'))) { |
|
17 | 17 | $url .= '&'.$key.'='.urlencode($_REQUEST[$key]); |
18 | - } |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | ?> |
@@ -30,5 +30,5 @@ discard block |
||
30 | 30 | |
31 | 31 | <?php |
32 | 32 | |
33 | - } |
|
33 | + } |
|
34 | 34 | } |
@@ -4,18 +4,18 @@ discard block |
||
4 | 4 | |
5 | 5 | class Jjwg_MapsViewMap_Display extends SugarView { |
6 | 6 | |
7 | - function Jjwg_MapsViewMap_Display() { |
|
7 | + function Jjwg_MapsViewMap_Display() { |
|
8 | 8 | parent::SugarView(); |
9 | - } |
|
9 | + } |
|
10 | 10 | |
11 | - function display() { |
|
11 | + function display() { |
|
12 | 12 | // Limit URI query string parameters. Used to avoid URL length errors. |
13 | 13 | $valid_names = array('action', 'module', 'entryPoint', 'submit', 'cron', 'geocoding_process', 'process_trigger', 'distance', 'unit_type', 'record', 'related_id', 'related_module', 'quick_address', 'display_module', 'list_id', 'uid', 'current_post'); |
14 | 14 | $url = $GLOBALS['sugar_config']['site_url'] . '/index.php?module=' . $GLOBALS['currentModule'] . '&action=map_markers'; |
15 | 15 | foreach (array_keys($_REQUEST) as $key) { |
16 | - if (in_array($key, $valid_names) && !in_array($key, array('action', 'module', 'entryPoint'))) { |
|
16 | + if (in_array($key, $valid_names) && !in_array($key, array('action', 'module', 'entryPoint'))) { |
|
17 | 17 | $url .= '&'.$key.'='.urlencode($_REQUEST[$key]); |
18 | - } |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | ?> |
@@ -76,5 +76,5 @@ discard block |
||
76 | 76 | |
77 | 77 | <?php |
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | } |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | class Jjwg_MapsViewDonate extends SugarView { |
6 | 6 | |
7 | - function Jjwg_MapsViewDonate() { |
|
8 | - parent::SugarView(); |
|
9 | - } |
|
7 | + function Jjwg_MapsViewDonate() { |
|
8 | + parent::SugarView(); |
|
9 | + } |
|
10 | 10 | |
11 | - function display() { |
|
11 | + function display() { |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
@@ -75,6 +75,6 @@ discard block |
||
75 | 75 | |
76 | 76 | <?php |
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | class Jjwg_MapsViewMap_Markers extends SugarView { |
6 | 6 | |
7 | - function Jjwg_MapsViewMap_Markers() { |
|
7 | + function Jjwg_MapsViewMap_Markers() { |
|
8 | 8 | parent::SugarView(); |
9 | - } |
|
9 | + } |
|
10 | 10 | |
11 | - function display() { |
|
11 | + function display() { |
|
12 | 12 | |
13 | 13 | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
14 | 14 | |
@@ -125,22 +125,22 @@ discard block |
||
125 | 125 | // Define Dir of Group Icons |
126 | 126 | $icons_dir_base = 'custom/themes/default/images/jjwg_Maps/'; |
127 | 127 | if ($num_groups <= 10) { |
128 | - $icons_dir = $icons_dir_base.'0-10/'; |
|
128 | + $icons_dir = $icons_dir_base.'0-10/'; |
|
129 | 129 | } elseif ($num_groups <= 25) { |
130 | - $icons_dir = $icons_dir_base.'0-25/'; |
|
130 | + $icons_dir = $icons_dir_base.'0-25/'; |
|
131 | 131 | } elseif ($num_groups <= 100) { |
132 | - $icons_dir = $icons_dir_base.'0-100/'; |
|
132 | + $icons_dir = $icons_dir_base.'0-100/'; |
|
133 | 133 | } elseif ($num_groups <= 216) { |
134 | - $icons_dir = $icons_dir_base.'0-216/'; |
|
134 | + $icons_dir = $icons_dir_base.'0-216/'; |
|
135 | 135 | } else { |
136 | - $icons_dir = $icons_dir_base.'0-10/'; // Demo Version |
|
136 | + $icons_dir = $icons_dir_base.'0-10/'; // Demo Version |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | // Define Custom Markers Dir and Common Icons |
140 | 140 | $custom_markers_dir = 'custom/themes/default/images/jjwg_Markers/'; |
141 | 141 | $custom_markers_icons = array(); |
142 | 142 | foreach($this->bean->custom_markers as $marker) { |
143 | - $custom_markers_icons[] = $marker['image']; |
|
143 | + $custom_markers_icons[] = $marker['image']; |
|
144 | 144 | } |
145 | 145 | $num_custom_markers = count($this->bean->custom_markers); |
146 | 146 | $custom_markers_icons = array_unique($custom_markers_icons); |
@@ -890,21 +890,21 @@ discard block |
||
890 | 890 | <br clear="all" /> |
891 | 891 | |
892 | 892 | <?php |
893 | - if (!empty($this->bean->map_center) || $num_markers > 0) { |
|
893 | + if (!empty($this->bean->map_center) || $num_markers > 0) { |
|
894 | 894 | ?> |
895 | 895 | <div id="legend"> |
896 | 896 | <b><?php echo $GLOBALS['mod_strings']['LBL_MAP_LEGEND']; ?></b><br/> |
897 | 897 | <?php |
898 | - if (!empty($this->bean->map_center)) { |
|
898 | + if (!empty($this->bean->map_center)) { |
|
899 | 899 | ?> |
900 | 900 | <img src="<?php echo './'.$icons_dir.'/marker_0.png'; ?>" align="middle" /> |
901 | 901 | <?php echo $this->bean->map_center['name']; ?><br/> |
902 | 902 | <?php |
903 | - } |
|
903 | + } |
|
904 | 904 | ?> |
905 | 905 | <!-- <b><?php echo $GLOBALS['mod_strings']['LBL_MAP_USER_GROUPS']; ?> </b><br/> --> |
906 | 906 | <?php |
907 | - foreach($group_name_to_num as $group_name => $group_number) { |
|
907 | + foreach($group_name_to_num as $group_name => $group_number) { |
|
908 | 908 | ?> |
909 | 909 | <img src="<?php echo './'.$icons_dir.'/marker_'.$group_number.'.png'; ?>" |
910 | 910 | rel="<?php echo $group_number; ?>" align="middle" /> |
@@ -916,15 +916,15 @@ discard block |
||
916 | 916 | } |
917 | 917 | ?><br/> |
918 | 918 | <?php |
919 | - } |
|
919 | + } |
|
920 | 920 | ?> |
921 | 921 | </div> |
922 | 922 | <?php |
923 | - } |
|
923 | + } |
|
924 | 924 | ?> |
925 | 925 | |
926 | 926 | <?php |
927 | - if ($num_markers > 0) { |
|
927 | + if ($num_markers > 0) { |
|
928 | 928 | ?> |
929 | 929 | <div id="DataTable"> |
930 | 930 | <table cellpadding="3" cellspacing="0" border="1" width="100%" class="list view" id="displayDataTable"> |
@@ -947,11 +947,11 @@ discard block |
||
947 | 947 | </table> |
948 | 948 | </div> |
949 | 949 | <?php |
950 | - } |
|
950 | + } |
|
951 | 951 | ?> |
952 | 952 | |
953 | 953 | <?php |
954 | - if (in_array($this->bean->display_object->module_name, array('Accounts', 'Contacts', 'Leads', 'Prospects', 'Users')) && |
|
954 | + if (in_array($this->bean->display_object->module_name, array('Accounts', 'Contacts', 'Leads', 'Prospects', 'Users')) && |
|
955 | 955 | ($GLOBALS['current_user']->isAdmin() || $this->bean->ACLAccess('list')) && |
956 | 956 | empty($_REQUEST['list_id']) && !empty($this->bean->list_array)) { |
957 | 957 | ?> |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | </form> |
973 | 973 | </div> |
974 | 974 | <?php |
975 | - } |
|
975 | + } |
|
976 | 976 | ?> |
977 | 977 | |
978 | 978 | </body> |
@@ -992,5 +992,5 @@ discard block |
||
992 | 992 | </html> |
993 | 993 | <?php |
994 | 994 | |
995 | - } |
|
995 | + } |
|
996 | 996 | } |