@@ -177,7 +177,7 @@ |
||
177 | 177 | /** |
178 | 178 | * Customize automatically generated filter fields |
179 | 179 | */ |
180 | - public function get_filter_fields(Array &$filters) |
|
180 | + public function get_filter_fields(array &$filters) |
|
181 | 181 | { |
182 | 182 | // In resources, not all categories are used |
183 | 183 | $filters['cat_id']['type'] = 'select'; |
@@ -199,9 +199,9 @@ |
||
199 | 199 | * Get selectbox values |
200 | 200 | */ |
201 | 201 | protected function get_selects() |
202 | - { |
|
202 | + { |
|
203 | 203 | $this->selects = array(); |
204 | - } |
|
204 | + } |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Customize automatically generated filter fields |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param egw_record $_definition |
34 | 34 | */ |
35 | - public function export( $_stream, importexport_definition $_definition) |
|
35 | + public function export($_stream, importexport_definition $_definition) |
|
36 | 36 | { |
37 | 37 | $options = $_definition->plugin_options; |
38 | 38 | |
@@ -41,50 +41,50 @@ discard block |
||
41 | 41 | { |
42 | 42 | // ui selection with checkbox 'selected' |
43 | 43 | $query = Api\Cache::getSession('resources', 'get_rows'); |
44 | - $query['num_rows'] = -1; // all |
|
44 | + $query['num_rows'] = -1; // all |
|
45 | 45 | unset($query['store_state']); |
46 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
47 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
46 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
47 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
48 | 48 | } |
49 | - elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') |
|
49 | + elseif ($options['selection'] == 'all' || $options['selection'] == 'filter') |
|
50 | 50 | { |
51 | 51 | $query = array( |
52 | 52 | 'num_rows' => -1, |
53 | - 'filter2' => -3, // Accessories & resources |
|
54 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
55 | - ); // all |
|
53 | + 'filter2' => -3, // Accessories & resources |
|
54 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
55 | + ); // all |
|
56 | 56 | |
57 | - if($options['selection'] == 'filter') |
|
57 | + if ($options['selection'] == 'filter') |
|
58 | 58 | { |
59 | 59 | $filter = $_definition->filter; |
60 | 60 | // Handle ranges |
61 | - foreach($filter as $field => $value) |
|
61 | + foreach ($filter as $field => $value) |
|
62 | 62 | { |
63 | - if($field == 'cat_id') |
|
63 | + if ($field == 'cat_id') |
|
64 | 64 | { |
65 | 65 | $query['filter'] = $value; |
66 | 66 | continue; |
67 | 67 | } |
68 | - if($field == 'filter2') |
|
68 | + if ($field == 'filter2') |
|
69 | 69 | { |
70 | 70 | $query['filter2'] = $value; |
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | $query['col_filter'][$field] = $value; |
74 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
74 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
75 | 75 | |
76 | 76 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
77 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
78 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
77 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
78 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
79 | 79 | unset($query['col_filter'][$field]); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
83 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
84 | 84 | } |
85 | 85 | else |
86 | 86 | { |
87 | - $selection = explode(',',$options['selection']); |
|
87 | + $selection = explode(',', $options['selection']); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | // Check if we need to load the custom fields |
94 | 94 | $need_custom = false; |
95 | - foreach(Api\Storage\Customfields::get('resources') as $field => $settings) |
|
95 | + foreach (Api\Storage\Customfields::get('resources') as $field => $settings) |
|
96 | 96 | { |
97 | - if($options['mapping']['#'.$field]) |
|
97 | + if ($options['mapping']['#'.$field]) |
|
98 | 98 | { |
99 | 99 | $need_custom = true; |
100 | 100 | break; |
@@ -103,25 +103,25 @@ discard block |
||
103 | 103 | |
104 | 104 | foreach ($selection as $record) |
105 | 105 | { |
106 | - if(!is_array($record) || !$record['res_id']) continue; |
|
106 | + if (!is_array($record) || !$record['res_id']) continue; |
|
107 | 107 | |
108 | - if($need_custom) |
|
108 | + if ($need_custom) |
|
109 | 109 | { |
110 | 110 | $record = $this->bo->read($record['res_id']); |
111 | 111 | } |
112 | 112 | $resource = new resources_egw_record(); |
113 | 113 | $resource->set_record($record); |
114 | 114 | $resource->long_description = strip_tags($resource->long_description); |
115 | - if($options['convert']) |
|
115 | + if ($options['convert']) |
|
116 | 116 | { |
117 | 117 | importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects); |
118 | 118 | } |
119 | 119 | else |
120 | 120 | { |
121 | 121 | // Implode arrays, so they don't say 'Array' |
122 | - foreach($resource->get_record_array() as $key => $value) |
|
122 | + foreach ($resource->get_record_array() as $key => $value) |
|
123 | 123 | { |
124 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
124 | + if (is_array($value)) $resource->$key = implode(',', $value); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // In resources, not all categories are used |
212 | 212 | $filters['cat_id']['type'] = 'select'; |
213 | 213 | $filters['cat_id']['name'] = 'filter'; |
214 | - $filters['cat_id']['values']= (array)$this->bo->acl->get_cats(Acl::READ); |
|
214 | + $filters['cat_id']['values'] = (array)$this->bo->acl->get_cats(Acl::READ); |
|
215 | 215 | |
216 | 216 | // Add in resources / accessories |
217 | 217 | $filters['filter2'] = array( |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | 'rows' => 5, |
222 | 222 | 'values' => resources_bo::$filter_options |
223 | 223 | ); |
224 | - foreach($filters as $field_name => &$settings) |
|
224 | + foreach ($filters as $field_name => &$settings) |
|
225 | 225 | { |
226 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
226 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 |
@@ -71,11 +71,20 @@ discard block |
||
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | $query['col_filter'][$field] = $value; |
74 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
74 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
75 | + { |
|
76 | + continue; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
77 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
78 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
80 | + if($value['from']) |
|
81 | + { |
|
82 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
83 | + } |
|
84 | + if($value['to']) |
|
85 | + { |
|
86 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
87 | + } |
|
79 | 88 | unset($query['col_filter'][$field]); |
80 | 89 | } |
81 | 90 | } |
@@ -103,7 +112,10 @@ discard block |
||
103 | 112 | |
104 | 113 | foreach ($selection as $record) |
105 | 114 | { |
106 | - if(!is_array($record) || !$record['res_id']) continue; |
|
115 | + if(!is_array($record) || !$record['res_id']) |
|
116 | + { |
|
117 | + continue; |
|
118 | + } |
|
107 | 119 | |
108 | 120 | if($need_custom) |
109 | 121 | { |
@@ -121,7 +133,10 @@ discard block |
||
121 | 133 | // Implode arrays, so they don't say 'Array' |
122 | 134 | foreach($resource->get_record_array() as $key => $value) |
123 | 135 | { |
124 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
136 | + if(is_array($value)) |
|
137 | + { |
|
138 | + $resource->$key = implode(',', $value); |
|
139 | + } |
|
125 | 140 | } |
126 | 141 | } |
127 | 142 | |
@@ -199,7 +214,7 @@ discard block |
||
199 | 214 | * Get selectbox values |
200 | 215 | */ |
201 | 216 | protected function get_selects() |
202 | - { |
|
217 | + { |
|
203 | 218 | $this->selects = array(); |
204 | 219 | } |
205 | 220 | |
@@ -223,7 +238,10 @@ discard block |
||
223 | 238 | ); |
224 | 239 | foreach($filters as $field_name => &$settings) |
225 | 240 | { |
226 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
241 | + if($this->selects[$field_name]) |
|
242 | + { |
|
243 | + $settings['values'] = $this->selects[$field_name]; |
|
244 | + } |
|
227 | 245 | } |
228 | 246 | } |
229 | 247 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Exports records as defined in $_definition |
25 | 25 | * |
26 | - * @param egw_record $_definition |
|
26 | + * @param importexport_definition $_definition |
|
27 | 27 | */ |
28 | 28 | public function export( $_stream, importexport_definition $_definition) |
29 | 29 | { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param $definition Specific definition |
146 | 146 | * |
147 | - * @return array ( |
|
147 | + * @return boolean ( |
|
148 | 148 | * name => string, |
149 | 149 | * content => array, |
150 | 150 | * sel_options => array, |
@@ -76,9 +76,12 @@ |
||
76 | 76 | |
77 | 77 | // This is just copy+pasted from resources_ui line 816, but we don't want |
78 | 78 | // the etemplate exec to fire again. |
79 | - if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
79 | + if (is_array($content) && isset($content['nm']['rows']['document'])) |
|
80 | + { |
|
81 | + // handle insert in default document button like an action |
|
80 | 82 | { |
81 | 83 | list($id) = @each($content['nm']['rows']['document']); |
84 | + } |
|
82 | 85 | $content['nm']['action'] = 'document'; |
83 | 86 | $content['nm']['selected'] = array($id); |
84 | 87 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * Construct the portlet |
24 | 24 | * |
25 | 25 | */ |
26 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
26 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
27 | 27 | { |
28 | 28 | $context['appname'] = 'resources'; |
29 | 29 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $context['appname'] = 'resources'; |
29 | 29 | |
30 | 30 | // Let parent handle the basic stuff |
31 | - parent::__construct($context,$need_reload); |
|
31 | + parent::__construct($context, $need_reload); |
|
32 | 32 | |
33 | 33 | $this->context['template'] = 'resources.show.rows'; |
34 | 34 | $this->nm_settings += array( |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | { |
53 | 53 | $ui = new resources_ui(); |
54 | 54 | |
55 | - $this->context['sel_options']['filter']= array(''=>lang('all categories'))+(array)$ui->bo->acl->get_cats(Acl::READ); |
|
55 | + $this->context['sel_options']['filter'] = array(''=>lang('all categories')) + (array)$ui->bo->acl->get_cats(Acl::READ); |
|
56 | 56 | $this->context['sel_options']['filter2'] = resources_bo::$filter_options; |
57 | - if(!$content['nm']['filter2']) |
|
57 | + if (!$content['nm']['filter2']) |
|
58 | 58 | { |
59 | 59 | $content['nm']['filter2'] = key(resources_bo::$filter_options); |
60 | 60 | } |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | if (!count($content['nm']['selected']) && !$content['nm']['select_all']) |
93 | 93 | { |
94 | 94 | $msg = lang('You need to select some entries first!'); |
95 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
95 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
99 | 99 | $success = $failed = $action_msg = null; |
100 | - if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
101 | - $success,$failed,$action_msg,'index',$msg)) |
|
100 | + if ($ui->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
101 | + $success, $failed, $action_msg, 'index', $msg)) |
|
102 | 102 | { |
103 | - $msg .= lang('%1 resource(s) %2',$success,$action_msg); |
|
103 | + $msg .= lang('%1 resource(s) %2', $success, $action_msg); |
|
104 | 104 | |
105 | - Api\Json\Response::get()->apply('egw.message',array($msg,'success')); |
|
106 | - foreach($content['nm']['selected'] as &$id) |
|
105 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'success')); |
|
106 | + foreach ($content['nm']['selected'] as &$id) |
|
107 | 107 | { |
108 | 108 | $id = 'resources::'.$id; |
109 | 109 | } |
110 | 110 | // Directly request an update - this will get resources tab too |
111 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); |
|
111 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected'])); |
|
112 | 112 | } |
113 | - elseif(empty($msg)) |
|
113 | + elseif (empty($msg)) |
|
114 | 114 | { |
115 | - $msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
116 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
115 | + $msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
116 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -572,7 +572,7 @@ |
||
572 | 572 | * @param array $options Array of options for the search |
573 | 573 | * |
574 | 574 | */ |
575 | - function link_query( $pattern, Array &$options = array() ) |
|
575 | + function link_query( $pattern, array &$options = array() ) |
|
576 | 576 | { |
577 | 577 | if (is_array($pattern)) |
578 | 578 | { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Constructor |
81 | 81 | * |
82 | - * @param int $user=null account_id of user to use for Acl, default current user |
|
82 | + * @param integer $user |
|
83 | 83 | */ |
84 | 84 | function __construct($user=null) |
85 | 85 | { |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | /** |
682 | 682 | * @author Cornelius Weiss <[email protected]> |
683 | 683 | * query infolog for entries matching $pattern |
684 | - * @param string|array $pattern if it's a string it is the string we will search for as a criteria, if it's an array we |
|
684 | + * @param string $pattern if it's a string it is the string we will search for as a criteria, if it's an array we |
|
685 | 685 | * will seach for 'search' key in this array to get the string criteria. others keys handled are actually used |
686 | 686 | * for calendar disponibility. |
687 | 687 | * @param array $options Array of options for the search |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | * Cornelius Weiss <[email protected]> |
896 | 896 | * @param array $file array with key => value |
897 | 897 | * @param int $resource_id |
898 | - * @return mixed string with msg if somthing went wrong; nothing if all right |
|
898 | + * @return string|null string with msg if somthing went wrong; nothing if all right |
|
899 | 899 | */ |
900 | 900 | function save_picture($file,$resource_id) |
901 | 901 | { |
@@ -105,9 +105,12 @@ discard block |
||
105 | 105 | { |
106 | 106 | Api\Cache::setSession('resources', 'index_nm', $query); |
107 | 107 | } |
108 | - if ($query['store_state']) // request to store state in session and filter in prefs? |
|
108 | + if ($query['store_state']) |
|
109 | + { |
|
110 | + // request to store state in session and filter in prefs? |
|
109 | 111 | { |
110 | 112 | Api\Cache::setSession('resources',$query['store_state'],$query); |
113 | + } |
|
111 | 114 | //echo "<p>".__METHOD__."() query[filter]=$query[filter], prefs[resources][filter]={$GLOBALS['egw_info']['user']['preferences']['resources']['filter']}</p>\n"; |
112 | 115 | if ($query['filter'] != $GLOBALS['egw_info']['user']['preferences']['resources']['filter']) |
113 | 116 | { |
@@ -115,7 +118,10 @@ discard block |
||
115 | 118 | $GLOBALS['egw']->preferences->save_repository(); |
116 | 119 | } |
117 | 120 | } |
118 | - if ($this->debug) _debug_array($query); |
|
121 | + if ($this->debug) |
|
122 | + { |
|
123 | + _debug_array($query); |
|
124 | + } |
|
119 | 125 | $read_onlys = 'res_id,name,short_description,quantity,useable,bookable,buyable,cat_id,location,storage_info'; |
120 | 126 | |
121 | 127 | $filter = array(); |
@@ -172,7 +178,8 @@ discard block |
||
172 | 178 | $filter['cat_id'] = array_keys($readcats); |
173 | 179 | } |
174 | 180 | // if there is no catfilter -> this means you have no rights, so set the cat filter to null |
175 | - if (!isset($filter['cat_id']) || empty($filter['cat_id'])) { |
|
181 | + if (!isset($filter['cat_id']) || empty($filter['cat_id'])) |
|
182 | + { |
|
176 | 183 | $filter['cat_id'] = NUll; |
177 | 184 | } |
178 | 185 | |
@@ -183,7 +190,10 @@ discard block |
||
183 | 190 | $order_by = $query['order'] ? $query['order'].' '. $query['sort'] : ''; |
184 | 191 | $start = (int)$query['start']; |
185 | 192 | |
186 | - foreach ($filter as $k => $v) $query['col_filter'][$k] = $v; |
|
193 | + foreach ($filter as $k => $v) |
|
194 | + { |
|
195 | + $query['col_filter'][$k] = $v; |
|
196 | + } |
|
187 | 197 | $this->so->get_rows($query, $rows, $readonlys, $join, false, false, $extra_cols); |
188 | 198 | $nr = $this->so->total; |
189 | 199 | |
@@ -212,8 +222,7 @@ discard block |
||
212 | 222 | } |
213 | 223 | if (!$this->acl->is_permitted($resource['cat_id'],Acl::DELETE) || |
214 | 224 | ($resource['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history') |
215 | - ) |
|
216 | - { |
|
225 | + ) { |
|
217 | 226 | $readonlys["delete[$resource[res_id]]"] = true; |
218 | 227 | $resource['class'] .= 'no_delete '; |
219 | 228 | } |
@@ -251,7 +260,9 @@ discard block |
||
251 | 260 | { |
252 | 261 | $resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id)); |
253 | 262 | } |
254 | - } elseif ($resource['accessory_of'] > 0) { |
|
263 | + } |
|
264 | + elseif ($resource['accessory_of'] > 0) |
|
265 | + { |
|
255 | 266 | $resource['accessory_of_label'] = $this->link_title($resource['accessory_of']); |
256 | 267 | } |
257 | 268 | |
@@ -505,13 +516,19 @@ discard block |
||
505 | 516 | */ |
506 | 517 | function get_acc_list($res_id,$deleted=false) |
507 | 518 | { |
508 | - if($res_id < 1){return;} |
|
519 | + if($res_id < 1) |
|
520 | + { |
|
521 | +return;} |
|
509 | 522 | $data = $this->so->search('','res_id,name,deleted','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true); |
510 | 523 | $acc_list = array(); |
511 | - if($data) { |
|
524 | + if($data) |
|
525 | + { |
|
512 | 526 | foreach($data as $num => $resource) |
513 | 527 | { |
514 | - if($resource['deleted'] && !$deleted) continue; |
|
528 | + if($resource['deleted'] && !$deleted) |
|
529 | + { |
|
530 | + continue; |
|
531 | + } |
|
515 | 532 | $acc_list[$resource['res_id']] = $resource['name']; |
516 | 533 | } |
517 | 534 | } |
@@ -560,7 +577,9 @@ discard block |
||
560 | 577 | if(count($resources) && !$options['exec']) |
561 | 578 | { |
562 | 579 | $_resources = array_map( |
563 | - function($id) { return 'r'.$id;}, |
|
580 | + function($id) |
|
581 | + { |
|
582 | +return 'r'.$id;}, |
|
564 | 583 | array_keys($resources) |
565 | 584 | ); |
566 | 585 | $list['cat-'.$cat_id] = array( |
@@ -571,7 +590,13 @@ discard block |
||
571 | 590 | else if ($resources && $options['exec']) |
572 | 591 | { |
573 | 592 | array_map( |
574 | - function($id,$name) use (&$list) { if(!$list[''.$id]) $list[''.$id] = $name;}, |
|
593 | + function($id,$name) use (&$list) |
|
594 | + { |
|
595 | +if(!$list[''.$id]) |
|
596 | + { |
|
597 | + $list[''.$id] = $name; |
|
598 | + } |
|
599 | + }, |
|
575 | 600 | array_keys($resources), $resources |
576 | 601 | ); |
577 | 602 | } |
@@ -630,13 +655,18 @@ discard block |
||
630 | 655 | 'name' => $this->acl->get_cat_name($cat_id), |
631 | 656 | 'rights' => $this->acl->get_permissions($cat_id), |
632 | 657 | 'resources' => array_map( |
633 | - function($id) { return 'r'.$id;}, |
|
658 | + function($id) |
|
659 | + { |
|
660 | +return 'r'.$id;}, |
|
634 | 661 | array_keys($this->get_resources_by_category($cat_id)) |
635 | 662 | ) |
636 | 663 | )); |
637 | 664 | } |
638 | 665 | |
639 | - if(!is_array($res_id) && $res_id < 1) return; |
|
666 | + if(!is_array($res_id) && $res_id < 1) |
|
667 | + { |
|
668 | + return; |
|
669 | + } |
|
640 | 670 | |
641 | 671 | $data = $this->so->search(array('res_id' => $res_id),self::TITLE_COLS.',useable'); |
642 | 672 | if (!is_array($data)) |
@@ -712,7 +742,8 @@ discard block |
||
712 | 742 | 'deleted' => null |
713 | 743 | ); |
714 | 744 | $limit = false; |
715 | - if($options['start'] || $options['num_rows']) { |
|
745 | + if($options['start'] || $options['num_rows']) |
|
746 | + { |
|
716 | 747 | $limit = array($options['start'], $options['num_rows']); |
717 | 748 | } |
718 | 749 | if($options['cat_id'] && in_array($options['cat_id'], $filter['cat_id'])) |
@@ -741,11 +772,14 @@ discard block |
||
741 | 772 | } |
742 | 773 | $start = new Api\DateTime($cal_info['start']); |
743 | 774 | $startarr= getdate($start->format('ts')); |
744 | - if (isset($cal_info['whole_day']) && $cal_info['whole_day']) { |
|
775 | + if (isset($cal_info['whole_day']) && $cal_info['whole_day']) |
|
776 | + { |
|
745 | 777 | $startarr['hour'] = $startarr['minute'] = 0; |
746 | 778 | $start = new Api\DateTime($startarr); |
747 | 779 | $end = $start->format('ts') + 86399; |
748 | - } else { |
|
780 | + } |
|
781 | + else |
|
782 | + { |
|
749 | 783 | $start = $start->format('ts'); |
750 | 784 | $end = $start + ($cal_info['duration']); |
751 | 785 | } |
@@ -757,7 +791,8 @@ discard block |
||
757 | 791 | // we only need resources id for the search, but with a 'r' prefix |
758 | 792 | // now we take this loop to store a new resource array indexed with resource id |
759 | 793 | // and as we work for calendar we use only bookable resources |
760 | - if ((isset($resource['bookable'])) && ($resource['bookable'])){ |
|
794 | + if ((isset($resource['bookable'])) && ($resource['bookable'])) |
|
795 | + { |
|
761 | 796 | $res_info_cache[$resource['res_id']]=$resource; |
762 | 797 | $resource_list[]='r'.$resource['res_id']; |
763 | 798 | } |
@@ -773,22 +808,34 @@ discard block |
||
773 | 808 | // parse theses overlapping events |
774 | 809 | foreach($overlapping_events as $event) |
775 | 810 | { |
776 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
777 | - if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) { |
|
811 | + if ($event['non_blocking']) |
|
812 | + { |
|
813 | + continue; |
|
814 | + } |
|
815 | + // ignore non_blocking events |
|
816 | + if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) |
|
817 | + { |
|
778 | 818 | continue; //ignore this event, it's the current edited event, no conflict by def |
779 | 819 | } |
780 | 820 | // now we are interested only on resources booked by theses events |
781 | - if (isset($event['participants']) && is_array($event['participants'])){ |
|
782 | - foreach($event['participants'] as $part_key => $part_detail){ |
|
821 | + if (isset($event['participants']) && is_array($event['participants'])) |
|
822 | + { |
|
823 | + foreach($event['participants'] as $part_key => $part_detail) |
|
824 | + { |
|
783 | 825 | if ($part_key{0}=='r') |
784 | - { //now we gatta resource here |
|
826 | + { |
|
827 | +//now we gatta resource here |
|
785 | 828 | //need to check the quantity of this resource |
786 | 829 | $resource_id=substr($part_key,1); |
787 | 830 | // if we do not find this resource in our indexed array it's certainly |
788 | 831 | // because it was unset, non bookable maybe |
789 | - if (!isset($res_info_cache[$resource_id])) continue; |
|
832 | + if (!isset($res_info_cache[$resource_id])) |
|
833 | + { |
|
834 | + continue; |
|
835 | + } |
|
790 | 836 | // to detect ressources with default to 1 quantity |
791 | - if (!isset($res_info_cache[$resource_id]['useable'])) { |
|
837 | + if (!isset($res_info_cache[$resource_id]['useable'])) |
|
838 | + { |
|
792 | 839 | $res_info_cache[$resource_id]['useable'] = 1; |
793 | 840 | } |
794 | 841 | // now decrement this quantity useable |
@@ -802,11 +849,13 @@ discard block |
||
802 | 849 | } |
803 | 850 | } |
804 | 851 | } |
805 | - if (isset($res_info_cache)) { |
|
852 | + if (isset($res_info_cache)) |
|
853 | + { |
|
806 | 854 | $show_conflict= $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] !== 'resources_without_conflict'; |
807 | 855 | // if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar |
808 | 856 | // so we'll loop on this one and not $data |
809 | - foreach($res_info_cache as $id => $resource) { |
|
857 | + foreach($res_info_cache as $id => $resource) |
|
858 | + { |
|
810 | 859 | //maybe this resource is reserved |
811 | 860 | if ( ($resource['useable'] < 1) ) |
812 | 861 | { |
@@ -821,15 +870,20 @@ discard block |
||
821 | 870 | ($resource['useable'] > 1 ? " ( {$resource['useable']} / {$resource['quantity']} )" : ''); |
822 | 871 | } |
823 | 872 | } |
824 | - } else { |
|
873 | + } |
|
874 | + else |
|
875 | + { |
|
825 | 876 | // we are not working for the calendar, we loop on the initial $data |
826 | - if (is_array($data)) { |
|
877 | + if (is_array($data)) |
|
878 | + { |
|
827 | 879 | foreach($data as $num => $resource) |
828 | 880 | { |
829 | 881 | $id=$resource['res_id']; |
830 | 882 | $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
831 | 883 | } |
832 | - } else { |
|
884 | + } |
|
885 | + else |
|
886 | + { |
|
833 | 887 | error_log(__METHOD__." No Data found for Resource with id ".$resource['res_id']); |
834 | 888 | } |
835 | 889 | } |
@@ -848,7 +902,10 @@ discard block |
||
848 | 902 | { |
849 | 903 | if (!is_array($resource)) |
850 | 904 | { |
851 | - if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
905 | + if (!($resource = $this->read(array('res_id' => $resource)))) |
|
906 | + { |
|
907 | + return $resource; |
|
908 | + } |
|
852 | 909 | } |
853 | 910 | elseif (!$this->acl->is_permitted($resource['cat_id'],Acl::READ)) |
854 | 911 | { |
@@ -943,7 +1000,10 @@ discard block |
||
943 | 1000 | */ |
944 | 1001 | function get_picture($resource,$fullsize=false) |
945 | 1002 | { |
946 | - if ($resource && !is_array($resource)) $resource = $this->read($resource); |
|
1003 | + if ($resource && !is_array($resource)) |
|
1004 | + { |
|
1005 | + $resource = $this->read($resource); |
|
1006 | + } |
|
947 | 1007 | |
948 | 1008 | switch($resource['picture_src']) |
949 | 1009 | { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @param int $user=null account_id of user to use for Acl, default current user |
83 | 83 | */ |
84 | - function __construct($user=null) |
|
84 | + function __construct($user = null) |
|
85 | 85 | { |
86 | 86 | $this->so = new resources_so(); |
87 | 87 | $this->acl = new resources_acl_bo($user); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->cal_right_transform = array( |
91 | 91 | resources_acl_bo::CAL_READ => Acl::READ, |
92 | - resources_acl_bo::DIRECT_BOOKING => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE, |
|
93 | - resources_acl_bo::CAT_ADMIN => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE, |
|
92 | + resources_acl_bo::DIRECT_BOOKING => Acl::READ|Acl::ADD|Acl::EDIT|Acl::DELETE, |
|
93 | + resources_acl_bo::CAT_ADMIN => Acl::READ|Acl::ADD|Acl::EDIT|Acl::DELETE, |
|
94 | 94 | ); |
95 | 95 | } |
96 | 96 | |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * |
100 | 100 | * Cornelius Weiss <[email protected]> |
101 | 101 | */ |
102 | - function get_rows($query,&$rows,&$readonlys) |
|
102 | + function get_rows($query, &$rows, &$readonlys) |
|
103 | 103 | { |
104 | - if(!$query['csv_export']) |
|
104 | + if (!$query['csv_export']) |
|
105 | 105 | { |
106 | 106 | Api\Cache::setSession('resources', 'index_nm', $query); |
107 | 107 | } |
108 | 108 | if ($query['store_state']) // request to store state in session and filter in prefs? |
109 | 109 | { |
110 | - Api\Cache::setSession('resources',$query['store_state'],$query); |
|
110 | + Api\Cache::setSession('resources', $query['store_state'], $query); |
|
111 | 111 | //echo "<p>".__METHOD__."() query[filter]=$query[filter], prefs[resources][filter]={$GLOBALS['egw_info']['user']['preferences']['resources']['filter']}</p>\n"; |
112 | 112 | if ($query['filter'] != $GLOBALS['egw_info']['user']['preferences']['resources']['filter']) |
113 | 113 | { |
114 | - $GLOBALS['egw']->preferences->add('resources','filter',$query['filter'],'user'); |
|
114 | + $GLOBALS['egw']->preferences->add('resources', 'filter', $query['filter'], 'user'); |
|
115 | 115 | $GLOBALS['egw']->preferences->save_repository(); |
116 | 116 | } |
117 | 117 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | // Sub-query to get the count of accessories |
127 | 127 | $acc_join = "LEFT JOIN (SELECT accessory_of AS accessory_id, count(res_id) as acc_count FROM {$this->so->table_name} GROUP BY accessory_of) AS acc ON acc.accessory_id = {$this->so->table_name}.res_id "; |
128 | 128 | |
129 | - switch($query['filter2']) |
|
129 | + switch ($query['filter2']) |
|
130 | 130 | { |
131 | 131 | case -1: |
132 | 132 | // Resources only |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | default: |
152 | 152 | $filter['accessory_of'] = $query['filter2']; |
153 | 153 | } |
154 | - if($query['filter2'] != self::DELETED) |
|
154 | + if ($query['filter2'] != self::DELETED) |
|
155 | 155 | { |
156 | 156 | $filter['deleted'] = null; |
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($query['filter']) |
160 | 160 | { |
161 | - if (($children = $this->acl->get_cats(Acl::READ,$query['filter']))) |
|
161 | + if (($children = $this->acl->get_cats(Acl::READ, $query['filter']))) |
|
162 | 162 | { |
163 | 163 | $filter['cat_id'] = array_keys($children); |
164 | 164 | $filter['cat_id'][] = $query['filter']; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | { |
182 | 182 | $filter['bookable'] = true; |
183 | 183 | } |
184 | - $order_by = $query['order'] ? $query['order'].' '. $query['sort'] : ''; |
|
184 | + $order_by = $query['order'] ? $query['order'].' '.$query['sort'] : ''; |
|
185 | 185 | $start = (int)$query['start']; |
186 | 186 | |
187 | 187 | foreach ($filter as $k => $v) $query['col_filter'][$k] = $v; |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | $nr = $this->so->total; |
190 | 190 | |
191 | 191 | // we are called to serve bookable resources (e.g. calendar-dialog) |
192 | - if($query['show_bookable']) |
|
192 | + if ($query['show_bookable']) |
|
193 | 193 | { |
194 | 194 | // This is somehow ugly, i know... |
195 | - foreach((array)$rows as $num => $resource) |
|
195 | + foreach ((array)$rows as $num => $resource) |
|
196 | 196 | { |
197 | 197 | $rows[$num]['default_qty'] = 1; |
198 | 198 | } |
@@ -201,24 +201,24 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | $config = Api\Config::read('resources'); |
204 | - foreach($rows as $num => &$resource) |
|
204 | + foreach ($rows as $num => &$resource) |
|
205 | 205 | { |
206 | - if (!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT)) |
|
206 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::EDIT)) |
|
207 | 207 | { |
208 | 208 | $readonlys["edit[$resource[res_id]]"] = true; |
209 | 209 | } |
210 | - elseif($resource['deleted']) |
|
210 | + elseif ($resource['deleted']) |
|
211 | 211 | { |
212 | 212 | $resource['class'] .= 'deleted '; |
213 | 213 | } |
214 | - if (!$this->acl->is_permitted($resource['cat_id'],Acl::DELETE) || |
|
214 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::DELETE) || |
|
215 | 215 | ($resource['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history') |
216 | 216 | ) |
217 | 217 | { |
218 | 218 | $readonlys["delete[$resource[res_id]]"] = true; |
219 | 219 | $resource['class'] .= 'no_delete '; |
220 | 220 | } |
221 | - if ((!$this->acl->is_permitted($resource['cat_id'],Acl::ADD)) || |
|
221 | + if ((!$this->acl->is_permitted($resource['cat_id'], Acl::ADD)) || |
|
222 | 222 | // Allow new accessory action when viewing accessories of a certain resource |
223 | 223 | $query['filter2'] <= 0 && $resource['accessory_of'] != -1) |
224 | 224 | { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $resource['class'] .= 'no_book '; |
233 | 233 | $resource['class'] .= 'no_view_calendar '; |
234 | 234 | } |
235 | - if(!$this->acl->is_permitted($resource['cat_id'],resources_acl_bo::CAL_READ)) |
|
235 | + if (!$this->acl->is_permitted($resource['cat_id'], resources_acl_bo::CAL_READ)) |
|
236 | 236 | { |
237 | 237 | $readonlys["calendar[$resource[res_id]]"] = true; |
238 | 238 | $resource['class'] .= 'no_view_calendar '; |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | $resource['class'] .= 'no_buy '; |
244 | 244 | } |
245 | 245 | $readonlys["view_acc[{$resource['res_id']}]"] = ($resource['acc_count'] == 0); |
246 | - $resource['class'] .= ($resource['accessory_of']==-1 ? 'resource ' : 'accessory '); |
|
247 | - if($resource['acc_count']) |
|
246 | + $resource['class'] .= ($resource['accessory_of'] == -1 ? 'resource ' : 'accessory '); |
|
247 | + if ($resource['acc_count']) |
|
248 | 248 | { |
249 | 249 | $resource['class'] .= 'hasAccessories '; |
250 | - $accessories = $this->get_acc_list($resource['res_id'],$query['filter2']==self::DELETED); |
|
251 | - foreach($accessories as $acc_id => $acc_name) |
|
250 | + $accessories = $this->get_acc_list($resource['res_id'], $query['filter2'] == self::DELETED); |
|
251 | + foreach ($accessories as $acc_id => $acc_name) |
|
252 | 252 | { |
253 | 253 | $resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id)); |
254 | 254 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $resource['accessory_of_label'] = $this->link_title($resource['accessory_of']); |
257 | 257 | } |
258 | 258 | |
259 | - if($resource['deleted']) |
|
259 | + if ($resource['deleted']) |
|
260 | 260 | { |
261 | 261 | $rows[$num]['picture_thumb'] = 'deleted'; |
262 | 262 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']); |
278 | 278 | } |
279 | 279 | |
280 | - if(!Api\Storage\Customfields::get('resources')) |
|
280 | + if (!Api\Storage\Customfields::get('resources')) |
|
281 | 281 | { |
282 | 282 | $rows['no_customfields'] = true; |
283 | 283 | } |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | { |
296 | 296 | if (!($data = $this->so->read(array('res_id' => $res_id)))) |
297 | 297 | { |
298 | - return null; // not found |
|
298 | + return null; // not found |
|
299 | 299 | } |
300 | - if (!$this->acl->is_permitted($data['cat_id'],Acl::READ)) |
|
300 | + if (!$this->acl->is_permitted($data['cat_id'], Acl::READ)) |
|
301 | 301 | { |
302 | - return false; // permission denied |
|
302 | + return false; // permission denied |
|
303 | 303 | } |
304 | 304 | return $data; |
305 | 305 | } |
@@ -313,35 +313,35 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function save($resource) |
315 | 315 | { |
316 | - if(!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT)) |
|
316 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::EDIT)) |
|
317 | 317 | { |
318 | 318 | return lang('You are not permitted to edit this resource!'); |
319 | 319 | } |
320 | 320 | $old = array(); |
321 | 321 | // we need an id to save pictures and make links... |
322 | - if(!$resource['res_id']) |
|
322 | + if (!$resource['res_id']) |
|
323 | 323 | { |
324 | 324 | $resource['res_creator'] = $GLOBALS['egw_info']['user']['account_id']; |
325 | - $resource['res_created'] = Api\DateTime::server2user(time(),'ts'); |
|
325 | + $resource['res_created'] = Api\DateTime::server2user(time(), 'ts'); |
|
326 | 326 | $resource['res_id'] = $this->so->save($resource); |
327 | 327 | } |
328 | 328 | else |
329 | 329 | { |
330 | 330 | $resource['res_modifier'] = $GLOBALS['egw_info']['user']['account_id']; |
331 | - $resource['res_modified'] = Api\DateTime::server2user(time(),'ts'); |
|
331 | + $resource['res_modified'] = Api\DateTime::server2user(time(), 'ts'); |
|
332 | 332 | $old = $this->read($resource['res_id']); |
333 | 333 | } |
334 | 334 | |
335 | 335 | switch ($resource['picture_src']) |
336 | 336 | { |
337 | 337 | case 'own_src': |
338 | - if($resource['own_file']['size'] > 0) |
|
338 | + if ($resource['own_file']['size'] > 0) |
|
339 | 339 | { |
340 | - $msg = $this->save_picture($resource['own_file'],$resource['res_id']); |
|
340 | + $msg = $this->save_picture($resource['own_file'], $resource['res_id']); |
|
341 | 341 | unset($resource['own_file']); |
342 | 342 | break; |
343 | 343 | } |
344 | - elseif(@Vfs::stat('/apps/resources/'.$resource['res_id'].'/'.self::PICTURE_NAME)) |
|
344 | + elseif (@Vfs::stat('/apps/resources/'.$resource['res_id'].'/'.self::PICTURE_NAME)) |
|
345 | 345 | { |
346 | 346 | break; |
347 | 347 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | $resource['picture_src'] = 'gen_src'; |
353 | 353 | break; |
354 | 354 | default: |
355 | - if($resource['own_file']['size'] > 0) |
|
355 | + if ($resource['own_file']['size'] > 0) |
|
356 | 356 | { |
357 | 357 | $resource['picture_src'] = 'own_src'; |
358 | - $msg = $this->save_picture($resource['own_file'],$resource['res_id']); |
|
358 | + $msg = $this->save_picture($resource['own_file'], $resource['res_id']); |
|
359 | 359 | } |
360 | 360 | else |
361 | 361 | { |
@@ -363,40 +363,40 @@ discard block |
||
363 | 363 | } |
364 | 364 | } |
365 | 365 | // somthing went wrong on saving own picture |
366 | - if($msg) |
|
366 | + if ($msg) |
|
367 | 367 | { |
368 | 368 | return $msg; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Check for restore of deleted, restore held links |
372 | - if($old && $old['deleted'] && !$resource['deleted']) |
|
372 | + if ($old && $old['deleted'] && !$resource['deleted']) |
|
373 | 373 | { |
374 | 374 | Link::restore('resources', $resource['res_id']); |
375 | 375 | } |
376 | 376 | |
377 | 377 | // delete old pictures |
378 | - if($resource['picture_src'] != 'own_src') |
|
378 | + if ($resource['picture_src'] != 'own_src') |
|
379 | 379 | { |
380 | 380 | $this->remove_picture($resource['res_id']); |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Update link title |
384 | - Link::notify_update('resources',$resource['res_id'], $resource); |
|
384 | + Link::notify_update('resources', $resource['res_id'], $resource); |
|
385 | 385 | // save links |
386 | - if(is_array($resource['link_to']['to_id'])) |
|
386 | + if (is_array($resource['link_to']['to_id'])) |
|
387 | 387 | { |
388 | - Link::link('resources',$resource['res_id'],$resource['link_to']['to_id']); |
|
388 | + Link::link('resources', $resource['res_id'], $resource['link_to']['to_id']); |
|
389 | 389 | } |
390 | - if($resource['accessory_of'] != $old['accessory_of']) |
|
390 | + if ($resource['accessory_of'] != $old['accessory_of']) |
|
391 | 391 | { |
392 | - Link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']); |
|
392 | + Link::unlink(0, 'resources', $resource['res_id'], '', 'resources', $old['accessory_of']); |
|
393 | 393 | |
394 | 394 | // Check for resource changing to accessory - move its accessories to resource |
395 | - if($old['accessory_of'] == -1 && ($accessories = $this->get_acc_list($resource['res_id']))) |
|
395 | + if ($old['accessory_of'] == -1 && ($accessories = $this->get_acc_list($resource['res_id']))) |
|
396 | 396 | { |
397 | - foreach($accessories as $accessory => $name) |
|
397 | + foreach ($accessories as $accessory => $name) |
|
398 | 398 | { |
399 | - Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']); |
|
399 | + Link::unlink(0, 'resources', $accessory, '', 'resources', $resource['res_id']); |
|
400 | 400 | if (($acc = $this->read($accessory))) |
401 | 401 | { |
402 | 402 | $acc['accessory_of'] = -1; |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
408 | - if($resource['accessory_of'] != -1) |
|
408 | + if ($resource['accessory_of'] != -1) |
|
409 | 409 | { |
410 | - Link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']); |
|
410 | + Link::link('resources', $resource['res_id'], 'resources', $resource['accessory_of']); |
|
411 | 411 | } |
412 | 412 | |
413 | - if(!empty($resource['res_id']) && $this->so->get_value("cat_id",$resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1) |
|
413 | + if (!empty($resource['res_id']) && $this->so->get_value("cat_id", $resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1) |
|
414 | 414 | { |
415 | 415 | $accessories = $this->get_acc_list($resource['res_id']); |
416 | - foreach($accessories as $accessory => $name) |
|
416 | + foreach ($accessories as $accessory => $name) |
|
417 | 417 | { |
418 | 418 | if (($acc = $this->so->read($accessory))) |
419 | 419 | { |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | { |
431 | 431 | $this->tracking = new resources_tracking(); |
432 | 432 | } |
433 | - if ($this->tracking->track($resource,$old,$this->user) === false) |
|
433 | + if ($this->tracking->track($resource, $old, $this->user) === false) |
|
434 | 434 | { |
435 | - return implode(', ',$this->tracking->errors); |
|
435 | + return implode(', ', $this->tracking->errors); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | return $res_id ? $res_id : lang('Something went wrong by saving resource'); |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | function delete($res_id) |
449 | 449 | { |
450 | - if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),Acl::DELETE)) |
|
450 | + if (!$this->acl->is_permitted($this->so->get_value('cat_id', $res_id), Acl::DELETE)) |
|
451 | 451 | { |
452 | 452 | return lang('You are not permitted to delete this resource!'); |
453 | 453 | } |
@@ -462,16 +462,16 @@ discard block |
||
462 | 462 | { |
463 | 463 | $old['deleted'] = time(); |
464 | 464 | $this->save($old); |
465 | - Link::unlink(0,'resources',$res_id,'','','',true); |
|
465 | + Link::unlink(0, 'resources', $res_id, '', '', '', true); |
|
466 | 466 | $accessories = $this->get_acc_list($res_id); |
467 | - foreach($accessories as $acc_id => $name) |
|
467 | + foreach ($accessories as $acc_id => $name) |
|
468 | 468 | { |
469 | 469 | // Don't purge already deleted accessories |
470 | 470 | if (($acc = $this->read($acc_id)) && !$acc['deleted']) |
471 | 471 | { |
472 | 472 | $acc['deleted'] = time(); |
473 | 473 | $this->save($acc); |
474 | - Link::unlink(0,'resources',$acc_id,'','','',true); |
|
474 | + Link::unlink(0, 'resources', $acc_id, '', '', '', true); |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | return false; |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | elseif ($this->so->delete(array('res_id'=>$res_id))) |
480 | 480 | { |
481 | 481 | $accessories = $this->get_acc_list($res_id, true); |
482 | - foreach($accessories as $acc_id => $name) |
|
482 | + foreach ($accessories as $acc_id => $name) |
|
483 | 483 | { |
484 | - if($this->delete($acc_id) && ($acc = $this->read($acc_id))) |
|
484 | + if ($this->delete($acc_id) && ($acc = $this->read($acc_id))) |
|
485 | 485 | { |
486 | 486 | $acc['accessory_of'] = -1; |
487 | 487 | $this->save($acc); |
488 | 488 | } |
489 | 489 | }; |
490 | 490 | $this->remove_picture($res_id); |
491 | - Link::unlink(0,'resources',$res_id); |
|
491 | + Link::unlink(0, 'resources', $res_id); |
|
492 | 492 | // delete the resource from the calendar |
493 | - ExecMethod('calendar.calendar_so.deleteaccount','r'.$res_id); |
|
493 | + ExecMethod('calendar.calendar_so.deleteaccount', 'r'.$res_id); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | return lang('Something went wrong by deleting resource'); |
@@ -504,15 +504,15 @@ discard block |
||
504 | 504 | * @param boolean $deleted Include deleted accessories |
505 | 505 | * @return array |
506 | 506 | */ |
507 | - function get_acc_list($res_id,$deleted=false) |
|
507 | + function get_acc_list($res_id, $deleted = false) |
|
508 | 508 | { |
509 | - if($res_id < 1){return;} |
|
510 | - $data = $this->so->search('','res_id,name,deleted','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true); |
|
509 | + if ($res_id < 1) {return; } |
|
510 | + $data = $this->so->search('', 'res_id,name,deleted', '', '', '', '', '', $start, array('accessory_of' => $res_id), '', $need_full_no_count = true); |
|
511 | 511 | $acc_list = array(); |
512 | - if($data) { |
|
513 | - foreach($data as $num => $resource) |
|
512 | + if ($data) { |
|
513 | + foreach ($data as $num => $resource) |
|
514 | 514 | { |
515 | - if($resource['deleted'] && !$deleted) continue; |
|
515 | + if ($resource['deleted'] && !$deleted) continue; |
|
516 | 516 | $acc_list[$resource['res_id']] = $resource['name']; |
517 | 517 | } |
518 | 518 | } |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | |
542 | 542 | // Categories |
543 | 543 | $cats = $bo->acl->get_cats(Acl::READ); |
544 | - foreach($cats as $cat_id => $cat) |
|
544 | + foreach ($cats as $cat_id => $cat) |
|
545 | 545 | { |
546 | - if($cat && stripos($cat, $search) !== FALSE) |
|
546 | + if ($cat && stripos($cat, $search) !== FALSE) |
|
547 | 547 | { |
548 | 548 | // Get resources for that category |
549 | - if(!$options['exec']) |
|
549 | + if (!$options['exec']) |
|
550 | 550 | { |
551 | 551 | $resources = $bo->get_resources_by_category($cat_id); |
552 | 552 | } |
@@ -554,14 +554,14 @@ discard block |
||
554 | 554 | { |
555 | 555 | $cat_options = $options; |
556 | 556 | $cat_options['cat_id'] = $cat_id; |
557 | - $resources = $bo->link_query('',$cat_options); |
|
557 | + $resources = $bo->link_query('', $cat_options); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | // Edit dialog sends exec as an option, don't add categories |
561 | - if(count($resources) && !$options['exec']) |
|
561 | + if (count($resources) && !$options['exec']) |
|
562 | 562 | { |
563 | 563 | $_resources = array_map( |
564 | - function($id) { return 'r'.$id;}, |
|
564 | + function($id) { return 'r'.$id; }, |
|
565 | 565 | array_keys($resources) |
566 | 566 | ); |
567 | 567 | $list['cat-'.$cat_id] = array( |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | else if ($resources && $options['exec']) |
573 | 573 | { |
574 | 574 | array_map( |
575 | - function($id,$name) use (&$list) { if(!$list[''.$id]) $list[''.$id] = $name;}, |
|
575 | + function($id, $name) use (&$list) { if (!$list[''.$id]) $list[''.$id] = $name; }, |
|
576 | 576 | array_keys($resources), $resources |
577 | 577 | ); |
578 | 578 | } |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | 'deleted' => null |
597 | 597 | ); |
598 | 598 | $only_keys = 'res_id,name'; |
599 | - $data = $this->so->search(array(),$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',false,$filter); |
|
600 | - if(is_array($data) && $data) |
|
599 | + $data = $this->so->search(array(), $only_keys, $order_by = 'name', $extra_cols = '', $wildcard = '%', $empty, $op = 'OR', false, $filter); |
|
600 | + if (is_array($data) && $data) |
|
601 | 601 | { |
602 | - foreach($data as $resource) |
|
602 | + foreach ($data as $resource) |
|
603 | 603 | { |
604 | 604 | $resources[$resource['res_id']] = $resource['name']; |
605 | 605 | } |
@@ -620,37 +620,37 @@ discard block |
||
620 | 620 | //error_log(__METHOD__ . "(".print_r($res_id,true).")"); |
621 | 621 | |
622 | 622 | // Resource category |
623 | - if(is_string($res_id) && strpos($res_id, 'cat-') === 0) |
|
623 | + if (is_string($res_id) && strpos($res_id, 'cat-') === 0) |
|
624 | 624 | { |
625 | 625 | $cat_id = (int)substr($res_id, 4); |
626 | - if(!$this->acl->is_permitted($cat_id, Acl::READ)) |
|
626 | + if (!$this->acl->is_permitted($cat_id, Acl::READ)) |
|
627 | 627 | { |
628 | 628 | return array(); |
629 | 629 | } |
630 | - return array( array( |
|
630 | + return array(array( |
|
631 | 631 | 'name' => $this->acl->get_cat_name($cat_id), |
632 | 632 | 'rights' => $this->acl->get_permissions($cat_id), |
633 | 633 | 'resources' => array_map( |
634 | - function($id) { return 'r'.$id;}, |
|
634 | + function($id) { return 'r'.$id; }, |
|
635 | 635 | array_keys($this->get_resources_by_category($cat_id)) |
636 | 636 | ) |
637 | 637 | )); |
638 | 638 | } |
639 | 639 | |
640 | - if(!is_array($res_id) && $res_id < 1) return; |
|
640 | + if (!is_array($res_id) && $res_id < 1) return; |
|
641 | 641 | |
642 | - $data = $this->so->search(array('res_id' => $res_id),self::TITLE_COLS.',useable'); |
|
642 | + $data = $this->so->search(array('res_id' => $res_id), self::TITLE_COLS.',useable'); |
|
643 | 643 | if (!is_array($data)) |
644 | 644 | { |
645 | 645 | //error_log(__METHOD__." No Calendar Data found for Resource with id $res_id"); |
646 | 646 | return array(); |
647 | 647 | } |
648 | - foreach($data as $num => &$resource) |
|
648 | + foreach ($data as $num => &$resource) |
|
649 | 649 | { |
650 | 650 | $resource['rights'] = false; |
651 | - foreach($this->cal_right_transform as $res_right => $cal_right) |
|
651 | + foreach ($this->cal_right_transform as $res_right => $cal_right) |
|
652 | 652 | { |
653 | - if($this->acl->is_permitted($resource['cat_id'],$res_right)) |
|
653 | + if ($this->acl->is_permitted($resource['cat_id'], $res_right)) |
|
654 | 654 | { |
655 | 655 | $resource['rights'] = $cal_right; |
656 | 656 | } |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | $resource['responsible'] = $this->acl->get_cat_admin($resource['cat_id']); |
659 | 659 | |
660 | 660 | // preseed the cache |
661 | - Link::set_cache('resources',$resource['res_id'],$t=$this->link_title($resource)); |
|
661 | + Link::set_cache('resources', $resource['res_id'], $t = $this->link_title($resource)); |
|
662 | 662 | } |
663 | 663 | return $data; |
664 | 664 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | { |
676 | 676 | return false; |
677 | 677 | } |
678 | - return $this->acl->is_permitted($data['cat_id'],resources_acl_bo::DIRECT_BOOKING) ? A : U; |
|
678 | + return $this->acl->is_permitted($data['cat_id'], resources_acl_bo::DIRECT_BOOKING) ? A : U; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
@@ -687,11 +687,11 @@ discard block |
||
687 | 687 | * @param array $options Array of options for the search |
688 | 688 | * |
689 | 689 | */ |
690 | - function link_query( $pattern, Array &$options = array() ) |
|
690 | + function link_query($pattern, Array &$options = array()) |
|
691 | 691 | { |
692 | 692 | if (is_array($pattern)) |
693 | 693 | { |
694 | - $criteria =array('name' => $pattern['search'] |
|
694 | + $criteria = array('name' => $pattern['search'] |
|
695 | 695 | ,'short_description' => $pattern['search']); |
696 | 696 | } |
697 | 697 | else |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $only_keys = 'res_id,name,short_description,bookable,useable,quantity'; |
703 | 703 | |
704 | 704 | // If no read access to any category, just stop |
705 | - if(!$this->acl->get_cats(Acl::READ)) |
|
705 | + if (!$this->acl->get_cats(Acl::READ)) |
|
706 | 706 | { |
707 | 707 | $options['total'] = 0; |
708 | 708 | return array(); |
@@ -713,35 +713,35 @@ discard block |
||
713 | 713 | 'deleted' => null |
714 | 714 | ); |
715 | 715 | $limit = false; |
716 | - if($options['start'] || $options['num_rows']) { |
|
716 | + if ($options['start'] || $options['num_rows']) { |
|
717 | 717 | $limit = array($options['start'], $options['num_rows']); |
718 | 718 | } |
719 | - if($options['cat_id'] && in_array($options['cat_id'], $filter['cat_id'])) |
|
719 | + if ($options['cat_id'] && in_array($options['cat_id'], $filter['cat_id'])) |
|
720 | 720 | { |
721 | 721 | $filter['cat_id'] = $options['cat_id']; |
722 | 722 | } |
723 | - if($options['accessory_of']) |
|
723 | + if ($options['accessory_of']) |
|
724 | 724 | { |
725 | 725 | $filter['accessory_of'] = $options['accessory_of']; |
726 | 726 | } |
727 | 727 | $list = array(); |
728 | - $data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter); |
|
728 | + $data = $this->so->search($criteria, $only_keys, $order_by = 'name', $extra_cols = '', $wildcard = '%', $empty, $op = 'OR', $limit, $filter); |
|
729 | 729 | // we need to check availability of the searched resources in the calendar if $pattern ['exec'] contains some extra args |
730 | - $show_conflict=False; |
|
730 | + $show_conflict = False; |
|
731 | 731 | if ($data && $options['exec']) |
732 | 732 | { |
733 | 733 | // we'll use a cache for resources info taken from database |
734 | 734 | static $res_info_cache = array(); |
735 | - $cal_info=$options['exec']; |
|
736 | - if ( isset($cal_info['start']) && isset($cal_info['duration'])) |
|
735 | + $cal_info = $options['exec']; |
|
736 | + if (isset($cal_info['start']) && isset($cal_info['duration'])) |
|
737 | 737 | { |
738 | 738 | //get a calendar objet for reservations |
739 | - if ( (!isset($this->bocal)) || !(is_object($this->bocal))) |
|
739 | + if ((!isset($this->bocal)) || !(is_object($this->bocal))) |
|
740 | 740 | { |
741 | 741 | $this->bocal = new calendar_bo(); |
742 | 742 | } |
743 | 743 | $start = new Api\DateTime($cal_info['start']); |
744 | - $startarr= getdate($start->format('ts')); |
|
744 | + $startarr = getdate($start->format('ts')); |
|
745 | 745 | if (isset($cal_info['whole_day']) && $cal_info['whole_day']) { |
746 | 746 | $startarr['hour'] = $startarr['minute'] = 0; |
747 | 747 | $start = new Api\DateTime($startarr); |
@@ -752,39 +752,39 @@ discard block |
||
752 | 752 | } |
753 | 753 | |
754 | 754 | // search events matching our timestamps |
755 | - $resource_list=array(); |
|
756 | - foreach($data as $num => $resource) |
|
755 | + $resource_list = array(); |
|
756 | + foreach ($data as $num => $resource) |
|
757 | 757 | { |
758 | 758 | // we only need resources id for the search, but with a 'r' prefix |
759 | 759 | // now we take this loop to store a new resource array indexed with resource id |
760 | 760 | // and as we work for calendar we use only bookable resources |
761 | - if ((isset($resource['bookable'])) && ($resource['bookable'])){ |
|
762 | - $res_info_cache[$resource['res_id']]=$resource; |
|
763 | - $resource_list[]='r'.$resource['res_id']; |
|
761 | + if ((isset($resource['bookable'])) && ($resource['bookable'])) { |
|
762 | + $res_info_cache[$resource['res_id']] = $resource; |
|
763 | + $resource_list[] = 'r'.$resource['res_id']; |
|
764 | 764 | } |
765 | 765 | } |
766 | - $overlapping_events =& $this->bocal->search(array( |
|
766 | + $overlapping_events = & $this->bocal->search(array( |
|
767 | 767 | 'start' => $start, |
768 | 768 | 'end' => $end, |
769 | 769 | 'users' => $resource_list, |
770 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
771 | - 'enum_groups' => false, // otherwise group-events would not block time |
|
770 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
771 | + 'enum_groups' => false, // otherwise group-events would not block time |
|
772 | 772 | )); |
773 | 773 | |
774 | 774 | // parse theses overlapping events |
775 | - foreach($overlapping_events as $event) |
|
775 | + foreach ($overlapping_events as $event) |
|
776 | 776 | { |
777 | 777 | if ($event['non_blocking']) continue; // ignore non_blocking events |
778 | - if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) { |
|
778 | + if (isset($cal_info['event_id']) && $event['id'] == $cal_info['event_id']) { |
|
779 | 779 | continue; //ignore this event, it's the current edited event, no conflict by def |
780 | 780 | } |
781 | 781 | // now we are interested only on resources booked by theses events |
782 | - if (isset($event['participants']) && is_array($event['participants'])){ |
|
783 | - foreach($event['participants'] as $part_key => $part_detail){ |
|
784 | - if ($part_key{0}=='r') |
|
782 | + if (isset($event['participants']) && is_array($event['participants'])) { |
|
783 | + foreach ($event['participants'] as $part_key => $part_detail) { |
|
784 | + if ($part_key{0} == 'r') |
|
785 | 785 | { //now we gatta resource here |
786 | 786 | //need to check the quantity of this resource |
787 | - $resource_id=substr($part_key,1); |
|
787 | + $resource_id = substr($part_key, 1); |
|
788 | 788 | // if we do not find this resource in our indexed array it's certainly |
789 | 789 | // because it was unset, non bookable maybe |
790 | 790 | if (!isset($res_info_cache[$resource_id])) continue; |
@@ -794,9 +794,9 @@ discard block |
||
794 | 794 | } |
795 | 795 | // now decrement this quantity useable |
796 | 796 | $quantity = 1; |
797 | - $this->bocal->so->split_status($part_detail,$quantity); |
|
797 | + $this->bocal->so->split_status($part_detail, $quantity); |
|
798 | 798 | |
799 | - $res_info_cache[$resource_id]['useable']-=$quantity; |
|
799 | + $res_info_cache[$resource_id]['useable'] -= $quantity; |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | } |
@@ -804,31 +804,31 @@ discard block |
||
804 | 804 | } |
805 | 805 | } |
806 | 806 | if (isset($res_info_cache)) { |
807 | - $show_conflict= $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] !== 'resources_without_conflict'; |
|
807 | + $show_conflict = $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] !== 'resources_without_conflict'; |
|
808 | 808 | // if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar |
809 | 809 | // so we'll loop on this one and not $data |
810 | - foreach($res_info_cache as $id => $resource) { |
|
810 | + foreach ($res_info_cache as $id => $resource) { |
|
811 | 811 | //maybe this resource is reserved |
812 | - if ( ($resource['useable'] < 1) ) |
|
812 | + if (($resource['useable'] < 1)) |
|
813 | 813 | { |
814 | - if($show_conflict) |
|
814 | + if ($show_conflict) |
|
815 | 815 | { |
816 | - $list[$id] = ' ('.lang('conflict').') '.$resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
816 | + $list[$id] = ' ('.lang('conflict').') '.$resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | else |
820 | 820 | { |
821 | - $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'') . |
|
821 | + $list[$id] = $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''). |
|
822 | 822 | ($resource['useable'] > 1 ? " ( {$resource['useable']} / {$resource['quantity']} )" : ''); |
823 | 823 | } |
824 | 824 | } |
825 | 825 | } else { |
826 | 826 | // we are not working for the calendar, we loop on the initial $data |
827 | 827 | if (is_array($data)) { |
828 | - foreach($data as $num => $resource) |
|
828 | + foreach ($data as $num => $resource) |
|
829 | 829 | { |
830 | - $id=$resource['res_id']; |
|
831 | - $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
830 | + $id = $resource['res_id']; |
|
831 | + $list[$id] = $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
832 | 832 | } |
833 | 833 | } else { |
834 | 834 | error_log(__METHOD__." No Data found for Resource with id ".$resource['res_id']); |
@@ -845,17 +845,17 @@ discard block |
||
845 | 845 | * @param int|array $resource |
846 | 846 | * @return string|boolean string with title, null if resource does not exist or false if no perms to view it |
847 | 847 | */ |
848 | - function link_title( $resource ) |
|
848 | + function link_title($resource) |
|
849 | 849 | { |
850 | 850 | if (!is_array($resource)) |
851 | 851 | { |
852 | - if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
852 | + if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
853 | 853 | } |
854 | - elseif (!$this->acl->is_permitted($resource['cat_id'],Acl::READ)) |
|
854 | + elseif (!$this->acl->is_permitted($resource['cat_id'], Acl::READ)) |
|
855 | 855 | { |
856 | 856 | return false; |
857 | 857 | } |
858 | - return $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
858 | + return $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -875,15 +875,15 @@ discard block |
||
875 | 875 | function link_titles(array $ids) |
876 | 876 | { |
877 | 877 | $titles = array(); |
878 | - if (($resources =& $this->so->search(array('res_id' => $ids),self::TITLE_COLS))) |
|
878 | + if (($resources = & $this->so->search(array('res_id' => $ids), self::TITLE_COLS))) |
|
879 | 879 | { |
880 | - foreach($resources as $resource) |
|
880 | + foreach ($resources as $resource) |
|
881 | 881 | { |
882 | 882 | $titles[$resource['res_id']] = $this->link_title($resource); |
883 | 883 | } |
884 | 884 | } |
885 | 885 | // we assume all not returned contacts are not readable for the user (as we report all deleted contacts to Link) |
886 | - foreach($ids as $id) |
|
886 | + foreach ($ids as $id) |
|
887 | 887 | { |
888 | 888 | if (!isset($titles[$id])) |
889 | 889 | { |
@@ -901,13 +901,13 @@ discard block |
||
901 | 901 | * @param int $resource_id |
902 | 902 | * @return mixed string with msg if somthing went wrong; nothing if all right |
903 | 903 | */ |
904 | - function save_picture($file,$resource_id) |
|
904 | + function save_picture($file, $resource_id) |
|
905 | 905 | { |
906 | 906 | if ($file['type'] == 'application/octet-stream') |
907 | 907 | { |
908 | 908 | $file['type'] = Api\MimeMagic::filename2mime($file['name']); |
909 | 909 | } |
910 | - switch($file['type']) |
|
910 | + switch ($file['type']) |
|
911 | 911 | { |
912 | 912 | case 'image/gif': |
913 | 913 | $src_img = imagecreatefromgif($file['tmp_name']); |
@@ -924,11 +924,11 @@ discard block |
||
924 | 924 | return $file['type'].': '.lang('Picture type is not supported, sorry!'); |
925 | 925 | } |
926 | 926 | |
927 | - $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'resources-picture'); |
|
928 | - imagejpeg($src_img,$tmp_name); |
|
927 | + $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'resources-picture'); |
|
928 | + imagejpeg($src_img, $tmp_name); |
|
929 | 929 | imagedestroy($src_img); |
930 | 930 | |
931 | - Link::attach_file('resources',$resource_id,array( |
|
931 | + Link::attach_file('resources', $resource_id, array( |
|
932 | 932 | 'tmp_name' => $tmp_name, |
933 | 933 | 'name' => self::PICTURE_NAME, |
934 | 934 | 'type' => 'image/jpeg', |
@@ -942,14 +942,14 @@ discard block |
||
942 | 942 | * @param bool $fullsize false = thumb, true = full pic |
943 | 943 | * @return string url of picture |
944 | 944 | */ |
945 | - function get_picture($resource,$fullsize=false) |
|
945 | + function get_picture($resource, $fullsize = false) |
|
946 | 946 | { |
947 | 947 | if ($resource && !is_array($resource)) $resource = $this->read($resource); |
948 | 948 | |
949 | - switch($resource['picture_src']) |
|
949 | + switch ($resource['picture_src']) |
|
950 | 950 | { |
951 | 951 | case 'own_src': |
952 | - $picture = Link::vfs_path('resources',$resource['res_id'],self::PICTURE_NAME,true); // vfs path |
|
952 | + $picture = Link::vfs_path('resources', $resource['res_id'], self::PICTURE_NAME, true); // vfs path |
|
953 | 953 | if ($fullsize) |
954 | 954 | { |
955 | 955 | $picture = Egw::link(Vfs::download_url($picture)); |
@@ -958,23 +958,23 @@ discard block |
||
958 | 958 | { |
959 | 959 | $picture = Egw::link('/api/thumbnail.php', array( |
960 | 960 | 'path' => $picture |
961 | - ),false); |
|
961 | + ), false); |
|
962 | 962 | } |
963 | 963 | break; |
964 | 964 | |
965 | 965 | case 'cat_src': |
966 | 966 | $picture = Api\Categories::id2name($resource['cat_id'], 'data'); |
967 | - if($picture['icon']) |
|
967 | + if ($picture['icon']) |
|
968 | 968 | { |
969 | - $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$picture['icon']:self::ICON_PATH.'/'.$picture['icon']; |
|
969 | + $picture = !$fullsize ? $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$picture['icon'] : self::ICON_PATH.'/'.$picture['icon']; |
|
970 | 970 | break; |
971 | 971 | } |
972 | 972 | // fall through |
973 | 973 | case 'gen_src': |
974 | 974 | default : |
975 | 975 | $src = $resource['picture_src']; |
976 | - $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons:$this->resource_icons; |
|
977 | - $picture .= strpos($src,'.') !== false ? $src : 'generic.png'; |
|
976 | + $picture = !$fullsize ? $GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons : $this->resource_icons; |
|
977 | + $picture .= strpos($src, '.') !== false ? $src : 'generic.png'; |
|
978 | 978 | } |
979 | 979 | return $picture; |
980 | 980 | } |
@@ -988,9 +988,9 @@ discard block |
||
988 | 988 | */ |
989 | 989 | function remove_picture($res_id) |
990 | 990 | { |
991 | - if (($arr = Link::delete_attached('resources',$res_id,self::PICTURE_NAME)) && is_array($arr)) |
|
991 | + if (($arr = Link::delete_attached('resources', $res_id, self::PICTURE_NAME)) && is_array($arr)) |
|
992 | 992 | { |
993 | - return array_shift($arr); // $arr = array($path => (bool)$ok); |
|
993 | + return array_shift($arr); // $arr = array($path => (bool)$ok); |
|
994 | 994 | } |
995 | 995 | return false; |
996 | 996 | } |
@@ -1006,11 +1006,11 @@ discard block |
||
1006 | 1006 | { |
1007 | 1007 | $icons['generic.png'] = lang('gernal resource'); |
1008 | 1008 | $dir = dir(EGW_SERVER_ROOT.$this->resource_icons); |
1009 | - while($file = $dir->read()) |
|
1009 | + while ($file = $dir->read()) |
|
1010 | 1010 | { |
1011 | - if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png') |
|
1011 | + if (preg_match('/\\.(png|gif|jpe?g)$/i', $file) && $file != 'generic.png') |
|
1012 | 1012 | { |
1013 | - $icons[$file] = substr($file,0,strpos($file,'.')); |
|
1013 | + $icons[$file] = substr($file, 0, strpos($file, '.')); |
|
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | $dir->close(); |
@@ -119,7 +119,11 @@ discard block |
||
119 | 119 | { |
120 | 120 | $cat = Api\Categories::read($args['cat_id']); |
121 | 121 | |
122 | - if(!$cat) return; // Can't find current cat? |
|
122 | + if(!$cat) |
|
123 | + { |
|
124 | + return; |
|
125 | + } |
|
126 | + // Can't find current cat? |
|
123 | 127 | |
124 | 128 | if($cat['parent'] == 0) |
125 | 129 | { |
@@ -134,7 +138,8 @@ discard block |
||
134 | 138 | { |
135 | 139 | // Default missing, look for 'No category' |
136 | 140 | $new_cat_id = $categories->name2id('No category'); |
137 | - if($new_cat_id == 0) { |
|
141 | + if($new_cat_id == 0) |
|
142 | + { |
|
138 | 143 | // No category not there, add it |
139 | 144 | $new_cat_id = $categories->add(array( |
140 | 145 | 'name' => 'No category', |
@@ -52,7 +52,7 @@ |
||
52 | 52 | |
53 | 53 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
54 | 54 | { |
55 | - $file = Array( |
|
55 | + $file = array( |
|
56 | 56 | 'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'), |
57 | 57 | 'Global Categories' => Egw::link('/index.php',array( |
58 | 58 | 'menuaction' => 'admin.admin_categories.index', |
@@ -36,25 +36,25 @@ discard block |
||
36 | 36 | |
37 | 37 | $title = $GLOBALS['egw_info']['apps']['resources']['title'].' '.lang('Menu'); |
38 | 38 | $file = array( |
39 | - 'Resources list' => Egw::link('/index.php',array( |
|
39 | + 'Resources list' => Egw::link('/index.php', array( |
|
40 | 40 | 'menuaction' => 'resources.resources_ui.index', |
41 | 41 | 'ajax' => 'true')), |
42 | 42 | ); |
43 | - if($this->acl->get_cats(Acl::ADD)) |
|
43 | + if ($this->acl->get_cats(Acl::ADD)) |
|
44 | 44 | { |
45 | - $file['Add resource'] = "javascript:egw_openWindowCentered2('".Egw::link('/index.php',array( |
|
45 | + $file['Add resource'] = "javascript:egw_openWindowCentered2('".Egw::link('/index.php', array( |
|
46 | 46 | 'menuaction' => 'resources.resources_ui.edit', |
47 | 47 | 'accessory_of' => -1 |
48 | - ),false)."','_blank',800,600,'yes')"; |
|
48 | + ), false)."','_blank',800,600,'yes')"; |
|
49 | 49 | } |
50 | - display_sidebox($appname,$title,$file); |
|
50 | + display_sidebox($appname, $title, $file); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
54 | 54 | { |
55 | 55 | $file = Array( |
56 | - 'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'), |
|
57 | - 'Global Categories' => Egw::link('/index.php',array( |
|
56 | + 'Site Configuration' => Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname='.$appname.'&ajax=true'), |
|
57 | + 'Global Categories' => Egw::link('/index.php', array( |
|
58 | 58 | 'menuaction' => 'admin.admin_categories.index', |
59 | 59 | 'appname' => $appname, |
60 | 60 | 'global_cats'=> true, |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | ); |
68 | 68 | if ($location == 'admin') |
69 | 69 | { |
70 | - display_section($appname,$file); |
|
70 | + display_section($appname, $file); |
|
71 | 71 | } |
72 | 72 | else |
73 | 73 | { |
74 | - display_sidebox($appname,lang('Admin'),$file); |
|
74 | + display_sidebox($appname, lang('Admin'), $file); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | 'add_app' => 'link_app', |
95 | 95 | 'add_id' => 'link_id', |
96 | 96 | 'add_popup' => '800x600', |
97 | - 'find_extra' => array('name_preg' => '/^(?(?=^.picture.jpg$)|.+)$/'), // remove pictures from regular attachment list |
|
97 | + 'find_extra' => array('name_preg' => '/^(?(?=^.picture.jpg$)|.+)$/'), // remove pictures from regular attachment list |
|
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | function calendar_resources($args) |
102 | 102 | { |
103 | 103 | return array( |
104 | - 'search' => 'resources_bo::calendar_search',// method to use for the selection of resources, otherwise Link system is used |
|
105 | - 'info' => 'resources.resources_bo.get_calendar_info',// info method, returns array with id, type & name for a given id |
|
106 | - 'max_quantity' => 'useable',// if set, key for max. quantity in array returned by info method |
|
107 | - 'new_status' => 'resources.resources_bo.get_calendar_new_status',// method returning the status for new items, else 'U' is used |
|
108 | - 'type' => 'r',// one char type-identifiy for this resources |
|
109 | - 'icon' => 'calicon',//icon |
|
104 | + 'search' => 'resources_bo::calendar_search', // method to use for the selection of resources, otherwise Link system is used |
|
105 | + 'info' => 'resources.resources_bo.get_calendar_info', // info method, returns array with id, type & name for a given id |
|
106 | + 'max_quantity' => 'useable', // if set, key for max. quantity in array returned by info method |
|
107 | + 'new_status' => 'resources.resources_bo.get_calendar_new_status', // method returning the status for new items, else 'U' is used |
|
108 | + 'type' => 'r', // one char type-identifiy for this resources |
|
109 | + 'icon' => 'calicon', //icon |
|
110 | 110 | 'participants_header' => lang('resources'), // header of participants from this type |
111 | 111 | 'check_invite' => 'resources_acl_bo::check_calendar_invite' // Check that the current user is allowed to invite the givent resource |
112 | 112 | ); |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | { |
123 | 123 | $cat = Api\Categories::read($args['cat_id']); |
124 | 124 | |
125 | - if(!$cat) return; // Can't find current cat? |
|
125 | + if (!$cat) return; // Can't find current cat? |
|
126 | 126 | |
127 | - if($cat['parent'] == 0) |
|
127 | + if ($cat['parent'] == 0) |
|
128 | 128 | { |
129 | 129 | // No parent, try the default cat from setup |
130 | 130 | $categories = new Api\Categories('', 'resources'); |
131 | 131 | $default = $categories->name2id('General resources'); |
132 | - if($default) |
|
132 | + if ($default) |
|
133 | 133 | { |
134 | 134 | $new_cat_id = $default; |
135 | 135 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | // Default missing, look for 'No category' |
139 | 139 | $new_cat_id = $categories->name2id('No category'); |
140 | - if($new_cat_id == 0) { |
|
140 | + if ($new_cat_id == 0) { |
|
141 | 141 | // No category not there, add it |
142 | 142 | $new_cat_id = $categories->add(array( |
143 | 143 | 'name' => 'No category', |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'parent' => 0 |
146 | 146 | )); |
147 | 147 | $admin = -2; |
148 | - resources_acl_bo::set_rights($new_cat_id, array($admin), array($admin), array($admin), array($admin),array($admin)); |
|
148 | + resources_acl_bo::set_rights($new_cat_id, array($admin), array($admin), array($admin), array($admin), array($admin)); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | $bo = new resources_bo(); |
160 | 160 | $bo->get_rows($query, $resources, $readonly); |
161 | 161 | |
162 | - foreach($resources as $resource) |
|
162 | + foreach ($resources as $resource) |
|
163 | 163 | { |
164 | - if(is_array($resource)) |
|
164 | + if (is_array($resource)) |
|
165 | 165 | { |
166 | 166 | $resource['cat_id'] = $new_cat_id; |
167 | 167 | $bo->save($resource); |
@@ -20,4 +20,6 @@ |
||
20 | 20 | * @depreacated use Api\Contacts |
21 | 21 | */ |
22 | 22 | |
23 | -class addressbook_so extends Api\Contacts\Storage {} |
|
23 | +class addressbook_so extends Api\Contacts\Storage |
|
24 | +{ |
|
25 | +} |
@@ -68,7 +68,7 @@ |
||
68 | 68 | |
69 | 69 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences') |
70 | 70 | { |
71 | - $file = Array( |
|
71 | + $file = array( |
|
72 | 72 | 'Site configuration' => Egw::link('/index.php',array( |
73 | 73 | 'menuaction' => 'admin.uiconfig.index', |
74 | 74 | 'appname' => $appname, |
@@ -498,11 +498,14 @@ discard block |
||
498 | 498 | } |
499 | 499 | } |
500 | 500 | $own_account_acl['link_to'] = 'Links'; |
501 | - if ($config['account_repository'] != 'ldap') // no custom-fields in ldap |
|
501 | + if ($config['account_repository'] != 'ldap') |
|
502 | + { |
|
503 | + // no custom-fields in ldap |
|
502 | 504 | { |
503 | 505 | foreach(Api\Storage\Customfields::get('addressbook') as $name => $data) |
504 | 506 | { |
505 | 507 | $own_account_acl['#'.$name] = $data['label']; |
508 | + } |
|
506 | 509 | } |
507 | 510 | } |
508 | 511 | |
@@ -522,11 +525,14 @@ discard block |
||
522 | 525 | $copy_fields[$field] = $label; |
523 | 526 | } |
524 | 527 | } |
525 | - if ($config['contact_repository'] != 'ldap') // no custom-fields in ldap |
|
528 | + if ($config['contact_repository'] != 'ldap') |
|
529 | + { |
|
530 | + // no custom-fields in ldap |
|
526 | 531 | { |
527 | 532 | foreach(Api\Storage\Customfields::get('addressbook') as $name => $data) |
528 | 533 | { |
529 | 534 | $copy_fields['#'.$name] = $data['label']; |
535 | + } |
|
530 | 536 | } |
531 | 537 | } |
532 | 538 | // Remove country codes as an option, it will be added by UI constructor |
@@ -559,7 +565,10 @@ discard block |
||
559 | 565 | ) |
560 | 566 | ); |
561 | 567 | |
562 | - if (empty($config['geolocation_url'])) $ret ['geolocation_url'] = $geoLocation[0]['value']; |
|
568 | + if (empty($config['geolocation_url'])) |
|
569 | + { |
|
570 | + $ret ['geolocation_url'] = $geoLocation[0]['value']; |
|
571 | + } |
|
563 | 572 | return $ret; |
564 | 573 | } |
565 | 574 | } |
@@ -43,38 +43,38 @@ discard block |
||
43 | 43 | 'link' => false, |
44 | 44 | 'icon' => false, |
45 | 45 | ), |
46 | - 'menuOpened' => true, // display it open by default |
|
46 | + 'menuOpened' => true, // display it open by default |
|
47 | 47 | )); |
48 | 48 | } |
49 | 49 | // Magic etemplate2 favorites menu (from nextmatch widget) |
50 | 50 | display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites('addressbook')); |
51 | 51 | |
52 | 52 | $file = array( |
53 | - 'Addressbook list' => Egw::link('/index.php',array( |
|
53 | + 'Addressbook list' => Egw::link('/index.php', array( |
|
54 | 54 | 'menuaction' => 'addressbook.addressbook_ui.index', |
55 | 55 | 'ajax' => 'true')), |
56 | 56 | array( |
57 | - 'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))), |
|
57 | + 'text' => lang('Add %1', lang(Link::get_registry($appname, 'entry'))), |
|
58 | 58 | 'no_lang' => true, |
59 | 59 | 'link' => "javascript:egw.open('','$appname','add')" |
60 | 60 | ), |
61 | 61 | 'Advanced search' => "javascript:egw_openWindowCentered2('". |
62 | - Egw::link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.search'),false). |
|
62 | + Egw::link('/index.php', array('menuaction' => 'addressbook.addressbook_ui.search'), false). |
|
63 | 63 | "','_blank',870,610,'yes')", |
64 | - 'Placeholders' => Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements') |
|
64 | + 'Placeholders' => Egw::link('/index.php', 'menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements') |
|
65 | 65 | ); |
66 | - display_sidebox($appname,lang('Addressbook menu'),$file); |
|
66 | + display_sidebox($appname, lang('Addressbook menu'), $file); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences') |
70 | 70 | { |
71 | 71 | $file = Array( |
72 | - 'Site configuration' => Egw::link('/index.php',array( |
|
72 | + 'Site configuration' => Egw::link('/index.php', array( |
|
73 | 73 | 'menuaction' => 'admin.uiconfig.index', |
74 | 74 | 'appname' => $appname, |
75 | 75 | 'ajax' => 'true', |
76 | 76 | )), |
77 | - 'Global Categories' => Egw::link('/index.php',array( |
|
77 | + 'Global Categories' => Egw::link('/index.php', array( |
|
78 | 78 | 'menuaction' => 'admin.admin_categories.index', |
79 | 79 | 'appname' => $appname, |
80 | 80 | 'global_cats'=> True, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | // custom fields are not availible in LDAP |
85 | 85 | if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
86 | 86 | { |
87 | - $file['Custom fields'] = Egw::link('/index.php',array( |
|
87 | + $file['Custom fields'] = Egw::link('/index.php', array( |
|
88 | 88 | 'menuaction' => 'admin.admin_customfields.index', |
89 | 89 | 'appname' => $appname, |
90 | 90 | 'use_private'=> 1, |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | } |
94 | 94 | if ($location == 'admin') |
95 | 95 | { |
96 | - display_section($appname,$file); |
|
96 | + display_section($appname, $file); |
|
97 | 97 | } |
98 | 98 | else |
99 | 99 | { |
100 | - display_sidebox($appname,lang('Admin'),$file); |
|
100 | + display_sidebox($appname, lang('Admin'), $file); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'label' => 'Default addressbook for adding contacts', |
125 | 125 | 'name' => 'add_default', |
126 | 126 | 'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.', |
127 | - 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',Acl::ADD) : array(), |
|
127 | + 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks', Acl::ADD) : array(), |
|
128 | 128 | 'xmlrpc' => True, |
129 | 129 | 'admin' => False, |
130 | 130 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $contacts = new Api\Contacts(); |
152 | 152 | $fileas_options = $contacts->fileas_options(); |
153 | - foreach(Api\Contacts\Storage::$duplicate_fields as $key => $label) |
|
153 | + foreach (Api\Contacts\Storage::$duplicate_fields as $key => $label) |
|
154 | 154 | { |
155 | 155 | $duplicate_options[$key] = lang($label); |
156 | 156 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'name' => 'link_title', |
162 | 162 | 'values' => array( |
163 | 163 | 'n_fileas' => lang('own sorting').' ('.lang('default').': '.lang('Company').': '.lang('lastname').', '.lang('firstname').')', |
164 | - )+$fileas_options, // plus all fileas types |
|
164 | + ) + $fileas_options, // plus all fileas types |
|
165 | 165 | 'help' => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!', |
166 | 166 | 'xmlrpc' => True, |
167 | 167 | 'admin' => false, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | '~edit~' => lang('Edit contact'), |
227 | 227 | 'infolog' => lang('Open %1 CRM view', lang('infolog')), |
228 | 228 | ); |
229 | - if($GLOBALS['egw_info']['user']['apps']['tracker']) |
|
229 | + if ($GLOBALS['egw_info']['user']['apps']['tracker']) |
|
230 | 230 | { |
231 | 231 | $crm_list_options['tracker'] = lang('Open %1 CRM view', lang('tracker')); |
232 | 232 | } |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | 'label' => 'Default document to insert contacts', |
274 | 274 | 'name' => 'default_document', |
275 | 275 | 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('addressbook')).' '. |
276 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
|
277 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
276 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '. |
|
277 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
278 | 278 | 'run_lang' => false, |
279 | 279 | 'xmlrpc' => True, |
280 | 280 | 'admin' => False, |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | 'size' => 60, |
285 | 285 | 'label' => 'Directory with documents to insert contacts', |
286 | 286 | 'name' => 'document_dir', |
287 | - 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('addressbook')).' '. |
|
288 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
|
289 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
287 | + 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.', lang('addressbook')).' '. |
|
288 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '. |
|
289 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
290 | 290 | 'run_lang' => false, |
291 | 291 | 'xmlrpc' => True, |
292 | 292 | 'admin' => False, |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | static function search_link($location) |
372 | 372 | { |
373 | - unset($location); // not used, but required by function signature |
|
373 | + unset($location); // not used, but required by function signature |
|
374 | 374 | |
375 | 375 | $links = array( |
376 | 376 | 'query' => 'api.EGroupware\\Api\\Contacts.link_query', |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | 'add_app' => 'link_app', |
397 | 397 | 'add_id' => 'link_id', |
398 | 398 | 'add_popup' => '870x610', |
399 | - 'file_access_user' => true, // file_access supports 4th parameter $user |
|
399 | + 'file_access_user' => true, // file_access supports 4th parameter $user |
|
400 | 400 | 'file_access'=> 'api.EGroupware\\Api\\Contacts.file_access', |
401 | - 'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png','template' => 'addressbook.edit'))), |
|
401 | + 'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png', 'template' => 'addressbook.edit'))), |
|
402 | 402 | // registers an addtional type 'addressbook-email', returning only contacts with email, title has email appended |
403 | 403 | 'additional' => array( |
404 | 404 | 'addressbook-email' => array( |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | static function getAppExportLimit($location) |
427 | 427 | { |
428 | - unset($location); // not used, but required by function signature |
|
428 | + unset($location); // not used, but required by function signature |
|
429 | 429 | |
430 | 430 | return $GLOBALS['egw_info']['server']['contact_export_limit']; |
431 | 431 | } |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | */ |
439 | 439 | static function calendar_resources($args) |
440 | 440 | { |
441 | - unset($args); // not used, but required by function signature |
|
441 | + unset($args); // not used, but required by function signature |
|
442 | 442 | |
443 | 443 | return array( |
444 | - 'type' => 'c',// one char type-identifiy for this resources |
|
445 | - 'info' => 'api.EGroupware\\Api\\Contacts.calendar_info',// info method, returns array with id, type & name for a given id |
|
444 | + 'type' => 'c', // one char type-identifiy for this resources |
|
445 | + 'info' => 'api.EGroupware\\Api\\Contacts.calendar_info', // info method, returns array with id, type & name for a given id |
|
446 | 446 | ); |
447 | 447 | } |
448 | 448 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | static function group_acl($args) |
456 | 456 | { |
457 | - unset($args); // not used, but required by function signature |
|
457 | + unset($args); // not used, but required by function signature |
|
458 | 458 | |
459 | 459 | // addressbook uses group-acl, only if contacts-backend is NOT LDAP, as the ACL can not be modified there |
460 | 460 | return $GLOBALS['egw_info']['server']['contact_repository'] != 'ldap'; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | */ |
469 | 469 | static function not_enum_group_acls($data) |
470 | 470 | { |
471 | - unset($data); // not used, but required by function signature |
|
471 | + unset($data); // not used, but required by function signature |
|
472 | 472 | |
473 | 473 | return true; |
474 | 474 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | */ |
482 | 482 | public static function acl_rights($params) |
483 | 483 | { |
484 | - unset($params); // not used, but required by function signature |
|
484 | + unset($params); // not used, but required by function signature |
|
485 | 485 | |
486 | 486 | return array( |
487 | 487 | Acl::READ => 'read', |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | */ |
500 | 500 | public static function categories($data) |
501 | 501 | { |
502 | - unset($data); // not used, but required by function signature |
|
502 | + unset($data); // not used, but required by function signature |
|
503 | 503 | |
504 | 504 | return true; |
505 | 505 | } |
@@ -516,10 +516,10 @@ discard block |
||
516 | 516 | |
517 | 517 | // get the list of account fields |
518 | 518 | $own_account_acl = array(); |
519 | - foreach($bocontacts->contact_fields as $field => $label) |
|
519 | + foreach ($bocontacts->contact_fields as $field => $label) |
|
520 | 520 | { |
521 | 521 | // some fields the user should never be allowed to edit or are covert by an other attribute (n_fn for all n_*) |
522 | - if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix'))) |
|
522 | + if (!in_array($field, array('id', 'tid', 'owner', 'created', 'creator', 'modified', 'modifier', 'private', 'n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix'))) |
|
523 | 523 | { |
524 | 524 | $own_account_acl[$field] = $label; |
525 | 525 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | $own_account_acl['link_to'] = 'Links'; |
528 | 528 | if ($config['account_repository'] != 'ldap') // no custom-fields in ldap |
529 | 529 | { |
530 | - foreach(Api\Storage\Customfields::get('addressbook') as $name => $data) |
|
530 | + foreach (Api\Storage\Customfields::get('addressbook') as $name => $data) |
|
531 | 531 | { |
532 | 532 | $own_account_acl['#'.$name] = $data['label']; |
533 | 533 | } |
@@ -538,26 +538,26 @@ discard block |
||
538 | 538 | // Remove country codes as an option, it will be added by BO constructor |
539 | 539 | unset($org_fields['adr_one_countrycode'], $org_fields['adr_two_countrycode']); |
540 | 540 | |
541 | - $supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!) |
|
541 | + $supported_fields = $bocontacts->get_fields('supported', null, 0); // fields supported by the backend (ldap schemas!) |
|
542 | 542 | // get the list of account fields |
543 | 543 | $copy_fields = array(); |
544 | - foreach($bocontacts->contact_fields as $field => $label) |
|
544 | + foreach ($bocontacts->contact_fields as $field => $label) |
|
545 | 545 | { |
546 | 546 | // some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*) |
547 | - if (!in_array($field,array('id','tid','created','creator','modified','modifier','account_id','uid','etag','n_fn'))) |
|
547 | + if (!in_array($field, array('id', 'tid', 'created', 'creator', 'modified', 'modifier', 'account_id', 'uid', 'etag', 'n_fn'))) |
|
548 | 548 | { |
549 | 549 | $copy_fields[$field] = $label; |
550 | 550 | } |
551 | 551 | } |
552 | 552 | if ($config['contact_repository'] != 'ldap') // no custom-fields in ldap |
553 | 553 | { |
554 | - foreach(Api\Storage\Customfields::get('addressbook') as $name => $data) |
|
554 | + foreach (Api\Storage\Customfields::get('addressbook') as $name => $data) |
|
555 | 555 | { |
556 | 556 | $copy_fields['#'.$name] = $data['label']; |
557 | 557 | } |
558 | 558 | } |
559 | 559 | // Remove country codes as an option, it will be added by UI constructor |
560 | - if(in_array('adr_one_countrycode', $supported_fields)) |
|
560 | + if (in_array('adr_one_countrycode', $supported_fields)) |
|
561 | 561 | { |
562 | 562 | unset($copy_fields['adr_one_countrycode'], $copy_fields['adr_two_countrycode']); |
563 | 563 | } |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | $ret = array( |
579 | 579 | 'sel_options' => array( |
580 | 580 | 'own_account_acl' => $own_account_acl, |
581 | - 'org_fileds_to_update' => $org_fields, // typo has to stay, as it was there allways and we would loose existing config :( |
|
581 | + 'org_fileds_to_update' => $org_fields, // typo has to stay, as it was there allways and we would loose existing config :( |
|
582 | 582 | 'copy_fields' => $copy_fields, |
583 | 583 | 'fileas' => $bocontacts->fileas_options(), |
584 | 584 | 'contact_repository' => $repositories, |
@@ -18,4 +18,6 @@ |
||
18 | 18 | * |
19 | 19 | * @deprecated use Api\Contacts\Merge |
20 | 20 | */ |
21 | -class addressbook_merge extends Merge {} |
|
22 | 21 | \ No newline at end of file |
22 | +class addressbook_merge extends Merge |
|
23 | +{ |
|
24 | +} |
|
23 | 25 | \ No newline at end of file |
@@ -82,13 +82,22 @@ |
||
82 | 82 | unset($attrs); // not used |
83 | 83 | |
84 | 84 | // Already done |
85 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
85 | + if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) |
|
86 | + { |
|
87 | + return $value; |
|
88 | + } |
|
86 | 89 | |
87 | 90 | // Link entry, already in array format |
88 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
91 | + if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) |
|
92 | + { |
|
93 | + $value = $value['id']; |
|
94 | + } |
|
89 | 95 | |
90 | 96 | // Link entry, in string format |
91 | - if (substr($value,0,8) == 'infolog:') $value = substr($value,8); |
|
97 | + if (substr($value,0,8) == 'infolog:') |
|
98 | + { |
|
99 | + $value = substr($value,8); |
|
100 | + } |
|
92 | 101 | if($value) |
93 | 102 | { |
94 | 103 | return $this->infolog->read($value); |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | |
105 | 105 | public function get_entry($value, array $attrs) |
106 | 106 | { |
107 | - unset($attrs); // not used |
|
107 | + unset($attrs); // not used |
|
108 | 108 | |
109 | 109 | // Already done |
110 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
110 | + if (is_array($value) && !(array_key_exists('app', $value) && array_key_exists('id', $value))) return $value; |
|
111 | 111 | |
112 | 112 | // Link entry, already in array format |
113 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
113 | + if (is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
114 | 114 | |
115 | 115 | // Link entry, in string format |
116 | - if (substr($value,0,8) == 'infolog:') $value = substr($value,8); |
|
117 | - if($value) |
|
116 | + if (substr($value, 0, 8) == 'infolog:') $value = substr($value, 8); |
|
117 | + if ($value) |
|
118 | 118 | { |
119 | 119 | return $this->infolog->read($value); |
120 | 120 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | function _get_fields() |
125 | 125 | { |
126 | - static $fields=null; |
|
126 | + static $fields = null; |
|
127 | 127 | |
128 | 128 | if (!isset($fields)) |
129 | 129 | { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | // 'info_confirm' => lang('Confirm'), |
160 | 160 | // 'info_custom_from' => lang('Custom from'), |
161 | 161 | ); |
162 | - foreach(Api\Storage\Customfields::get('infolog') as $name => $data) |
|
162 | + foreach (Api\Storage\Customfields::get('infolog') as $name => $data) |
|
163 | 163 | { |
164 | 164 | $fields['#'.$name] = lang($data['label']); |
165 | 165 | } |
@@ -169,4 +169,4 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | // register widgets for etemplate2 |
172 | -Etemplate\Widget::registerWidget('infolog_widget',array('infolog-value', 'infolog-fields')); |
|
172 | +Etemplate\Widget::registerWidget('infolog_widget', array('infolog-value', 'infolog-fields')); |
@@ -247,7 +247,7 @@ |
||
247 | 247 | $this->selects['info_status'] = $this->bo->get_status(); |
248 | 248 | } |
249 | 249 | |
250 | - public function get_filter_fields(Array &$filters) |
|
250 | + public function get_filter_fields(array &$filters) |
|
251 | 251 | { |
252 | 252 | foreach($filters as $field_name => &$settings) |
253 | 253 | { |
@@ -54,7 +54,8 @@ discard block |
||
54 | 54 | case 'all': |
55 | 55 | // do we need to query the cf's |
56 | 56 | $query['custom_fields'] = false; |
57 | - foreach($options['mapping'] + (array)$_definition->filter as $field => $map) { |
|
57 | + foreach($options['mapping'] + (array)$_definition->filter as $field => $map) |
|
58 | + { |
|
58 | 59 | if($field[0] == '#') |
59 | 60 | { |
60 | 61 | $query['custom_fields'] = true; |
@@ -80,11 +81,20 @@ discard block |
||
80 | 81 | // Handle ranges |
81 | 82 | foreach($query['col_filter'] as $field => $value) |
82 | 83 | { |
83 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
84 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
85 | + { |
|
86 | + continue; |
|
87 | + } |
|
84 | 88 | |
85 | 89 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
86 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
87 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
90 | + if($value['from']) |
|
91 | + { |
|
92 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
93 | + } |
|
94 | + if($value['to']) |
|
95 | + { |
|
96 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
97 | + } |
|
88 | 98 | unset($query['col_filter'][$field]); |
89 | 99 | } |
90 | 100 | } |
@@ -101,7 +111,10 @@ discard block |
||
101 | 111 | { |
102 | 112 | foreach($selection as &$row) |
103 | 113 | { |
104 | - if($row[$field]) $cf_preload[$app][] = $row[$field]; |
|
114 | + if($row[$field]) |
|
115 | + { |
|
116 | + $cf_preload[$app][] = $row[$field]; |
|
117 | + } |
|
105 | 118 | } |
106 | 119 | if($cf_preload[$app]) |
107 | 120 | { |
@@ -132,7 +145,10 @@ discard block |
||
132 | 145 | $links = Link::get_links_multiple('infolog', $ids, true, '!'.Link::VFS_APPNAME); |
133 | 146 | foreach($links as $id => $link) |
134 | 147 | { |
135 | - if(!is_array($selection[$id])) break; |
|
148 | + if(!is_array($selection[$id])) |
|
149 | + { |
|
150 | + break; |
|
151 | + } |
|
136 | 152 | $selection[$id]['info_link_id'] = $link = array_pop($link); |
137 | 153 | if(!$options['convert']) |
138 | 154 | { |
@@ -146,7 +162,10 @@ discard block |
||
146 | 162 | $projects = Link::get_links_multiple('infolog', $ids, true, 'projectmanager'); |
147 | 163 | foreach($projects as $id => $links) |
148 | 164 | { |
149 | - if(!is_array($selection[$id])) break; |
|
165 | + if(!is_array($selection[$id])) |
|
166 | + { |
|
167 | + break; |
|
168 | + } |
|
150 | 169 | $selection[$id]['pm_id'] = current($links); |
151 | 170 | $selection[$id]['project'] = Link::title('projectmanager', $selection[$id]['pm_id']); |
152 | 171 | $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist',$selection[$id]['pm_id']); |
@@ -183,7 +202,10 @@ discard block |
||
183 | 202 | // Force 0 times to '' |
184 | 203 | foreach(array('info_planned_time', 'info_used_time', 'info_replanned_time') as $field) |
185 | 204 | { |
186 | - if($record->$field == 0) $record->$field = ''; |
|
205 | + if($record->$field == 0) |
|
206 | + { |
|
207 | + $record->$field = ''; |
|
208 | + } |
|
187 | 209 | } |
188 | 210 | } |
189 | 211 | else |
@@ -191,7 +213,10 @@ discard block |
||
191 | 213 | // Implode arrays, so they don't say 'Array' |
192 | 214 | foreach($record->get_record_array() as $key => $value) |
193 | 215 | { |
194 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
216 | + if(is_array($value)) |
|
217 | + { |
|
218 | + $record->$key = implode(',', $value); |
|
219 | + } |
|
195 | 220 | } |
196 | 221 | } |
197 | 222 | $export_object->export_record($record); |
@@ -280,10 +305,16 @@ discard block |
||
280 | 305 | { |
281 | 306 | foreach($filters as $field_name => &$settings) |
282 | 307 | { |
283 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
308 | + if($this->selects[$field_name]) |
|
309 | + { |
|
310 | + $settings['values'] = $this->selects[$field_name]; |
|
311 | + } |
|
284 | 312 | |
285 | 313 | // Infolog can't handle ranges in custom fields due to the way searching is done. |
286 | - if(strpos($field_name, '#') === 0 && strpos($settings['type'],'date') === 0) unset($filters[$field_name]); |
|
314 | + if(strpos($field_name, '#') === 0 && strpos($settings['type'],'date') === 0) |
|
315 | + { |
|
316 | + unset($filters[$field_name]); |
|
317 | + } |
|
287 | 318 | } |
288 | 319 | } |
289 | 320 |
@@ -288,10 +288,10 @@ |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | - * Convert some internal data to something with more meaning |
|
292 | - * |
|
293 | - * This is for something specific to Infolog, in addition to the normal conversions. |
|
294 | - */ |
|
291 | + * Convert some internal data to something with more meaning |
|
292 | + * |
|
293 | + * This is for something specific to Infolog, in addition to the normal conversions. |
|
294 | + */ |
|
295 | 295 | public static function convert(infolog_egw_record &$record) |
296 | 296 | { |
297 | 297 | // Stub, for now |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param egw_record $_definition |
35 | 35 | */ |
36 | - public function export( $_stream, importexport_definition $_definition) |
|
36 | + public function export($_stream, importexport_definition $_definition) |
|
37 | 37 | { |
38 | 38 | $options = $_definition->plugin_options; |
39 | 39 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $this->export_object->set_mapping($options['mapping']); |
46 | 46 | |
47 | 47 | $ids = array(); |
48 | - switch($options['selection']) |
|
48 | + switch ($options['selection']) |
|
49 | 49 | { |
50 | 50 | case 'search': |
51 | 51 | $query = array_merge((array)Api\Cache::getSession('infolog', 'session_data'), $query); |
@@ -54,37 +54,37 @@ discard block |
||
54 | 54 | case 'all': |
55 | 55 | // do we need to query the cf's |
56 | 56 | $query['custom_fields'] = false; |
57 | - foreach($options['mapping'] + (array)$_definition->filter as $field => $map) { |
|
58 | - if($field[0] == '#') |
|
57 | + foreach ($options['mapping'] + (array)$_definition->filter as $field => $map) { |
|
58 | + if ($field[0] == '#') |
|
59 | 59 | { |
60 | 60 | $query['custom_fields'] = true; |
61 | 61 | $query['selectcols'] .= ",$field"; |
62 | 62 | |
63 | - if($GLOBALS['egw_info']['user']['apps'][$this->bo->customfields[substr($field,1)]['type']]) |
|
63 | + if ($GLOBALS['egw_info']['user']['apps'][$this->bo->customfields[substr($field, 1)]['type']]) |
|
64 | 64 | { |
65 | - $cf_links[$field] = $this->bo->customfields[substr($field,1)]['type']; |
|
65 | + $cf_links[$field] = $this->bo->customfields[substr($field, 1)]['type']; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | - if($options['selection'] == 'filter') |
|
69 | + if ($options['selection'] == 'filter') |
|
70 | 70 | { |
71 | 71 | $fields = importexport_helper_functions::get_filter_fields($_definition->application, $this); |
72 | 72 | $query['col_filter'] = $_definition->filter; |
73 | 73 | |
74 | 74 | // Backend expects a string |
75 | - if($query['col_filter']['info_responsible']) |
|
75 | + if ($query['col_filter']['info_responsible']) |
|
76 | 76 | { |
77 | - $query['col_filter']['info_responsible'] = implode(',',$query['col_filter']['info_responsible']); |
|
77 | + $query['col_filter']['info_responsible'] = implode(',', $query['col_filter']['info_responsible']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Handle ranges |
81 | - foreach($query['col_filter'] as $field => $value) |
|
81 | + foreach ($query['col_filter'] as $field => $value) |
|
82 | 82 | { |
83 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
83 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
84 | 84 | |
85 | 85 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
86 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
87 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
86 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
87 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
88 | 88 | unset($query['col_filter'][$field]); |
89 | 89 | } |
90 | 90 | } |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | |
98 | 98 | // Pre-load any cfs that are links |
99 | 99 | $cf_preload = array(); |
100 | - foreach($cf_links as $field => $app) |
|
100 | + foreach ($cf_links as $field => $app) |
|
101 | 101 | { |
102 | - foreach($selection as &$row) |
|
102 | + foreach ($selection as &$row) |
|
103 | 103 | { |
104 | - if($row[$field]) $cf_preload[$app][] = $row[$field]; |
|
104 | + if ($row[$field]) $cf_preload[$app][] = $row[$field]; |
|
105 | 105 | } |
106 | - if($cf_preload[$app]) |
|
106 | + if ($cf_preload[$app]) |
|
107 | 107 | { |
108 | 108 | $selects[$field] = Link::titles($app, $cf_preload[$app]); |
109 | 109 | //error_log('Preload ' . $field . '['.$app . ']: ' . implode(',',$cf_preload[$app])); |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | $this->export_records($this->export_object, $options, $selection, $ids); |
114 | 114 | $query['start'] += $query['num_rows']; |
115 | - } while($query['start'] < $query['total']); |
|
115 | + } while ($query['start'] < $query['total']); |
|
116 | 116 | |
117 | 117 | return $this->export_object; |
118 | 118 | |
119 | 119 | default: |
120 | - $ids = $selection = explode(',',$options['selection']); |
|
120 | + $ids = $selection = explode(',', $options['selection']); |
|
121 | 121 | $this->export_records($this->export_object, $options, $selection, $ids); |
122 | 122 | break; |
123 | 123 | } |
@@ -127,42 +127,42 @@ discard block |
||
127 | 127 | protected function export_records(&$export_object, $options, &$selection, $ids = array()) |
128 | 128 | { |
129 | 129 | // Pre-load links all at once |
130 | - if($ids && $options['mapping']['info_link_id']) |
|
130 | + if ($ids && $options['mapping']['info_link_id']) |
|
131 | 131 | { |
132 | 132 | $links = Link::get_links_multiple('infolog', $ids, true, '!'.Link::VFS_APPNAME); |
133 | - foreach($links as $id => $link) |
|
133 | + foreach ($links as $id => $link) |
|
134 | 134 | { |
135 | - if(!is_array($selection[$id])) break; |
|
135 | + if (!is_array($selection[$id])) break; |
|
136 | 136 | $selection[$id]['info_link_id'] = $link = array_pop($link); |
137 | - if(!$options['convert']) |
|
137 | + if (!$options['convert']) |
|
138 | 138 | { |
139 | - $selection[$id]['info_link_id'] = $link['app'].':'. $link['id']; |
|
139 | + $selection[$id]['info_link_id'] = $link['app'].':'.$link['id']; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | // If exporting PM fields, pre-load them all at once |
144 | - if($ids && ($options['mapping']['pm_id'] || $options['mapping']['project'])) |
|
144 | + if ($ids && ($options['mapping']['pm_id'] || $options['mapping']['project'])) |
|
145 | 145 | { |
146 | 146 | $projects = Link::get_links_multiple('infolog', $ids, true, 'projectmanager'); |
147 | - foreach($projects as $id => $links) |
|
147 | + foreach ($projects as $id => $links) |
|
148 | 148 | { |
149 | - if(!is_array($selection[$id])) break; |
|
149 | + if (!is_array($selection[$id])) break; |
|
150 | 150 | $selection[$id]['pm_id'] = current($links); |
151 | 151 | $selection[$id]['project'] = Link::title('projectmanager', $selection[$id]['pm_id']); |
152 | - $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist',$selection[$id]['pm_id']); |
|
152 | + $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist', $selection[$id]['pm_id']); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | foreach ($selection as $_identifier) |
157 | 157 | { |
158 | - if(!is_array($_identifier)) |
|
158 | + if (!is_array($_identifier)) |
|
159 | 159 | { |
160 | 160 | $record = new infolog_egw_record($_identifier); |
161 | - if(($link = $links[$record->info_id])) |
|
161 | + if (($link = $links[$record->info_id])) |
|
162 | 162 | { |
163 | 163 | $record->info_link_id = $options['convert'] ? Link::title($link['app'], $link['id']) : ($link['app'].':'.$link['id']); |
164 | 164 | } |
165 | - if(($project = $projects[$record->info_id])) |
|
165 | + if (($project = $projects[$record->info_id])) |
|
166 | 166 | { |
167 | 167 | $record->pm_id = current($project); |
168 | 168 | $record->project = Link::title('projectmanager', $record->pm_id); |
@@ -174,24 +174,24 @@ discard block |
||
174 | 174 | $record->set_record($_identifier); |
175 | 175 | } |
176 | 176 | // Some conversion |
177 | - if($options['convert']) |
|
177 | + if ($options['convert']) |
|
178 | 178 | { |
179 | 179 | $this->selects['info_status'] = $this->bo->get_status($record->info_type); |
180 | 180 | importexport_export_csv::convert($record, infolog_egw_record::$types, 'infolog', $this->selects); |
181 | 181 | $this->convert($record); |
182 | 182 | |
183 | 183 | // Force 0 times to '' |
184 | - foreach(array('info_planned_time', 'info_used_time', 'info_replanned_time') as $field) |
|
184 | + foreach (array('info_planned_time', 'info_used_time', 'info_replanned_time') as $field) |
|
185 | 185 | { |
186 | - if($record->$field == 0) $record->$field = ''; |
|
186 | + if ($record->$field == 0) $record->$field = ''; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | else |
190 | 190 | { |
191 | 191 | // Implode arrays, so they don't say 'Array' |
192 | - foreach($record->get_record_array() as $key => $value) |
|
192 | + foreach ($record->get_record_array() as $key => $value) |
|
193 | 193 | { |
194 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
194 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | $export_object->export_record($record); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function get_filename() |
242 | 242 | { |
243 | - if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
243 | + if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
244 | 244 | { |
245 | 245 | return $this->export_object->record->get_title(); |
246 | 246 | } |
@@ -272,18 +272,18 @@ discard block |
||
272 | 272 | { |
273 | 273 | $this->selects['info_type'] = $this->bo->enums['type']; |
274 | 274 | $this->selects['info_priority'] = $this->bo->enums['priority']; |
275 | - $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist',false); |
|
275 | + $this->selects['pl_id'] = ExecMethod('projectmanager.projectmanager_pricelist_bo.pricelist', false); |
|
276 | 276 | $this->selects['info_status'] = $this->bo->get_status(); |
277 | 277 | } |
278 | 278 | |
279 | 279 | public function get_filter_fields(Array &$filters) |
280 | 280 | { |
281 | - foreach($filters as $field_name => &$settings) |
|
281 | + foreach ($filters as $field_name => &$settings) |
|
282 | 282 | { |
283 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
283 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
284 | 284 | |
285 | 285 | // Infolog can't handle ranges in custom fields due to the way searching is done. |
286 | - if(strpos($field_name, '#') === 0 && strpos($settings['type'],'date') === 0) unset($filters[$field_name]); |
|
286 | + if (strpos($field_name, '#') === 0 && strpos($settings['type'], 'date') === 0) unset($filters[$field_name]); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Exports records as defined in $_definition |
25 | 25 | * |
26 | - * @param egw_record $_definition |
|
26 | + * @param importexport_definition $_definition |
|
27 | 27 | */ |
28 | 28 | public function export( $_stream, importexport_definition $_definition) |
29 | 29 | { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param $definition Specific definition |
146 | 146 | * |
147 | - * @return array ( |
|
147 | + * @return boolean ( |
|
148 | 148 | * name => string, |
149 | 149 | * content => array, |
150 | 150 | * sel_options => array, |