@@ -115,6 +115,7 @@ discard block |
||
115 | 115 | /** |
116 | 116 | * Sets the sidebox width accoringly to the app_specific_sidebar_width setting, either |
117 | 117 | * in the current application or globaly |
118 | + * @param integer $val |
|
118 | 119 | */ |
119 | 120 | private static function set_sidebar_width($app, $val) |
120 | 121 | { |
@@ -427,11 +428,6 @@ discard block |
||
427 | 428 | /** |
428 | 429 | * Add menu items to the topmenu template class to be displayed |
429 | 430 | * |
430 | - * @param array $app application data |
|
431 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
432 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
433 | - * @access protected |
|
434 | - * @return void |
|
435 | 431 | */ |
436 | 432 | function _add_topmenu_item(array $app_data,$alt_label=null) |
437 | 433 | { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Sets the sidebox width accoringly to the app_specific_sidebar_width setting, either |
117 | - * in the current application or globaly |
|
117 | + * in the current application or globaly |
|
118 | 118 | */ |
119 | 119 | private static function set_sidebar_width($app, $val) |
120 | 120 | { |
@@ -408,16 +408,16 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
411 | - * called by hooks to add an icon in the topmenu info location |
|
412 | - * |
|
413 | - * @param string $id unique element id |
|
414 | - * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
415 | - * @param string $iconlink where the icon links to |
|
416 | - * @param booleon $blink set true to make the icon blink |
|
417 | - * @param mixed $tooltip string containing the tooltip html, or null of no tooltip |
|
418 | - * @todo implement in a reasonable way for jdots |
|
419 | - * @return void |
|
420 | - */ |
|
411 | + * called by hooks to add an icon in the topmenu info location |
|
412 | + * |
|
413 | + * @param string $id unique element id |
|
414 | + * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
415 | + * @param string $iconlink where the icon links to |
|
416 | + * @param booleon $blink set true to make the icon blink |
|
417 | + * @param mixed $tooltip string containing the tooltip html, or null of no tooltip |
|
418 | + * @todo implement in a reasonable way for jdots |
|
419 | + * @return void |
|
420 | + */ |
|
421 | 421 | function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
422 | 422 | { |
423 | 423 | unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
428 | - * Add menu items to the topmenu template class to be displayed |
|
429 | - * |
|
430 | - * @param array $app application data |
|
431 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
432 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
433 | - * @access protected |
|
434 | - * @return void |
|
435 | - */ |
|
428 | + * Add menu items to the topmenu template class to be displayed |
|
429 | + * |
|
430 | + * @param array $app application data |
|
431 | + * @param mixed $alt_label string with alternative menu item label default value = null |
|
432 | + * @param string $urlextra string with alternate additional code inside <a>-tag |
|
433 | + * @access protected |
|
434 | + * @return void |
|
435 | + */ |
|
436 | 436 | function _add_topmenu_item(array $app_data,$alt_label=null) |
437 | 437 | { |
438 | 438 | switch($app_data['name']) |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param string $template = 'idots' name of the template |
52 | 52 | */ |
53 | - function __construct($template=self::APP) |
|
53 | + function __construct($template = self::APP) |
|
54 | 54 | { |
55 | - parent::__construct($template); // call the constructor of the extended class |
|
55 | + parent::__construct($template); // call the constructor of the extended class |
|
56 | 56 | |
57 | - $this->template_dir = '/'.$template; // we are packaged as an application |
|
57 | + $this->template_dir = '/'.$template; // we are packaged as an application |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | public static function app_from_url($url) |
133 | 133 | { |
134 | 134 | $matches = null; |
135 | - if (preg_match('/menuaction=([a-z0-9_-]+)\./i',$url,$matches)) |
|
135 | + if (preg_match('/menuaction=([a-z0-9_-]+)\./i', $url, $matches)) |
|
136 | 136 | { |
137 | 137 | return $matches[1]; |
138 | 138 | } |
139 | 139 | if ($GLOBALS['egw_info']['server']['webserver_url'] && |
140 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH))) |
|
140 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH))) |
|
141 | 141 | { |
142 | - list(,$url) = explode($webserver_path, parse_url($url,PHP_URL_PATH),2); |
|
142 | + list(,$url) = explode($webserver_path, parse_url($url, PHP_URL_PATH), 2); |
|
143 | 143 | } |
144 | - if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/',$url,$matches)) |
|
144 | + if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/', $url, $matches)) |
|
145 | 145 | { |
146 | 146 | return $matches[1]; |
147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $link_app = null if appname or true, some templates generate a special link-handler url |
158 | 158 | * @return string The full url after processing |
159 | 159 | */ |
160 | - static function link($url = '', $extravars = '', $link_app=null) |
|
160 | + static function link($url = '', $extravars = '', $link_app = null) |
|
161 | 161 | { |
162 | 162 | if (is_null($link_app)) $link_app = self::$link_app; |
163 | 163 | $link = parent::link($url, $extravars); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | // Link gets handled in JS, so quotes need slashes as well as url-encoded |
169 | 169 | // encoded ampersands in get parameters (%26) need to be encoded twise, |
170 | 170 | // so they are still encoded when assigned to window.location |
171 | - $link_with_slashes = str_replace(array('%27','%26'), array('\%27','%2526'), $link); |
|
171 | + $link_with_slashes = str_replace(array('%27', '%26'), array('\%27', '%2526'), $link); |
|
172 | 172 | |
173 | 173 | //$link = "javascript:window.egw_link_handler?egw_link_handler('$link','$link_app'):parent.egw_link_handler('$link','$link_app');"; |
174 | 174 | $link = "javascript:egw_link_handler('$link_with_slashes','$link_app')"; |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | $ret = parent::_get_css(); |
188 | 188 | |
189 | 189 | // color to use |
190 | - $color = str_replace('custom',$GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'], |
|
190 | + $color = str_replace('custom', $GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'], |
|
191 | 191 | $GLOBALS['egw_info']['user']['preferences']['common']['template_color']); |
192 | 192 | // use active tab or header, beside sidebox |
193 | - if (($use_active_tab = $color[0] == '@')) $color = substr($color,1); |
|
193 | + if (($use_active_tab = $color[0] == '@')) $color = substr($color, 1); |
|
194 | 194 | |
195 | - if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) // a little xss check |
|
195 | + if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i', $color)) // a little xss check |
|
196 | 196 | { |
197 | 197 | $ret['app_css'] .= " |
198 | 198 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | protected function _get_csp_frame_src() |
235 | 235 | { |
236 | 236 | $srcs = array(); |
237 | - foreach($GLOBALS['egw']->hooks->process('csp-frame-src') as $src) |
|
237 | + foreach ($GLOBALS['egw']->hooks->process('csp-frame-src') as $src) |
|
238 | 238 | { |
239 | 239 | if ($src) $srcs = array_merge($srcs, $src); |
240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param array $extra = array() extra attributes passed as data-attribute to egw.js |
248 | 248 | * @return string with html |
249 | 249 | */ |
250 | - function header(array $extra=array()) |
|
250 | + function header(array $extra = array()) |
|
251 | 251 | { |
252 | 252 | // make sure header is output only once |
253 | 253 | if (self::$header_done) return ''; |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | { |
273 | 273 | $this->tpl->set_file(array('_head' => 'head.tpl')); |
274 | 274 | } |
275 | - $this->tpl->set_block('_head','head'); |
|
276 | - $this->tpl->set_block('_head','framework'); |
|
275 | + $this->tpl->set_block('_head', 'head'); |
|
276 | + $this->tpl->set_block('_head', 'framework'); |
|
277 | 277 | |
278 | 278 | // should we draw the framework, or just a header |
279 | 279 | $do_framework = isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | { |
291 | 291 | //echo __METHOD__.__LINE__.' do framework ...'.'<br>'; |
292 | 292 | // framework javascript classes only need for framework |
293 | - self::validate_file('jquery','jquery-ui'); |
|
293 | + self::validate_file('jquery', 'jquery-ui'); |
|
294 | 294 | self::validate_file('framework', 'fw', self::JS_INCLUDE_APP); |
295 | 295 | self::validate_file('framework', 'fw_browser', self::JS_INCLUDE_APP); |
296 | 296 | self::validate_file('framework', 'fw_ui', self::JS_INCLUDE_APP); |
@@ -303,12 +303,12 @@ discard block |
||
303 | 303 | self::validate_file('.', 'fw_'.static::APP, static::JS_INCLUDE_APP); |
304 | 304 | } |
305 | 305 | self::validate_file('.', 'egw_fw_classes', self::JS_INCLUDE_APP); |
306 | - self::validate_file('.','etemplate2','etemplate'); |
|
306 | + self::validate_file('.', 'etemplate2', 'etemplate'); |
|
307 | 307 | |
308 | 308 | // Need to load this here to get enhanced selectboxes working |
309 | 309 | self::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.js'); |
310 | 310 | |
311 | - egw_cache::unsetSession(__CLASS__,'sidebox_md5'); // sideboxes need to be send again |
|
311 | + egw_cache::unsetSession(__CLASS__, 'sidebox_md5'); // sideboxes need to be send again |
|
312 | 312 | |
313 | 313 | // load jscalendar for calendar users |
314 | 314 | if ($GLOBALS['egw_info']['user']['apps']['calendar']) |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // load dhtmlxtree for pm or email users |
319 | 319 | if ($GLOBALS['egw_info']['user']['apps']['projectmanager'] || $GLOBALS['egw_info']['user']['apps']['felamimail']) |
320 | 320 | { |
321 | - $GLOBALS['egw_info']['flags']['java_script'] .= html::tree(null,null); |
|
321 | + $GLOBALS['egw_info']['flags']['java_script'] .= html::tree(null, null); |
|
322 | 322 | } |
323 | 323 | $extra['navbar-apps'] = $this->get_navbar_apps($_SERVER['REQUEST_URI']); |
324 | 324 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | // - if not we need to check if we have an opener (are a popup window) |
328 | 328 | // - as popups can open further popups, we need to decend all the way down until we find a framework |
329 | 329 | // - only if we cant find a framework in all openers, we redirect to create a new framework |
330 | - if(!$do_framework) |
|
330 | + if (!$do_framework) |
|
331 | 331 | { |
332 | 332 | // fetch sidebox from application and set it in extra data, if we are no popup |
333 | 333 | if (!$GLOBALS['egw_info']['flags']['nonavbar']) |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | // for remote manual never check/create framework |
338 | 338 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
339 | 339 | { |
340 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
340 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script'] = ''; |
|
341 | 341 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
342 | 342 | } |
343 | 343 | } |
344 | 344 | $this->tpl->set_var($this->_get_header($extra)); |
345 | - $content = $this->tpl->fp('out','head').$content; |
|
345 | + $content = $this->tpl->fp('out', 'head').$content; |
|
346 | 346 | |
347 | 347 | if (!$do_framework) |
348 | 348 | { |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | |
352 | 352 | // topmenu |
353 | 353 | $vars = $this->_get_navbar($apps = $this->_get_navbar_apps()); |
354 | - $this->tpl->set_var($this->topmenu($vars,$apps)); |
|
354 | + $this->tpl->set_var($this->topmenu($vars, $apps)); |
|
355 | 355 | |
356 | 356 | // hook after_navbar (eg. notifications) |
357 | - $this->tpl->set_var('hook_after_navbar',$this->_get_after_navbar()); |
|
357 | + $this->tpl->set_var('hook_after_navbar', $this->_get_after_navbar()); |
|
358 | 358 | |
359 | 359 | //Global sidebar width |
360 | 360 | $this->tpl->set_var('sidebox_width', self::get_global_sidebar_width()); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | // add framework div's |
373 | 373 | $this->tpl->set_var($this->_get_footer()); |
374 | - $content .= $this->tpl->fp('out','framework'); |
|
374 | + $content .= $this->tpl->fp('out', 'framework'); |
|
375 | 375 | $content .= self::footer(false); |
376 | 376 | |
377 | 377 | echo $content; |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * @param array $apps |
391 | 391 | * @return array |
392 | 392 | */ |
393 | - function topmenu(array $vars,array $apps) |
|
393 | + function topmenu(array $vars, array $apps) |
|
394 | 394 | { |
395 | 395 | $this->topmenu_items = $this->topmenu_info_items = array(); |
396 | 396 | |
397 | - parent::topmenu($vars,$apps); |
|
398 | - $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>",$this->topmenu_items)."</li>\n</ul>"; |
|
397 | + parent::topmenu($vars, $apps); |
|
398 | + $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>", $this->topmenu_items)."</li>\n</ul>"; |
|
399 | 399 | $vars['topmenu_info_items'] = ''; |
400 | - foreach($this->topmenu_info_items as $id => $item) |
|
400 | + foreach ($this->topmenu_info_items as $id => $item) |
|
401 | 401 | { |
402 | 402 | $vars['topmenu_info_items'] .= '<div class="topmenu_info_item"'. |
403 | 403 | (is_numeric($id) ? '' : ' id="topmenu_info_'.$id.'"').'>'.$item."</div>\n"; |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | * @todo implement in a reasonable way for jdots |
419 | 419 | * @return void |
420 | 420 | */ |
421 | - function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
|
421 | + function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null) |
|
422 | 422 | { |
423 | - unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
|
423 | + unset($id, $icon_src, $iconlink, $blink, $tooltip); // not used |
|
424 | 424 | // not yet implemented, only used in admin/inc/hook_topmenu_info.inc.php to notify about pending updates |
425 | 425 | } |
426 | 426 | |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | * @access protected |
434 | 434 | * @return void |
435 | 435 | */ |
436 | - function _add_topmenu_item(array $app_data,$alt_label=null) |
|
436 | + function _add_topmenu_item(array $app_data, $alt_label = null) |
|
437 | 437 | { |
438 | - switch($app_data['name']) |
|
438 | + switch ($app_data['name']) |
|
439 | 439 | { |
440 | 440 | case 'logout': |
441 | 441 | if (html::$ua_mobile || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile') |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | } |
445 | 445 | else |
446 | 446 | { |
447 | - return; // no need for logout in topmenu on jdots |
|
447 | + return; // no need for logout in topmenu on jdots |
|
448 | 448 | } |
449 | 449 | break; |
450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | break; |
454 | 454 | |
455 | 455 | default: |
456 | - if (strpos($app_data['url'],'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
456 | + if (strpos($app_data['url'], 'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
457 | 457 | { |
458 | 458 | $app_data['url'] = "javascript:egw_link_handler('".$app_data['url']."','". |
459 | 459 | (isset($GLOBALS['egw_info']['user']['apps'][$app_data['name']]) ? |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $id = $app_data['id'] ? $app_data['id'] : ($app_data['name'] ? $app_data['name'] : $app_data['title']); |
464 | 464 | $title = html::$ua_mobile || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile' |
465 | 465 | ? '' : htmlspecialchars($alt_label ? $alt_label : $app_data['title']); |
466 | - $this->topmenu_items[] = '<a id="topmenu_' . $id . '" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
466 | + $this->topmenu_items[] = '<a id="topmenu_'.$id.'" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @access protected |
475 | 475 | * @return void |
476 | 476 | */ |
477 | - function _add_topmenu_info_item($content, $id=null) |
|
477 | + function _add_topmenu_info_item($content, $id = null) |
|
478 | 478 | { |
479 | - if(strpos($content,'menuaction=admin.admin_accesslog.sessions') !== false) |
|
479 | + if (strpos($content, 'menuaction=admin.admin_accesslog.sessions') !== false) |
|
480 | 480 | { |
481 | - $content = preg_replace('/href="([^"]+)"/',"href=\"javascript:egw_link_handler('\\1','admin')\"",$content); |
|
481 | + $content = preg_replace('/href="([^"]+)"/', "href=\"javascript:egw_link_handler('\\1','admin')\"", $content); |
|
482 | 482 | } |
483 | 483 | if ($id) |
484 | 484 | { |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | */ |
498 | 498 | function ajax_tz_selection($tz) |
499 | 499 | { |
500 | - egw_time::setUserPrefs($tz); // throws exception, if tz is invalid |
|
500 | + egw_time::setUserPrefs($tz); // throws exception, if tz is invalid |
|
501 | 501 | |
502 | 502 | $GLOBALS['egw']->preferences->read_repository(); |
503 | - $GLOBALS['egw']->preferences->add('common','tz',$tz); |
|
503 | + $GLOBALS['egw']->preferences->add('common', 'tz', $tz); |
|
504 | 504 | $GLOBALS['egw']->preferences->save_repository(); |
505 | 505 | } |
506 | 506 | |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | // only send admin sidebox, for admin index url (when clicked on admin), |
553 | 553 | // not for other admin pages, called eg. from sidebox menu of other apps |
554 | 554 | // --> that way we always stay in the app, and NOT open admin sidebox for an app tab!!! |
555 | - if ($app == 'admin' && substr($_SERVER['PHP_SELF'],-16) != '/admin/index.php' && |
|
555 | + if ($app == 'admin' && substr($_SERVER['PHP_SELF'], -16) != '/admin/index.php' && |
|
556 | 556 | $_GET['menuaction'] != 'admin.admin_ui.index') |
557 | 557 | { |
558 | 558 | //error_log(__METHOD__."() app=$app, menuaction=$_GET[menuaction], PHP_SELF=$_SERVER[PHP_SELF] --> sidebox request ignored"); |
559 | 559 | return; |
560 | 560 | } |
561 | - $md5_session =& egw_cache::getSession(__CLASS__,'sidebox_md5'); |
|
561 | + $md5_session = & egw_cache::getSession(__CLASS__, 'sidebox_md5'); |
|
562 | 562 | |
563 | 563 | //Set the sidebox content |
564 | 564 | $sidebox = $this->get_sidebox($app); |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | if ($md5_session[$app] !== $md5) |
568 | 568 | { |
569 | 569 | //error_log(__METHOD__."() header changed md5_session[$app]!=='$md5' --> setting it on egw_framework::\$extra[setSidebox]"); |
570 | - $md5_session[$app] = $md5; // update md5 in session |
|
570 | + $md5_session[$app] = $md5; // update md5 in session |
|
571 | 571 | egw_framework::$extra['setSidebox'] = array($app, $sidebox, $md5); |
572 | 572 | } |
573 | 573 | //else error_log(__METHOD__."() md5_session[$app]==='$md5' --> nothing to do"); |
@@ -581,9 +581,9 @@ discard block |
||
581 | 581 | * @return boolean $consider_navbar_not_yet_called_as_true=true ignored by jdots, we only care for cd=yes GET param |
582 | 582 | * @return boolean |
583 | 583 | */ |
584 | - public function isTop($consider_navbar_not_yet_called_as_true=true) |
|
584 | + public function isTop($consider_navbar_not_yet_called_as_true = true) |
|
585 | 585 | { |
586 | - unset($consider_navbar_not_yet_called_as_true); // not used |
|
586 | + unset($consider_navbar_not_yet_called_as_true); // not used |
|
587 | 587 | return isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
588 | 588 | } |
589 | 589 | |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * @param array $file |
610 | 610 | * @param string $type = null 'admin', 'preferences', 'favorites', ... |
611 | 611 | */ |
612 | - public function sidebox($appname,$menu_title,$file,$type=null) |
|
612 | + public function sidebox($appname, $menu_title, $file, $type = null) |
|
613 | 613 | { |
614 | 614 | if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
615 | 615 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | if (($type == 'admin' || $menu_title == lang('Admin')) && $appname != 'admin') |
620 | 620 | { |
621 | 621 | $file = preg_replace("/^(javascript:egw_link_handler\(')(.*)menuaction=([^&]+)(.*)(','[^']+'\))$/", |
622 | - '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=true\',\'admin\')', $file_was=$file); |
|
622 | + '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=true\',\'admin\')', $file_was = $file); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | $this->sideboxes[$appname][$menu_title] = $file; |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | self::$link_app = $appname; |
655 | 655 | // allow other apps to hook into sidebox menu of an app, hook-name: sidebox_$appname |
656 | 656 | $this->sidebox_menu_opened = true; |
657 | - $GLOBALS['egw']->hooks->process('sidebox_'.$appname,array($appname),true); // true = call independent of app-permissions |
|
657 | + $GLOBALS['egw']->hooks->process('sidebox_'.$appname, array($appname), true); // true = call independent of app-permissions |
|
658 | 658 | |
659 | 659 | // calling the old hook |
660 | 660 | $this->sidebox_menu_opened = true; |
661 | - $GLOBALS['egw']->hooks->single('sidebox_menu',$appname); |
|
661 | + $GLOBALS['egw']->hooks->single('sidebox_menu', $appname); |
|
662 | 662 | self::$link_app = null; |
663 | 663 | |
664 | 664 | // allow other apps to hook into sidebox menu of every app: sidebox_all |
665 | - $GLOBALS['egw']->hooks->process('sidebox_all',array($GLOBALS['egw_info']['flags']['currentapp']),true); |
|
665 | + $GLOBALS['egw']->hooks->process('sidebox_all', array($GLOBALS['egw_info']['flags']['currentapp']), true); |
|
666 | 666 | } |
667 | 667 | //If there still is no sidebox content, return null here |
668 | 668 | if (!isset($this->sideboxes[$appname])) |
@@ -671,17 +671,17 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | $data = array(); |
674 | - foreach($this->sideboxes[$appname] as $menu_name => &$file) |
|
674 | + foreach ($this->sideboxes[$appname] as $menu_name => &$file) |
|
675 | 675 | { |
676 | 676 | $current_menu = array( |
677 | - 'menu_name' => md5($menu_name), // can contain html tags and javascript! |
|
677 | + 'menu_name' => md5($menu_name), // can contain html tags and javascript! |
|
678 | 678 | 'title' => $menu_name, |
679 | 679 | 'entries' => array(), |
680 | 680 | 'opened' => (boolean)$file['menuOpened'], |
681 | 681 | ); |
682 | - foreach($file as $item_text => $item_link) |
|
682 | + foreach ($file as $item_text => $item_link) |
|
683 | 683 | { |
684 | - if ($item_text === 'menuOpened' || // flag, not menu entry |
|
684 | + if ($item_text === 'menuOpened' || // flag, not menu entry |
|
685 | 685 | $item_text === '_NewLine_' || $item_link === '_NewLine_') |
686 | 686 | { |
687 | 687 | continue; |
@@ -692,14 +692,14 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | $var = array(); |
695 | - $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images/bullet.png'; |
|
695 | + $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images/bullet.png'; |
|
696 | 696 | $var['target'] = ''; |
697 | - if(is_array($item_link)) |
|
697 | + if (is_array($item_link)) |
|
698 | 698 | { |
699 | - if(isset($item_link['icon'])) |
|
699 | + if (isset($item_link['icon'])) |
|
700 | 700 | { |
701 | 701 | $app = isset($item_link['app']) ? $item_link['app'] : $appname; |
702 | - $var['icon_or_star'] = $item_link['icon'] ? common::image($app,$item_link['icon']) : False; |
|
702 | + $var['icon_or_star'] = $item_link['icon'] ? common::image($app, $item_link['icon']) : False; |
|
703 | 703 | } |
704 | 704 | $var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']); |
705 | 705 | $var['item_link'] = $item_link['link']; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | public function ajax_tab_changed_state($tablist) |
736 | 736 | { |
737 | 737 | $tabs = array(); |
738 | - foreach($tablist as $data) |
|
738 | + foreach ($tablist as $data) |
|
739 | 739 | { |
740 | 740 | $tabs[] = $data['appName']; |
741 | 741 | if ($data['active']) $active = $data['appName']; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | // used eg. in phpFreeChat to leave the chat |
745 | 745 | if (($old_tabs = egw_cache::getSession(__CLASS__, 'open_tabs'))) |
746 | 746 | { |
747 | - foreach(array_diff(explode(',',$old_tabs),$tabs) as $app) |
|
747 | + foreach (array_diff(explode(',', $old_tabs), $tabs) as $app) |
|
748 | 748 | { |
749 | 749 | //error_log("Tab '$app' closed, old_tabs=$old_tabs"); |
750 | 750 | $GLOBALS['egw']->hooks->single(array( |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | ), $app); |
754 | 754 | } |
755 | 755 | } |
756 | - $open = implode(',',$tabs); |
|
756 | + $open = implode(',', $tabs); |
|
757 | 757 | |
758 | 758 | if ($open != $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'] || |
759 | 759 | $active != $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']) |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $i = 0; |
821 | 821 | |
822 | 822 | //Parse the "$apps" array for valid content (security) |
823 | - foreach($apps as $app) |
|
823 | + foreach ($apps as $app) |
|
824 | 824 | { |
825 | 825 | //Check whether the app really exists and add it to the $app_arr var |
826 | 826 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | */ |
881 | 881 | public function navbar_apps() |
882 | 882 | { |
883 | - $apps = parent::_get_navbar_apps(common::svg_usable()); // use svg if usable in browser |
|
883 | + $apps = parent::_get_navbar_apps(common::svg_usable()); // use svg if usable in browser |
|
884 | 884 | //$apps += $this->jdots_remote_apps(); currently not used/usable |
885 | 885 | |
886 | 886 | //Add its sidebox width to each app |
@@ -888,10 +888,10 @@ discard block |
||
888 | 888 | { |
889 | 889 | $data['sideboxwidth'] = self::get_sidebar_width($app); |
890 | 890 | // overwrite icon with svg, if supported by browser |
891 | - unset($data['icon_hover']); // not used in jdots |
|
891 | + unset($data['icon_hover']); // not used in jdots |
|
892 | 892 | } |
893 | 893 | |
894 | - unset($apps['logout']); // never display it |
|
894 | + unset($apps['logout']); // never display it |
|
895 | 895 | if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
896 | 896 | if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
897 | 897 | if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | // check if user called a specific url --> open it as active tab |
943 | - $last_direct_url =& egw_cache::getSession(__CLASS__, 'last_direct_url'); |
|
943 | + $last_direct_url = & egw_cache::getSession(__CLASS__, 'last_direct_url'); |
|
944 | 944 | if ($url !== $last_direct_url) |
945 | 945 | { |
946 | 946 | $active_tab = $url_tab = self::app_from_url($url); |
@@ -953,9 +953,9 @@ discard block |
||
953 | 953 | if ($active_tab && array_key_exists($active_tab, $apps)) |
954 | 954 | { |
955 | 955 | // Do not remove cd=yes if it's an ajax=true app |
956 | - if (strpos( $apps[$active_tab]['url'],'ajax=true') !== False) |
|
956 | + if (strpos($apps[$active_tab]['url'], 'ajax=true') !== False) |
|
957 | 957 | { |
958 | - $url = preg_replace('/[&?]cd=yes/','',$url); |
|
958 | + $url = preg_replace('/[&?]cd=yes/', '', $url); |
|
959 | 959 | } |
960 | 960 | $apps[$active_tab]['openOnce'] = $url; |
961 | 961 | $store_prefs = true; |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | { |
971 | 971 | $open_tabs = $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs']; |
972 | 972 | } |
973 | - $open_tabs = $open_tabs ? explode(',',$open_tabs) : array(); |
|
974 | - if ($active_tab && !in_array($active_tab,$open_tabs)) |
|
973 | + $open_tabs = $open_tabs ? explode(',', $open_tabs) : array(); |
|
974 | + if ($active_tab && !in_array($active_tab, $open_tabs)) |
|
975 | 975 | { |
976 | 976 | $open_tabs[] = $active_tab; |
977 | 977 | $store_prefs = true; |
@@ -979,14 +979,14 @@ discard block |
||
979 | 979 | if ($store_prefs) |
980 | 980 | { |
981 | 981 | $GLOBALS['egw']->preferences->read_repository(); |
982 | - $GLOBALS['egw']->preferences->change('common', 'open_tabs', implode(',',$open_tabs)); |
|
982 | + $GLOBALS['egw']->preferences->change('common', 'open_tabs', implode(',', $open_tabs)); |
|
983 | 983 | $GLOBALS['egw']->preferences->change('common', 'active_tab', $active_tab); |
984 | 984 | $GLOBALS['egw']->preferences->save_repository(true); |
985 | 985 | } |
986 | 986 | |
987 | 987 | //error_log(__METHOD__."('$url') url_tab='$url_tab', active_tab=$active_tab, open_tabs=".array2string($open_tabs)); |
988 | 988 | // Restore Tabs |
989 | - foreach($open_tabs as $n => $app) |
|
989 | + foreach ($open_tabs as $n => $app) |
|
990 | 990 | { |
991 | 991 | if (isset($apps[$app])) // user might no longer have app rights |
992 | 992 | { |
@@ -1013,10 +1013,10 @@ discard block |
||
1013 | 1013 | * @param boolean $no_framework = true |
1014 | 1014 | * @return string |
1015 | 1015 | */ |
1016 | - function footer($no_framework=true) |
|
1016 | + function footer($no_framework = true) |
|
1017 | 1017 | { |
1018 | 1018 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
1019 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
1019 | + if (self::$footer_done) return; // prevent (multiple) footers |
|
1020 | 1020 | self::$footer_done = true; |
1021 | 1021 | |
1022 | 1022 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | return $footer. |
1031 | - $GLOBALS['egw_info']['flags']['need_footer']."\n". // eg. javascript, which need to be at the end of the page |
|
1031 | + $GLOBALS['egw_info']['flags']['need_footer']."\n".// eg. javascript, which need to be at the end of the page |
|
1032 | 1032 | "</body>\n</html>\n"; |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1066,14 +1066,14 @@ discard block |
||
1066 | 1066 | if ($parts['query']) |
1067 | 1067 | { |
1068 | 1068 | $_SERVER['REQUEST_URI'] = '?'.$parts['query']; |
1069 | - parse_str($parts['query'],$_GET); |
|
1069 | + parse_str($parts['query'], $_GET); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | if (!isset($_GET['menuaction'])) |
1073 | 1073 | { |
1074 | 1074 | throw new egw_exception_wrong_parameter(__METHOD__."('$link') no menuaction set!"); |
1075 | 1075 | } |
1076 | - list($app,$class,$method) = explode('.',$_GET['menuaction']); |
|
1076 | + list($app, $class, $method) = explode('.', $_GET['menuaction']); |
|
1077 | 1077 | |
1078 | 1078 | if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
1079 | 1079 | { |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | |
1086 | 1086 | $GLOBALS[$class] = $obj = CreateObject($app.'.'.$class); |
1087 | 1087 | |
1088 | - if(!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
1088 | + if (!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
1089 | 1089 | { |
1090 | 1090 | throw new egw_exception_no_permission("Bad menuaction {$_GET['menuaction']}, not listed in public_functions!"); |
1091 | 1091 | } |
@@ -97,7 +97,9 @@ discard block |
||
97 | 97 | |
98 | 98 | //Width may not be smaller than MIN_SIDEBAR_WIDTH |
99 | 99 | if ($width < self::MIN_SIDEBAR_WIDTH) |
100 | - $width = self::MIN_SIDEBAR_WIDTH; |
|
100 | + { |
|
101 | + $width = self::MIN_SIDEBAR_WIDTH; |
|
102 | + } |
|
101 | 103 | |
102 | 104 | return $width; |
103 | 105 | } |
@@ -159,7 +161,10 @@ discard block |
||
159 | 161 | */ |
160 | 162 | static function link($url = '', $extravars = '', $link_app=null) |
161 | 163 | { |
162 | - if (is_null($link_app)) $link_app = self::$link_app; |
|
164 | + if (is_null($link_app)) |
|
165 | + { |
|
166 | + $link_app = self::$link_app; |
|
167 | + } |
|
163 | 168 | $link = parent::link($url, $extravars); |
164 | 169 | |
165 | 170 | // $link_app === true --> detect application, otherwise use given application |
@@ -190,9 +195,14 @@ discard block |
||
190 | 195 | $color = str_replace('custom',$GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'], |
191 | 196 | $GLOBALS['egw_info']['user']['preferences']['common']['template_color']); |
192 | 197 | // use active tab or header, beside sidebox |
193 | - if (($use_active_tab = $color[0] == '@')) $color = substr($color,1); |
|
198 | + if (($use_active_tab = $color[0] == '@')) |
|
199 | + { |
|
200 | + $color = substr($color,1); |
|
201 | + } |
|
194 | 202 | |
195 | - if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) // a little xss check |
|
203 | + if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) |
|
204 | + { |
|
205 | + // a little xss check |
|
196 | 206 | { |
197 | 207 | $ret['app_css'] .= " |
198 | 208 | /** |
@@ -221,6 +231,7 @@ discard block |
||
221 | 231 | background-color: $color; |
222 | 232 | }"); |
223 | 233 | } |
234 | + } |
|
224 | 235 | return $ret; |
225 | 236 | } |
226 | 237 | |
@@ -236,7 +247,10 @@ discard block |
||
236 | 247 | $srcs = array(); |
237 | 248 | foreach($GLOBALS['egw']->hooks->process('csp-frame-src') as $src) |
238 | 249 | { |
239 | - if ($src) $srcs = array_merge($srcs, $src); |
|
250 | + if ($src) |
|
251 | + { |
|
252 | + $srcs = array_merge($srcs, $src); |
|
253 | + } |
|
240 | 254 | } |
241 | 255 | return $srcs; |
242 | 256 | } |
@@ -250,7 +264,10 @@ discard block |
||
250 | 264 | function header(array $extra=array()) |
251 | 265 | { |
252 | 266 | // make sure header is output only once |
253 | - if (self::$header_done) return ''; |
|
267 | + if (self::$header_done) |
|
268 | + { |
|
269 | + return ''; |
|
270 | + } |
|
254 | 271 | self::$header_done = true; |
255 | 272 | |
256 | 273 | $this->send_headers(); |
@@ -337,7 +354,10 @@ discard block |
||
337 | 354 | // for remote manual never check/create framework |
338 | 355 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
339 | 356 | { |
340 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
357 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) |
|
358 | + { |
|
359 | + $GLOBALS['egw_info']['flags']['java_script']=''; |
|
360 | + } |
|
341 | 361 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
342 | 362 | } |
343 | 363 | } |
@@ -611,7 +631,10 @@ discard block |
||
611 | 631 | */ |
612 | 632 | public function sidebox($appname,$menu_title,$file,$type=null) |
613 | 633 | { |
614 | - if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
634 | + if (!isset($file['menuOpened'])) |
|
635 | + { |
|
636 | + $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
637 | + } |
|
615 | 638 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
616 | 639 | $this->sidebox_menu_opened = false; |
617 | 640 | |
@@ -738,7 +761,10 @@ discard block |
||
738 | 761 | foreach($tablist as $data) |
739 | 762 | { |
740 | 763 | $tabs[] = $data['appName']; |
741 | - if ($data['active']) $active = $data['appName']; |
|
764 | + if ($data['active']) |
|
765 | + { |
|
766 | + $active = $data['appName']; |
|
767 | + } |
|
742 | 768 | } |
743 | 769 | // send app a notification, that it's tab got closed |
744 | 770 | // used eg. in phpFreeChat to leave the chat |
@@ -892,10 +918,22 @@ discard block |
||
892 | 918 | } |
893 | 919 | |
894 | 920 | unset($apps['logout']); // never display it |
895 | - if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
|
896 | - if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
|
897 | - if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
|
898 | - if (isset($apps['home'])) $apps['home']['noNavbar'] = true; |
|
921 | + if (isset($apps['about'])) |
|
922 | + { |
|
923 | + $apps['about']['noNavbar'] = true; |
|
924 | + } |
|
925 | + if (isset($apps['preferences'])) |
|
926 | + { |
|
927 | + $apps['preferences']['noNavbar'] = true; |
|
928 | + } |
|
929 | + if (isset($apps['manual'])) |
|
930 | + { |
|
931 | + $apps['manual']['noNavbar'] = true; |
|
932 | + } |
|
933 | + if (isset($apps['home'])) |
|
934 | + { |
|
935 | + $apps['home']['noNavbar'] = true; |
|
936 | + } |
|
899 | 937 | |
900 | 938 | // no need for website icon, if we have sitemgr |
901 | 939 | if (isset($apps['sitemgr']) && isset($apps['sitemgr-link'])) |
@@ -963,7 +1001,10 @@ discard block |
||
963 | 1001 | else |
964 | 1002 | { |
965 | 1003 | $active_tab = $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']; |
966 | - if (!$active_tab) $active_tab = $default_app; |
|
1004 | + if (!$active_tab) |
|
1005 | + { |
|
1006 | + $active_tab = $default_app; |
|
1007 | + } |
|
967 | 1008 | } |
968 | 1009 | // if we have the open tabs in the session, use it instead the maybe forced common prefs open_tabs |
969 | 1010 | if (!($open_tabs = egw_cache::getSession(__CLASS__, 'open_tabs'))) |
@@ -988,9 +1029,12 @@ discard block |
||
988 | 1029 | // Restore Tabs |
989 | 1030 | foreach($open_tabs as $n => $app) |
990 | 1031 | { |
991 | - if (isset($apps[$app])) // user might no longer have app rights |
|
1032 | + if (isset($apps[$app])) |
|
1033 | + { |
|
1034 | + // user might no longer have app rights |
|
992 | 1035 | { |
993 | 1036 | $apps[$app]['opened'] = $n; |
1037 | + } |
|
994 | 1038 | if ($app == $active_tab) |
995 | 1039 | { |
996 | 1040 | $apps[$app]['active'] = true; |
@@ -1016,7 +1060,11 @@ discard block |
||
1016 | 1060 | function footer($no_framework=true) |
1017 | 1061 | { |
1018 | 1062 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
1019 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
1063 | + if (self::$footer_done) |
|
1064 | + { |
|
1065 | + return; |
|
1066 | + } |
|
1067 | + // prevent (multiple) footers |
|
1020 | 1068 | self::$footer_done = true; |
1021 | 1069 | |
1022 | 1070 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -309,13 +309,7 @@ discard block |
||
309 | 309 | * the new message as any other new message in a folder. |
310 | 310 | * |
311 | 311 | * @param string $rfc822 mail |
312 | - * @param array $smartdata=array() values for keys: |
|
313 | - * 'task': 'forward', 'new', 'reply' |
|
314 | - * 'itemid': id of message if it's an reply or forward |
|
315 | - * 'folderid': folder |
|
316 | - * 'replacemime': false = send as is, false = decode and recode for whatever reason ??? |
|
317 | - * 'saveinsentitems': 1 or absent? |
|
318 | - * @param boolean|double $protocolversion=false |
|
312 | + * @param boolean|double $protocolversion |
|
319 | 313 | * @return boolean true on success, false on error |
320 | 314 | * |
321 | 315 | * @see eg. BackendIMAP::SendMail() |
@@ -1762,7 +1756,7 @@ discard block |
||
1762 | 1756 | * @param string $displayname => new folder name (to be created, or to be renamed to) |
1763 | 1757 | * @param string $type folder type, ignored in IMAP |
1764 | 1758 | * |
1765 | - * @return array|boolean stat array or false on error |
|
1759 | + * @return boolean stat array or false on error |
|
1766 | 1760 | */ |
1767 | 1761 | public function ChangeFolder($id, $oldid, $displayname, $type) |
1768 | 1762 | { |
@@ -1777,7 +1771,7 @@ discard block |
||
1777 | 1771 | * @param string $id of the folder to delete |
1778 | 1772 | * |
1779 | 1773 | * @return |
1780 | - * @TODO check what is to be returned |
|
1774 | + boolean @TODO check what is to be returned |
|
1781 | 1775 | */ |
1782 | 1776 | public function DeleteFolder($parentid, $id) |
1783 | 1777 | { |
@@ -1811,7 +1805,6 @@ discard block |
||
1811 | 1805 | * |
1812 | 1806 | * @param int $account mail account id |
1813 | 1807 | * @param string $folder |
1814 | - * @param int $id=0 |
|
1815 | 1808 | * @return string |
1816 | 1809 | * @throws egw_exception_wrong_parameter |
1817 | 1810 | */ |
@@ -300,28 +300,28 @@ discard block |
||
300 | 300 | return $folderlist; |
301 | 301 | } |
302 | 302 | |
303 | - /** |
|
304 | - * Sends a message which is passed as rfc822. You basically can do two things |
|
305 | - * 1) Send the message to an SMTP server as-is |
|
306 | - * 2) Parse the message yourself, and send it some other way |
|
307 | - * It is up to you whether you want to put the message in the sent items folder. If you |
|
308 | - * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
309 | - * the new message as any other new message in a folder. |
|
310 | - * |
|
311 | - * @param string $rfc822 mail |
|
312 | - * @param array $smartdata=array() values for keys: |
|
313 | - * 'task': 'forward', 'new', 'reply' |
|
314 | - * 'itemid': id of message if it's an reply or forward |
|
315 | - * 'folderid': folder |
|
316 | - * 'replacemime': false = send as is, false = decode and recode for whatever reason ??? |
|
303 | + /** |
|
304 | + * Sends a message which is passed as rfc822. You basically can do two things |
|
305 | + * 1) Send the message to an SMTP server as-is |
|
306 | + * 2) Parse the message yourself, and send it some other way |
|
307 | + * It is up to you whether you want to put the message in the sent items folder. If you |
|
308 | + * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
309 | + * the new message as any other new message in a folder. |
|
310 | + * |
|
311 | + * @param string $rfc822 mail |
|
312 | + * @param array $smartdata=array() values for keys: |
|
313 | + * 'task': 'forward', 'new', 'reply' |
|
314 | + * 'itemid': id of message if it's an reply or forward |
|
315 | + * 'folderid': folder |
|
316 | + * 'replacemime': false = send as is, false = decode and recode for whatever reason ??? |
|
317 | 317 | * 'saveinsentitems': 1 or absent? |
318 | - * @param boolean|double $protocolversion=false |
|
319 | - * @return boolean true on success, false on error |
|
320 | - * |
|
321 | - * @see eg. BackendIMAP::SendMail() |
|
322 | - * @todo implement either here or in mail backend |
|
323 | - * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
324 | - */ |
|
318 | + * @param boolean|double $protocolversion=false |
|
319 | + * @return boolean true on success, false on error |
|
320 | + * |
|
321 | + * @see eg. BackendIMAP::SendMail() |
|
322 | + * @todo implement either here or in mail backend |
|
323 | + * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
324 | + */ |
|
325 | 325 | public function SendMail($rfc822, $smartdata=array(), $protocolversion = false) |
326 | 326 | { |
327 | 327 | //$this->debugLevel=3; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | if ($protocolversion < 14.0) |
342 | - debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
342 | + debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | 343 | if ($this->debugLevel>0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
344 | 344 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
345 | 345 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
446 | 446 | // if this is a multipart message with a boundary, we must use the original body |
447 | 447 | //if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
448 | - if ($use_orgbody) { |
|
449 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
448 | + if ($use_orgbody) { |
|
449 | + if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
450 | 450 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
451 | 451 | if (stripos($ContentType,'text/calendar') !== false ) |
452 | 452 | { |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | foreach ((array)$tA as $k => $p) if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
460 | 460 | $ClientSideMeetingRequest = true; |
461 | 461 | } |
462 | - } |
|
462 | + } |
|
463 | 463 | // now handle the addressee list |
464 | 464 | $toCount = 0; |
465 | 465 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
540 | 540 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
541 | 541 | if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
542 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
542 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
543 | 543 | // may be html |
544 | 544 | if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
545 | 545 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $this->splitID($smartdata['folderid'], $account, $folder); |
587 | 587 | |
588 | 588 | $this->mail->reopen($folder); |
589 | - // receive entire mail (header + body) |
|
589 | + // receive entire mail (header + body) |
|
590 | 590 | // get message headers for specified message |
591 | 591 | $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
592 | 592 | // build a new mime message, forward entire old mail as file |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | } |
673 | 673 | //advanced debugging |
674 | 674 | // Horde SMTP Class uses utf-8 by default. |
675 | - //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
675 | + //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
676 | 676 | if ($this->debugLevel>2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
677 | 677 | |
678 | 678 | // set a higher timeout for big messages |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | //$asf = false; |
766 | 766 | debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
767 | 767 | } |
768 | - debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
768 | + debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
769 | 769 | } |
770 | 770 | //$this->mail->closeConnection(); |
771 | 771 | } |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
855 | 855 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
856 | 856 | if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
857 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
857 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
858 | 858 | // may be html |
859 | 859 | if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
860 | 860 | $css = $this->mail->getStyles($bodyStruct); |
@@ -954,14 +954,14 @@ discard block |
||
954 | 954 | if ($output->airsyncbasenativebodytype==2) { //html |
955 | 955 | if ($this->debugLevel>0) debugLog("HTML Body with requested pref 4"); |
956 | 956 | $html = '<html>'. |
957 | - '<head>'. |
|
958 | - '<meta name="Generator" content="Z-Push">'. |
|
959 | - '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'. |
|
957 | + '<head>'. |
|
958 | + '<meta name="Generator" content="Z-Push">'. |
|
959 | + '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'. |
|
960 | 960 | $css. |
961 | - '</head>'. |
|
962 | - '<body>'. |
|
963 | - str_replace("\n","<BR>",str_replace("\r","", str_replace("\r\n","<BR>",$body))). |
|
964 | - '</body>'. |
|
961 | + '</head>'. |
|
962 | + '<body>'. |
|
963 | + str_replace("\n","<BR>",str_replace("\r","", str_replace("\r\n","<BR>",$body))). |
|
964 | + '</body>'. |
|
965 | 965 | '</html>'; |
966 | 966 | $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
967 | 967 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | $output->airsyncbasebody->type = 1; |
1042 | 1042 | if(isset($bodypreference[1]["TruncationSize"]) && |
1043 | - strlen($plainBody) > $bodypreference[1]["TruncationSize"]) |
|
1043 | + strlen($plainBody) > $bodypreference[1]["TruncationSize"]) |
|
1044 | 1044 | { |
1045 | 1045 | $plainBody = utf8_truncate($plainBody, $bodypreference[1]["TruncationSize"]); |
1046 | 1046 | $output->airsyncbasebody->truncated = 1; |
@@ -1200,8 +1200,8 @@ discard block |
||
1200 | 1200 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
1201 | 1201 | * encode any information you need to find the attachment in that 'attname' property. |
1202 | 1202 | * |
1203 | - * @param string $fid - id |
|
1204 | - * @param string $attname - should contain (folder)id |
|
1203 | + * @param string $fid - id |
|
1204 | + * @param string $attname - should contain (folder)id |
|
1205 | 1205 | * @return true, prints the content of the attachment |
1206 | 1206 | */ |
1207 | 1207 | function GetAttachmentData($fid,$attname) { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
1227 | 1227 | * encode any information you need to find the attachment in that 'attname' property. |
1228 | 1228 | * |
1229 | - * @param string $fid - id |
|
1230 | - * @param string $attname - should contain (folder)id |
|
1229 | + * @param string $fid - id |
|
1230 | + * @param string $attname - should contain (folder)id |
|
1231 | 1231 | * @return SyncAirSyncBaseFileAttachment-object |
1232 | 1232 | */ |
1233 | 1233 | function ItemOperationsGetAttachmentData($fid,$attname) { |
@@ -1651,24 +1651,24 @@ discard block |
||
1651 | 1651 | if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
1652 | 1652 | |
1653 | 1653 | $changes = array(); |
1654 | - debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
|
1655 | - $this->mail->reopen($folder); |
|
1656 | - |
|
1657 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1658 | - if (!$status) { |
|
1659 | - debugLog("AlterPingChanges: could not stat folder $folder "); |
|
1660 | - return false; |
|
1661 | - } else { |
|
1662 | - $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1663 | - |
|
1664 | - // message number is different - change occured |
|
1665 | - if ($syncstate != $newstate) { |
|
1666 | - $syncstate = $newstate; |
|
1667 | - debugLog("AlterPingChanges: Change FOUND!"); |
|
1668 | - // build a dummy change |
|
1669 | - $changes = array(array("type" => "fakeChange")); |
|
1670 | - } |
|
1671 | - } |
|
1654 | + debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
|
1655 | + $this->mail->reopen($folder); |
|
1656 | + |
|
1657 | + $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1658 | + if (!$status) { |
|
1659 | + debugLog("AlterPingChanges: could not stat folder $folder "); |
|
1660 | + return false; |
|
1661 | + } else { |
|
1662 | + $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1663 | + |
|
1664 | + // message number is different - change occured |
|
1665 | + if ($syncstate != $newstate) { |
|
1666 | + $syncstate = $newstate; |
|
1667 | + debugLog("AlterPingChanges: Change FOUND!"); |
|
1668 | + // build a dummy change |
|
1669 | + $changes = array(array("type" => "fakeChange")); |
|
1670 | + } |
|
1671 | + } |
|
1672 | 1672 | //error_log(__METHOD__."('$folderid','$syncstate_was') syncstate='$syncstate' returning ".array2string($changes)); |
1673 | 1673 | return $changes; |
1674 | 1674 | } |
@@ -91,29 +91,47 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function __construct(BackendEGW $backend) |
93 | 93 | { |
94 | - if ($GLOBALS['egw_setup']) return; |
|
94 | + if ($GLOBALS['egw_setup']) |
|
95 | + { |
|
96 | + return; |
|
97 | + } |
|
95 | 98 | |
96 | 99 | //$this->debugLevel=2; |
97 | 100 | $this->backend = $backend; |
98 | 101 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
99 | 102 | { |
100 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
103 | + if ($this->debugLevel>1) |
|
104 | + { |
|
105 | + error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
106 | + } |
|
101 | 107 | // globals preferences add appname varname value |
102 | 108 | $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
103 | 109 | // save prefs |
104 | 110 | $GLOBALS['egw']->preferences->save_repository(true); |
105 | 111 | } |
106 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
112 | + if ($this->debugLevel>1) |
|
113 | + { |
|
114 | + error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
115 | + } |
|
107 | 116 | |
108 | 117 | if (is_null(self::$profileID)) |
109 | 118 | { |
110 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
119 | + if ($this->debugLevel>1) |
|
120 | + { |
|
121 | + error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
122 | + } |
|
111 | 123 | self::$profileID =& egw_cache::getSession('mail','activeSyncProfileID'); |
112 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
124 | + if ($this->debugLevel>1) |
|
125 | + { |
|
126 | + error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
127 | + } |
|
113 | 128 | } |
114 | 129 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
115 | 130 | { |
116 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
131 | + if ($this->debugLevel>1) |
|
132 | + { |
|
133 | + error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
134 | + } |
|
117 | 135 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
118 | 136 | { |
119 | 137 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -123,7 +141,10 @@ discard block |
||
123 | 141 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
124 | 142 | } |
125 | 143 | } |
126 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
144 | + if ($this->debugLevel>1) |
|
145 | + { |
|
146 | + error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
147 | + } |
|
127 | 148 | |
128 | 149 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
129 | 150 | if (!isset($GLOBALS['egw_setup'])) |
@@ -136,7 +157,10 @@ discard block |
||
136 | 157 | self::$profileID = emailadmin_account::get_default_acc_id(); |
137 | 158 | } |
138 | 159 | } |
139 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
160 | + if ($this->debugLevel>0) |
|
161 | + { |
|
162 | + error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
163 | + } |
|
140 | 164 | //$this->debugLevel=0; |
141 | 165 | } |
142 | 166 | |
@@ -211,8 +235,14 @@ discard block |
||
211 | 235 | $this->_connect(0,true); |
212 | 236 | $this->_disconnect(); |
213 | 237 | |
214 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
215 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
238 | + if (!$this->_wasteID) |
|
239 | + { |
|
240 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
241 | + } |
|
242 | + if (!$this->_sentID) |
|
243 | + { |
|
244 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
245 | + } |
|
216 | 246 | } |
217 | 247 | catch(Exception $e) { |
218 | 248 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -234,8 +264,14 @@ discard block |
||
234 | 264 | */ |
235 | 265 | private function _connect($account=0) |
236 | 266 | { |
237 | - if (is_null($account)) $account = 0; |
|
238 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
267 | + if (is_null($account)) |
|
268 | + { |
|
269 | + $account = 0; |
|
270 | + } |
|
271 | + if ($this->mail && $this->account != $account) |
|
272 | + { |
|
273 | + $this->_disconnect(); |
|
274 | + } |
|
239 | 275 | |
240 | 276 | $this->_wasteID = false; |
241 | 277 | $this->_sentID = false; |
@@ -247,7 +283,10 @@ discard block |
||
247 | 283 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
248 | 284 | $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
249 | 285 | } |
250 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
286 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
287 | + { |
|
288 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
289 | + } |
|
251 | 290 | $this->mail->openConnection(self::$profileID,false); |
252 | 291 | |
253 | 292 | $this->_wasteID = $this->mail->getTrashFolder(false); |
@@ -264,7 +303,10 @@ discard block |
||
264 | 303 | private function _disconnect() |
265 | 304 | { |
266 | 305 | debugLog(__METHOD__); |
267 | - if ($this->mail) $this->mail->closeConnection(); |
|
306 | + if ($this->mail) |
|
307 | + { |
|
308 | + $this->mail->closeConnection(); |
|
309 | + } |
|
268 | 310 | |
269 | 311 | unset($this->mail); |
270 | 312 | unset($this->account); |
@@ -283,16 +325,23 @@ discard block |
||
283 | 325 | /*foreach($available_accounts as $account)*/ $account = 0; |
284 | 326 | { |
285 | 327 | $this->_connect($account); |
286 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
328 | + if (!isset($this->folders)) |
|
329 | + { |
|
330 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
331 | + } |
|
287 | 332 | //debugLog(__METHOD__.__LINE__.array2string($this->folders)); |
288 | 333 | |
289 | - foreach ($this->folders as $folder => $folderObj) { |
|
334 | + foreach ($this->folders as $folder => $folderObj) |
|
335 | + { |
|
290 | 336 | $folderlist[] = $f = array( |
291 | 337 | 'id' => $this->createID($account,$folder), |
292 | 338 | 'mod' => $folderObj->shortDisplayName, |
293 | 339 | 'parent' => $this->getParentID($account,$folder), |
294 | 340 | ); |
295 | - if ($this->debugLevel>0) debugLog(__METHOD__."() returning ".array2string($f)); |
|
341 | + if ($this->debugLevel>0) |
|
342 | + { |
|
343 | + debugLog(__METHOD__."() returning ".array2string($f)); |
|
344 | + } |
|
296 | 345 | } |
297 | 346 | } |
298 | 347 | //debugLog(__METHOD__."() returning ".array2string($folderlist)); |
@@ -339,17 +388,28 @@ discard block |
||
339 | 388 | } |
340 | 389 | |
341 | 390 | if ($protocolversion < 14.0) |
342 | - debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
391 | + { |
|
392 | + debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
393 | + } |
|
394 | + if ($this->debugLevel>0) |
|
395 | + { |
|
396 | + debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
397 | + } |
|
344 | 398 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
345 | 399 | |
346 | 400 | // initialize our mail_bo |
347 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
401 | + if (!isset($this->mail)) |
|
402 | + { |
|
403 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
404 | + } |
|
348 | 405 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
349 | 406 | // use the standardIdentity |
350 | 407 | $activeMailProfile = mail_bo::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
351 | 408 | |
352 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
409 | + if ($this->debugLevel>2) |
|
410 | + { |
|
411 | + debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
412 | + } |
|
353 | 413 | |
354 | 414 | // initialize the new egw_mailer object for sending |
355 | 415 | $mailObject = new egw_mailer(); |
@@ -364,23 +424,44 @@ discard block |
||
364 | 424 | // prepare addressee list; moved the adding of addresses to the mailobject down |
365 | 425 | // to |
366 | 426 | |
367 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
368 | - if (!$addressObject->valid) continue; |
|
369 | - if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) ); |
|
427 | + foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
428 | + { |
|
429 | + if (!$addressObject->valid) |
|
430 | + { |
|
431 | + continue; |
|
432 | + } |
|
433 | + if ($this->debugLevel>0) |
|
434 | + { |
|
435 | + debugLog("Header Sentmail To: ".array2string($addressObject) ); |
|
436 | + } |
|
370 | 437 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
371 | 438 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
372 | 439 | } |
373 | 440 | // CC |
374 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
375 | - if (!$addressObject->valid) continue; |
|
376 | - if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) ); |
|
441 | + foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
442 | + { |
|
443 | + if (!$addressObject->valid) |
|
444 | + { |
|
445 | + continue; |
|
446 | + } |
|
447 | + if ($this->debugLevel>0) |
|
448 | + { |
|
449 | + debugLog("Header Sentmail CC: ".array2string($addressObject) ); |
|
450 | + } |
|
377 | 451 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
378 | 452 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
379 | 453 | } |
380 | 454 | // BCC |
381 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
382 | - if (!$addressObject->valid) continue; |
|
383 | - if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) ); |
|
455 | + foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) |
|
456 | + { |
|
457 | + if (!$addressObject->valid) |
|
458 | + { |
|
459 | + continue; |
|
460 | + } |
|
461 | + if ($this->debugLevel>0) |
|
462 | + { |
|
463 | + debugLog("Header Sentmail BCC: ".array2string($addressObject) ); |
|
464 | + } |
|
384 | 465 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
385 | 466 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
386 | 467 | } |
@@ -392,12 +473,14 @@ discard block |
||
392 | 473 | $ContentType =$mailObject->getHeader('Content-Type'); |
393 | 474 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
394 | 475 | // if the message is a multipart message, then we should use the sent body |
395 | - if (preg_match("/multipart/i", $ContentType)) { |
|
476 | + if (preg_match("/multipart/i", $ContentType)) |
|
477 | + { |
|
396 | 478 | $use_orgbody = true; |
397 | 479 | } |
398 | 480 | |
399 | 481 | // save the original content-type header for the body part when forwarding |
400 | - if ($smartdata['task'] == 'forward' && $smartdata['itemid'] && !$use_orgbody) { |
|
482 | + if ($smartdata['task'] == 'forward' && $smartdata['itemid'] && !$use_orgbody) |
|
483 | + { |
|
401 | 484 | //continue; // ignore |
402 | 485 | } |
403 | 486 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -406,7 +489,8 @@ discard block |
||
406 | 489 | // if the message is a multipart message, then we should use the sent body |
407 | 490 | if (($smartdata['task'] == 'new' || $smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && |
408 | 491 | ((isset($smartdata['replacemime']) && $smartdata['replacemime'] == true) || |
409 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
492 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
493 | + { |
|
410 | 494 | $use_orgbody = true; |
411 | 495 | } |
412 | 496 | $Body = $AltBody = ""; |
@@ -422,13 +506,19 @@ discard block |
||
422 | 506 | { |
423 | 507 | $Body = $body; |
424 | 508 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
425 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
509 | + if ($this->debugLevel>1) |
|
510 | + { |
|
511 | + debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
512 | + } |
|
426 | 513 | } |
427 | 514 | else |
428 | 515 | { |
429 | 516 | $AltBody = $body; |
430 | 517 | $Body = trim(translation::convertHTMLToText($body)); |
431 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
518 | + if ($this->debugLevel>1) |
|
519 | + { |
|
520 | + debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
521 | + } |
|
432 | 522 | } |
433 | 523 | } |
434 | 524 | else |
@@ -440,57 +530,95 @@ discard block |
||
440 | 530 | $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $Body); |
441 | 531 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $AltBody); |
442 | 532 | } |
443 | - if ($this->debugLevel>1 && $Body) debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
444 | - if ($this->debugLevel>1 && $AltBody) debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
533 | + if ($this->debugLevel>1 && $Body) |
|
534 | + { |
|
535 | + debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
536 | + } |
|
537 | + if ($this->debugLevel>1 && $AltBody) |
|
538 | + { |
|
539 | + debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
540 | + } |
|
445 | 541 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
446 | 542 | // if this is a multipart message with a boundary, we must use the original body |
447 | 543 | //if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
448 | - if ($use_orgbody) { |
|
449 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
544 | + if ($use_orgbody) |
|
545 | + { |
|
546 | + if ($this->debugLevel>0) |
|
547 | + { |
|
548 | + debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
549 | + } |
|
450 | 550 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
451 | 551 | if (stripos($ContentType,'text/calendar') !== false ) |
452 | 552 | { |
453 | 553 | $body = ($text_body = $mailObject->findBody('calendar')) ? $text_body->getContents() : null; |
454 | 554 | $Body = $body; |
455 | 555 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
456 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
556 | + if ($this->debugLevel>0) |
|
557 | + { |
|
558 | + debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
559 | + } |
|
457 | 560 | // try figuring out the METHOD -> [ContentType] => text/calendar; name=meeting.ics; method=REQUEST |
458 | 561 | $tA = explode(' ',$ContentType); |
459 | - foreach ((array)$tA as $k => $p) if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
|
562 | + foreach ((array)$tA as $k => $p) |
|
563 | + { |
|
564 | + if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
|
565 | + } |
|
460 | 566 | $ClientSideMeetingRequest = true; |
461 | 567 | } |
462 | 568 | } |
463 | 569 | // now handle the addressee list |
464 | 570 | $toCount = 0; |
465 | 571 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
466 | - foreach((array)$toMailAddr as $address) { |
|
467 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
572 | + foreach((array)$toMailAddr as $address) |
|
573 | + { |
|
574 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
575 | + { |
|
468 | 576 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
469 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; |
|
577 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) |
|
578 | + { |
|
579 | + continue; |
|
580 | + } |
|
470 | 581 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
471 | 582 | $toCount++; |
472 | 583 | } |
473 | 584 | } |
474 | 585 | $ccCount = 0; |
475 | - foreach((array)$ccMailAddr as $address) { |
|
476 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
586 | + foreach((array)$ccMailAddr as $address) |
|
587 | + { |
|
588 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
589 | + { |
|
477 | 590 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
478 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
591 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
592 | + { |
|
593 | + continue; |
|
594 | + } |
|
479 | 595 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
480 | 596 | $ccCount++; |
481 | 597 | } |
482 | 598 | } |
483 | 599 | $bccCount = 0; |
484 | - foreach((array)$bccMailAddr as $address) { |
|
485 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
600 | + foreach((array)$bccMailAddr as $address) |
|
601 | + { |
|
602 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
603 | + { |
|
486 | 604 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
487 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
605 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
606 | + { |
|
607 | + continue; |
|
608 | + } |
|
488 | 609 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
489 | 610 | $bccCount++; |
490 | 611 | } |
491 | 612 | } |
492 | - if ($toCount+$ccCount+$bccCount == 0) return 0; // noone to send mail to |
|
493 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
613 | + if ($toCount+$ccCount+$bccCount == 0) |
|
614 | + { |
|
615 | + return 0; |
|
616 | + } |
|
617 | + // noone to send mail to |
|
618 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
619 | + { |
|
620 | + return true; |
|
621 | + } |
|
494 | 622 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
495 | 623 | /* |
496 | 624 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -498,7 +626,10 @@ discard block |
||
498 | 626 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
499 | 627 | */ |
500 | 628 | // add signature!! ----------------------------------------------------------------- |
501 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
629 | + if ($this->debugLevel>2) |
|
630 | + { |
|
631 | + debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
632 | + } |
|
502 | 633 | try |
503 | 634 | { |
504 | 635 | $acc = emailadmin_account::read($this->mail->icServer->ImapServerId); |
@@ -520,7 +651,10 @@ discard block |
||
520 | 651 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
521 | 652 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
522 | 653 | $sigText = emailadmin_imapbase::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
523 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
654 | + if ($this->debugLevel>0) |
|
655 | + { |
|
656 | + debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
657 | + } |
|
524 | 658 | $sigTextHtml = $beforeHtml.$sigText; |
525 | 659 | $sigTextPlain = $beforePlain.translation::convertHTMLToText($sigText); |
526 | 660 | $isreply = $isforward = false; |
@@ -532,26 +666,43 @@ discard block |
||
532 | 666 | { |
533 | 667 | // now get on, and fetch the original mail |
534 | 668 | $uid = $smartdata['itemid']; |
535 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
669 | + if ($this->debugLevel>0) |
|
670 | + { |
|
671 | + debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
672 | + } |
|
536 | 673 | $this->splitID($smartdata['folderid'], $account, $folder); |
537 | 674 | |
538 | 675 | $this->mail->reopen($folder); |
539 | 676 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
540 | 677 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
541 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
542 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
678 | + if ($this->debugLevel>3) |
|
679 | + { |
|
680 | + debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
681 | + } |
|
682 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
683 | + { |
|
543 | 684 | // may be html |
544 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
685 | + if ($this->debugLevel>0) |
|
686 | + { |
|
687 | + debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
688 | + } |
|
545 | 689 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
546 | 690 | $isreply = true; |
547 | 691 | } |
548 | 692 | // plain text Message part |
549 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
693 | + if ($this->debugLevel>0) |
|
694 | + { |
|
695 | + debugLog("MIME Body".' Type:plain, fetch text:'); |
|
696 | + } |
|
550 | 697 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
551 | 698 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
552 | 699 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
553 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
554 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
700 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
701 | + { |
|
702 | + if ($this->debugLevel>0) |
|
703 | + { |
|
704 | + debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
705 | + } |
|
555 | 706 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
556 | 707 | $isreply = true; |
557 | 708 | } |
@@ -559,7 +710,10 @@ discard block |
||
559 | 710 | { |
560 | 711 | $isreply = true; |
561 | 712 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
562 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
713 | + if ($this->debugLevel>0) |
|
714 | + { |
|
715 | + debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
716 | + } |
|
563 | 717 | } |
564 | 718 | } |
565 | 719 | |
@@ -573,16 +727,25 @@ discard block |
||
573 | 727 | (isset($smartdata['replacemime']) && $smartdata['replacemime'] == false))) |
574 | 728 | { |
575 | 729 | //force the default for the forwarding -> asmail |
576 | - if (is_array($preferencesArray)) { |
|
730 | + if (is_array($preferencesArray)) |
|
731 | + { |
|
577 | 732 | if (!array_key_exists('message_forwarding',$preferencesArray) |
578 | 733 | || !isset($preferencesArray['message_forwarding']) |
579 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
580 | - } else { |
|
734 | + || empty($preferencesArray['message_forwarding'])) |
|
735 | + { |
|
736 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
737 | + } |
|
738 | + } |
|
739 | + else |
|
740 | + { |
|
581 | 741 | $preferencesArray['message_forwarding'] = 'asmail'; |
582 | 742 | } |
583 | 743 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
584 | 744 | $uid = $smartdata['itemid']; |
585 | - if ($this->debugLevel>0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
745 | + if ($this->debugLevel>0) |
|
746 | + { |
|
747 | + debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
748 | + } |
|
586 | 749 | $this->splitID($smartdata['folderid'], $account, $folder); |
587 | 750 | |
588 | 751 | $this->mail->reopen($folder); |
@@ -604,33 +767,53 @@ discard block |
||
604 | 767 | { |
605 | 768 | // now get on, and fetch the original mail |
606 | 769 | $uid = $smartdata['itemid']; |
607 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
770 | + if ($this->debugLevel>0) |
|
771 | + { |
|
772 | + debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
773 | + } |
|
608 | 774 | $this->splitID($smartdata['folderid'], $account, $folder); |
609 | 775 | |
610 | 776 | $this->mail->reopen($folder); |
611 | 777 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
612 | 778 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
613 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
614 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
779 | + if ($this->debugLevel>3) |
|
780 | + { |
|
781 | + debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
782 | + } |
|
783 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
784 | + { |
|
615 | 785 | // may be html |
616 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
786 | + if ($this->debugLevel>0) |
|
787 | + { |
|
788 | + debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
789 | + } |
|
617 | 790 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
618 | 791 | $isforward = true; |
619 | 792 | } |
620 | 793 | // plain text Message part |
621 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
794 | + if ($this->debugLevel>0) |
|
795 | + { |
|
796 | + debugLog("MIME Body".' Type:plain, fetch text:'); |
|
797 | + } |
|
622 | 798 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
623 | 799 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
624 | 800 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
625 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
626 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
801 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
802 | + { |
|
803 | + if ($this->debugLevel>0) |
|
804 | + { |
|
805 | + debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
806 | + } |
|
627 | 807 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
628 | 808 | $isforward = true; |
629 | 809 | } |
630 | 810 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
631 | 811 | { |
632 | 812 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
633 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
813 | + if ($this->debugLevel>0) |
|
814 | + { |
|
815 | + debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
816 | + } |
|
634 | 817 | $isforward = true; |
635 | 818 | } |
636 | 819 | // get all the attachments and add them too. |
@@ -640,10 +823,16 @@ discard block |
||
640 | 823 | $attachmentNames = false; |
641 | 824 | if (is_array($attachments) && count($attachments)>0) |
642 | 825 | { |
643 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
826 | + if ($this->debugLevel>0) |
|
827 | + { |
|
828 | + debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
829 | + } |
|
644 | 830 | foreach((array)$attachments as $key => $attachment) |
645 | 831 | { |
646 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
832 | + if ($this->debugLevel>0) |
|
833 | + { |
|
834 | + debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
835 | + } |
|
647 | 836 | $attachmentNames .= $attachment['name']."\n"; |
648 | 837 | $attachmentData = ''; |
649 | 838 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
@@ -662,18 +851,27 @@ discard block |
||
662 | 851 | // now set the body |
663 | 852 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
664 | 853 | { |
665 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
854 | + if ($this->debugLevel>1) |
|
855 | + { |
|
856 | + debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
857 | + } |
|
666 | 858 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
667 | 859 | } |
668 | 860 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
669 | 861 | { |
670 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
862 | + if ($this->debugLevel>1) |
|
863 | + { |
|
864 | + debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
865 | + } |
|
671 | 866 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
672 | 867 | } |
673 | 868 | //advanced debugging |
674 | 869 | // Horde SMTP Class uses utf-8 by default. |
675 | 870 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
676 | - if ($this->debugLevel>2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
871 | + if ($this->debugLevel>2) |
|
872 | + { |
|
873 | + debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
874 | + } |
|
677 | 875 | |
678 | 876 | // set a higher timeout for big messages |
679 | 877 | @set_time_limit(120); |
@@ -691,7 +889,10 @@ discard block |
||
691 | 889 | if (( $smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
692 | 890 | { |
693 | 891 | $uid = $smartdata['itemid']; |
694 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
892 | + if ($this->debugLevel>0) |
|
893 | + { |
|
894 | + debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
895 | + } |
|
695 | 896 | $this->splitID($smartdata['folderid'], $account, $folder); |
696 | 897 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
697 | 898 | $this->mail->reopen($folder); |
@@ -700,7 +901,9 @@ discard block |
||
700 | 901 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
701 | 902 | { |
702 | 903 | $this->mail->deleteMessages(array($uid),$folder); |
703 | - } else { |
|
904 | + } |
|
905 | + else |
|
906 | + { |
|
704 | 907 | $this->mail->flagMessages("answered", array($uid),$folder); |
705 | 908 | if ($smartdata['task']== "forward") |
706 | 909 | { |
@@ -714,7 +917,8 @@ discard block |
||
714 | 917 | { |
715 | 918 | $asf = false; |
716 | 919 | $sentFolder = $this->mail->getSentFolder(); |
717 | - if ($this->_sentID) { |
|
920 | + if ($this->_sentID) |
|
921 | + { |
|
718 | 922 | $folderArray[] = $this->_sentID; |
719 | 923 | } |
720 | 924 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -728,27 +932,40 @@ discard block |
||
728 | 932 | // we dont try guessing |
729 | 933 | $asf = true; |
730 | 934 | } |
731 | - if (count($folderArray) > 0) { |
|
732 | - foreach((array)$bccMailAddr as $address) { |
|
733 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
935 | + if (count($folderArray) > 0) |
|
936 | + { |
|
937 | + foreach((array)$bccMailAddr as $address) |
|
938 | + { |
|
939 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
940 | + { |
|
734 | 941 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
735 | 942 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
736 | 943 | } |
737 | 944 | } |
738 | 945 | $BCCmail=''; |
739 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
740 | - foreach($folderArray as $folderName) { |
|
741 | - if($this->mail->isSentFolder($folderName)) { |
|
946 | + if (count($mailAddr)>0) |
|
947 | + { |
|
948 | + $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
949 | + } |
|
950 | + foreach($folderArray as $folderName) |
|
951 | + { |
|
952 | + if($this->mail->isSentFolder($folderName)) |
|
953 | + { |
|
742 | 954 | $flags = '\\Seen'; |
743 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
955 | + } |
|
956 | + elseif($this->mail->isDraftFolder($folderName)) |
|
957 | + { |
|
744 | 958 | $flags = '\\Draft'; |
745 | - } else { |
|
959 | + } |
|
960 | + else |
|
961 | + { |
|
746 | 962 | $flags = ''; |
747 | 963 | } |
748 | 964 | $asf = true; |
749 | 965 | //debugLog(__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
750 | 966 | $this->mail->openConnection(self::$profileID,false); |
751 | - if ($this->mail->folderExists($folderName)) { |
|
967 | + if ($this->mail->folderExists($folderName)) |
|
968 | + { |
|
752 | 969 | try |
753 | 970 | { |
754 | 971 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -795,12 +1012,18 @@ discard block |
||
795 | 1012 | public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
796 | 1013 | { |
797 | 1014 | //$this->debugLevel=4; |
798 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1015 | + if (!isset($this->mail)) |
|
1016 | + { |
|
1017 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1018 | + } |
|
799 | 1019 | debugLog(__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
800 | 1020 | $rv = $this->splitID($folderid,$account,$_folderName,$xid); |
801 | 1021 | $this->mail->reopen($_folderName); |
802 | 1022 | $stat = $this->StatMessage($folderid, $id); |
803 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
1023 | + if ($this->debugLevel>3) |
|
1024 | + { |
|
1025 | + debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
1026 | + } |
|
804 | 1027 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
805 | 1028 | if ($stat) |
806 | 1029 | { |
@@ -816,15 +1039,24 @@ discard block |
||
816 | 1039 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
817 | 1040 | // simple style |
818 | 1041 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
819 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
820 | - if ($bodypreference === false) { |
|
1042 | + if ($this->debugLevel>0) |
|
1043 | + { |
|
1044 | + debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
1045 | + } |
|
1046 | + if ($bodypreference === false) |
|
1047 | + { |
|
821 | 1048 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
822 | 1049 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
823 | 1050 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
824 | - if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
1051 | + if (stripos($body,'<style')!==false) |
|
1052 | + { |
|
1053 | + $body = preg_replace("/<style.*?<\/style>/is", "", $body); |
|
1054 | + } |
|
1055 | + // in case there is only a html part |
|
825 | 1056 | // remove all other html |
826 | 1057 | $body = strip_tags($body); |
827 | - if(strlen($body) > $truncsize) { |
|
1058 | + if(strlen($body) > $truncsize) |
|
1059 | + { |
|
828 | 1060 | $body = utf8_truncate($body, $truncsize); |
829 | 1061 | $output->bodytruncated = 1; |
830 | 1062 | } |
@@ -838,38 +1070,73 @@ discard block |
||
838 | 1070 | else // style with bodypreferences |
839 | 1071 | { |
840 | 1072 | if (isset($bodypreference[1]) && !isset($bodypreference[1]["TruncationSize"])) |
841 | - $bodypreference[1]["TruncationSize"] = 1024*1024; |
|
1073 | + { |
|
1074 | + $bodypreference[1]["TruncationSize"] = 1024*1024; |
|
1075 | + } |
|
842 | 1076 | if (isset($bodypreference[2]) && !isset($bodypreference[2]["TruncationSize"])) |
843 | - $bodypreference[2]["TruncationSize"] = 1024*1024; |
|
1077 | + { |
|
1078 | + $bodypreference[2]["TruncationSize"] = 1024*1024; |
|
1079 | + } |
|
844 | 1080 | if (isset($bodypreference[3]) && !isset($bodypreference[3]["TruncationSize"])) |
845 | - $bodypreference[3]["TruncationSize"] = 1024*1024; |
|
1081 | + { |
|
1082 | + $bodypreference[3]["TruncationSize"] = 1024*1024; |
|
1083 | + } |
|
846 | 1084 | if (isset($bodypreference[4]) && !isset($bodypreference[4]["TruncationSize"])) |
847 | - $bodypreference[4]["TruncationSize"] = 1024*1024; |
|
1085 | + { |
|
1086 | + $bodypreference[4]["TruncationSize"] = 1024*1024; |
|
1087 | + } |
|
848 | 1088 | // set the protocoll class |
849 | 1089 | $output->airsyncbasebody = new SyncAirSyncBaseBody(); |
850 | - if ($this->debugLevel>0) debugLog("airsyncbasebody!"); |
|
1090 | + if ($this->debugLevel>0) |
|
1091 | + { |
|
1092 | + debugLog("airsyncbasebody!"); |
|
1093 | + } |
|
851 | 1094 | // fetch the body (try to gather data only once) |
852 | 1095 | $css =''; |
853 | 1096 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
854 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
1097 | + if ($this->debugLevel>2) |
|
1098 | + { |
|
1099 | + debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
1100 | + } |
|
855 | 1101 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
856 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
857 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
1102 | + if ($this->debugLevel>3) |
|
1103 | + { |
|
1104 | + debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
1105 | + } |
|
1106 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
1107 | + { |
|
858 | 1108 | // may be html |
859 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
1109 | + if ($this->debugLevel>0) |
|
1110 | + { |
|
1111 | + debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
1112 | + } |
|
860 | 1113 | $css = $this->mail->getStyles($bodyStruct); |
861 | 1114 | $output->airsyncbasenativebodytype=2; |
862 | - } else { |
|
1115 | + } |
|
1116 | + else |
|
1117 | + { |
|
863 | 1118 | // plain text Message |
864 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
1119 | + if ($this->debugLevel>0) |
|
1120 | + { |
|
1121 | + debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
1122 | + } |
|
865 | 1123 | $output->airsyncbasenativebodytype=1; |
866 | 1124 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
867 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
1125 | + if ($this->debugLevel>3) |
|
1126 | + { |
|
1127 | + debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
1128 | + } |
|
868 | 1129 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
869 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
1130 | + if ($this->debugLevel>3) |
|
1131 | + { |
|
1132 | + debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
1133 | + } |
|
870 | 1134 | } |
871 | 1135 | // whatever format decode (using the correct encoding) |
872 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype==2?' html ':' plain ').$body); |
|
1136 | + if ($this->debugLevel>3) |
|
1137 | + { |
|
1138 | + debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype==2?' html ':' plain ').$body); |
|
1139 | + } |
|
873 | 1140 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
874 | 1141 | // prepare plaintextbody |
875 | 1142 | if ($output->airsyncbasenativebodytype == 2) |
@@ -889,7 +1156,10 @@ discard block |
||
889 | 1156 | // remove all other html |
890 | 1157 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
891 | 1158 | $plainBody = strip_tags($plainBody); |
892 | - if ($this->debugLevel>3 && $output->airsyncbasenativebodytype==1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
1159 | + if ($this->debugLevel>3 && $output->airsyncbasenativebodytype==1) |
|
1160 | + { |
|
1161 | + debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
1162 | + } |
|
893 | 1163 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
894 | 1164 | if (isset($bodypreference[4]) && ($mimesupport==2 || ($mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false))) |
895 | 1165 | { |
@@ -903,7 +1173,10 @@ discard block |
||
903 | 1173 | // we create a complete new rfc822 message here to pass a clean one to the client. |
904 | 1174 | // this strips a lot of information, but ... |
905 | 1175 | $Header = $Body = ''; |
906 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
1176 | + if ($this->debugLevel>0) |
|
1177 | + { |
|
1178 | + debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
1179 | + } |
|
907 | 1180 | //if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__." Using data from ".$rawHeaders.$rawBody); |
908 | 1181 | //$this->mail->parseRawMessageIntoMailObject($mailObject,$rawHeaders.$rawBody,$Header,$Body); |
909 | 1182 | //debugLog(__METHOD__.__LINE__.array2string($headers)); |
@@ -916,33 +1189,52 @@ discard block |
||
916 | 1189 | $mailObject->Subject = $headers['SUBJECT']; |
917 | 1190 | $mailObject->MessageID = $headers['MESSAGE-ID']; |
918 | 1191 | // from |
919 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) { |
|
1192 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) |
|
1193 | + { |
|
920 | 1194 | //debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
921 | - if (!$addressObject->valid) continue; |
|
1195 | + if (!$addressObject->valid) |
|
1196 | + { |
|
1197 | + continue; |
|
1198 | + } |
|
922 | 1199 | $mailObject->From = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
923 | 1200 | $mailObject->FromName = $addressObject->personal; |
924 | 1201 | //error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
925 | 1202 | } |
926 | 1203 | // to |
927 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) { |
|
1204 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) |
|
1205 | + { |
|
928 | 1206 | //debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject)); |
929 | - if (!$addressObject->valid) continue; |
|
1207 | + if (!$addressObject->valid) |
|
1208 | + { |
|
1209 | + continue; |
|
1210 | + } |
|
930 | 1211 | $mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
931 | 1212 | } |
932 | 1213 | // CC |
933 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) { |
|
1214 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) |
|
1215 | + { |
|
934 | 1216 | //debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject)); |
935 | - if (!$addressObject->valid) continue; |
|
1217 | + if (!$addressObject->valid) |
|
1218 | + { |
|
1219 | + continue; |
|
1220 | + } |
|
936 | 1221 | $mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
937 | 1222 | } |
938 | 1223 | // AddReplyTo |
939 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) { |
|
1224 | + foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) |
|
1225 | + { |
|
940 | 1226 | //debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject)); |
941 | - if (!$addressObject->valid) continue; |
|
1227 | + if (!$addressObject->valid) |
|
1228 | + { |
|
1229 | + continue; |
|
1230 | + } |
|
942 | 1231 | $mailObject->AddReplyTo($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
943 | 1232 | } |
944 | 1233 | $Header = $Body = ''; // we do not use Header and Body we use the MailObject |
945 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
1234 | + if ($this->debugLevel>0) |
|
1235 | + { |
|
1236 | + debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
1237 | + } |
|
946 | 1238 | } |
947 | 1239 | catch (egw_exception_assertion_failed $e) |
948 | 1240 | { |
@@ -950,11 +1242,23 @@ discard block |
||
950 | 1242 | $Header = $Body = ''; |
951 | 1243 | } |
952 | 1244 | |
953 | - if ($this->debugLevel>0) debugLog("MIME Body -> ".$body); // body is retrieved up |
|
954 | - if ($output->airsyncbasenativebodytype==2) { //html |
|
955 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 4"); |
|
1245 | + if ($this->debugLevel>0) |
|
1246 | + { |
|
1247 | + debugLog("MIME Body -> ".$body); |
|
1248 | + } |
|
1249 | + // body is retrieved up |
|
1250 | + if ($output->airsyncbasenativebodytype==2) |
|
1251 | + { |
|
1252 | +//html |
|
1253 | + if ($this->debugLevel>0) |
|
1254 | + { |
|
1255 | + debugLog("HTML Body with requested pref 4"); |
|
1256 | + } |
|
956 | 1257 | // if we happen to extract css from body. then remove it |
957 | - if ($css) translation::replaceTagsCompletley($body,'style'); |
|
1258 | + if ($css) |
|
1259 | + { |
|
1260 | + translation::replaceTagsCompletley($body,'style'); |
|
1261 | + } |
|
958 | 1262 | $html = '<html>'. |
959 | 1263 | '<head>'. |
960 | 1264 | '<meta name="Generator" content="Z-Push">'. |
@@ -966,11 +1270,19 @@ discard block |
||
966 | 1270 | '</body>'. |
967 | 1271 | '</html>'; |
968 | 1272 | $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
969 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
1273 | + if ($this->debugLevel>2) |
|
1274 | + { |
|
1275 | + debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
1276 | + } |
|
970 | 1277 | $mailObject->setBody(empty($plainBody)?strip_tags($body):$plainBody); |
971 | 1278 | } |
972 | - if ($output->airsyncbasenativebodytype==1) { //plain |
|
973 | - if ($this->debugLevel>0) debugLog("Plain Body with requested pref 4"); |
|
1279 | + if ($output->airsyncbasenativebodytype==1) |
|
1280 | + { |
|
1281 | +//plain |
|
1282 | + if ($this->debugLevel>0) |
|
1283 | + { |
|
1284 | + debugLog("Plain Body with requested pref 4"); |
|
1285 | + } |
|
974 | 1286 | $mailObject->setBody($plainBody); |
975 | 1287 | } |
976 | 1288 | // we still need the attachments to be added ( if there are any ) |
@@ -983,7 +1295,10 @@ discard block |
||
983 | 1295 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
984 | 1296 | foreach((array)$attachments as $key => $attachment) |
985 | 1297 | { |
986 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
1298 | + if ($this->debugLevel>0) |
|
1299 | + { |
|
1300 | + debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
1301 | + } |
|
987 | 1302 | $attachmentData = ''; |
988 | 1303 | $attachmentData = $this->mail->getAttachment($id, $attachment['partID'],0,false,false,$_folderName); |
989 | 1304 | $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
@@ -993,13 +1308,22 @@ discard block |
||
993 | 1308 | $Header = $mailObject->getMessageHeader(); |
994 | 1309 | //debugLog(__METHOD__.__LINE__.' MailObject-Header:'.array2string($Header)); |
995 | 1310 | $Body = trim($mailObject->getMessageBody()); // philip thinks this is needed, so lets try if it does any good/harm |
996 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
997 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
1311 | + if ($this->debugLevel>3) |
|
1312 | + { |
|
1313 | + debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
1314 | + } |
|
1315 | + if ($this->debugLevel>2) |
|
1316 | + { |
|
1317 | + debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
1318 | + } |
|
998 | 1319 | $output->airsyncbasebody->data = $Header.self::$LE.self::$LE.$Body; |
999 | 1320 | } |
1000 | 1321 | else if (isset($bodypreference[2])) |
1001 | 1322 | { |
1002 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
1323 | + if ($this->debugLevel>0) |
|
1324 | + { |
|
1325 | + debugLog("HTML Body with requested pref 2"); |
|
1326 | + } |
|
1003 | 1327 | // Send HTML if requested and native type was html |
1004 | 1328 | $output->airsyncbasebody->type = 2; |
1005 | 1329 | $htmlbody = '<html>'. |
@@ -1032,7 +1356,10 @@ discard block |
||
1032 | 1356 | else |
1033 | 1357 | { |
1034 | 1358 | // Send Plaintext as Fallback or if original body is plainttext |
1035 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
1359 | + if ($this->debugLevel>0) |
|
1360 | + { |
|
1361 | + debugLog("Plaintext Body:".$plainBody); |
|
1362 | + } |
|
1036 | 1363 | /* we use plainBody (set above) instead |
1037 | 1364 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
1038 | 1365 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1102,7 +1429,10 @@ discard block |
||
1102 | 1429 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
1103 | 1430 | foreach ($attachments as $key => $attach) |
1104 | 1431 | { |
1105 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1432 | + if ($this->debugLevel>0) |
|
1433 | + { |
|
1434 | + debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1435 | + } |
|
1106 | 1436 | |
1107 | 1437 | // pass meeting requests to calendar plugin |
1108 | 1438 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1113,9 +1443,12 @@ discard block |
||
1113 | 1443 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
1114 | 1444 | continue; // do NOT add attachment as attachment |
1115 | 1445 | } |
1116 | - if(isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1446 | + if(isset($output->_mapping['POOMMAIL:Attachments'])) |
|
1447 | + { |
|
1117 | 1448 | $attachment = new SyncAttachment(); |
1118 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1449 | + } |
|
1450 | + else if(isset($output->_mapping['AirSyncBase:Attachments'])) |
|
1451 | + { |
|
1119 | 1452 | $attachment = new SyncAirSyncBaseAttachment(); |
1120 | 1453 | } |
1121 | 1454 | $attachment->attsize = $attach['size']; |
@@ -1132,20 +1465,28 @@ discard block |
||
1132 | 1465 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
1133 | 1466 | $attachment->contenttype = trim($attach['mimeType']); |
1134 | 1467 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
1135 | - } else { |
|
1468 | + } |
|
1469 | + else |
|
1470 | + { |
|
1136 | 1471 | $attachment->attmethod=1; |
1137 | 1472 | } |
1138 | 1473 | |
1139 | - if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1474 | + if (isset($output->_mapping['POOMMAIL:Attachments'])) |
|
1475 | + { |
|
1140 | 1476 | array_push($output->attachments, $attachment); |
1141 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1477 | + } |
|
1478 | + else if(isset($output->_mapping['AirSyncBase:Attachments'])) |
|
1479 | + { |
|
1142 | 1480 | array_push($output->airsyncbaseattachments, $attachment); |
1143 | 1481 | } |
1144 | 1482 | } |
1145 | 1483 | } |
1146 | 1484 | //$this->debugLevel=0; |
1147 | 1485 | // end handle Attachments |
1148 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1486 | + if ($this->debugLevel>3) |
|
1487 | + { |
|
1488 | + debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1489 | + } |
|
1149 | 1490 | return $output; |
1150 | 1491 | } |
1151 | 1492 | return false; |
@@ -1206,14 +1547,18 @@ discard block |
||
1206 | 1547 | * @param string $attname - should contain (folder)id |
1207 | 1548 | * @return true, prints the content of the attachment |
1208 | 1549 | */ |
1209 | - function GetAttachmentData($fid,$attname) { |
|
1550 | + function GetAttachmentData($fid,$attname) |
|
1551 | + { |
|
1210 | 1552 | debugLog("getAttachmentData: $fid (attname: '$attname')"); |
1211 | 1553 | error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1212 | 1554 | list($folderid, $id, $part) = explode(":", $attname); |
1213 | 1555 | |
1214 | 1556 | $this->splitID($folderid, $account, $folder); |
1215 | 1557 | |
1216 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1558 | + if (!isset($this->mail)) |
|
1559 | + { |
|
1560 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1561 | + } |
|
1217 | 1562 | |
1218 | 1563 | $this->mail->reopen($folder); |
1219 | 1564 | $attachment = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
@@ -1232,14 +1577,18 @@ discard block |
||
1232 | 1577 | * @param string $attname - should contain (folder)id |
1233 | 1578 | * @return SyncAirSyncBaseFileAttachment-object |
1234 | 1579 | */ |
1235 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1580 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
1581 | + { |
|
1236 | 1582 | debugLog("ItemOperationsGetAttachmentData: (attname: '$attname')"); |
1237 | 1583 | |
1238 | 1584 | list($folderid, $id, $part) = explode(":", $attname); |
1239 | 1585 | |
1240 | 1586 | $this->splitID($folderid, $account, $folder); |
1241 | 1587 | |
1242 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
1588 | + if (!isset($this->mail)) |
|
1589 | + { |
|
1590 | + $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
1591 | + } |
|
1243 | 1592 | |
1244 | 1593 | $this->mail->reopen($folder); |
1245 | 1594 | $att = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
@@ -1251,7 +1600,8 @@ discard block |
||
1251 | 1600 | return $attachment; |
1252 | 1601 | } |
1253 | 1602 | */ |
1254 | - if (is_array($att)) { |
|
1603 | + if (is_array($att)) |
|
1604 | + { |
|
1255 | 1605 | $attachment->_data = $att['attachment']; |
1256 | 1606 | $attachment->contenttype = trim($att['type']); |
1257 | 1607 | } |
@@ -1299,12 +1649,16 @@ discard block |
||
1299 | 1649 | * at all on the source folder, and the destination folder will show the new message |
1300 | 1650 | * |
1301 | 1651 | */ |
1302 | - function MoveMessage($folderid, $id, $newfolderid) { |
|
1652 | + function MoveMessage($folderid, $id, $newfolderid) |
|
1653 | + { |
|
1303 | 1654 | debugLog("IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
1304 | 1655 | $this->splitID($folderid, $account, $srcFolder); |
1305 | 1656 | $this->splitID($newfolderid, $account, $destFolder); |
1306 | 1657 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
1307 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1658 | + if (!isset($this->mail)) |
|
1659 | + { |
|
1660 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1661 | + } |
|
1308 | 1662 | $this->mail->reopen($destFolder); |
1309 | 1663 | $status = $this->mail->getFolderStatus($destFolder); |
1310 | 1664 | $uidNext = $status['uidnext']; |
@@ -1325,7 +1679,10 @@ discard block |
||
1325 | 1679 | public function GetMessageList($folderid, $cutoffdate=NULL) |
1326 | 1680 | { |
1327 | 1681 | static $cutdate; |
1328 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1682 | + if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) |
|
1683 | + { |
|
1684 | + $cutdate = $cutoffdate; |
|
1685 | + } |
|
1329 | 1686 | debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
1330 | 1687 | if (empty($cutdate)) |
1331 | 1688 | { |
@@ -1337,7 +1694,10 @@ discard block |
||
1337 | 1694 | |
1338 | 1695 | private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
1339 | 1696 | { |
1340 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
1697 | + if ($this->debugLevel>1) |
|
1698 | + { |
|
1699 | + $gstarttime = microtime (true); |
|
1700 | + } |
|
1341 | 1701 | //debugLog(__METHOD__.__LINE__); |
1342 | 1702 | $rv_messages = array(); |
1343 | 1703 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1348,7 +1708,10 @@ discard block |
||
1348 | 1708 | } |
1349 | 1709 | if (empty($rv_messages)) |
1350 | 1710 | { |
1351 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1711 | + if ($this->debugLevel>1) |
|
1712 | + { |
|
1713 | + $starttime = microtime (true); |
|
1714 | + } |
|
1352 | 1715 | $this->_connect($this->account); |
1353 | 1716 | if ($this->debugLevel>1) |
1354 | 1717 | { |
@@ -1357,16 +1720,28 @@ discard block |
||
1357 | 1720 | } |
1358 | 1721 | $messagelist = array(); |
1359 | 1722 | // if not connected, any further action must fail |
1360 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
1361 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1723 | + if (!empty($cutoffdate)) |
|
1724 | + { |
|
1725 | + $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
1726 | + } |
|
1727 | + if ($this->debugLevel>1) |
|
1728 | + { |
|
1729 | + $starttime = microtime (true); |
|
1730 | + } |
|
1362 | 1731 | $rv = $this->splitID($folderid,$account,$_folderName,$id); |
1363 | 1732 | if ($this->debugLevel>1) |
1364 | 1733 | { |
1365 | 1734 | $endtime = microtime(true) - $starttime; |
1366 | 1735 | debugLog(__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
1367 | 1736 | } |
1368 | - if ($this->debugLevel>1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1369 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1737 | + if ($this->debugLevel>1) |
|
1738 | + { |
|
1739 | + debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1740 | + } |
|
1741 | + if ($this->debugLevel>1) |
|
1742 | + { |
|
1743 | + $starttime = microtime (true); |
|
1744 | + } |
|
1370 | 1745 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
1371 | 1746 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
1372 | 1747 | if ($this->debugLevel>1) |
@@ -1375,25 +1750,54 @@ discard block |
||
1375 | 1750 | debugLog(__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
1376 | 1751 | } |
1377 | 1752 | } |
1378 | - if ($_id == NULL && $this->debugLevel>1) debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
1753 | + if ($_id == NULL && $this->debugLevel>1) |
|
1754 | + { |
|
1755 | + debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
1756 | + } |
|
1379 | 1757 | //debugLog(__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
1380 | 1758 | foreach ((array)$rv_messages['header'] as $k => $vars) |
1381 | 1759 | { |
1382 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1760 | + if ($this->debugLevel>3) |
|
1761 | + { |
|
1762 | + debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1763 | + } |
|
1383 | 1764 | $this->messages[$vars['uid']] = $vars; |
1384 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1385 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
1386 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
1387 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1765 | + if ($this->debugLevel>3) |
|
1766 | + { |
|
1767 | + debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1768 | + } |
|
1769 | + if (!empty($vars['deleted'])) |
|
1770 | + { |
|
1771 | + continue; |
|
1772 | + } |
|
1773 | + // cut of deleted messages |
|
1774 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
1775 | + { |
|
1776 | + continue; |
|
1777 | + } |
|
1778 | + // message is out of range for cutoffdate, ignore it |
|
1779 | + if ($this->debugLevel>0) |
|
1780 | + { |
|
1781 | + debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1782 | + } |
|
1388 | 1783 | $mess["mod"] = $vars['date']; |
1389 | 1784 | $mess["id"] = $vars['uid']; |
1390 | 1785 | // 'seen' aka 'read' is the only flag we want to know about |
1391 | 1786 | $mess["flags"] = 0; |
1392 | 1787 | // outlook supports additional flags, set them to 0 |
1393 | 1788 | $mess["olflags"] = 0; |
1394 | - if($vars["seen"]) $mess["flags"] = 1; |
|
1395 | - if($vars["flagged"]) $mess["olflags"] = 2; |
|
1396 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1789 | + if($vars["seen"]) |
|
1790 | + { |
|
1791 | + $mess["flags"] = 1; |
|
1792 | + } |
|
1793 | + if($vars["flagged"]) |
|
1794 | + { |
|
1795 | + $mess["olflags"] = 2; |
|
1796 | + } |
|
1797 | + if ($this->debugLevel>3) |
|
1798 | + { |
|
1799 | + debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1800 | + } |
|
1397 | 1801 | $messagelist[$vars['uid']] = $mess; |
1398 | 1802 | unset($mess); |
1399 | 1803 | } |
@@ -1414,8 +1818,14 @@ discard block |
||
1414 | 1818 | */ |
1415 | 1819 | public function getSearchResultsMailbox($searchquery) |
1416 | 1820 | { |
1417 | - if (!is_array($searchquery)) return array(); |
|
1418 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1821 | + if (!is_array($searchquery)) |
|
1822 | + { |
|
1823 | + return array(); |
|
1824 | + } |
|
1825 | + if ($this->debugLevel>0) |
|
1826 | + { |
|
1827 | + debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1828 | + } |
|
1419 | 1829 | // 19.10.2011 16:28:59 [24502] mail_activesync::getSearchResultsMailbox1408 |
1420 | 1830 | //Array( |
1421 | 1831 | // [query] => Array( |
@@ -1434,27 +1844,45 @@ discard block |
||
1434 | 1844 | // [rebuildresults] => 1 |
1435 | 1845 | // [deeptraversal] => |
1436 | 1846 | // [range] => 0-999) |
1437 | - if (isset($searchquery['rebuildresults'])) { |
|
1847 | + if (isset($searchquery['rebuildresults'])) |
|
1848 | + { |
|
1438 | 1849 | $rebuildresults = $searchquery['rebuildresults']; |
1439 | - } else { |
|
1850 | + } |
|
1851 | + else |
|
1852 | + { |
|
1440 | 1853 | $rebuildresults = false; |
1441 | 1854 | } |
1442 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1855 | + if ($this->debugLevel>0) |
|
1856 | + { |
|
1857 | + debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1858 | + } |
|
1443 | 1859 | |
1444 | - if (isset($searchquery['deeptraversal'])) { |
|
1860 | + if (isset($searchquery['deeptraversal'])) |
|
1861 | + { |
|
1445 | 1862 | $deeptraversal = $searchquery['deeptraversal']; |
1446 | - } else { |
|
1863 | + } |
|
1864 | + else |
|
1865 | + { |
|
1447 | 1866 | $deeptraversal = false; |
1448 | 1867 | } |
1449 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1868 | + if ($this->debugLevel>0) |
|
1869 | + { |
|
1870 | + debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1871 | + } |
|
1450 | 1872 | |
1451 | - if (isset($searchquery['range'])) { |
|
1873 | + if (isset($searchquery['range'])) |
|
1874 | + { |
|
1452 | 1875 | $range = explode("-",$searchquery['range']); |
1453 | 1876 | $limit = $range[1] - $range[0] + 1; |
1454 | - } else { |
|
1877 | + } |
|
1878 | + else |
|
1879 | + { |
|
1455 | 1880 | $range = false; |
1456 | 1881 | } |
1457 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
1882 | + if ($this->debugLevel>0) |
|
1883 | + { |
|
1884 | + debugLog( 'Range ['.print_r($range, true).']' ); |
|
1885 | + } |
|
1458 | 1886 | |
1459 | 1887 | //foreach($searchquery['query'] as $k => $value) { |
1460 | 1888 | // $query = $value; |
@@ -1467,7 +1895,10 @@ discard block |
||
1467 | 1895 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
1468 | 1896 | { |
1469 | 1897 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
1470 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]=true; |
|
1898 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
|
1899 | + { |
|
1900 | + emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]=true; |
|
1901 | + } |
|
1471 | 1902 | } |
1472 | 1903 | |
1473 | 1904 | if (isset($searchquery['query'][0]['value']['Search:FreeText'])) |
@@ -1493,7 +1924,10 @@ discard block |
||
1493 | 1924 | ); |
1494 | 1925 | |
1495 | 1926 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1496 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1927 | + if ($this->debugLevel>1) |
|
1928 | + { |
|
1929 | + debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1930 | + } |
|
1497 | 1931 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
1498 | 1932 | //debugLog(__METHOD__.__LINE__.array2string($rv_messages)); |
1499 | 1933 | $list=array(); |
@@ -1521,17 +1955,26 @@ discard block |
||
1521 | 1955 | private function getParentID($account,$folder) |
1522 | 1956 | { |
1523 | 1957 | $this->_connect($account); |
1524 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1958 | + if (!isset($this->folders)) |
|
1959 | + { |
|
1960 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
1961 | + } |
|
1525 | 1962 | |
1526 | 1963 | $mailFolder = $this->folders[$folder]; |
1527 | - if (!isset($mailFolder)) return false; |
|
1964 | + if (!isset($mailFolder)) |
|
1965 | + { |
|
1966 | + return false; |
|
1967 | + } |
|
1528 | 1968 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
1529 | 1969 | $parent = explode($delimiter,$folder); |
1530 | 1970 | array_pop($parent); |
1531 | 1971 | $parent = implode($delimiter,$parent); |
1532 | 1972 | |
1533 | 1973 | $id = $parent ? $this->createID($account, $parent) : '0'; |
1534 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1974 | + if ($this->debugLevel>1) |
|
1975 | + { |
|
1976 | + debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1977 | + } |
|
1535 | 1978 | return $id; |
1536 | 1979 | } |
1537 | 1980 | |
@@ -1545,7 +1988,10 @@ discard block |
||
1545 | 1988 | { |
1546 | 1989 | static $last_id; |
1547 | 1990 | static $folderObj; |
1548 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
1991 | + if (isset($last_id) && $last_id === $id) |
|
1992 | + { |
|
1993 | + return $folderObj; |
|
1994 | + } |
|
1549 | 1995 | |
1550 | 1996 | try { |
1551 | 1997 | $this->splitID($id, $account, $folder); |
@@ -1555,18 +2001,30 @@ discard block |
||
1555 | 2001 | return $folderObj=false; |
1556 | 2002 | } |
1557 | 2003 | $this->_connect($account); |
1558 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
2004 | + if (!isset($this->folders)) |
|
2005 | + { |
|
2006 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
2007 | + } |
|
1559 | 2008 | |
1560 | 2009 | $mailFolder = $this->folders[$folder]; |
1561 | - if (!isset($mailFolder)) return $folderObj=false; |
|
2010 | + if (!isset($mailFolder)) |
|
2011 | + { |
|
2012 | + return $folderObj=false; |
|
2013 | + } |
|
1562 | 2014 | |
1563 | 2015 | $folderObj = new SyncFolder(); |
1564 | 2016 | $folderObj->serverid = $id; |
1565 | 2017 | $folderObj->parentid = $this->getParentID($account,$folder); |
1566 | 2018 | $folderObj->displayname = $mailFolder->shortDisplayName; |
1567 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
2019 | + if ($this->debugLevel>1) |
|
2020 | + { |
|
2021 | + debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
2022 | + } |
|
1568 | 2023 | // get folder-type |
1569 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
2024 | + foreach($this->folders as $inbox => $mailFolder) |
|
2025 | + { |
|
2026 | + break; |
|
2027 | + } |
|
1570 | 2028 | if ($folder == $inbox) |
1571 | 2029 | { |
1572 | 2030 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1603,7 +2061,10 @@ discard block |
||
1603 | 2061 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
1604 | 2062 | } |
1605 | 2063 | |
1606 | - if ($this->debugLevel>1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
2064 | + if ($this->debugLevel>1) |
|
2065 | + { |
|
2066 | + debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
2067 | + } |
|
1607 | 2068 | return $folderObj; |
1608 | 2069 | } |
1609 | 2070 | |
@@ -1647,24 +2108,37 @@ discard block |
||
1647 | 2108 | { |
1648 | 2109 | debugLog(__METHOD__.' called with '.$folderid); |
1649 | 2110 | $this->splitID($folderid, $account, $folder); |
1650 | - if (is_numeric($account)) $type = 'mail'; |
|
1651 | - if ($type != 'mail') return false; |
|
2111 | + if (is_numeric($account)) |
|
2112 | + { |
|
2113 | + $type = 'mail'; |
|
2114 | + } |
|
2115 | + if ($type != 'mail') |
|
2116 | + { |
|
2117 | + return false; |
|
2118 | + } |
|
1652 | 2119 | |
1653 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
2120 | + if (!isset($this->mail)) |
|
2121 | + { |
|
2122 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
2123 | + } |
|
1654 | 2124 | |
1655 | 2125 | $changes = array(); |
1656 | 2126 | debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
1657 | 2127 | $this->mail->reopen($folder); |
1658 | 2128 | |
1659 | 2129 | $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
1660 | - if (!$status) { |
|
2130 | + if (!$status) |
|
2131 | + { |
|
1661 | 2132 | debugLog("AlterPingChanges: could not stat folder $folder "); |
1662 | 2133 | return false; |
1663 | - } else { |
|
2134 | + } |
|
2135 | + else |
|
2136 | + { |
|
1664 | 2137 | $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
1665 | 2138 | |
1666 | 2139 | // message number is different - change occured |
1667 | - if ($syncstate != $newstate) { |
|
2140 | + if ($syncstate != $newstate) |
|
2141 | + { |
|
1668 | 2142 | $syncstate = $newstate; |
1669 | 2143 | debugLog("AlterPingChanges: Change FOUND!"); |
1670 | 2144 | // build a dummy change |
@@ -1720,7 +2194,10 @@ discard block |
||
1720 | 2194 | $error = $e->getMessage(); |
1721 | 2195 | debugLog(__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
1722 | 2196 | // if the server thinks the message does not exist report deletion as success |
1723 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
2197 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
2198 | + { |
|
2199 | + return true; |
|
2200 | + } |
|
1724 | 2201 | return false; |
1725 | 2202 | } |
1726 | 2203 | |
@@ -1827,7 +2304,10 @@ discard block |
||
1827 | 2304 | |
1828 | 2305 | $str = $this->backend->createID($account, $folder, $id); |
1829 | 2306 | |
1830 | - if ($this->debugLevel>1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
2307 | + if ($this->debugLevel>1) |
|
2308 | + { |
|
2309 | + debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
2310 | + } |
|
1831 | 2311 | |
1832 | 2312 | return $str; |
1833 | 2313 | } |
@@ -1848,7 +2328,10 @@ discard block |
||
1848 | 2328 | // convert numeric folder-id back to folder name |
1849 | 2329 | $folder = $this->hash2folder($account,$f=$folder); |
1850 | 2330 | |
1851 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
2331 | + if ($this->debugLevel>1) |
|
2332 | + { |
|
2333 | + debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
2334 | + } |
|
1852 | 2335 | } |
1853 | 2336 | |
1854 | 2337 | /** |
@@ -1867,7 +2350,10 @@ discard block |
||
1867 | 2350 | */ |
1868 | 2351 | private function folder2hash($account,$folder) |
1869 | 2352 | { |
1870 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2353 | + if(!isset($this->folderHashes)) |
|
2354 | + { |
|
2355 | + $this->readFolderHashes(); |
|
2356 | + } |
|
1871 | 2357 | |
1872 | 2358 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
1873 | 2359 | { |
@@ -1890,7 +2376,10 @@ discard block |
||
1890 | 2376 | */ |
1891 | 2377 | private function hash2folder($account,$index) |
1892 | 2378 | { |
1893 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2379 | + if(!isset($this->folderHashes)) |
|
2380 | + { |
|
2381 | + $this->readFolderHashes(); |
|
2382 | + } |
|
1894 | 2383 | |
1895 | 2384 | return $this->folderHashes[$account][$index]; |
1896 | 2385 | } |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | $this->backend = $backend; |
98 | 98 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
99 | 99 | { |
100 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
100 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
101 | 101 | // globals preferences add appname varname value |
102 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
102 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
103 | 103 | // save prefs |
104 | 104 | $GLOBALS['egw']->preferences->save_repository(true); |
105 | 105 | } |
106 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
106 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
107 | 107 | |
108 | 108 | if (is_null(self::$profileID)) |
109 | 109 | { |
110 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
111 | - self::$profileID =& egw_cache::getSession('mail','activeSyncProfileID'); |
|
112 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
110 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
111 | + self::$profileID = & egw_cache::getSession('mail', 'activeSyncProfileID'); |
|
112 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
113 | 113 | } |
114 | 114 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
115 | 115 | { |
116 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
116 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
117 | 117 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
118 | 118 | { |
119 | 119 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
124 | 124 | } |
125 | 125 | } |
126 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
126 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
127 | 127 | |
128 | 128 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
129 | 129 | if (!isset($GLOBALS['egw_setup'])) |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | try { |
132 | 132 | emailadmin_account::read(self::$profileID); |
133 | 133 | } |
134 | - catch(Exception $e) { |
|
134 | + catch (Exception $e) { |
|
135 | 135 | unset($e); |
136 | 136 | self::$profileID = emailadmin_account::get_default_acc_id(); |
137 | 137 | } |
138 | 138 | } |
139 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
139 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
140 | 140 | //$this->debugLevel=0; |
141 | 141 | } |
142 | 142 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | $this->__construct($this->backend); |
209 | 209 | |
210 | 210 | try { |
211 | - $this->_connect(0,true); |
|
211 | + $this->_connect(0, true); |
|
212 | 212 | $this->_disconnect(); |
213 | 213 | |
214 | 214 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
215 | 215 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
216 | 216 | } |
217 | - catch(Exception $e) { |
|
217 | + catch (Exception $e) { |
|
218 | 218 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
219 | 219 | } |
220 | 220 | if ($errors) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param int $account integer id of account to use |
233 | 233 | * @todo support different accounts |
234 | 234 | */ |
235 | - private function _connect($account=0) |
|
235 | + private function _connect($account = 0) |
|
236 | 236 | { |
237 | 237 | if (is_null($account)) $account = 0; |
238 | 238 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $this->account = $account; |
246 | 246 | // todo: tell mail which account to use |
247 | 247 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
248 | - $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
248 | + $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
249 | 249 | } |
250 | 250 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
251 | - $this->mail->openConnection(self::$profileID,false); |
|
251 | + $this->mail->openConnection(self::$profileID, false); |
|
252 | 252 | |
253 | 253 | $this->_wasteID = $this->mail->getTrashFolder(false); |
254 | 254 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | /*foreach($available_accounts as $account)*/ $account = 0; |
284 | 284 | { |
285 | 285 | $this->_connect($account); |
286 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
286 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
287 | 287 | //debugLog(__METHOD__.__LINE__.array2string($this->folders)); |
288 | 288 | |
289 | 289 | foreach ($this->folders as $folder => $folderObj) { |
290 | 290 | $folderlist[] = $f = array( |
291 | - 'id' => $this->createID($account,$folder), |
|
291 | + 'id' => $this->createID($account, $folder), |
|
292 | 292 | 'mod' => $folderObj->shortDisplayName, |
293 | - 'parent' => $this->getParentID($account,$folder), |
|
293 | + 'parent' => $this->getParentID($account, $folder), |
|
294 | 294 | ); |
295 | - if ($this->debugLevel>0) debugLog(__METHOD__."() returning ".array2string($f)); |
|
295 | + if ($this->debugLevel > 0) debugLog(__METHOD__."() returning ".array2string($f)); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | //debugLog(__METHOD__."() returning ".array2string($folderlist)); |
@@ -322,64 +322,64 @@ discard block |
||
322 | 322 | * @todo implement either here or in mail backend |
323 | 323 | * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
324 | 324 | */ |
325 | - public function SendMail($rfc822, $smartdata=array(), $protocolversion = false) |
|
325 | + public function SendMail($rfc822, $smartdata = array(), $protocolversion = false) |
|
326 | 326 | { |
327 | 327 | //$this->debugLevel=3; |
328 | 328 | $ClientSideMeetingRequest = false; |
329 | 329 | $allowSendingInvitations = 'sendifnocalnotif'; |
330 | 330 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
331 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
331 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
332 | 332 | { |
333 | 333 | $allowSendingInvitations = false; |
334 | 334 | } |
335 | 335 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
336 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
336 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
337 | 337 | { |
338 | 338 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
339 | 339 | } |
340 | 340 | |
341 | 341 | if ($protocolversion < 14.0) |
342 | - debugLog("IMAP-SendMail: " . (isset($rfc822) ? $rfc822 : ""). "task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
342 | + debugLog("IMAP-SendMail: ".(isset($rfc822) ? $rfc822 : "")."task: ".(isset($smartdata['task']) ? $smartdata['task'] : "")." itemid: ".(isset($smartdata['itemid']) ? $smartdata['itemid'] : "")." folder: ".(isset($smartdata['folderid']) ? $smartdata['folderid'] : "")); |
|
343 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
|
344 | 344 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
345 | 345 | |
346 | 346 | // initialize our mail_bo |
347 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
347 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
348 | 348 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
349 | 349 | // use the standardIdentity |
350 | - $activeMailProfile = mail_bo::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
350 | + $activeMailProfile = mail_bo::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
351 | 351 | |
352 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
352 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
353 | 353 | |
354 | 354 | // initialize the new egw_mailer object for sending |
355 | 355 | $mailObject = new egw_mailer(); |
356 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$rfc822); |
|
356 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $rfc822); |
|
357 | 357 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
358 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
359 | - $mailObject->setFrom($activeMailProfile['ident_email'],$mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile,false))); |
|
358 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
359 | + $mailObject->setFrom($activeMailProfile['ident_email'], $mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile, false))); |
|
360 | 360 | $mailObject->AddCustomHeader('X-Mailer: mail-Activesync'); |
361 | 361 | |
362 | 362 | |
363 | 363 | // prepare addressee list; moved the adding of addresses to the mailobject down |
364 | 364 | // to |
365 | 365 | |
366 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
366 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
367 | 367 | if (!$addressObject->valid) continue; |
368 | - if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) ); |
|
368 | + if ($this->debugLevel > 0) debugLog("Header Sentmail To: ".array2string($addressObject)); |
|
369 | 369 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
370 | 370 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
371 | 371 | } |
372 | 372 | // CC |
373 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
373 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
374 | 374 | if (!$addressObject->valid) continue; |
375 | - if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) ); |
|
375 | + if ($this->debugLevel > 0) debugLog("Header Sentmail CC: ".array2string($addressObject)); |
|
376 | 376 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
377 | 377 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
378 | 378 | } |
379 | 379 | // BCC |
380 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
380 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
381 | 381 | if (!$addressObject->valid) continue; |
382 | - if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) ); |
|
382 | + if ($this->debugLevel > 0) debugLog("Header Sentmail BCC: ".array2string($addressObject)); |
|
383 | 383 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
384 | 384 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
385 | 385 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $use_orgbody = false; |
389 | 389 | |
390 | 390 | $k = 'Content-Type'; |
391 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
391 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
392 | 392 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
393 | 393 | // if the message is a multipart message, then we should use the sent body |
394 | 394 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -408,26 +408,26 @@ discard block |
||
408 | 408 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
409 | 409 | $use_orgbody = true; |
410 | 410 | } |
411 | - $Body = $AltBody = ""; |
|
411 | + $Body = $AltBody = ""; |
|
412 | 412 | // get body of the transmitted message |
413 | 413 | // if this is a simple message, no structure at all |
414 | 414 | if (preg_match("/text/i", $ContentType)) |
415 | 415 | { |
416 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
416 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
417 | 417 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
418 | - $body = $bodyObj ?$bodyObj->getContents() : null; |
|
419 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $body); |
|
420 | - if ($simpleBodyType == "text/plain") |
|
418 | + $body = $bodyObj ? $bodyObj->getContents() : null; |
|
419 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $body); |
|
420 | + if ($simpleBodyType == "text/plain") |
|
421 | 421 | { |
422 | 422 | $Body = $body; |
423 | 423 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
424 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
424 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
425 | 425 | } |
426 | 426 | else |
427 | 427 | { |
428 | 428 | $AltBody = $body; |
429 | - $Body = trim(translation::convertHTMLToText($body)); |
|
430 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
429 | + $Body = trim(translation::convertHTMLToText($body)); |
|
430 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | else |
@@ -436,60 +436,60 @@ discard block |
||
436 | 436 | $Body = ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null; |
437 | 437 | $AltBody = ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null; |
438 | 438 | // prefer plain over html |
439 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $Body); |
|
440 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $AltBody); |
|
439 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $Body); |
|
440 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $AltBody); |
|
441 | 441 | } |
442 | - if ($this->debugLevel>1 && $Body) debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
443 | - if ($this->debugLevel>1 && $AltBody) debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
442 | + if ($this->debugLevel > 1 && $Body) debugLog("IMAP-Sendmail: fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
443 | + if ($this->debugLevel > 1 && $AltBody) debugLog("IMAP-Sendmail: fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
444 | 444 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
445 | 445 | // if this is a multipart message with a boundary, we must use the original body |
446 | 446 | //if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
447 | 447 | if ($use_orgbody) { |
448 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
448 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
449 | 449 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
450 | - if (stripos($ContentType,'text/calendar') !== false ) |
|
450 | + if (stripos($ContentType, 'text/calendar') !== false) |
|
451 | 451 | { |
452 | 452 | $body = ($text_body = $mailObject->findBody('calendar')) ? $text_body->getContents() : null; |
453 | 453 | $Body = $body; |
454 | 454 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
455 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
455 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
456 | 456 | // try figuring out the METHOD -> [ContentType] => text/calendar; name=meeting.ics; method=REQUEST |
457 | - $tA = explode(' ',$ContentType); |
|
458 | - foreach ((array)$tA as $k => $p) if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
|
457 | + $tA = explode(' ', $ContentType); |
|
458 | + foreach ((array)$tA as $k => $p) if (stripos($p, "method=") !== false) $cSMRMethod = trim(str_replace('METHOD=', '', strtoupper($p))); |
|
459 | 459 | $ClientSideMeetingRequest = true; |
460 | 460 | } |
461 | 461 | } |
462 | 462 | // now handle the addressee list |
463 | 463 | $toCount = 0; |
464 | 464 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
465 | - foreach((array)$toMailAddr as $address) { |
|
466 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
467 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
468 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; |
|
465 | + foreach ((array)$toMailAddr as $address) { |
|
466 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
467 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
468 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress, (isset($cSMRMethod) ? $cSMRMethod : 'REQUEST'))) continue; |
|
469 | 469 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
470 | 470 | $toCount++; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | $ccCount = 0; |
474 | - foreach((array)$ccMailAddr as $address) { |
|
475 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
476 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
474 | + foreach ((array)$ccMailAddr as $address) { |
|
475 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
476 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
477 | 477 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
478 | 478 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
479 | 479 | $ccCount++; |
480 | 480 | } |
481 | 481 | } |
482 | 482 | $bccCount = 0; |
483 | - foreach((array)$bccMailAddr as $address) { |
|
484 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
485 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
483 | + foreach ((array)$bccMailAddr as $address) { |
|
484 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
485 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
486 | 486 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
487 | 487 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
488 | 488 | $bccCount++; |
489 | 489 | } |
490 | 490 | } |
491 | - if ($toCount+$ccCount+$bccCount == 0) return 0; // noone to send mail to |
|
492 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
491 | + if ($toCount + $ccCount + $bccCount == 0) return 0; // noone to send mail to |
|
492 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
493 | 493 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
494 | 494 | /* |
495 | 495 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -497,29 +497,29 @@ discard block |
||
497 | 497 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
498 | 498 | */ |
499 | 499 | // add signature!! ----------------------------------------------------------------- |
500 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
500 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
501 | 501 | try |
502 | 502 | { |
503 | 503 | $acc = emailadmin_account::read($this->mail->icServer->ImapServerId); |
504 | 504 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
505 | - $_signature = emailadmin_account::read_identity($acc['ident_id'],true); |
|
505 | + $_signature = emailadmin_account::read_identity($acc['ident_id'], true); |
|
506 | 506 | } |
507 | 507 | catch (Exception $e) |
508 | 508 | { |
509 | - $_signature=array(); |
|
509 | + $_signature = array(); |
|
510 | 510 | } |
511 | 511 | $signature = $_signature['ident_signature']; |
512 | 512 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
513 | 513 | $preferencesArray['disableRulerForSignatureSeparation']) || |
514 | - empty($signature) || trim(translation::convertHTMLToText($signature)) =='') |
|
514 | + empty($signature) || trim(translation::convertHTMLToText($signature)) == '') |
|
515 | 515 | { |
516 | 516 | $disableRuler = true; |
517 | 517 | } |
518 | 518 | $beforePlain = $beforeHtml = ""; |
519 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
520 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
521 | - $sigText = emailadmin_imapbase::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
522 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
519 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
520 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
521 | + $sigText = emailadmin_imapbase::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
522 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
523 | 523 | $sigTextHtml = $beforeHtml.$sigText; |
524 | 524 | $sigTextPlain = $beforePlain.translation::convertHTMLToText($sigText); |
525 | 525 | $isreply = $isforward = false; |
@@ -531,26 +531,26 @@ discard block |
||
531 | 531 | { |
532 | 532 | // now get on, and fetch the original mail |
533 | 533 | $uid = $smartdata['itemid']; |
534 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
534 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
535 | 535 | $this->splitID($smartdata['folderid'], $account, $folder); |
536 | 536 | |
537 | 537 | $this->mail->reopen($folder); |
538 | 538 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
539 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
540 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
541 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
539 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
540 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
541 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
542 | 542 | // may be html |
543 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
543 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
544 | 544 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
545 | 545 | $isreply = true; |
546 | 546 | } |
547 | 547 | // plain text Message part |
548 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
548 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
549 | 549 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
550 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
551 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
552 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
553 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
550 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
551 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
552 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
553 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
554 | 554 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
555 | 555 | $isreply = true; |
556 | 556 | } |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | { |
559 | 559 | $isreply = true; |
560 | 560 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
561 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
561 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
565 | 565 | // how to forward and other prefs |
566 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
566 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
567 | 567 | |
568 | 568 | // forward ------------------------------------------------------------------------- |
569 | 569 | if ($smartdata['task'] == 'forward' && isset($smartdata['itemid']) && |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | { |
574 | 574 | //force the default for the forwarding -> asmail |
575 | 575 | if (is_array($preferencesArray)) { |
576 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
576 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
577 | 577 | || !isset($preferencesArray['message_forwarding']) |
578 | 578 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
579 | 579 | } else { |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | } |
582 | 582 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
583 | 583 | $uid = $smartdata['itemid']; |
584 | - if ($this->debugLevel>0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
584 | + if ($this->debugLevel > 0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
585 | 585 | $this->splitID($smartdata['folderid'], $account, $folder); |
586 | 586 | |
587 | 587 | $this->mail->reopen($folder); |
588 | 588 | // receive entire mail (header + body) |
589 | 589 | // get message headers for specified message |
590 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
590 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
591 | 591 | // build a new mime message, forward entire old mail as file |
592 | 592 | if ($preferencesArray['message_forwarding'] == 'asmail') |
593 | 593 | { |
594 | - $rawHeader=''; |
|
595 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID,$folder); |
|
596 | - $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID,$folder); |
|
594 | + $rawHeader = ''; |
|
595 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID, $folder); |
|
596 | + $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID, $folder); |
|
597 | 597 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
598 | 598 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
599 | 599 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -603,49 +603,49 @@ discard block |
||
603 | 603 | { |
604 | 604 | // now get on, and fetch the original mail |
605 | 605 | $uid = $smartdata['itemid']; |
606 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
606 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
607 | 607 | $this->splitID($smartdata['folderid'], $account, $folder); |
608 | 608 | |
609 | 609 | $this->mail->reopen($folder); |
610 | 610 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
611 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
612 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
613 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
611 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
612 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
613 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
614 | 614 | // may be html |
615 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
615 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
616 | 616 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
617 | 617 | $isforward = true; |
618 | 618 | } |
619 | 619 | // plain text Message part |
620 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
620 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
621 | 621 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
622 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
623 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
624 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
625 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
622 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
623 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
624 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
625 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
626 | 626 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
627 | 627 | $isforward = true; |
628 | 628 | } |
629 | 629 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
630 | 630 | { |
631 | 631 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
632 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
632 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
633 | 633 | $isforward = true; |
634 | 634 | } |
635 | 635 | // get all the attachments and add them too. |
636 | 636 | // start handle Attachments |
637 | 637 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
638 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
638 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
639 | 639 | $attachmentNames = false; |
640 | - if (is_array($attachments) && count($attachments)>0) |
|
640 | + if (is_array($attachments) && count($attachments) > 0) |
|
641 | 641 | { |
642 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
643 | - foreach((array)$attachments as $key => $attachment) |
|
642 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
643 | + foreach ((array)$attachments as $key => $attachment) |
|
644 | 644 | { |
645 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
645 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
646 | 646 | $attachmentNames .= $attachment['name']."\n"; |
647 | 647 | $attachmentData = ''; |
648 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
648 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
649 | 649 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
650 | 650 | //debugLog(__METHOD__.__LINE__.' added part with number:'.$x); |
651 | 651 | } |
@@ -661,18 +661,18 @@ discard block |
||
661 | 661 | // now set the body |
662 | 662 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
663 | 663 | { |
664 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
665 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
664 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
665 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
666 | 666 | } |
667 | 667 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
668 | 668 | { |
669 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
670 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
669 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
670 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
671 | 671 | } |
672 | 672 | //advanced debugging |
673 | 673 | // Horde SMTP Class uses utf-8 by default. |
674 | 674 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
675 | - if ($this->debugLevel>2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
675 | + if ($this->debugLevel > 2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
676 | 676 | |
677 | 677 | // set a higher timeout for big messages |
678 | 678 | @set_time_limit(120); |
@@ -682,15 +682,15 @@ discard block |
||
682 | 682 | try { |
683 | 683 | $mailObject->Send(); |
684 | 684 | } |
685 | - catch(phpmailerException $e) { |
|
686 | - debugLog("The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
685 | + catch (phpmailerException $e) { |
|
686 | + debugLog("The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
687 | 687 | $send = false; |
688 | 688 | } |
689 | 689 | |
690 | - if (( $smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
690 | + if (($smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
691 | 691 | { |
692 | 692 | $uid = $smartdata['itemid']; |
693 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
693 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
694 | 694 | $this->splitID($smartdata['folderid'], $account, $folder); |
695 | 695 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
696 | 696 | $this->mail->reopen($folder); |
@@ -698,25 +698,25 @@ discard block |
||
698 | 698 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
699 | 699 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
700 | 700 | { |
701 | - $this->mail->deleteMessages(array($uid),$folder); |
|
701 | + $this->mail->deleteMessages(array($uid), $folder); |
|
702 | 702 | } else { |
703 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
704 | - if ($smartdata['task']== "forward") |
|
703 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
704 | + if ($smartdata['task'] == "forward") |
|
705 | 705 | { |
706 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
706 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | } |
710 | 710 | |
711 | - $asf = ($send ? true:false); // initalize accordingly |
|
712 | - if (($smartdata['saveinsentitems']==1 || !isset($smartdata['saveinsentitems'])) && $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
711 | + $asf = ($send ? true : false); // initalize accordingly |
|
712 | + if (($smartdata['saveinsentitems'] == 1 || !isset($smartdata['saveinsentitems'])) && $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
713 | 713 | { |
714 | 714 | $asf = false; |
715 | 715 | $sentFolder = $this->mail->getSentFolder(); |
716 | 716 | if ($this->_sentID) { |
717 | 717 | $folderArray[] = $this->_sentID; |
718 | 718 | } |
719 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
719 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
720 | 720 | { |
721 | 721 | $folderArray[] = $sentFolder; |
722 | 722 | } |
@@ -728,43 +728,43 @@ discard block |
||
728 | 728 | $asf = true; |
729 | 729 | } |
730 | 730 | if (count($folderArray) > 0) { |
731 | - foreach((array)$bccMailAddr as $address) { |
|
732 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
733 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
731 | + foreach ((array)$bccMailAddr as $address) { |
|
732 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
733 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
734 | 734 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
735 | 735 | } |
736 | 736 | } |
737 | - $BCCmail=''; |
|
738 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
739 | - foreach($folderArray as $folderName) { |
|
740 | - if($this->mail->isSentFolder($folderName)) { |
|
737 | + $BCCmail = ''; |
|
738 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
739 | + foreach ($folderArray as $folderName) { |
|
740 | + if ($this->mail->isSentFolder($folderName)) { |
|
741 | 741 | $flags = '\\Seen'; |
742 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
742 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
743 | 743 | $flags = '\\Draft'; |
744 | 744 | } else { |
745 | 745 | $flags = ''; |
746 | 746 | } |
747 | 747 | $asf = true; |
748 | 748 | //debugLog(__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
749 | - $this->mail->openConnection(self::$profileID,false); |
|
749 | + $this->mail->openConnection(self::$profileID, false); |
|
750 | 750 | if ($this->mail->folderExists($folderName)) { |
751 | 751 | try |
752 | 752 | { |
753 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
753 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
754 | 754 | $flags); |
755 | 755 | } |
756 | 756 | catch (egw_exception_wrong_userinput $e) |
757 | 757 | { |
758 | 758 | //$asf = false; |
759 | - debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage())); |
|
759 | + debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage())); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | else |
763 | 763 | { |
764 | 764 | //$asf = false; |
765 | - debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
765 | + debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
766 | 766 | } |
767 | - debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
767 | + debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
768 | 768 | } |
769 | 769 | //$this->mail->closeConnection(); |
770 | 770 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | } |
779 | 779 | else |
780 | 780 | { |
781 | - debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
782 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
781 | + debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
782 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | } |
@@ -791,39 +791,39 @@ discard block |
||
791 | 791 | * |
792 | 792 | * @see activesync_plugin_read::GetMessage() |
793 | 793 | */ |
794 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
794 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
795 | 795 | { |
796 | 796 | //$this->debugLevel=4; |
797 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
797 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
798 | 798 | debugLog(__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
799 | - $rv = $this->splitID($folderid,$account,$_folderName,$xid); |
|
799 | + $rv = $this->splitID($folderid, $account, $_folderName, $xid); |
|
800 | 800 | $this->mail->reopen($_folderName); |
801 | 801 | $stat = $this->StatMessage($folderid, $id); |
802 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
802 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
803 | 803 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
804 | 804 | if ($stat) |
805 | 805 | { |
806 | 806 | debugLog(__METHOD__.__LINE__." Message $id with stat ".array2string($stat)); |
807 | 807 | // initialize the object |
808 | 808 | $output = new SyncMail(); |
809 | - $headers = $this->mail->getMessageHeader($id,'',true,true,$_folderName); |
|
809 | + $headers = $this->mail->getMessageHeader($id, '', true, true, $_folderName); |
|
810 | 810 | if (empty($headers)) |
811 | 811 | { |
812 | 812 | error_log(__METHOD__.__LINE__.' Retrieval of Headers Failed! for .'.$this->account.'/'.$GLOBALS['egw_info']['user']['account_lid'].' ServerID:'.self::$profileID.'FolderID:'.$folderid.'/'.$_folderName.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference).' Stat was:'.array2string($stat)); |
813 | - return $output;//empty object |
|
813 | + return $output; //empty object |
|
814 | 814 | } |
815 | 815 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
816 | 816 | // simple style |
817 | 817 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
818 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
818 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
819 | 819 | if ($bodypreference === false) { |
820 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
821 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
820 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
821 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
822 | 822 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
823 | - if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
823 | + if (stripos($body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
824 | 824 | // remove all other html |
825 | 825 | $body = strip_tags($body); |
826 | - if(strlen($body) > $truncsize) { |
|
826 | + if (strlen($body) > $truncsize) { |
|
827 | 827 | $body = utf8_truncate($body, $truncsize); |
828 | 828 | $output->bodytruncated = 1; |
829 | 829 | } |
@@ -837,60 +837,60 @@ discard block |
||
837 | 837 | else // style with bodypreferences |
838 | 838 | { |
839 | 839 | if (isset($bodypreference[1]) && !isset($bodypreference[1]["TruncationSize"])) |
840 | - $bodypreference[1]["TruncationSize"] = 1024*1024; |
|
840 | + $bodypreference[1]["TruncationSize"] = 1024 * 1024; |
|
841 | 841 | if (isset($bodypreference[2]) && !isset($bodypreference[2]["TruncationSize"])) |
842 | - $bodypreference[2]["TruncationSize"] = 1024*1024; |
|
842 | + $bodypreference[2]["TruncationSize"] = 1024 * 1024; |
|
843 | 843 | if (isset($bodypreference[3]) && !isset($bodypreference[3]["TruncationSize"])) |
844 | - $bodypreference[3]["TruncationSize"] = 1024*1024; |
|
844 | + $bodypreference[3]["TruncationSize"] = 1024 * 1024; |
|
845 | 845 | if (isset($bodypreference[4]) && !isset($bodypreference[4]["TruncationSize"])) |
846 | - $bodypreference[4]["TruncationSize"] = 1024*1024; |
|
846 | + $bodypreference[4]["TruncationSize"] = 1024 * 1024; |
|
847 | 847 | // set the protocoll class |
848 | 848 | $output->airsyncbasebody = new SyncAirSyncBaseBody(); |
849 | - if ($this->debugLevel>0) debugLog("airsyncbasebody!"); |
|
849 | + if ($this->debugLevel > 0) debugLog("airsyncbasebody!"); |
|
850 | 850 | // fetch the body (try to gather data only once) |
851 | - $css =''; |
|
852 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
853 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
854 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
855 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
856 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
851 | + $css = ''; |
|
852 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
853 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
854 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
855 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' html_only:'.$body); |
|
856 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
857 | 857 | // may be html |
858 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
858 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
859 | 859 | $css = $this->mail->getStyles($bodyStruct); |
860 | - $output->airsyncbasenativebodytype=2; |
|
860 | + $output->airsyncbasenativebodytype = 2; |
|
861 | 861 | } else { |
862 | 862 | // plain text Message |
863 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
864 | - $output->airsyncbasenativebodytype=1; |
|
865 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
866 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
867 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
868 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
863 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
864 | + $output->airsyncbasenativebodytype = 1; |
|
865 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
866 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
867 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
868 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
869 | 869 | } |
870 | 870 | // whatever format decode (using the correct encoding) |
871 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype==2?' html ':' plain ').$body); |
|
871 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
872 | 872 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
873 | 873 | // prepare plaintextbody |
874 | 874 | if ($output->airsyncbasenativebodytype == 2) |
875 | 875 | { |
876 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
877 | - if($bodyStructplain[0]['error']==1) |
|
876 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
877 | + if ($bodyStructplain[0]['error'] == 1) |
|
878 | 878 | { |
879 | 879 | $plainBody = translation::convertHTMLToText($body); // always display with preserved HTML |
880 | 880 | } |
881 | 881 | else |
882 | 882 | { |
883 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
883 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | //if ($this->debugLevel>0) debugLog("MIME Body".$body); |
887 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
887 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
888 | 888 | // remove all other html |
889 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
889 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
890 | 890 | $plainBody = strip_tags($plainBody); |
891 | - if ($this->debugLevel>3 && $output->airsyncbasenativebodytype==1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
891 | + if ($this->debugLevel > 3 && $output->airsyncbasenativebodytype == 1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
892 | 892 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
893 | - if (isset($bodypreference[4]) && ($mimesupport==2 || ($mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false))) |
|
893 | + if (isset($bodypreference[4]) && ($mimesupport == 2 || ($mimesupport == 1 && stristr($headers['CONTENT-TYPE'], 'signed') !== false))) |
|
894 | 894 | { |
895 | 895 | debugLog(__METHOD__.__LINE__." bodypreference 4 requested"); |
896 | 896 | $output->airsyncbasebody->type = 4; |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | // we create a complete new rfc822 message here to pass a clean one to the client. |
903 | 903 | // this strips a lot of information, but ... |
904 | 904 | $Header = $Body = ''; |
905 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
905 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
906 | 906 | //if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__." Using data from ".$rawHeaders.$rawBody); |
907 | 907 | //$this->mail->parseRawMessageIntoMailObject($mailObject,$rawHeaders.$rawBody,$Header,$Body); |
908 | 908 | //debugLog(__METHOD__.__LINE__.array2string($headers)); |
@@ -915,33 +915,33 @@ discard block |
||
915 | 915 | $mailObject->Subject = $headers['SUBJECT']; |
916 | 916 | $mailObject->MessageID = $headers['MESSAGE-ID']; |
917 | 917 | // from |
918 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) { |
|
918 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['FROM']) : $headers['FROM'])) as $addressObject) { |
|
919 | 919 | //debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
920 | 920 | if (!$addressObject->valid) continue; |
921 | - $mailObject->From = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
921 | + $mailObject->From = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
922 | 922 | $mailObject->FromName = $addressObject->personal; |
923 | 923 | //error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
924 | 924 | } |
925 | 925 | // to |
926 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) { |
|
926 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['TO']) : $headers['TO'])) as $addressObject) { |
|
927 | 927 | //debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject)); |
928 | 928 | if (!$addressObject->valid) continue; |
929 | - $mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
929 | + $mailObject->AddAddress($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
930 | 930 | } |
931 | 931 | // CC |
932 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) { |
|
932 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['CC']) : $headers['CC'])) as $addressObject) { |
|
933 | 933 | //debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject)); |
934 | 934 | if (!$addressObject->valid) continue; |
935 | - $mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
935 | + $mailObject->AddCC($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
936 | 936 | } |
937 | 937 | // AddReplyTo |
938 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) { |
|
938 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['REPLY-TO']) : $headers['REPLY-TO'])) as $addressObject) { |
|
939 | 939 | //debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject)); |
940 | 940 | if (!$addressObject->valid) continue; |
941 | - $mailObject->AddReplyTo($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
941 | + $mailObject->AddReplyTo($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
942 | 942 | } |
943 | 943 | $Header = $Body = ''; // we do not use Header and Body we use the MailObject |
944 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
944 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
945 | 945 | } |
946 | 946 | catch (egw_exception_assertion_failed $e) |
947 | 947 | { |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | $Header = $Body = ''; |
950 | 950 | } |
951 | 951 | |
952 | - if ($this->debugLevel>0) debugLog("MIME Body -> ".$body); // body is retrieved up |
|
953 | - if ($output->airsyncbasenativebodytype==2) { //html |
|
954 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 4"); |
|
952 | + if ($this->debugLevel > 0) debugLog("MIME Body -> ".$body); // body is retrieved up |
|
953 | + if ($output->airsyncbasenativebodytype == 2) { //html |
|
954 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 4"); |
|
955 | 955 | // if we happen to extract css from body. then remove it |
956 | - if ($css) translation::replaceTagsCompletley($body,'style'); |
|
956 | + if ($css) translation::replaceTagsCompletley($body, 'style'); |
|
957 | 957 | $html = '<html>'. |
958 | 958 | '<head>'. |
959 | 959 | '<meta name="Generator" content="Z-Push">'. |
@@ -961,30 +961,30 @@ discard block |
||
961 | 961 | $css. |
962 | 962 | '</head>'. |
963 | 963 | '<body>'. |
964 | - str_replace("\n","<BR>",str_replace("\r","", str_replace("\r\n","<BR>",$body))). |
|
964 | + str_replace("\n", "<BR>", str_replace("\r", "", str_replace("\r\n", "<BR>", $body))). |
|
965 | 965 | '</body>'. |
966 | 966 | '</html>'; |
967 | - $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
|
968 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
969 | - $mailObject->setBody(empty($plainBody)?strip_tags($body):$plainBody); |
|
967 | + $mailObject->setHtmlBody(str_replace("\n", "\r\n", str_replace("\r", "", $html)), null, false); |
|
968 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
969 | + $mailObject->setBody(empty($plainBody) ? strip_tags($body) : $plainBody); |
|
970 | 970 | } |
971 | - if ($output->airsyncbasenativebodytype==1) { //plain |
|
972 | - if ($this->debugLevel>0) debugLog("Plain Body with requested pref 4"); |
|
971 | + if ($output->airsyncbasenativebodytype == 1) { //plain |
|
972 | + if ($this->debugLevel > 0) debugLog("Plain Body with requested pref 4"); |
|
973 | 973 | $mailObject->setBody($plainBody); |
974 | 974 | } |
975 | 975 | // we still need the attachments to be added ( if there are any ) |
976 | 976 | // start handle Attachments |
977 | 977 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
978 | - $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true , $_folderName); |
|
979 | - if (is_array($attachments) && count($attachments)>0) |
|
978 | + $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true, $_folderName); |
|
979 | + if (is_array($attachments) && count($attachments) > 0) |
|
980 | 980 | { |
981 | 981 | debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$id.' found:'.count($attachments)); |
982 | 982 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
983 | - foreach((array)$attachments as $key => $attachment) |
|
983 | + foreach ((array)$attachments as $key => $attachment) |
|
984 | 984 | { |
985 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
985 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
986 | 986 | $attachmentData = ''; |
987 | - $attachmentData = $this->mail->getAttachment($id, $attachment['partID'],0,false,false,$_folderName); |
|
987 | + $attachmentData = $this->mail->getAttachment($id, $attachment['partID'], 0, false, false, $_folderName); |
|
988 | 988 | $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
989 | 989 | } |
990 | 990 | } |
@@ -992,13 +992,13 @@ discard block |
||
992 | 992 | $Header = $mailObject->getMessageHeader(); |
993 | 993 | //debugLog(__METHOD__.__LINE__.' MailObject-Header:'.array2string($Header)); |
994 | 994 | $Body = trim($mailObject->getMessageBody()); // philip thinks this is needed, so lets try if it does any good/harm |
995 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
996 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
995 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
996 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
997 | 997 | $output->airsyncbasebody->data = $Header.self::$LE.self::$LE.$Body; |
998 | 998 | } |
999 | 999 | else if (isset($bodypreference[2])) |
1000 | 1000 | { |
1001 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
1001 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 2"); |
|
1002 | 1002 | // Send HTML if requested and native type was html |
1003 | 1003 | $output->airsyncbasebody->type = 2; |
1004 | 1004 | $htmlbody = '<html>'. |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $css. |
1009 | 1009 | '</head>'. |
1010 | 1010 | '<body>'; |
1011 | - if ($output->airsyncbasenativebodytype==2) |
|
1011 | + if ($output->airsyncbasenativebodytype == 2) |
|
1012 | 1012 | { |
1013 | 1013 | // as we fetch html, and body is HTML, we may not need to handle this |
1014 | 1014 | $htmlbody .= $body; |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | else |
1017 | 1017 | { |
1018 | 1018 | // html requested but got only plaintext, so fake html |
1019 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
1019 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
1020 | 1020 | } |
1021 | 1021 | $htmlbody .= '</body>'. |
1022 | 1022 | '</html>'; |
1023 | 1023 | |
1024 | - if(isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
1024 | + if (isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
1025 | 1025 | { |
1026 | - $htmlbody = utf8_truncate($htmlbody,$bodypreference[2]["TruncationSize"]); |
|
1026 | + $htmlbody = utf8_truncate($htmlbody, $bodypreference[2]["TruncationSize"]); |
|
1027 | 1027 | $output->airsyncbasebody->truncated = 1; |
1028 | 1028 | } |
1029 | 1029 | $output->airsyncbasebody->data = $htmlbody; |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | else |
1032 | 1032 | { |
1033 | 1033 | // Send Plaintext as Fallback or if original body is plainttext |
1034 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
1034 | + if ($this->debugLevel > 0) debugLog("Plaintext Body:".$plainBody); |
|
1035 | 1035 | /* we use plainBody (set above) instead |
1036 | 1036 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
1037 | 1037 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | //$plain = str_replace("\n","\r\n",str_replace("\r","",$plain)); |
1041 | 1041 | */ |
1042 | 1042 | $output->airsyncbasebody->type = 1; |
1043 | - if(isset($bodypreference[1]["TruncationSize"]) && |
|
1043 | + if (isset($bodypreference[1]["TruncationSize"]) && |
|
1044 | 1044 | strlen($plainBody) > $bodypreference[1]["TruncationSize"]) |
1045 | 1045 | { |
1046 | 1046 | $plainBody = utf8_truncate($plainBody, $bodypreference[1]["TruncationSize"]); |
@@ -1061,21 +1061,20 @@ discard block |
||
1061 | 1061 | debugLog(__METHOD__.__LINE__.' gather Header info:'.$headers['SUBJECT'].' from:'.$headers['DATE']); |
1062 | 1062 | $output->read = $stat["flags"]; |
1063 | 1063 | $output->subject = $this->messages[$id]['subject']; |
1064 | - $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : |
|
1065 | - ($this->messages[$id]['priority'] < 3 ? 2 : 1) ; |
|
1066 | - $output->datereceived = $this->mail->_strtotime($headers['DATE'],'ts',true); |
|
1067 | - $output->displayto = ($headers['TO'] ? $headers['TO']:null); //$stat['FETCHED_HEADER']['to_name'] |
|
1064 | + $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : ($this->messages[$id]['priority'] < 3 ? 2 : 1); |
|
1065 | + $output->datereceived = $this->mail->_strtotime($headers['DATE'], 'ts', true); |
|
1066 | + $output->displayto = ($headers['TO'] ? $headers['TO'] : null); //$stat['FETCHED_HEADER']['to_name'] |
|
1068 | 1067 | // $output->to = $this->messages[$id]['to_address']; //$stat['FETCHED_HEADER']['to_name'] |
1069 | 1068 | // $output->from = $this->messages[$id]['sender_address']; //$stat['FETCHED_HEADER']['sender_name'] |
1070 | 1069 | //error_log(__METHOD__.__LINE__.' To:'.$headers['TO']); |
1071 | 1070 | $output->to = $headers['TO']; |
1072 | 1071 | //error_log(__METHOD__.__LINE__.' From:'.$headers['FROM']); |
1073 | 1072 | $output->from = $headers['FROM']; |
1074 | - $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
1075 | - $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
1073 | + $output->cc = ($headers['CC'] ? $headers['CC'] : null); |
|
1074 | + $output->reply_to = ($headers['REPLY_TO'] ? $headers['REPLY_TO'] : null); |
|
1076 | 1075 | $output->messageclass = "IPM.Note"; |
1077 | - if (stripos($this->messages[$id]['mimetype'],'multipart')!== false && |
|
1078 | - stripos($this->messages[$id]['mimetype'],'signed')!== false) |
|
1076 | + if (stripos($this->messages[$id]['mimetype'], 'multipart') !== false && |
|
1077 | + stripos($this->messages[$id]['mimetype'], 'signed') !== false) |
|
1079 | 1078 | { |
1080 | 1079 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
1081 | 1080 | } |
@@ -1090,61 +1089,61 @@ discard block |
||
1090 | 1089 | } |
1091 | 1090 | |
1092 | 1091 | $output->internetcpid = 65001; |
1093 | - $output->contentclass="urn:content-classes:message"; |
|
1092 | + $output->contentclass = "urn:content-classes:message"; |
|
1094 | 1093 | // end AS12 Stuff |
1095 | 1094 | |
1096 | 1095 | // start handle Attachments (include text/calendar multipart alternative) |
1097 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
1098 | - if (is_array($attachments) && count($attachments)>0) |
|
1096 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
1097 | + if (is_array($attachments) && count($attachments) > 0) |
|
1099 | 1098 | { |
1100 | 1099 | debugLog(__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
1101 | 1100 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
1102 | 1101 | foreach ($attachments as $key => $attach) |
1103 | 1102 | { |
1104 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1103 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1105 | 1104 | |
1106 | 1105 | // pass meeting requests to calendar plugin |
1107 | 1106 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1108 | 1107 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
1109 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
1108 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
1110 | 1109 | ($output->meetingrequest = calendar_activesync::meetingRequest($attachment['attachment']))) |
1111 | 1110 | { |
1112 | 1111 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
1113 | - continue; // do NOT add attachment as attachment |
|
1112 | + continue; // do NOT add attachment as attachment |
|
1114 | 1113 | } |
1115 | - if(isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1114 | + if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
1116 | 1115 | $attachment = new SyncAttachment(); |
1117 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1116 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1118 | 1117 | $attachment = new SyncAirSyncBaseAttachment(); |
1119 | 1118 | } |
1120 | 1119 | $attachment->attsize = $attach['size']; |
1121 | 1120 | $attachment->displayname = $attach['name']; |
1122 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
1121 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
1123 | 1122 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
1124 | 1123 | $attachment->attmethod = 1; |
1125 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1126 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
1124 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1125 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
1127 | 1126 | { |
1128 | - $attachment->isinline=true; |
|
1129 | - $attachment->attmethod=6; |
|
1130 | - $attachment->contentid= $attach['cid']; |
|
1127 | + $attachment->isinline = true; |
|
1128 | + $attachment->attmethod = 6; |
|
1129 | + $attachment->contentid = $attach['cid']; |
|
1131 | 1130 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
1132 | 1131 | $attachment->contenttype = trim($attach['mimeType']); |
1133 | 1132 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
1134 | 1133 | } else { |
1135 | - $attachment->attmethod=1; |
|
1134 | + $attachment->attmethod = 1; |
|
1136 | 1135 | } |
1137 | 1136 | |
1138 | 1137 | if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
1139 | 1138 | array_push($output->attachments, $attachment); |
1140 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1139 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
1141 | 1140 | array_push($output->airsyncbaseattachments, $attachment); |
1142 | 1141 | } |
1143 | 1142 | } |
1144 | 1143 | } |
1145 | 1144 | //$this->debugLevel=0; |
1146 | 1145 | // end handle Attachments |
1147 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1146 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
1148 | 1147 | return $output; |
1149 | 1148 | } |
1150 | 1149 | return false; |
@@ -1174,16 +1173,16 @@ discard block |
||
1174 | 1173 | return false; |
1175 | 1174 | } |
1176 | 1175 | $ret = false; |
1177 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
1176 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
1178 | 1177 | { |
1179 | 1178 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1180 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
1179 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
1181 | 1180 | { |
1182 | 1181 | debugLog(__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
1183 | 1182 | |
1184 | 1183 | // calling backend again with iCal attachment, to let calendar add the event |
1185 | 1184 | if (($ret = $this->backend->MeetingResponse($attachment['attachment'], |
1186 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
1185 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
1187 | 1186 | $response, $calendarid))) |
1188 | 1187 | { |
1189 | 1188 | $ret = $calendarid; |
@@ -1205,17 +1204,17 @@ discard block |
||
1205 | 1204 | * @param string $attname - should contain (folder)id |
1206 | 1205 | * @return true, prints the content of the attachment |
1207 | 1206 | */ |
1208 | - function GetAttachmentData($fid,$attname) { |
|
1207 | + function GetAttachmentData($fid, $attname) { |
|
1209 | 1208 | debugLog("getAttachmentData: $fid (attname: '$attname')"); |
1210 | 1209 | error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1211 | 1210 | list($folderid, $id, $part) = explode(":", $attname); |
1212 | 1211 | |
1213 | 1212 | $this->splitID($folderid, $account, $folder); |
1214 | 1213 | |
1215 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1214 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1216 | 1215 | |
1217 | 1216 | $this->mail->reopen($folder); |
1218 | - $attachment = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
1217 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
1219 | 1218 | print $attachment['attachment']; |
1220 | 1219 | unset($attachment); |
1221 | 1220 | return true; |
@@ -1231,17 +1230,17 @@ discard block |
||
1231 | 1230 | * @param string $attname - should contain (folder)id |
1232 | 1231 | * @return SyncAirSyncBaseFileAttachment-object |
1233 | 1232 | */ |
1234 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1233 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
1235 | 1234 | debugLog("ItemOperationsGetAttachmentData: (attname: '$attname')"); |
1236 | 1235 | |
1237 | 1236 | list($folderid, $id, $part) = explode(":", $attname); |
1238 | 1237 | |
1239 | 1238 | $this->splitID($folderid, $account, $folder); |
1240 | 1239 | |
1241 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
1240 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1242 | 1241 | |
1243 | 1242 | $this->mail->reopen($folder); |
1244 | - $att = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
1243 | + $att = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
1245 | 1244 | $attachment = new SyncAirSyncBaseFileAttachment(); |
1246 | 1245 | /* |
1247 | 1246 | debugLog(__METHOD__.__LINE__.array2string($att)); |
@@ -1303,17 +1302,17 @@ discard block |
||
1303 | 1302 | $this->splitID($folderid, $account, $srcFolder); |
1304 | 1303 | $this->splitID($newfolderid, $account, $destFolder); |
1305 | 1304 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
1306 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1305 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1307 | 1306 | $this->mail->reopen($destFolder); |
1308 | 1307 | $status = $this->mail->getFolderStatus($destFolder); |
1309 | 1308 | $uidNext = $status['uidnext']; |
1310 | 1309 | $this->mail->reopen($srcFolder); |
1311 | 1310 | |
1312 | 1311 | // move message |
1313 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
1312 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
1314 | 1313 | debugLog(__METHOD__.__LINE__.array2string($rv)); // this may be true, so try using the nextUID value by examine |
1315 | 1314 | // return the new id "as string"" |
1316 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
1315 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
1317 | 1316 | } |
1318 | 1317 | |
1319 | 1318 | /** |
@@ -1321,86 +1320,86 @@ discard block |
||
1321 | 1320 | * |
1322 | 1321 | * @ToDo loop over available email accounts |
1323 | 1322 | */ |
1324 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
1323 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
1325 | 1324 | { |
1326 | 1325 | static $cutdate; |
1327 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1328 | - debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1326 | + if (!empty($cutoffdate) && $cutoffdate > 0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1327 | + debugLog(__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1329 | 1328 | if (empty($cutdate)) |
1330 | 1329 | { |
1331 | - $cutdate = egw_time::to('now','ts')-(3600*24*28*3); |
|
1330 | + $cutdate = egw_time::to('now', 'ts') - (3600 * 24 * 28 * 3); |
|
1332 | 1331 | debugLog(__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate)); |
1333 | 1332 | } |
1334 | 1333 | return $this->fetchMessages($folderid, $cutdate); |
1335 | 1334 | } |
1336 | 1335 | |
1337 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
|
1336 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL) |
|
1338 | 1337 | { |
1339 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
1338 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
1340 | 1339 | //debugLog(__METHOD__.__LINE__); |
1341 | 1340 | $rv_messages = array(); |
1342 | 1341 | // if the message is still available within the class, we use it instead of fetching it again |
1343 | - if (is_array($_id) && count($_id)==1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1342 | + if (is_array($_id) && count($_id) == 1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1344 | 1343 | { |
1345 | 1344 | //debugLog(__METHOD__.__LINE__." the message ".$_id[0]." is still available within the class, we use it instead of fetching it again"); |
1346 | 1345 | $rv_messages = array('header'=>array($this->messages[$_id[0]])); |
1347 | 1346 | } |
1348 | 1347 | if (empty($rv_messages)) |
1349 | 1348 | { |
1350 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1349 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1351 | 1350 | $this->_connect($this->account); |
1352 | - if ($this->debugLevel>1) |
|
1351 | + if ($this->debugLevel > 1) |
|
1353 | 1352 | { |
1354 | 1353 | $endtime = microtime(true) - $starttime; |
1355 | - debugLog(__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
1354 | + debugLog(__METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
1356 | 1355 | } |
1357 | 1356 | $messagelist = array(); |
1358 | 1357 | // if not connected, any further action must fail |
1359 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
1360 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1361 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1362 | - if ($this->debugLevel>1) |
|
1358 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'type'=>"SINCE", 'string'=> date("d-M-Y", $cutoffdate)); |
|
1359 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1360 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
1361 | + if ($this->debugLevel > 1) |
|
1363 | 1362 | { |
1364 | 1363 | $endtime = microtime(true) - $starttime; |
1365 | - debugLog(__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1364 | + debugLog(__METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1366 | 1365 | } |
1367 | - if ($this->debugLevel>1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1368 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1369 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
1370 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
1371 | - if ($this->debugLevel>1) |
|
1366 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1367 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1368 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
1369 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
1370 | + if ($this->debugLevel > 1) |
|
1372 | 1371 | { |
1373 | 1372 | $endtime = microtime(true) - $starttime; |
1374 | - debugLog(__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1373 | + debugLog(__METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1375 | 1374 | } |
1376 | 1375 | } |
1377 | - if ($_id == NULL && $this->debugLevel>1) debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
1376 | + if ($_id == NULL && $this->debugLevel > 1) debugLog(__METHOD__." found :".count($rv_messages['header'])); |
|
1378 | 1377 | //debugLog(__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
1379 | 1378 | foreach ((array)$rv_messages['header'] as $k => $vars) |
1380 | 1379 | { |
1381 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1380 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1382 | 1381 | $this->messages[$vars['uid']] = $vars; |
1383 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1382 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1384 | 1383 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
1385 | 1384 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
1386 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1385 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1387 | 1386 | $mess["mod"] = $vars['date']; |
1388 | 1387 | $mess["id"] = $vars['uid']; |
1389 | 1388 | // 'seen' aka 'read' is the only flag we want to know about |
1390 | 1389 | $mess["flags"] = 0; |
1391 | 1390 | // outlook supports additional flags, set them to 0 |
1392 | 1391 | $mess["olflags"] = 0; |
1393 | - if($vars["seen"]) $mess["flags"] = 1; |
|
1394 | - if($vars["flagged"]) $mess["olflags"] = 2; |
|
1395 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1392 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
1393 | + if ($vars["flagged"]) $mess["olflags"] = 2; |
|
1394 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
1396 | 1395 | $messagelist[$vars['uid']] = $mess; |
1397 | 1396 | unset($mess); |
1398 | 1397 | } |
1399 | 1398 | |
1400 | - if ($this->debugLevel>1) |
|
1399 | + if ($this->debugLevel > 1) |
|
1401 | 1400 | { |
1402 | 1401 | $endtime = microtime(true) - $gstarttime; |
1403 | - debugLog(__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1402 | + debugLog(__METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1404 | 1403 | } |
1405 | 1404 | return $messagelist; |
1406 | 1405 | } |
@@ -1414,7 +1413,7 @@ discard block |
||
1414 | 1413 | public function getSearchResultsMailbox($searchquery) |
1415 | 1414 | { |
1416 | 1415 | if (!is_array($searchquery)) return array(); |
1417 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1416 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
1418 | 1417 | // 19.10.2011 16:28:59 [24502] mail_activesync::getSearchResultsMailbox1408 |
1419 | 1418 | //Array( |
1420 | 1419 | // [query] => Array( |
@@ -1438,22 +1437,22 @@ discard block |
||
1438 | 1437 | } else { |
1439 | 1438 | $rebuildresults = false; |
1440 | 1439 | } |
1441 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1440 | + if ($this->debugLevel > 0) debugLog('RebuildResults ['.$rebuildresults.']'); |
|
1442 | 1441 | |
1443 | 1442 | if (isset($searchquery['deeptraversal'])) { |
1444 | 1443 | $deeptraversal = $searchquery['deeptraversal']; |
1445 | 1444 | } else { |
1446 | 1445 | $deeptraversal = false; |
1447 | 1446 | } |
1448 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1447 | + if ($this->debugLevel > 0) debugLog('DeepTraversal ['.$deeptraversal.']'); |
|
1449 | 1448 | |
1450 | 1449 | if (isset($searchquery['range'])) { |
1451 | - $range = explode("-",$searchquery['range']); |
|
1450 | + $range = explode("-", $searchquery['range']); |
|
1452 | 1451 | $limit = $range[1] - $range[0] + 1; |
1453 | 1452 | } else { |
1454 | 1453 | $range = false; |
1455 | 1454 | } |
1456 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
1455 | + if ($this->debugLevel > 0) debugLog('Range ['.print_r($range, true).']'); |
|
1457 | 1456 | |
1458 | 1457 | //foreach($searchquery['query'] as $k => $value) { |
1459 | 1458 | // $query = $value; |
@@ -1465,38 +1464,38 @@ discard block |
||
1465 | 1464 | // other types may be possible - we support quicksearch first (freeText in subject and from (or TO in Sent Folder)) |
1466 | 1465 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
1467 | 1466 | { |
1468 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
|
1469 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]=true; |
|
1467 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10); |
|
1468 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] = true; |
|
1470 | 1469 | } |
1471 | 1470 | |
1472 | 1471 | if (isset($searchquery['query'][0]['value']['Search:FreeText'])) |
1473 | 1472 | { |
1474 | - $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'); |
|
1473 | + $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'); |
|
1475 | 1474 | $searchText = $searchquery['query'][0]['value']['Search:FreeText']; |
1476 | 1475 | } |
1477 | 1476 | if (!$folderid) |
1478 | 1477 | { |
1479 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
1480 | - $folderid = $this->createID($account=0,$_folderName); |
|
1478 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
1479 | + $folderid = $this->createID($account = 0, $_folderName); |
|
1481 | 1480 | } |
1482 | 1481 | //if ($searchquery['query'][0]['value'][subquery][0][op]=='Search:GreaterThan'); |
1483 | 1482 | //if (isset($searchquery['query'][0]['value'][subquery][0][value][POOMMAIL:DateReceived])); |
1484 | 1483 | //if ($searchquery['query'][0]['value'][subquery][1][op]=='Search:LessThan'); |
1485 | 1484 | //if (isset($searchquery['query'][0]['value'][subquery][1][value][POOMMAIL:DateReceived])); |
1486 | 1485 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1487 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1486 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
1488 | 1487 | $this->_connect($account); |
1489 | - $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'), |
|
1488 | + $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'), |
|
1490 | 1489 | 'string'=> $searchText, |
1491 | 1490 | 'status'=>'any', |
1492 | 1491 | ); |
1493 | 1492 | |
1494 | 1493 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1495 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1496 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
1494 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1495 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
1497 | 1496 | //debugLog(__METHOD__.__LINE__.array2string($rv_messages)); |
1498 | - $list=array(); |
|
1499 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
1497 | + $list = array(); |
|
1498 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
1500 | 1499 | { |
1501 | 1500 | $list[] = array( |
1502 | 1501 | "uniqueid" => $folderid.':'.$vars['uid'], |
@@ -1507,7 +1506,7 @@ discard block |
||
1507 | 1506 | } |
1508 | 1507 | //error_log(__METHOD__.__LINE__.array2string($list)); |
1509 | 1508 | //debugLog(__METHOD__.__LINE__.array2string($list)); |
1510 | - return $list;//array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
1509 | + return $list; //array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
1511 | 1510 | } |
1512 | 1511 | |
1513 | 1512 | /** |
@@ -1517,20 +1516,20 @@ discard block |
||
1517 | 1516 | * @param string $folder |
1518 | 1517 | * @return string |
1519 | 1518 | */ |
1520 | - private function getParentID($account,$folder) |
|
1519 | + private function getParentID($account, $folder) |
|
1521 | 1520 | { |
1522 | 1521 | $this->_connect($account); |
1523 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1522 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1524 | 1523 | |
1525 | 1524 | $mailFolder = $this->folders[$folder]; |
1526 | 1525 | if (!isset($mailFolder)) return false; |
1527 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
1528 | - $parent = explode($delimiter,$folder); |
|
1526 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
1527 | + $parent = explode($delimiter, $folder); |
|
1529 | 1528 | array_pop($parent); |
1530 | - $parent = implode($delimiter,$parent); |
|
1529 | + $parent = implode($delimiter, $parent); |
|
1531 | 1530 | |
1532 | 1531 | $id = $parent ? $this->createID($account, $parent) : '0'; |
1533 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1532 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1534 | 1533 | return $id; |
1535 | 1534 | } |
1536 | 1535 | |
@@ -1549,48 +1548,48 @@ discard block |
||
1549 | 1548 | try { |
1550 | 1549 | $this->splitID($id, $account, $folder); |
1551 | 1550 | } |
1552 | - catch(Exception $e) { |
|
1551 | + catch (Exception $e) { |
|
1553 | 1552 | debugLog(__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
1554 | - return $folderObj=false; |
|
1553 | + return $folderObj = false; |
|
1555 | 1554 | } |
1556 | 1555 | $this->_connect($account); |
1557 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1556 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1558 | 1557 | |
1559 | 1558 | $mailFolder = $this->folders[$folder]; |
1560 | - if (!isset($mailFolder)) return $folderObj=false; |
|
1559 | + if (!isset($mailFolder)) return $folderObj = false; |
|
1561 | 1560 | |
1562 | 1561 | $folderObj = new SyncFolder(); |
1563 | 1562 | $folderObj->serverid = $id; |
1564 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
1563 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
1565 | 1564 | $folderObj->displayname = $mailFolder->shortDisplayName; |
1566 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1565 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1567 | 1566 | // get folder-type |
1568 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
1567 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
1569 | 1568 | if ($folder == $inbox) |
1570 | 1569 | { |
1571 | 1570 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
1572 | 1571 | } |
1573 | - elseif($this->mail->isDraftFolder($folder, false)) |
|
1572 | + elseif ($this->mail->isDraftFolder($folder, false)) |
|
1574 | 1573 | { |
1575 | 1574 | //debugLog(__METHOD__.' isDraft'); |
1576 | 1575 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
1577 | 1576 | $folderObj->parentid = 0; // required by devices |
1578 | 1577 | } |
1579 | - elseif($this->mail->isTrashFolder($folder, false)) |
|
1578 | + elseif ($this->mail->isTrashFolder($folder, false)) |
|
1580 | 1579 | { |
1581 | 1580 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
1582 | 1581 | $this->_wasteID = $folder; |
1583 | 1582 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
1584 | 1583 | $folderObj->parentid = 0; // required by devices |
1585 | 1584 | } |
1586 | - elseif($this->mail->isSentFolder($folder, false)) |
|
1585 | + elseif ($this->mail->isSentFolder($folder, false)) |
|
1587 | 1586 | { |
1588 | 1587 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
1589 | 1588 | $folderObj->parentid = 0; // required by devices |
1590 | 1589 | $this->_sentID = $folder; |
1591 | 1590 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
1592 | 1591 | } |
1593 | - elseif($this->mail->isOutbox($folder, false)) |
|
1592 | + elseif ($this->mail->isOutbox($folder, false)) |
|
1594 | 1593 | { |
1595 | 1594 | //debugLog(__METHOD__.' isOutbox'); |
1596 | 1595 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1602,7 +1601,7 @@ discard block |
||
1602 | 1601 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
1603 | 1602 | } |
1604 | 1603 | |
1605 | - if ($this->debugLevel>1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1604 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1606 | 1605 | return $folderObj; |
1607 | 1606 | } |
1608 | 1607 | |
@@ -1649,18 +1648,18 @@ discard block |
||
1649 | 1648 | if (is_numeric($account)) $type = 'mail'; |
1650 | 1649 | if ($type != 'mail') return false; |
1651 | 1650 | |
1652 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
1651 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
1653 | 1652 | |
1654 | 1653 | $changes = array(); |
1655 | - debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
|
1654 | + debugLog("AlterPingChanges on $folderid ($folder) stat: ".$syncstate); |
|
1656 | 1655 | $this->mail->reopen($folder); |
1657 | 1656 | |
1658 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1657 | + $status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true); |
|
1659 | 1658 | if (!$status) { |
1660 | 1659 | debugLog("AlterPingChanges: could not stat folder $folder "); |
1661 | 1660 | return false; |
1662 | 1661 | } else { |
1663 | - $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1662 | + $newstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1664 | 1663 | |
1665 | 1664 | // message number is different - change occured |
1666 | 1665 | if ($syncstate != $newstate) { |
@@ -1719,7 +1718,7 @@ discard block |
||
1719 | 1718 | $error = $e->getMessage(); |
1720 | 1719 | debugLog(__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
1721 | 1720 | // if the server thinks the message does not exist report deletion as success |
1722 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
1721 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
1723 | 1722 | return false; |
1724 | 1723 | } |
1725 | 1724 | |
@@ -1749,8 +1748,8 @@ discard block |
||
1749 | 1748 | |
1750 | 1749 | $_messageUID = (array)$id; |
1751 | 1750 | $this->_connect($this->account); |
1752 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
1753 | - debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
1751 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
1752 | + debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
1754 | 1753 | |
1755 | 1754 | return $rv; |
1756 | 1755 | } |
@@ -1801,8 +1800,8 @@ discard block |
||
1801 | 1800 | $_messageUID = (array)$id; |
1802 | 1801 | $this->_connect($this->account); |
1803 | 1802 | $this->splitID($folderid, $account, $folder); |
1804 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
1805 | - debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
1803 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
1804 | + debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1806 | 1805 | |
1807 | 1806 | return $rv; |
1808 | 1807 | } |
@@ -1816,17 +1815,17 @@ discard block |
||
1816 | 1815 | * @return string |
1817 | 1816 | * @throws egw_exception_wrong_parameter |
1818 | 1817 | */ |
1819 | - private function createID($account,$folder,$id=0) |
|
1818 | + private function createID($account, $folder, $id = 0) |
|
1820 | 1819 | { |
1821 | 1820 | if (!is_numeric($folder)) |
1822 | 1821 | { |
1823 | 1822 | // convert string $folder in numeric id |
1824 | - $folder = $this->folder2hash($account,$f=$folder); |
|
1823 | + $folder = $this->folder2hash($account, $f = $folder); |
|
1825 | 1824 | } |
1826 | 1825 | |
1827 | 1826 | $str = $this->backend->createID($account, $folder, $id); |
1828 | 1827 | |
1829 | - if ($this->debugLevel>1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1828 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1830 | 1829 | |
1831 | 1830 | return $str; |
1832 | 1831 | } |
@@ -1840,14 +1839,14 @@ discard block |
||
1840 | 1839 | * @param int &$id=null |
1841 | 1840 | * @throws egw_exception_wrong_parameter |
1842 | 1841 | */ |
1843 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
1842 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
1844 | 1843 | { |
1845 | 1844 | $this->backend->splitID($str, $account, $folder, $id); |
1846 | 1845 | |
1847 | 1846 | // convert numeric folder-id back to folder name |
1848 | - $folder = $this->hash2folder($account,$f=$folder); |
|
1847 | + $folder = $this->hash2folder($account, $f = $folder); |
|
1849 | 1848 | |
1850 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
1849 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
1851 | 1850 | } |
1852 | 1851 | |
1853 | 1852 | /** |
@@ -1864,9 +1863,9 @@ discard block |
||
1864 | 1863 | * @param string $folder |
1865 | 1864 | * @return int |
1866 | 1865 | */ |
1867 | - private function folder2hash($account,$folder) |
|
1866 | + private function folder2hash($account, $folder) |
|
1868 | 1867 | { |
1869 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1868 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1870 | 1869 | |
1871 | 1870 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
1872 | 1871 | { |
@@ -1887,9 +1886,9 @@ discard block |
||
1887 | 1886 | * @param int $index |
1888 | 1887 | * @return string NULL if not used so far |
1889 | 1888 | */ |
1890 | - private function hash2folder($account,$index) |
|
1889 | + private function hash2folder($account, $index) |
|
1891 | 1890 | { |
1892 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1891 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1893 | 1892 | |
1894 | 1893 | return $this->folderHashes[$account][$index]; |
1895 | 1894 | } |
@@ -1904,9 +1903,9 @@ discard block |
||
1904 | 1903 | if (file_exists($file = $this->hashFile()) && |
1905 | 1904 | ($hashes = file_get_contents($file))) |
1906 | 1905 | { |
1907 | - $this->folderHashes = json_decode($hashes,true); |
|
1906 | + $this->folderHashes = json_decode($hashes, true); |
|
1908 | 1907 | // fallback in case hashes have been serialized instead of being json-encoded |
1909 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
1908 | + if (json_last_error() != JSON_ERROR_NONE) |
|
1910 | 1909 | { |
1911 | 1910 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
1912 | 1911 | $this->folderHashes = unserialize($hashes); |
@@ -1926,7 +1925,7 @@ discard block |
||
1926 | 1925 | private function storeFolderHashes() |
1927 | 1926 | { |
1928 | 1927 | // make sure $this->folderHashes is an array otherwise json_encode may fail on decode for string,integer,float or boolean |
1929 | - return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes)?$this->folderHashes:array($this->folderHashes)))); |
|
1928 | + return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes) ? $this->folderHashes : array($this->folderHashes)))); |
|
1930 | 1929 | } |
1931 | 1930 | |
1932 | 1931 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Mail tree constructor |
52 | 52 | * |
53 | - * @param object $mail_ui |
|
53 | + * @param mail_ui $mail_ui |
|
54 | 54 | */ |
55 | 55 | function __construct($mail_ui) { |
56 | 56 | $this->ui = $mail_ui; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param string $_profileID icServer profile id |
63 | 63 | * @param string $_err error message to be shown on tree node |
64 | 64 | * @param mixed $_path |
65 | - * @param mixed $_parent |
|
65 | + * @param string $_parent |
|
66 | 66 | * @return array returns an array of tree node |
67 | 67 | */ |
68 | 68 | static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Get folder data from path |
96 | 96 | * |
97 | - * @param string $path a node path |
|
97 | + * @param string $_path a node path |
|
98 | 98 | * @return array returns an array of data extracted from given node path |
99 | 99 | */ |
100 | 100 | static function pathToFolderData ($_path, $_hDelimiter) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * Check if the given tree id is account node (means root) |
133 | 133 | * |
134 | - * @param type $_node a tree id node |
|
134 | + * @param string|null $_node a tree id node |
|
135 | 135 | * @return boolean returns true if the node is account node otherwise false |
136 | 136 | */ |
137 | 137 | private static function isAccountNode ($_node) |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param string $_parent = null no parent node means root with the first level of folders |
165 | 165 | * @param string $_profileID = '' icServer id |
166 | - * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true, |
|
166 | + * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true, |
|
167 | 167 | * false|0 leaves them in closed state |
168 | 168 | * @param $_noCheckboxNS = false no checkbox for namesapaces makes sure to not put checkbox for namespaces node |
169 | 169 | * @param boolean $_subscribedOnly = false get only subscribed folders |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @param type $_profileID = null Null means all accounts and giving profileid means fetches node for the account |
446 | 446 | * @param type $_noCheckbox = false option to switch checkbox of |
447 | - * @param type $_openTopLevel = 0 option to either start the node opened (1) or closed (0) |
|
447 | + * @param integer $_openTopLevel = 0 option to either start the node opened (1) or closed (0) |
|
448 | 448 | * |
449 | 449 | * @return array an array of baseNodes of accounts |
450 | 450 | */ |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @param string $_parent = null no parent node means root with the first level of folders |
493 | 493 | * @param string $_profileID = '' active profile / acc_id |
494 | - * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true, |
|
494 | + * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true, |
|
495 | 495 | * false|0 leaves them in closed state |
496 | 496 | * @param boolean $_subscribedOnly = false get only subscribed folders |
497 | 497 | * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go |
@@ -52,7 +52,8 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param object $mail_ui |
54 | 54 | */ |
55 | - function __construct($mail_ui) { |
|
55 | + function __construct($mail_ui) |
|
56 | + { |
|
56 | 57 | $this->ui = $mail_ui; |
57 | 58 | } |
58 | 59 | |
@@ -99,7 +100,10 @@ discard block |
||
99 | 100 | */ |
100 | 101 | static function pathToFolderData ($_path, $_hDelimiter) |
101 | 102 | { |
102 | - if (!strpos($_path, self::$delimiter)) $_path = self::$delimiter.$_path; |
|
103 | + if (!strpos($_path, self::$delimiter)) |
|
104 | + { |
|
105 | + $_path = self::$delimiter.$_path; |
|
106 | + } |
|
103 | 107 | list(,$path) = explode(self::$delimiter, $_path); |
104 | 108 | $path_chain = $parts = explode($_hDelimiter, $path); |
105 | 109 | $name = array_pop($parts); |
@@ -124,7 +128,10 @@ discard block |
||
124 | 128 | $hasChildren = 0; |
125 | 129 | if (in_array('\haschildren', $_node['ATTRIBUTES']) || |
126 | 130 | in_array('\Haschildren', $_node['ATTRIBUTES']) || |
127 | - in_array('\HasChildren', $_node['ATTRIBUTES'])) $hasChildren = 1; |
|
131 | + in_array('\HasChildren', $_node['ATTRIBUTES'])) |
|
132 | + { |
|
133 | + $hasChildren = 1; |
|
134 | + } |
|
128 | 135 | return $hasChildren; |
129 | 136 | } |
130 | 137 | |
@@ -137,7 +144,10 @@ discard block |
||
137 | 144 | private static function isAccountNode ($_node) |
138 | 145 | { |
139 | 146 | list(,$leaf) = explode(self::$delimiter, $_node); |
140 | - if ($leaf || $_node == null) return false; |
|
147 | + if ($leaf || $_node == null) |
|
148 | + { |
|
149 | + return false; |
|
150 | + } |
|
141 | 151 | return true; |
142 | 152 | } |
143 | 153 | |
@@ -178,14 +188,18 @@ discard block |
||
178 | 188 | $tree = array(tree::ID=> $_parent?$_parent:0,tree::CHILDREN => array()); |
179 | 189 | $hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter(); |
180 | 190 | |
181 | - if ($_parent) list($_profileID) = explode(self::$delimiter, $_parent); |
|
191 | + if ($_parent) |
|
192 | + { |
|
193 | + list($_profileID) = explode(self::$delimiter, $_parent); |
|
194 | + } |
|
182 | 195 | |
183 | 196 | if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID) |
184 | 197 | { |
185 | 198 | try |
186 | 199 | { |
187 | 200 | $this->ui->changeProfile($_profileID); |
188 | - } catch (Exception $ex) { |
|
201 | + } |
|
202 | + catch (Exception $ex) { |
|
189 | 203 | return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), ''); |
190 | 204 | } |
191 | 205 | } |
@@ -201,9 +215,12 @@ discard block |
||
201 | 215 | 'Junk' => $this->ui->mail_bo->getJunkFolder(false), |
202 | 216 | 'Outbox' => $this->ui->mail_bo->getOutboxFolder(false), |
203 | 217 | ); |
204 | - if ($_parent && !self::isAccountNode($_parent)) // Single node loader |
|
218 | + if ($_parent && !self::isAccountNode($_parent)) |
|
219 | + { |
|
220 | + // Single node loader |
|
205 | 221 | { |
206 | 222 | $nodeInfo = self::pathToFolderData($_parent, $hDelimiter); |
223 | + } |
|
207 | 224 | $folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly); |
208 | 225 | |
209 | 226 | $childrenNode = array(); |
@@ -228,15 +245,21 @@ discard block |
||
228 | 245 | } |
229 | 246 | else //Top Level Nodes loader |
230 | 247 | { |
231 | - if (self::isAccountNode($_parent)) // An account called for open |
|
248 | + if (self::isAccountNode($_parent)) |
|
249 | + { |
|
250 | + // An account called for open |
|
232 | 251 | { |
233 | 252 | $_openTopLevel = 1; |
253 | + } |
|
234 | 254 | $tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel); |
235 | 255 | } |
236 | 256 | else // Initial accounts|root nodes |
237 | 257 | { |
238 | 258 | $tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel); |
239 | - if (!$_profileID && !$_openTopLevel) return $tree; |
|
259 | + if (!$_profileID && !$_openTopLevel) |
|
260 | + { |
|
261 | + return $tree; |
|
262 | + } |
|
240 | 263 | } |
241 | 264 | |
242 | 265 | //List of folders |
@@ -326,19 +349,28 @@ discard block |
||
326 | 349 | { |
327 | 350 | $helper = array_slice($parents,1,null,true); |
328 | 351 | $parent = $parents[0].self::$delimiter.implode($del, $helper); |
329 | - if ($parent) $parent .= $del; |
|
352 | + if ($parent) |
|
353 | + { |
|
354 | + $parent .= $del; |
|
355 | + } |
|
330 | 356 | } |
331 | 357 | else |
332 | 358 | { |
333 | 359 | $parent = implode(self::$delimiter, $parents); |
334 | - if ($parent) $parent .= self::$delimiter; |
|
360 | + if ($parent) |
|
361 | + { |
|
362 | + $parent .= self::$delimiter; |
|
363 | + } |
|
335 | 364 | } |
336 | 365 | |
337 | 366 | if (!is_array($insert) || !isset($insert['item'])) |
338 | 367 | { |
339 | 368 | // throwing an exeption here seems to be unrecoverable, |
340 | 369 | // even if the cause is a something that can be handeled by the mailserver |
341 | - if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!"); |
|
370 | + if (mail_bo::$debug) |
|
371 | + { |
|
372 | + error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!"); |
|
373 | + } |
|
342 | 374 | // should we hit the break? if in personal: sure, something is wrong with the folderstructure |
343 | 375 | // if in shared or others we may proceed as access to folders may very well be limited to |
344 | 376 | // a single folder within the tree |
@@ -349,11 +381,17 @@ discard block |
||
349 | 381 | // we want to create the node in question as we meet the above considerations |
350 | 382 | if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::$delimiter.$nsp['prefix'])===0) |
351 | 383 | { |
352 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::$delimiter.$nsp['prefix']); |
|
384 | + if (mail_bo::$debug) |
|
385 | + { |
|
386 | + error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::$delimiter.$nsp['prefix']); |
|
387 | + } |
|
353 | 388 | $break=false; |
354 | 389 | } |
355 | 390 | } |
356 | - if ($break) break; |
|
391 | + if ($break) |
|
392 | + { |
|
393 | + break; |
|
394 | + } |
|
357 | 395 | } |
358 | 396 | if ($insert['item']) |
359 | 397 | { |
@@ -454,7 +492,10 @@ discard block |
||
454 | 492 | |
455 | 493 | foreach(emailadmin_account::search(true, false) as $acc_id => $accObj) |
456 | 494 | { |
457 | - if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue; |
|
495 | + if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) |
|
496 | + { |
|
497 | + continue; |
|
498 | + } |
|
458 | 499 | $identity = emailadmin_account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
459 | 500 | // Open top level folders for active account |
460 | 501 | $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent) |
69 | 69 | { |
70 | 70 | $baseNode = array('id' => $_profileID); |
71 | - $leaf = array( |
|
71 | + $leaf = array( |
|
72 | 72 | 'id' => $_profileID.self::$delimiter.'INBOX', |
73 | 73 | 'text' => $_err, |
74 | 74 | 'tooltip' => $_err, |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | ); |
81 | 81 | self::setOutStructure($leaf, $baseNode, self::$delimiter); |
82 | 82 | |
83 | - return ($baseNode?$baseNode:array( // fallback not connected array |
|
83 | + return ($baseNode ? $baseNode : array( // fallback not connected array |
|
84 | 84 | 'id'=>0, |
85 | 85 | 'item'=> array( |
86 | 86 | 'text'=>'INBOX', |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param string $path a node path |
98 | 98 | * @return array returns an array of data extracted from given node path |
99 | 99 | */ |
100 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
100 | + static function pathToFolderData($_path, $_hDelimiter) |
|
101 | 101 | { |
102 | 102 | if (!strpos($_path, self::$delimiter)) $_path = self::$delimiter.$_path; |
103 | 103 | list(,$path) = explode(self::$delimiter, $_path); |
104 | 104 | $path_chain = $parts = explode($_hDelimiter, $path); |
105 | 105 | $name = array_pop($parts); |
106 | - return array ( |
|
106 | + return array( |
|
107 | 107 | 'name' => $name, |
108 | 108 | 'mailbox' => $path, |
109 | 109 | 'parent' => implode($_hDelimiter, $parts), |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param array $_node array of a node |
120 | 120 | * @return int returns 1 if it has children flag set otherwise 0 |
121 | 121 | */ |
122 | - private static function nodeHasChildren ($_node) |
|
122 | + private static function nodeHasChildren($_node) |
|
123 | 123 | { |
124 | 124 | $hasChildren = 0; |
125 | 125 | if (in_array('\haschildren', $_node['ATTRIBUTES']) || |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param type $_node a tree id node |
135 | 135 | * @return boolean returns true if the node is account node otherwise false |
136 | 136 | */ |
137 | - private static function isAccountNode ($_node) |
|
137 | + private static function isAccountNode($_node) |
|
138 | 138 | { |
139 | 139 | list(,$leaf) = explode(self::$delimiter, $_node); |
140 | 140 | if ($leaf || $_node == null) return false; |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return array returns an array of mail tree structure according to provided node |
174 | 174 | */ |
175 | - function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true) |
|
175 | + function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true) |
|
176 | 176 | { |
177 | 177 | //Init mail folders |
178 | - $tree = array(tree::ID=> $_parent?$_parent:0,tree::CHILDREN => array()); |
|
178 | + $tree = array(tree::ID=> $_parent ? $_parent : 0, tree::CHILDREN => array()); |
|
179 | 179 | $hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter(); |
180 | 180 | |
181 | 181 | if ($_parent) list($_profileID) = explode(self::$delimiter, $_parent); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $this->ui->changeProfile($_profileID); |
188 | 188 | } catch (Exception $ex) { |
189 | - return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), ''); |
|
189 | + return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), ''); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | if ($_parent && !self::isAccountNode($_parent)) // Single node loader |
199 | 199 | { |
200 | 200 | $nodeInfo = self::pathToFolderData($_parent, $hDelimiter); |
201 | - $folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly); |
|
201 | + $folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly); |
|
202 | 202 | |
203 | 203 | $childrenNode = array(); |
204 | 204 | foreach ($folders as &$node) |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | $nodeData = self::pathToFolderData($nodeId, $node['delimiter']); |
208 | 208 | $childrenNode[] = array( |
209 | 209 | tree::ID=> $nodeId, |
210 | - tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node), |
|
210 | + tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($node), |
|
211 | 211 | tree::CHILDREN =>array(), |
212 | 212 | tree::LABEL => $nodeData['text'], |
213 | 213 | tree::TOOLTIP => $nodeData['tooltip'], |
214 | 214 | tree::IMAGE_LEAF => self::$leafImages['folderLeaf'], |
215 | 215 | tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'], |
216 | 216 | tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClose'], |
217 | - tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false, |
|
217 | + tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false, |
|
218 | 218 | 'parent' => $_parent |
219 | 219 | ); |
220 | 220 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | //List of folders |
237 | - $foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, true); |
|
237 | + $foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, true); |
|
238 | 238 | |
239 | 239 | // User defined folders based on account |
240 | 240 | $definedFolders = array( |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | |
255 | 255 | $data = array( |
256 | 256 | tree::ID=>$_profileID.self::$delimiter.$folder['MAILBOX'], |
257 | - tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder), |
|
257 | + tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($folder), |
|
258 | 258 | tree::CHILDREN =>array(), |
259 | 259 | tree::LABEL =>lang($folder['MAILBOX']), |
260 | - tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0, |
|
260 | + tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0, |
|
261 | 261 | tree::TOOLTIP => lang($folder['MAILBOX']), |
262 | - tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false, |
|
262 | + tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false, |
|
263 | 263 | tree::NOCHECKBOX => 0, |
264 | - 'parent' => $parent?$_profileID.self::$delimiter.implode($folder['delimiter'], $parent):$_profileID, |
|
264 | + 'parent' => $parent ? $_profileID.self::$delimiter.implode($folder['delimiter'], $parent) : $_profileID, |
|
265 | 265 | 'path' => $path, |
266 | 266 | 'folderarray' => $folder |
267 | 267 | ); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | catch (Exception $ex) // Catch exceptions |
300 | 300 | { |
301 | 301 | //mail_ui::callWizard($ex->getMessage(), false, 'error'); |
302 | - return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), ''); |
|
302 | + return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), ''); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | return $tree; |
@@ -316,19 +316,19 @@ discard block |
||
316 | 316 | * as clearance for access may be limited to a single branch-node of a tree |
317 | 317 | * @return void |
318 | 318 | */ |
319 | - static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array()) |
|
319 | + static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array()) |
|
320 | 320 | { |
321 | 321 | //error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')"); |
322 | 322 | $components = $data['path']; |
323 | - array_pop($components); // remove own name |
|
323 | + array_pop($components); // remove own name |
|
324 | 324 | |
325 | 325 | $insert = &$out; |
326 | 326 | $parents = array(); |
327 | - foreach($components as $component) |
|
327 | + foreach ($components as $component) |
|
328 | 328 | { |
329 | - if (count($parents)>1) |
|
329 | + if (count($parents) > 1) |
|
330 | 330 | { |
331 | - $helper = array_slice($parents,1,null,true); |
|
331 | + $helper = array_slice($parents, 1, null, true); |
|
332 | 332 | $parent = $parents[0].self::$delimiter.implode($del, $helper); |
333 | 333 | if ($parent) $parent .= $del; |
334 | 334 | } |
@@ -351,21 +351,21 @@ discard block |
||
351 | 351 | { |
352 | 352 | // if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent |
353 | 353 | // we want to create the node in question as we meet the above considerations |
354 | - if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::$delimiter.$nsp['prefix'])===0) |
|
354 | + if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::$delimiter.$nsp['prefix']) === 0) |
|
355 | 355 | { |
356 | 356 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::$delimiter.$nsp['prefix']); |
357 | - $break=false; |
|
357 | + $break = false; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | if ($break) break; |
361 | 361 | } |
362 | 362 | if ($insert['item']) |
363 | 363 | { |
364 | - foreach($insert['item'] as &$item) |
|
364 | + foreach ($insert['item'] as &$item) |
|
365 | 365 | { |
366 | 366 | if ($item['id'] == $parent.$component) |
367 | 367 | { |
368 | - $insert =& $item; |
|
368 | + $insert = & $item; |
|
369 | 369 | break; |
370 | 370 | } |
371 | 371 | } |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | if ($createMissingParents) |
376 | 376 | { |
377 | 377 | unset($item); |
378 | - $item = array('id' => $parent.$component, 'text' => $component, 'im0' => "folderNoSelectClosed.gif",'im1' => "folderNoSelectOpen.gif",'im2' => "folderNoSelectClosed.gif",'tooltip' => lang('no access')); |
|
379 | - $insert['item'][] =& $item; |
|
380 | - $insert =& $item; |
|
378 | + $item = array('id' => $parent.$component, 'text' => $component, 'im0' => "folderNoSelectClosed.gif", 'im1' => "folderNoSelectOpen.gif", 'im2' => "folderNoSelectClosed.gif", 'tooltip' => lang('no access')); |
|
379 | + $insert['item'][] = & $item; |
|
380 | + $insert = & $item; |
|
381 | 381 | } |
382 | 382 | else |
383 | 383 | { |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $data[tree::IMAGE_FOLDER_OPEN] = |
411 | 411 | $data [tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png"; |
412 | 412 | } |
413 | - elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false) |
|
413 | + elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false) |
|
414 | 414 | { |
415 | 415 | $data[tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed']; |
416 | 416 | $data[tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen']; |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return array an array of baseNodes of accounts |
454 | 454 | */ |
455 | - static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 ) |
|
455 | + static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0) |
|
456 | 456 | { |
457 | 457 | $roots = array(tree::ID => 0, tree::CHILDREN => array()); |
458 | 458 | |
459 | - foreach(emailadmin_account::search(true, false) as $acc_id => $accObj) |
|
459 | + foreach (emailadmin_account::search(true, false) as $acc_id => $accObj) |
|
460 | 460 | { |
461 | - if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue; |
|
462 | - $identity = emailadmin_account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
461 | + if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue; |
|
462 | + $identity = emailadmin_account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
463 | 463 | // Open top level folders for active account |
464 | - $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0; |
|
464 | + $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0; |
|
465 | 465 | |
466 | 466 | $baseNode = array( |
467 | 467 | tree::ID=> (string)$acc_id, |
468 | - tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity), |
|
468 | + tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity), |
|
469 | 469 | tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity), |
470 | 470 | tree::IMAGE_LEAF => self::$leafImages['folderAccount'], |
471 | 471 | tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'], |
@@ -474,15 +474,15 @@ discard block |
||
474 | 474 | tree::CHILDREN => array(), // dynamic loading on unfold |
475 | 475 | tree::AUTOLOAD_CHILDREN => true, |
476 | 476 | 'parent' => '', |
477 | - tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount, |
|
477 | + tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount, |
|
478 | 478 | // mark on account if Sieve is enabled |
479 | 479 | 'data' => array( |
480 | 480 | 'sieve' => $accObj->imapServer()->acc_sieve_enabled, |
481 | - 'spamfolder'=> $accObj->imapServer()->acc_folder_junk?true:false |
|
481 | + 'spamfolder'=> $accObj->imapServer()->acc_folder_junk ? true : false |
|
482 | 482 | ), |
483 | 483 | tree::NOCHECKBOX => $_noCheckbox |
484 | 484 | ); |
485 | - self::setOutStructure($baseNode, $roots,self::$delimiter); |
|
485 | + self::setOutStructure($baseNode, $roots, self::$delimiter); |
|
486 | 486 | } |
487 | 487 | return $roots; |
488 | 488 | } |
@@ -501,15 +501,15 @@ discard block |
||
501 | 501 | * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go |
502 | 502 | * @return type an array of tree |
503 | 503 | */ |
504 | - function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false) |
|
504 | + function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false) |
|
505 | 505 | { |
506 | 506 | $tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo); |
507 | - $branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo); |
|
507 | + $branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo); |
|
508 | 508 | foreach ($tree[tree::CHILDREN] as &$account) |
509 | 509 | { |
510 | 510 | if ($account[tree::ID] == $_profileID) |
511 | 511 | { |
512 | - $account = array_merge($account , $branches); |
|
512 | + $account = array_merge($account, $branches); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | return $tree; |
@@ -102,7 +102,7 @@ |
||
102 | 102 | * this function calls all other recurring AJAX notifications methods |
103 | 103 | * to have ONE single recurring AJAX call per user |
104 | 104 | * |
105 | - * @return xajax response |
|
105 | + * @return string response |
|
106 | 106 | */ |
107 | 107 | public function get_notifications($browserNotify = false) |
108 | 108 | { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function __construct() |
76 | 76 | { |
77 | - if( class_exists('xajaxResponse') ) |
|
77 | + if (class_exists('xajaxResponse')) |
|
78 | 78 | { |
79 | 79 | $this->response = new xajaxResponse(); |
80 | 80 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | { |
138 | 138 | if ($notify_id) |
139 | 139 | { |
140 | - $this->db->delete(self::_notification_table,array( |
|
140 | + $this->db->delete(self::_notification_table, array( |
|
141 | 141 | 'notify_id' => $notify_id, |
142 | 142 | 'account_id' => $this->recipient->account_id, |
143 | 143 | 'notify_type' => self::_type |
144 | - ),__LINE__,__FILE__,self::_appname); |
|
144 | + ), __LINE__, __FILE__, self::_appname); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | 'account_id' => $this->recipient->account_id, |
159 | 159 | 'notify_type' => self::_type |
160 | 160 | ), |
161 | - __LINE__,__FILE__,false,'',self::_appname); |
|
161 | + __LINE__, __FILE__, false, '', self::_appname); |
|
162 | 162 | |
163 | - if( $rs->NumRows() > 0 ) |
|
163 | + if ($rs->NumRows() > 0) |
|
164 | 164 | { |
165 | 165 | foreach ($rs as $notification) |
166 | 166 | { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->response->data($jmessage); |
173 | 173 | } |
174 | 174 | |
175 | - switch( $this->preferences[self::_appname]['egwpopup_verbosity'] ) |
|
175 | + switch ($this->preferences[self::_appname]['egwpopup_verbosity']) |
|
176 | 176 | { |
177 | 177 | case 'low': |
178 | 178 |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * jdesk Json methods for notifications |
14 | 14 | */ |
15 | -class notifications_jdesk_ajax { |
|
15 | +class notifications_jdesk_ajax |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | public $public_functions = array( |
18 | 19 | 'get_notification' => true |
@@ -94,7 +95,9 @@ discard block |
||
94 | 95 | * destructor |
95 | 96 | * |
96 | 97 | */ |
97 | - public function __destruct() {} |
|
98 | + public function __destruct() |
|
99 | + { |
|
100 | +} |
|
98 | 101 | |
99 | 102 | /** |
100 | 103 | * public AJAX trigger function to be called by the JavaScript client |
@@ -150,7 +153,8 @@ discard block |
||
150 | 153 | * |
151 | 154 | * @return boolean true or false |
152 | 155 | */ |
153 | - private function get_egwpopup($browserNotify = false) { |
|
156 | + private function get_egwpopup($browserNotify = false) |
|
157 | + { |
|
154 | 158 | |
155 | 159 | $message = ''; |
156 | 160 |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * renders additional infos from sender and subject |
134 | 134 | * |
135 | 135 | * @param string $_subject |
136 | - * @return html rendered info as complete string |
|
136 | + * @return string rendered info as complete string |
|
137 | 137 | */ |
138 | 138 | private function render_infos($_subject = false) { |
139 | 139 | $infos = array(); |
@@ -149,7 +149,6 @@ discard block |
||
149 | 149 | * saves notification into database so that the client can fetch it from there |
150 | 150 | * |
151 | 151 | * @param string $_message |
152 | - * @param array $_user_sessions |
|
153 | 152 | */ |
154 | 153 | private function save( $_message ) { |
155 | 154 | $result = $this->db->insert( self::_notification_table, array( |
@@ -14,63 +14,63 @@ discard block |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | /** |
17 | - * Appname |
|
18 | - */ |
|
17 | + * Appname |
|
18 | + */ |
|
19 | 19 | const _appname = 'notifications'; |
20 | 20 | |
21 | 21 | /** |
22 | - * Notification table in SQL database |
|
23 | - */ |
|
22 | + * Notification table in SQL database |
|
23 | + */ |
|
24 | 24 | const _notification_table = 'egw_notificationpopup'; |
25 | 25 | |
26 | 26 | /** |
27 | - * Notification type |
|
28 | - */ |
|
27 | + * Notification type |
|
28 | + */ |
|
29 | 29 | const _type = 'jpopup'; |
30 | 30 | |
31 | 31 | /** |
32 | - * holds account object for user who sends the message |
|
33 | - * |
|
34 | - * @var object |
|
35 | - */ |
|
32 | + * holds account object for user who sends the message |
|
33 | + * |
|
34 | + * @var object |
|
35 | + */ |
|
36 | 36 | private $sender; |
37 | 37 | |
38 | 38 | /** |
39 | - * holds account object for user to notify |
|
40 | - * |
|
41 | - * @var object |
|
42 | - */ |
|
39 | + * holds account object for user to notify |
|
40 | + * |
|
41 | + * @var object |
|
42 | + */ |
|
43 | 43 | private $recipient; |
44 | 44 | |
45 | 45 | /** |
46 | - * holds config object (sitewide application config) |
|
47 | - * |
|
48 | - * @var object |
|
49 | - */ |
|
46 | + * holds config object (sitewide application config) |
|
47 | + * |
|
48 | + * @var object |
|
49 | + */ |
|
50 | 50 | private $config; |
51 | 51 | |
52 | 52 | /** |
53 | - * holds preferences object of user to notify |
|
54 | - * |
|
55 | - * @var object |
|
56 | - */ |
|
53 | + * holds preferences object of user to notify |
|
54 | + * |
|
55 | + * @var object |
|
56 | + */ |
|
57 | 57 | private $preferences; |
58 | 58 | |
59 | 59 | /** |
60 | - * holds db object of SQL database |
|
61 | - * |
|
62 | - * @var egw_db |
|
63 | - */ |
|
60 | + * holds db object of SQL database |
|
61 | + * |
|
62 | + * @var egw_db |
|
63 | + */ |
|
64 | 64 | private $db; |
65 | 65 | |
66 | 66 | /** |
67 | - * constructor of notifications_egwpopup |
|
68 | - * |
|
69 | - * @param object $_sender |
|
70 | - * @param object $_recipient |
|
71 | - * @param object $_config |
|
72 | - * @param object $_preferences |
|
73 | - */ |
|
67 | + * constructor of notifications_egwpopup |
|
68 | + * |
|
69 | + * @param object $_sender |
|
70 | + * @param object $_recipient |
|
71 | + * @param object $_config |
|
72 | + * @param object $_preferences |
|
73 | + */ |
|
74 | 74 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
75 | 75 | { |
76 | 76 | if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * sends notification if user is online |
|
88 | - * |
|
89 | - * @param array $_messages |
|
90 | - * @param string $_subject |
|
91 | - * @param array $_links |
|
92 | - * @param array $_attachments |
|
93 | - */ |
|
87 | + * sends notification if user is online |
|
88 | + * |
|
89 | + * @param array $_messages |
|
90 | + * @param string $_subject |
|
91 | + * @param array $_links |
|
92 | + * @param array $_attachments |
|
93 | + */ |
|
94 | 94 | public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false) |
95 | 95 | { |
96 | 96 | $jmessage = array(); |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * renders additional infos from sender and subject |
|
134 | - * |
|
135 | - * @param string $_subject |
|
136 | - * @return html rendered info as complete string |
|
137 | - */ |
|
133 | + * renders additional infos from sender and subject |
|
134 | + * |
|
135 | + * @param string $_subject |
|
136 | + * @return html rendered info as complete string |
|
137 | + */ |
|
138 | 138 | private function render_infos($_subject = false) { |
139 | 139 | $infos = array(); |
140 | 140 | $newline = "<br />"; |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | - * saves notification into database so that the client can fetch it from there |
|
150 | - * |
|
151 | - * @param string $_message |
|
152 | - * @param array $_user_sessions |
|
153 | - */ |
|
149 | + * saves notification into database so that the client can fetch it from there |
|
150 | + * |
|
151 | + * @param string $_message |
|
152 | + * @param array $_user_sessions |
|
153 | + */ |
|
154 | 154 | private function save( $_message ) { |
155 | 155 | $result = $this->db->insert( self::_notification_table, array( |
156 | 156 | 'account_id' => $this->recipient->account_id, |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
75 | 75 | { |
76 | - if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
|
77 | - if( !is_object($_recipient) ) { throw new Exception("no recipient given."); } |
|
76 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
77 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
78 | 78 | |
79 | 79 | $this->sender = $_sender; |
80 | - $this->recipient = $_recipient; |
|
80 | + $this->recipient = $_recipient; |
|
81 | 81 | $this->config = $_config; |
82 | - $this->preferences = $_preferences; |
|
83 | - $this->db = $GLOBALS['egw']->db; |
|
82 | + $this->preferences = $_preferences; |
|
83 | + $this->db = $GLOBALS['egw']->db; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | * @param array $_links |
92 | 92 | * @param array $_attachments |
93 | 93 | */ |
94 | - public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false) |
|
94 | + public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) |
|
95 | 95 | { |
96 | 96 | $jmessage = array(); |
97 | 97 | |
98 | 98 | // app-message |
99 | - if( ($_links != null) && (count($_links) > 0) ) |
|
99 | + if (($_links != null) && (count($_links) > 0)) |
|
100 | 100 | { |
101 | - $tlink = $_links[0]; |
|
102 | - $appname = ""; |
|
101 | + $tlink = $_links[0]; |
|
102 | + $appname = ""; |
|
103 | 103 | |
104 | - if( key_exists('menuaction', $tlink->view) ) |
|
104 | + if (key_exists('menuaction', $tlink->view)) |
|
105 | 105 | { |
106 | 106 | $tmp = explode(".", $tlink->view['menuaction']); |
107 | 107 | $appname = $tmp[0]; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | |
110 | 110 | $link = array(); |
111 | 111 | |
112 | - foreach( $tlink->view as $pkey => $pvalue ) |
|
112 | + foreach ($tlink->view as $pkey => $pvalue) |
|
113 | 113 | { |
114 | - $link[] = $pkey . '=' . $pvalue; |
|
114 | + $link[] = $pkey.'='.$pvalue; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // TODO more links? |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | .html::hr() |
123 | 123 | .$_messages['html']; |
124 | 124 | |
125 | - $jmessage['msghtml'] = $message; |
|
126 | - $jmessage['app'] = $appname; |
|
125 | + $jmessage['msghtml'] = $message; |
|
126 | + $jmessage['app'] = $appname; |
|
127 | 127 | |
128 | 128 | |
129 | - $this->save( serialize($jmessage) ); |
|
129 | + $this->save(serialize($jmessage)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | |
142 | 142 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
143 | 143 | $infos[] = lang('Message from').': '.$sender; |
144 | - if(!empty($_subject)) { $infos[] = html::bold($_subject); } |
|
145 | - return implode($newline,$infos); |
|
144 | + if (!empty($_subject)) { $infos[] = html::bold($_subject); } |
|
145 | + return implode($newline, $infos); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | * @param string $_message |
152 | 152 | * @param array $_user_sessions |
153 | 153 | */ |
154 | - private function save( $_message ) { |
|
155 | - $result = $this->db->insert( self::_notification_table, array( |
|
154 | + private function save($_message) { |
|
155 | + $result = $this->db->insert(self::_notification_table, array( |
|
156 | 156 | 'account_id' => $this->recipient->account_id, |
157 | 157 | 'notify_message' => $_message, |
158 | 158 | 'notify_type' => self::_type |
159 | - ), false,__LINE__,__FILE__,self::_appname); |
|
159 | + ), false, __LINE__, __FILE__, self::_appname); |
|
160 | 160 | if ($result === false) throw new Exception("Can't save notification into SQL table"); |
161 | 161 | } |
162 | 162 | } |
@@ -73,8 +73,12 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
75 | 75 | { |
76 | - if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
|
77 | - if( !is_object($_recipient) ) { throw new Exception("no recipient given."); } |
|
76 | + if( !is_object($_sender) ) |
|
77 | + { |
|
78 | +throw new Exception("no sender given."); } |
|
79 | + if( !is_object($_recipient) ) |
|
80 | + { |
|
81 | +throw new Exception("no recipient given."); } |
|
78 | 82 | |
79 | 83 | $this->sender = $_sender; |
80 | 84 | $this->recipient = $_recipient; |
@@ -135,13 +139,16 @@ discard block |
||
135 | 139 | * @param string $_subject |
136 | 140 | * @return html rendered info as complete string |
137 | 141 | */ |
138 | - private function render_infos($_subject = false) { |
|
142 | + private function render_infos($_subject = false) |
|
143 | + { |
|
139 | 144 | $infos = array(); |
140 | 145 | $newline = "<br />"; |
141 | 146 | |
142 | 147 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
143 | 148 | $infos[] = lang('Message from').': '.$sender; |
144 | - if(!empty($_subject)) { $infos[] = html::bold($_subject); } |
|
149 | + if(!empty($_subject)) |
|
150 | + { |
|
151 | +$infos[] = html::bold($_subject); } |
|
145 | 152 | return implode($newline,$infos); |
146 | 153 | } |
147 | 154 | |
@@ -151,12 +158,16 @@ discard block |
||
151 | 158 | * @param string $_message |
152 | 159 | * @param array $_user_sessions |
153 | 160 | */ |
154 | - private function save( $_message ) { |
|
161 | + private function save( $_message ) |
|
162 | + { |
|
155 | 163 | $result = $this->db->insert( self::_notification_table, array( |
156 | 164 | 'account_id' => $this->recipient->account_id, |
157 | 165 | 'notify_message' => $_message, |
158 | 166 | 'notify_type' => self::_type |
159 | 167 | ), false,__LINE__,__FILE__,self::_appname); |
160 | - if ($result === false) throw new Exception("Can't save notification into SQL table"); |
|
168 | + if ($result === false) |
|
169 | + { |
|
170 | + throw new Exception("Can't save notification into SQL table"); |
|
171 | + } |
|
161 | 172 | } |
162 | 173 | } |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Open CSV file and convert it into Data. |
84 | 84 | * |
85 | -* @param url file/ftp/http url |
|
86 | -* @param err returns the error message |
|
87 | -* @param timeout dispose if recordset has been alive for $timeout secs |
|
85 | +* @param url string url |
|
86 | +* @param err string|false the error message |
|
87 | +* @param timeout integer if recordset has been alive for $timeout secs |
|
88 | 88 | * |
89 | 89 | * @return recordset, or false if error occured. If no |
90 | 90 | * error occurred in sql INSERT/UPDATE/DELETE, |
@@ -261,6 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Save a file $filename and its $contents (normally for caching) with file locking |
264 | + * @param string $filename |
|
264 | 265 | */ |
265 | 266 | function adodb_write_file($filename, $contents,$debug=false) |
266 | 267 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | |
27 | 27 | /** |
28 | - * convert a recordset into special format |
|
28 | + * convert a recordset into special format |
|
29 | 29 | * |
30 | 30 | * @param rs the recordset |
31 | 31 | * |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | |
261 | 261 | |
262 | 262 | /** |
263 | - * Save a file $filename and its $contents (normally for caching) with file locking |
|
264 | - */ |
|
263 | + * Save a file $filename and its $contents (normally for caching) with file locking |
|
264 | + */ |
|
265 | 265 | function adodb_write_file($filename, $contents,$debug=false) |
266 | 266 | { |
267 | 267 | # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows |
@@ -152,32 +152,32 @@ |
||
152 | 152 | $tdiff = (integer)( $meta[1]+$timeout - time()); |
153 | 153 | if ($tdiff <= 2) { |
154 | 154 | switch($tdiff) { |
155 | - case 4: |
|
156 | - case 3: |
|
157 | - if ((rand() & 31) == 0) { |
|
155 | + case 4: |
|
156 | + case 3: |
|
157 | + if ((rand() & 31) == 0) { |
|
158 | + fclose($fp); |
|
159 | + $err = "Timeout 3"; |
|
160 | + return $false; |
|
161 | + } |
|
162 | + break; |
|
163 | + case 2: |
|
164 | + if ((rand() & 15) == 0) { |
|
165 | + fclose($fp); |
|
166 | + $err = "Timeout 2"; |
|
167 | + return $false; |
|
168 | + } |
|
169 | + break; |
|
170 | + case 1: |
|
171 | + if ((rand() & 3) == 0) { |
|
172 | + fclose($fp); |
|
173 | + $err = "Timeout 1"; |
|
174 | + return $false; |
|
175 | + } |
|
176 | + break; |
|
177 | + default: |
|
158 | 178 | fclose($fp); |
159 | - $err = "Timeout 3"; |
|
179 | + $err = "Timeout 0"; |
|
160 | 180 | return $false; |
161 | - } |
|
162 | - break; |
|
163 | - case 2: |
|
164 | - if ((rand() & 15) == 0) { |
|
165 | - fclose($fp); |
|
166 | - $err = "Timeout 2"; |
|
167 | - return $false; |
|
168 | - } |
|
169 | - break; |
|
170 | - case 1: |
|
171 | - if ((rand() & 3) == 0) { |
|
172 | - fclose($fp); |
|
173 | - $err = "Timeout 1"; |
|
174 | - return $false; |
|
175 | - } |
|
176 | - break; |
|
177 | - default: |
|
178 | - fclose($fp); |
|
179 | - $err = "Timeout 0"; |
|
180 | - return $false; |
|
181 | 181 | } // switch |
182 | 182 | |
183 | 183 | } // if check flush cache |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return the CSV formated data |
33 | 33 | */ |
34 | - function _rs2serialize(&$rs,$conn=false,$sql='') |
|
34 | + function _rs2serialize(&$rs, $conn = false, $sql = '') |
|
35 | 35 | { |
36 | 36 | $max = ($rs) ? $rs->FieldCount() : 0; |
37 | 37 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $line = "====1,$tt,$sql\n"; |
55 | 55 | |
56 | 56 | if ($rs->databaseType == 'array') { |
57 | - $rows =& $rs->_array; |
|
57 | + $rows = & $rs->_array; |
|
58 | 58 | } else { |
59 | 59 | $rows = array(); |
60 | 60 | while (!$rs->EOF) { |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - for($i=0; $i < $max; $i++) { |
|
67 | - $o =& $rs->FetchField($i); |
|
66 | + for ($i = 0; $i < $max; $i++) { |
|
67 | + $o = & $rs->FetchField($i); |
|
68 | 68 | $flds[] = $o; |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $rs2 = new $class(); |
74 | 74 | $rs2->sql = $rs->sql; |
75 | 75 | $rs2->oldProvider = $rs->dataProvider; |
76 | - $rs2->InitArrayFields($rows,$flds); |
|
76 | + $rs2->InitArrayFields($rows, $flds); |
|
77 | 77 | $rs2->fetchMode = $savefetch; |
78 | 78 | return $line.serialize($rs2); |
79 | 79 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * error occurred in sql INSERT/UPDATE/DELETE, |
91 | 91 | * empty recordset is returned |
92 | 92 | */ |
93 | - function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') |
|
93 | + function &csv2rs($url, &$err, $timeout = 0, $rsclass = 'ADORecordSet_array') |
|
94 | 94 | { |
95 | 95 | $false = false; |
96 | 96 | $err = false; |
97 | - $fp = @fopen($url,'rb'); |
|
97 | + $fp = @fopen($url, 'rb'); |
|
98 | 98 | if (!$fp) { |
99 | 99 | $err = $url.' file/URL not found'; |
100 | 100 | return $false; |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | |
106 | 106 | if ($meta = fgetcsv($fp, 32000, ",")) { |
107 | 107 | // check if error message |
108 | - if (strncmp($meta[0],'****',4) === 0) { |
|
109 | - $err = trim(substr($meta[0],4,1024)); |
|
108 | + if (strncmp($meta[0], '****', 4) === 0) { |
|
109 | + $err = trim(substr($meta[0], 4, 1024)); |
|
110 | 110 | fclose($fp); |
111 | 111 | return $false; |
112 | 112 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // $meta[0] is -1 means return an empty recordset |
115 | 115 | // $meta[1] contains a time |
116 | 116 | |
117 | - if (strncmp($meta[0], '====',4) === 0) { |
|
117 | + if (strncmp($meta[0], '====', 4) === 0) { |
|
118 | 118 | |
119 | 119 | if ($meta[0] == "====-1") { |
120 | 120 | if (sizeof($meta) < 5) { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return $false; |
130 | 130 | } |
131 | 131 | |
132 | - $rs = new $rsclass($val=true); |
|
132 | + $rs = new $rsclass($val = true); |
|
133 | 133 | $rs->fields = array(); |
134 | 134 | $rs->timeCreated = $meta[1]; |
135 | 135 | $rs->EOF = true; |
@@ -148,27 +148,27 @@ discard block |
||
148 | 148 | # -1 sec after timeout give processes 1/4 chance of timing out |
149 | 149 | # +0 sec after timeout, give processes 100% chance of timing out |
150 | 150 | if (sizeof($meta) > 1) { |
151 | - if($timeout >0){ |
|
152 | - $tdiff = (integer)( $meta[1]+$timeout - time()); |
|
151 | + if ($timeout > 0) { |
|
152 | + $tdiff = (integer)($meta[1] + $timeout - time()); |
|
153 | 153 | if ($tdiff <= 2) { |
154 | - switch($tdiff) { |
|
154 | + switch ($tdiff) { |
|
155 | 155 | case 4: |
156 | 156 | case 3: |
157 | - if ((rand() & 31) == 0) { |
|
157 | + if ((rand()&31) == 0) { |
|
158 | 158 | fclose($fp); |
159 | 159 | $err = "Timeout 3"; |
160 | 160 | return $false; |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | case 2: |
164 | - if ((rand() & 15) == 0) { |
|
164 | + if ((rand()&15) == 0) { |
|
165 | 165 | fclose($fp); |
166 | 166 | $err = "Timeout 2"; |
167 | 167 | return $false; |
168 | 168 | } |
169 | 169 | break; |
170 | 170 | case 1: |
171 | - if ((rand() & 3) == 0) { |
|
171 | + if ((rand()&3) == 0) { |
|
172 | 172 | fclose($fp); |
173 | 173 | $err = "Timeout 1"; |
174 | 174 | return $false; |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | // slurp in the data |
191 | 191 | $MAXSIZE = 128000; |
192 | 192 | |
193 | - $text = fread($fp,$MAXSIZE); |
|
193 | + $text = fread($fp, $MAXSIZE); |
|
194 | 194 | if (strlen($text)) { |
195 | - while ($txt = fread($fp,$MAXSIZE)) { |
|
195 | + while ($txt = fread($fp, $MAXSIZE)) { |
|
196 | 196 | $text .= $txt; |
197 | 197 | } |
198 | 198 | } |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | |
218 | 218 | // Get Column definitions |
219 | 219 | $flds = array(); |
220 | - foreach($meta as $o) { |
|
221 | - $o2 = explode(':',$o); |
|
222 | - if (sizeof($o2)!=3) { |
|
220 | + foreach ($meta as $o) { |
|
221 | + $o2 = explode(':', $o); |
|
222 | + if (sizeof($o2) != 3) { |
|
223 | 223 | $arr[] = $meta; |
224 | 224 | $flds = false; |
225 | 225 | break; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $MAXSIZE = 128000; |
241 | 241 | |
242 | 242 | $text = ''; |
243 | - while ($txt = fread($fp,$MAXSIZE)) { |
|
243 | + while ($txt = fread($fp, $MAXSIZE)) { |
|
244 | 244 | $text .= $txt; |
245 | 245 | } |
246 | 246 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | $rs = new $rsclass(); |
256 | 256 | $rs->timeCreated = $ttl; |
257 | - $rs->InitArrayFields($arr,$flds); |
|
257 | + $rs->InitArrayFields($arr, $flds); |
|
258 | 258 | return $rs; |
259 | 259 | } |
260 | 260 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | /** |
263 | 263 | * Save a file $filename and its $contents (normally for caching) with file locking |
264 | 264 | */ |
265 | - function adodb_write_file($filename, $contents,$debug=false) |
|
265 | + function adodb_write_file($filename, $contents, $debug = false) |
|
266 | 266 | { |
267 | 267 | # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows |
268 | 268 | # So to simulate locking, we assume that rename is an atomic operation. |
@@ -275,35 +275,35 @@ discard block |
||
275 | 275 | # 2. unlink($filename) fails -- ok, rename will fail |
276 | 276 | # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs |
277 | 277 | # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated |
278 | - if (strncmp(PHP_OS,'WIN',3) === 0) { |
|
278 | + if (strncmp(PHP_OS, 'WIN', 3) === 0) { |
|
279 | 279 | // skip the decimal place |
280 | - $mtime = substr(str_replace(' ','_',microtime()),2); |
|
280 | + $mtime = substr(str_replace(' ', '_', microtime()), 2); |
|
281 | 281 | // getmypid() actually returns 0 on Win98 - never mind! |
282 | 282 | $tmpname = $filename.uniqid($mtime).getmypid(); |
283 | - if (!($fd = @fopen($tmpname,'a'))) return false; |
|
284 | - $ok = ftruncate($fd,0); |
|
285 | - if (!fwrite($fd,$contents)) $ok = false; |
|
283 | + if (!($fd = @fopen($tmpname, 'a'))) return false; |
|
284 | + $ok = ftruncate($fd, 0); |
|
285 | + if (!fwrite($fd, $contents)) $ok = false; |
|
286 | 286 | fclose($fd); |
287 | - chmod($tmpname,0644); |
|
287 | + chmod($tmpname, 0644); |
|
288 | 288 | // the tricky moment |
289 | 289 | @unlink($filename); |
290 | - if (!@rename($tmpname,$filename)) { |
|
290 | + if (!@rename($tmpname, $filename)) { |
|
291 | 291 | unlink($tmpname); |
292 | 292 | $ok = false; |
293 | 293 | } |
294 | 294 | if (!$ok) { |
295 | - if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); |
|
295 | + if ($debug) ADOConnection::outp(" Rename $tmpname ".($ok ? 'ok' : 'failed')); |
|
296 | 296 | } |
297 | 297 | return $ok; |
298 | 298 | } |
299 | 299 | if (!($fd = @fopen($filename, 'a'))) return false; |
300 | 300 | if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { |
301 | - $ok = fwrite( $fd, $contents ); |
|
301 | + $ok = fwrite($fd, $contents); |
|
302 | 302 | fclose($fd); |
303 | - chmod($filename,0644); |
|
304 | - }else { |
|
303 | + chmod($filename, 0644); |
|
304 | + } else { |
|
305 | 305 | fclose($fd); |
306 | - if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n"); |
|
306 | + if ($debug)ADOConnection::outp(" Failed acquiring lock for $filename<br>\n"); |
|
307 | 307 | $ok = false; |
308 | 308 | } |
309 | 309 |
@@ -1,7 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // security - hide paths |
4 | -if (!defined('ADODB_DIR')) die(); |
|
4 | +if (!defined('ADODB_DIR')) |
|
5 | +{ |
|
6 | + die(); |
|
7 | +} |
|
5 | 8 | |
6 | 9 | global $ADODB_INCLUDED_CSV; |
7 | 10 | $ADODB_INCLUDED_CSV = 1; |
@@ -35,15 +38,23 @@ discard block |
||
35 | 38 | { |
36 | 39 | $max = ($rs) ? $rs->FieldCount() : 0; |
37 | 40 | |
38 | - if ($sql) $sql = urlencode($sql); |
|
41 | + if ($sql) |
|
42 | + { |
|
43 | + $sql = urlencode($sql); |
|
44 | + } |
|
39 | 45 | // metadata setup |
40 | 46 | |
41 | - if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete |
|
42 | - if (is_object($conn)) { |
|
47 | + if ($max <= 0 || $rs->dataProvider == 'empty') |
|
48 | + { |
|
49 | +// is insert/update/delete |
|
50 | + if (is_object($conn)) |
|
51 | + { |
|
43 | 52 | $sql .= ','.$conn->Affected_Rows(); |
44 | 53 | $sql .= ','.$conn->Insert_ID(); |
45 | - } else |
|
46 | - $sql .= ',,'; |
|
54 | + } |
|
55 | + else { |
|
56 | + $sql .= ',,'; |
|
57 | + } |
|
47 | 58 | |
48 | 59 | $text = "====-1,0,$sql\n"; |
49 | 60 | return $text; |
@@ -53,17 +64,22 @@ discard block |
||
53 | 64 | ## changed format from ====0 to ====1 |
54 | 65 | $line = "====1,$tt,$sql\n"; |
55 | 66 | |
56 | - if ($rs->databaseType == 'array') { |
|
67 | + if ($rs->databaseType == 'array') |
|
68 | + { |
|
57 | 69 | $rows =& $rs->_array; |
58 | - } else { |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
59 | 73 | $rows = array(); |
60 | - while (!$rs->EOF) { |
|
74 | + while (!$rs->EOF) |
|
75 | + { |
|
61 | 76 | $rows[] = $rs->fields; |
62 | 77 | $rs->MoveNext(); |
63 | 78 | } |
64 | 79 | } |
65 | 80 | |
66 | - for($i=0; $i < $max; $i++) { |
|
81 | + for($i=0; $i < $max; $i++) |
|
82 | + { |
|
67 | 83 | $o =& $rs->FetchField($i); |
68 | 84 | $flds[] = $o; |
69 | 85 | } |
@@ -95,7 +111,8 @@ discard block |
||
95 | 111 | $false = false; |
96 | 112 | $err = false; |
97 | 113 | $fp = @fopen($url,'rb'); |
98 | - if (!$fp) { |
|
114 | + if (!$fp) |
|
115 | + { |
|
99 | 116 | $err = $url.' file/URL not found'; |
100 | 117 | return $false; |
101 | 118 | } |
@@ -103,9 +120,11 @@ discard block |
||
103 | 120 | $arr = array(); |
104 | 121 | $ttl = 0; |
105 | 122 | |
106 | - if ($meta = fgetcsv($fp, 32000, ",")) { |
|
123 | + if ($meta = fgetcsv($fp, 32000, ",")) |
|
124 | + { |
|
107 | 125 | // check if error message |
108 | - if (strncmp($meta[0],'****',4) === 0) { |
|
126 | + if (strncmp($meta[0],'****',4) === 0) |
|
127 | + { |
|
109 | 128 | $err = trim(substr($meta[0],4,1024)); |
110 | 129 | fclose($fp); |
111 | 130 | return $false; |
@@ -114,17 +133,21 @@ discard block |
||
114 | 133 | // $meta[0] is -1 means return an empty recordset |
115 | 134 | // $meta[1] contains a time |
116 | 135 | |
117 | - if (strncmp($meta[0], '====',4) === 0) { |
|
136 | + if (strncmp($meta[0], '====',4) === 0) |
|
137 | + { |
|
118 | 138 | |
119 | - if ($meta[0] == "====-1") { |
|
120 | - if (sizeof($meta) < 5) { |
|
139 | + if ($meta[0] == "====-1") |
|
140 | + { |
|
141 | + if (sizeof($meta) < 5) |
|
142 | + { |
|
121 | 143 | $err = "Corrupt first line for format -1"; |
122 | 144 | fclose($fp); |
123 | 145 | return $false; |
124 | 146 | } |
125 | 147 | fclose($fp); |
126 | 148 | |
127 | - if ($timeout > 0) { |
|
149 | + if ($timeout > 0) |
|
150 | + { |
|
128 | 151 | $err = " Illegal Timeout $timeout "; |
129 | 152 | return $false; |
130 | 153 | } |
@@ -147,28 +170,35 @@ discard block |
||
147 | 170 | # -2 sec before timeout, give processes 1/16 chance of timing out |
148 | 171 | # -1 sec after timeout give processes 1/4 chance of timing out |
149 | 172 | # +0 sec after timeout, give processes 100% chance of timing out |
150 | - if (sizeof($meta) > 1) { |
|
151 | - if($timeout >0){ |
|
173 | + if (sizeof($meta) > 1) |
|
174 | + { |
|
175 | + if($timeout >0) |
|
176 | + { |
|
152 | 177 | $tdiff = (integer)( $meta[1]+$timeout - time()); |
153 | - if ($tdiff <= 2) { |
|
154 | - switch($tdiff) { |
|
178 | + if ($tdiff <= 2) |
|
179 | + { |
|
180 | + switch($tdiff) |
|
181 | + { |
|
155 | 182 | case 4: |
156 | 183 | case 3: |
157 | - if ((rand() & 31) == 0) { |
|
184 | + if ((rand() & 31) == 0) |
|
185 | + { |
|
158 | 186 | fclose($fp); |
159 | 187 | $err = "Timeout 3"; |
160 | 188 | return $false; |
161 | 189 | } |
162 | 190 | break; |
163 | 191 | case 2: |
164 | - if ((rand() & 15) == 0) { |
|
192 | + if ((rand() & 15) == 0) |
|
193 | + { |
|
165 | 194 | fclose($fp); |
166 | 195 | $err = "Timeout 2"; |
167 | 196 | return $false; |
168 | 197 | } |
169 | 198 | break; |
170 | 199 | case 1: |
171 | - if ((rand() & 3) == 0) { |
|
200 | + if ((rand() & 3) == 0) |
|
201 | + { |
|
172 | 202 | fclose($fp); |
173 | 203 | $err = "Timeout 1"; |
174 | 204 | return $false; |
@@ -186,20 +216,27 @@ discard block |
||
186 | 216 | } |
187 | 217 | //================================================ |
188 | 218 | // new cache format - use serialize extensively... |
189 | - if ($meta[0] === '====1') { |
|
219 | + if ($meta[0] === '====1') |
|
220 | + { |
|
190 | 221 | // slurp in the data |
191 | 222 | $MAXSIZE = 128000; |
192 | 223 | |
193 | 224 | $text = fread($fp,$MAXSIZE); |
194 | - if (strlen($text)) { |
|
195 | - while ($txt = fread($fp,$MAXSIZE)) { |
|
225 | + if (strlen($text)) |
|
226 | + { |
|
227 | + while ($txt = fread($fp,$MAXSIZE)) |
|
228 | + { |
|
196 | 229 | $text .= $txt; |
197 | 230 | } |
198 | 231 | } |
199 | 232 | fclose($fp); |
200 | 233 | $rs = unserialize($text); |
201 | - if (is_object($rs)) $rs->timeCreated = $ttl; |
|
202 | - else { |
|
234 | + if (is_object($rs)) |
|
235 | + { |
|
236 | + $rs->timeCreated = $ttl; |
|
237 | + } |
|
238 | + else |
|
239 | + { |
|
203 | 240 | $err = "Unable to unserialize recordset"; |
204 | 241 | //echo htmlspecialchars($text),' !--END--!<p>'; |
205 | 242 | } |
@@ -208,7 +245,8 @@ discard block |
||
208 | 245 | |
209 | 246 | $meta = false; |
210 | 247 | $meta = fgetcsv($fp, 32000, ","); |
211 | - if (!$meta) { |
|
248 | + if (!$meta) |
|
249 | + { |
|
212 | 250 | fclose($fp); |
213 | 251 | $err = "Unexpected EOF 1"; |
214 | 252 | return $false; |
@@ -217,9 +255,11 @@ discard block |
||
217 | 255 | |
218 | 256 | // Get Column definitions |
219 | 257 | $flds = array(); |
220 | - foreach($meta as $o) { |
|
258 | + foreach($meta as $o) |
|
259 | + { |
|
221 | 260 | $o2 = explode(':',$o); |
222 | - if (sizeof($o2)!=3) { |
|
261 | + if (sizeof($o2)!=3) |
|
262 | + { |
|
223 | 263 | $arr[] = $meta; |
224 | 264 | $flds = false; |
225 | 265 | break; |
@@ -230,7 +270,9 @@ discard block |
||
230 | 270 | $fld->max_length = $o2[2]; |
231 | 271 | $flds[] = $fld; |
232 | 272 | } |
233 | - } else { |
|
273 | + } |
|
274 | + else |
|
275 | + { |
|
234 | 276 | fclose($fp); |
235 | 277 | $err = "Recordset had unexpected EOF 2"; |
236 | 278 | return $false; |
@@ -240,16 +282,21 @@ discard block |
||
240 | 282 | $MAXSIZE = 128000; |
241 | 283 | |
242 | 284 | $text = ''; |
243 | - while ($txt = fread($fp,$MAXSIZE)) { |
|
285 | + while ($txt = fread($fp,$MAXSIZE)) |
|
286 | + { |
|
244 | 287 | $text .= $txt; |
245 | 288 | } |
246 | 289 | |
247 | 290 | fclose($fp); |
248 | 291 | @$arr = unserialize($text); |
249 | 292 | //var_dump($arr); |
250 | - if (!is_array($arr)) { |
|
293 | + if (!is_array($arr)) |
|
294 | + { |
|
251 | 295 | $err = "Recordset had unexpected EOF (in serialized recordset)"; |
252 | - if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!"; |
|
296 | + if (get_magic_quotes_runtime()) |
|
297 | + { |
|
298 | + $err .= ". Magic Quotes Runtime should be disabled!"; |
|
299 | + } |
|
253 | 300 | return $false; |
254 | 301 | } |
255 | 302 | $rs = new $rsclass(); |
@@ -263,7 +310,7 @@ discard block |
||
263 | 310 | * Save a file $filename and its $contents (normally for caching) with file locking |
264 | 311 | */ |
265 | 312 | function adodb_write_file($filename, $contents,$debug=false) |
266 | - { |
|
313 | + { |
|
267 | 314 | # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows |
268 | 315 | # So to simulate locking, we assume that rename is an atomic operation. |
269 | 316 | # First we delete $filename, then we create a $tempfile write to it and |
@@ -275,35 +322,56 @@ discard block |
||
275 | 322 | # 2. unlink($filename) fails -- ok, rename will fail |
276 | 323 | # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs |
277 | 324 | # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated |
278 | - if (strncmp(PHP_OS,'WIN',3) === 0) { |
|
325 | + if (strncmp(PHP_OS,'WIN',3) === 0) |
|
326 | + { |
|
279 | 327 | // skip the decimal place |
280 | 328 | $mtime = substr(str_replace(' ','_',microtime()),2); |
281 | 329 | // getmypid() actually returns 0 on Win98 - never mind! |
282 | 330 | $tmpname = $filename.uniqid($mtime).getmypid(); |
283 | - if (!($fd = @fopen($tmpname,'a'))) return false; |
|
331 | + if (!($fd = @fopen($tmpname,'a'))) |
|
332 | + { |
|
333 | + return false; |
|
334 | + } |
|
284 | 335 | $ok = ftruncate($fd,0); |
285 | - if (!fwrite($fd,$contents)) $ok = false; |
|
336 | + if (!fwrite($fd,$contents)) |
|
337 | + { |
|
338 | + $ok = false; |
|
339 | + } |
|
286 | 340 | fclose($fd); |
287 | 341 | chmod($tmpname,0644); |
288 | 342 | // the tricky moment |
289 | 343 | @unlink($filename); |
290 | - if (!@rename($tmpname,$filename)) { |
|
344 | + if (!@rename($tmpname,$filename)) |
|
345 | + { |
|
291 | 346 | unlink($tmpname); |
292 | 347 | $ok = false; |
293 | 348 | } |
294 | - if (!$ok) { |
|
295 | - if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); |
|
349 | + if (!$ok) |
|
350 | + { |
|
351 | + if ($debug) |
|
352 | + { |
|
353 | + ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); |
|
354 | + } |
|
296 | 355 | } |
297 | 356 | return $ok; |
298 | 357 | } |
299 | - if (!($fd = @fopen($filename, 'a'))) return false; |
|
300 | - if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { |
|
358 | + if (!($fd = @fopen($filename, 'a'))) |
|
359 | + { |
|
360 | + return false; |
|
361 | + } |
|
362 | + if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) |
|
363 | + { |
|
301 | 364 | $ok = fwrite( $fd, $contents ); |
302 | 365 | fclose($fd); |
303 | 366 | chmod($filename,0644); |
304 | - }else { |
|
367 | + } |
|
368 | + else |
|
369 | + { |
|
305 | 370 | fclose($fd); |
306 | - if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n"); |
|
371 | + if ($debug) |
|
372 | + { |
|
373 | + ADOConnection::outp( " Failed acquiring lock for $filename<br>\n"); |
|
374 | + } |
|
307 | 375 | $ok = false; |
308 | 376 | } |
309 | 377 |
@@ -196,18 +196,27 @@ discard block |
||
196 | 196 | return $this->connection->MetaTables(); |
197 | 197 | } |
198 | 198 | |
199 | + /** |
|
200 | + * @return string |
|
201 | + */ |
|
199 | 202 | function MetaColumns($tab, $upper=true, $schema=false) |
200 | 203 | { |
201 | 204 | if (!$this->connection->IsConnected()) return array(); |
202 | 205 | return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); |
203 | 206 | } |
204 | 207 | |
208 | + /** |
|
209 | + * @param string $tab |
|
210 | + */ |
|
205 | 211 | function MetaPrimaryKeys($tab,$owner=false,$intkey=false) |
206 | 212 | { |
207 | 213 | if (!$this->connection->IsConnected()) return array(); |
208 | 214 | return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); |
209 | 215 | } |
210 | 216 | |
217 | + /** |
|
218 | + * @param string $table |
|
219 | + */ |
|
211 | 220 | function MetaIndexes($table, $primary = false, $owner = false) |
212 | 221 | { |
213 | 222 | if (!$this->connection->IsConnected()) return array(); |
@@ -304,6 +313,11 @@ discard block |
||
304 | 313 | N: Numeric or decimal number |
305 | 314 | */ |
306 | 315 | |
316 | + /** |
|
317 | + * @param string $meta |
|
318 | + * |
|
319 | + * @return string |
|
320 | + */ |
|
307 | 321 | function ActualType($meta) |
308 | 322 | { |
309 | 323 | return $meta; |
@@ -325,6 +339,10 @@ discard block |
||
325 | 339 | /* |
326 | 340 | Generates the SQL to create index. Returns an array of sql strings. |
327 | 341 | */ |
342 | + |
|
343 | + /** |
|
344 | + * @param string $tabname |
|
345 | + */ |
|
328 | 346 | function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) |
329 | 347 | { |
330 | 348 | if (!is_array($flds)) { |
@@ -339,6 +357,9 @@ discard block |
||
339 | 357 | return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions)); |
340 | 358 | } |
341 | 359 | |
360 | + /** |
|
361 | + * @param string $tabname |
|
362 | + */ |
|
342 | 363 | function DropIndexSQL ($idxname, $tabname = NULL) |
343 | 364 | { |
344 | 365 | return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname))); |
@@ -349,6 +370,10 @@ discard block |
||
349 | 370 | $this->schema = $schema; |
350 | 371 | } |
351 | 372 | |
373 | + /** |
|
374 | + * @param string $tabname |
|
375 | + * @param string $flds |
|
376 | + */ |
|
352 | 377 | function AddColumnSQL($tabname, $flds) |
353 | 378 | { |
354 | 379 | $tabname = $this->TableName ($tabname); |
@@ -392,7 +417,7 @@ discard block |
||
392 | 417 | * @param string $oldcolumn column-name to be renamed |
393 | 418 | * @param string $newcolumn new column-name |
394 | 419 | * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' |
395 | - * @return array with SQL strings |
|
420 | + * @return string[] with SQL strings |
|
396 | 421 | */ |
397 | 422 | function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') |
398 | 423 | { |
@@ -433,6 +458,10 @@ discard block |
||
433 | 458 | return array (sprintf($this->dropTable, $this->TableName($tabname))); |
434 | 459 | } |
435 | 460 | |
461 | + /** |
|
462 | + * @param string $tabname |
|
463 | + * @param string $newname |
|
464 | + */ |
|
436 | 465 | function RenameTableSQL($tabname,$newname) |
437 | 466 | { |
438 | 467 | return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); |
@@ -613,6 +642,11 @@ discard block |
||
613 | 642 | |
614 | 643 | |
615 | 644 | // return string must begin with space |
645 | + |
|
646 | + /** |
|
647 | + * @param boolean $fautoinc |
|
648 | + * @param boolean $funsigned |
|
649 | + */ |
|
616 | 650 | function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) |
617 | 651 | { |
618 | 652 | $suffix = ''; |
@@ -65,92 +65,92 @@ discard block |
||
65 | 65 | while ($pos < $max) { |
66 | 66 | $ch = substr($args,$pos,1); |
67 | 67 | switch($ch) { |
68 | - case ' ': |
|
69 | - case "\t": |
|
70 | - case "\n": |
|
71 | - case "\r": |
|
72 | - if (!$quoted) { |
|
73 | - if ($intoken) { |
|
74 | - $intoken = false; |
|
75 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
68 | + case ' ': |
|
69 | + case "\t": |
|
70 | + case "\n": |
|
71 | + case "\r": |
|
72 | + if (!$quoted) { |
|
73 | + if ($intoken) { |
|
74 | + $intoken = false; |
|
75 | + $tokens[$stmtno][] = implode('',$tokarr); |
|
76 | + } |
|
77 | + break; |
|
76 | 78 | } |
79 | + |
|
80 | + $tokarr[] = $ch; |
|
77 | 81 | break; |
78 | - } |
|
79 | 82 | |
80 | - $tokarr[] = $ch; |
|
81 | - break; |
|
83 | + case '`': |
|
84 | + if ($intoken) $tokarr[] = $ch; |
|
85 | + case '(': |
|
86 | + case ')': |
|
87 | + case '"': |
|
88 | + case "'": |
|
82 | 89 | |
83 | - case '`': |
|
84 | - if ($intoken) $tokarr[] = $ch; |
|
85 | - case '(': |
|
86 | - case ')': |
|
87 | - case '"': |
|
88 | - case "'": |
|
90 | + if ($intoken) { |
|
91 | + if (empty($endquote)) { |
|
92 | + $tokens[$stmtno][] = implode('',$tokarr); |
|
93 | + if ($ch == '(') $endquote = ')'; |
|
94 | + else $endquote = $ch; |
|
95 | + $quoted = true; |
|
96 | + $intoken = true; |
|
97 | + $tokarr = array(); |
|
98 | + } else if ($endquote == $ch) { |
|
99 | + $ch2 = substr($args,$pos+1,1); |
|
100 | + if ($ch2 == $endquote) { |
|
101 | + $pos += 1; |
|
102 | + $tokarr[] = $ch2; |
|
103 | + } else { |
|
104 | + $quoted = false; |
|
105 | + $intoken = false; |
|
106 | + $tokens[$stmtno][] = implode('',$tokarr); |
|
107 | + $endquote = ''; |
|
108 | + } |
|
109 | + } else |
|
110 | + $tokarr[] = $ch; |
|
111 | + |
|
112 | + }else { |
|
89 | 113 | |
90 | - if ($intoken) { |
|
91 | - if (empty($endquote)) { |
|
92 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
93 | 114 | if ($ch == '(') $endquote = ')'; |
94 | 115 | else $endquote = $ch; |
95 | 116 | $quoted = true; |
96 | 117 | $intoken = true; |
97 | 118 | $tokarr = array(); |
98 | - } else if ($endquote == $ch) { |
|
99 | - $ch2 = substr($args,$pos+1,1); |
|
100 | - if ($ch2 == $endquote) { |
|
101 | - $pos += 1; |
|
102 | - $tokarr[] = $ch2; |
|
103 | - } else { |
|
104 | - $quoted = false; |
|
105 | - $intoken = false; |
|
106 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
107 | - $endquote = ''; |
|
108 | - } |
|
109 | - } else |
|
110 | - $tokarr[] = $ch; |
|
119 | + if ($ch == '`') $tokarr[] = '`'; |
|
120 | + } |
|
121 | + break; |
|
111 | 122 | |
112 | - }else { |
|
123 | + default: |
|
113 | 124 | |
114 | - if ($ch == '(') $endquote = ')'; |
|
115 | - else $endquote = $ch; |
|
116 | - $quoted = true; |
|
117 | - $intoken = true; |
|
118 | - $tokarr = array(); |
|
119 | - if ($ch == '`') $tokarr[] = '`'; |
|
120 | - } |
|
121 | - break; |
|
125 | + if (!$intoken) { |
|
126 | + if ($ch == $endstmtchar) { |
|
127 | + $stmtno += 1; |
|
128 | + $tokens[$stmtno] = array(); |
|
129 | + break; |
|
130 | + } |
|
122 | 131 | |
123 | - default: |
|
132 | + $intoken = true; |
|
133 | + $quoted = false; |
|
134 | + $endquote = false; |
|
135 | + $tokarr = array(); |
|
124 | 136 | |
125 | - if (!$intoken) { |
|
126 | - if ($ch == $endstmtchar) { |
|
127 | - $stmtno += 1; |
|
128 | - $tokens[$stmtno] = array(); |
|
129 | - break; |
|
130 | 137 | } |
131 | 138 | |
132 | - $intoken = true; |
|
133 | - $quoted = false; |
|
134 | - $endquote = false; |
|
135 | - $tokarr = array(); |
|
136 | - |
|
137 | - } |
|
138 | - |
|
139 | - if ($quoted) $tokarr[] = $ch; |
|
140 | - else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; |
|
141 | - else { |
|
142 | - if ($ch == $endstmtchar) { |
|
139 | + if ($quoted) $tokarr[] = $ch; |
|
140 | + else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; |
|
141 | + else { |
|
142 | + if ($ch == $endstmtchar) { |
|
143 | + $tokens[$stmtno][] = implode('',$tokarr); |
|
144 | + $stmtno += 1; |
|
145 | + $tokens[$stmtno] = array(); |
|
146 | + $intoken = false; |
|
147 | + $tokarr = array(); |
|
148 | + break; |
|
149 | + } |
|
143 | 150 | $tokens[$stmtno][] = implode('',$tokarr); |
144 | - $stmtno += 1; |
|
145 | - $tokens[$stmtno] = array(); |
|
151 | + $tokens[$stmtno][] = $ch; |
|
146 | 152 | $intoken = false; |
147 | - $tokarr = array(); |
|
148 | - break; |
|
149 | 153 | } |
150 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
151 | - $tokens[$stmtno][] = $ch; |
|
152 | - $intoken = false; |
|
153 | - } |
|
154 | 154 | } |
155 | 155 | $pos += 1; |
156 | 156 | } |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | $f1 = array(); |
470 | 470 | foreach($f0 as $token) { |
471 | 471 | switch (strtoupper($token)) { |
472 | - case 'CONSTRAINT': |
|
473 | - case 'DEFAULT': |
|
474 | - $hasparam = $token; |
|
475 | - break; |
|
476 | - default: |
|
477 | - if ($hasparam) $f1[$hasparam] = $token; |
|
478 | - else $f1[] = $token; |
|
479 | - $hasparam = false; |
|
480 | - break; |
|
472 | + case 'CONSTRAINT': |
|
473 | + case 'DEFAULT': |
|
474 | + $hasparam = $token; |
|
475 | + break; |
|
476 | + default: |
|
477 | + if ($hasparam) $f1[$hasparam] = $token; |
|
478 | + else $f1[] = $token; |
|
479 | + $hasparam = false; |
|
480 | + break; |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | $flds[] = $f1; |
@@ -511,31 +511,31 @@ discard block |
||
511 | 511 | else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); |
512 | 512 | |
513 | 513 | switch($attr) { |
514 | - case '0': |
|
515 | - case 'NAME': $fname = $v; break; |
|
516 | - case '1': |
|
517 | - case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; |
|
518 | - |
|
519 | - case 'SIZE': |
|
520 | - $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); |
|
521 | - if ($dotat === false) $fsize = $v; |
|
522 | - else { |
|
523 | - $fsize = substr($v,0,$dotat); |
|
524 | - $fprec = substr($v,$dotat+1); |
|
525 | - } |
|
526 | - break; |
|
527 | - case 'UNSIGNED': $funsigned = true; break; |
|
528 | - case 'AUTOINCREMENT': |
|
529 | - case 'AUTO': $fautoinc = true; $fnotnull = true; break; |
|
530 | - case 'KEY': |
|
531 | - case 'PRIMARY': $fprimary = $v; $fnotnull = true; break; |
|
532 | - case 'DEF': |
|
533 | - case 'DEFAULT': $fdefault = $v; break; |
|
534 | - case 'NOTNULL': $fnotnull = $v; break; |
|
535 | - case 'NOQUOTE': $fnoquote = $v; break; |
|
536 | - case 'DEFDATE': $fdefdate = $v; break; |
|
537 | - case 'DEFTIMESTAMP': $fdefts = $v; break; |
|
538 | - case 'CONSTRAINT': $fconstraint = $v; break; |
|
514 | + case '0': |
|
515 | + case 'NAME': $fname = $v; break; |
|
516 | + case '1': |
|
517 | + case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; |
|
518 | + |
|
519 | + case 'SIZE': |
|
520 | + $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); |
|
521 | + if ($dotat === false) $fsize = $v; |
|
522 | + else { |
|
523 | + $fsize = substr($v,0,$dotat); |
|
524 | + $fprec = substr($v,$dotat+1); |
|
525 | + } |
|
526 | + break; |
|
527 | + case 'UNSIGNED': $funsigned = true; break; |
|
528 | + case 'AUTOINCREMENT': |
|
529 | + case 'AUTO': $fautoinc = true; $fnotnull = true; break; |
|
530 | + case 'KEY': |
|
531 | + case 'PRIMARY': $fprimary = $v; $fnotnull = true; break; |
|
532 | + case 'DEF': |
|
533 | + case 'DEFAULT': $fdefault = $v; break; |
|
534 | + case 'NOTNULL': $fnotnull = $v; break; |
|
535 | + case 'NOQUOTE': $fnoquote = $v; break; |
|
536 | + case 'DEFDATE': $fdefdate = $v; break; |
|
537 | + case 'DEFTIMESTAMP': $fdefts = $v; break; |
|
538 | + case 'CONSTRAINT': $fconstraint = $v; break; |
|
539 | 539 | } //switch |
540 | 540 | } // foreach $fld |
541 | 541 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds"; |
26 | 26 | print "<p>$str</p>"; |
27 | -$a= Lens_ParseArgs($str); |
|
27 | +$a = Lens_ParseArgs($str); |
|
28 | 28 | print "<pre>"; |
29 | 29 | print_r($a); |
30 | 30 | print "</pre>"; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | @param tokenchars Include the following characters in tokens apart from A-Z and 0-9 |
52 | 52 | @returns 2 dimensional array containing parsed tokens. |
53 | 53 | */ |
54 | -function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-') |
|
54 | +function Lens_ParseArgs($args, $endstmtchar = ',', $tokenchars = '_.-') |
|
55 | 55 | { |
56 | 56 | $pos = 0; |
57 | 57 | $intoken = false; |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | $quoted = false; |
64 | 64 | |
65 | 65 | while ($pos < $max) { |
66 | - $ch = substr($args,$pos,1); |
|
67 | - switch($ch) { |
|
66 | + $ch = substr($args, $pos, 1); |
|
67 | + switch ($ch) { |
|
68 | 68 | case ' ': |
69 | 69 | case "\t": |
70 | 70 | case "\n": |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if (!$quoted) { |
73 | 73 | if ($intoken) { |
74 | 74 | $intoken = false; |
75 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
75 | + $tokens[$stmtno][] = implode('', $tokarr); |
|
76 | 76 | } |
77 | 77 | break; |
78 | 78 | } |
@@ -89,27 +89,27 @@ discard block |
||
89 | 89 | |
90 | 90 | if ($intoken) { |
91 | 91 | if (empty($endquote)) { |
92 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
92 | + $tokens[$stmtno][] = implode('', $tokarr); |
|
93 | 93 | if ($ch == '(') $endquote = ')'; |
94 | 94 | else $endquote = $ch; |
95 | 95 | $quoted = true; |
96 | 96 | $intoken = true; |
97 | 97 | $tokarr = array(); |
98 | 98 | } else if ($endquote == $ch) { |
99 | - $ch2 = substr($args,$pos+1,1); |
|
99 | + $ch2 = substr($args, $pos + 1, 1); |
|
100 | 100 | if ($ch2 == $endquote) { |
101 | 101 | $pos += 1; |
102 | 102 | $tokarr[] = $ch2; |
103 | 103 | } else { |
104 | 104 | $quoted = false; |
105 | 105 | $intoken = false; |
106 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
106 | + $tokens[$stmtno][] = implode('', $tokarr); |
|
107 | 107 | $endquote = ''; |
108 | 108 | } |
109 | 109 | } else |
110 | 110 | $tokarr[] = $ch; |
111 | 111 | |
112 | - }else { |
|
112 | + } else { |
|
113 | 113 | |
114 | 114 | if ($ch == '(') $endquote = ')'; |
115 | 115 | else $endquote = $ch; |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | if ($quoted) $tokarr[] = $ch; |
140 | - else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; |
|
140 | + else if (ctype_alnum($ch) || strpos($tokenchars, $ch) !== false) $tokarr[] = $ch; |
|
141 | 141 | else { |
142 | 142 | if ($ch == $endstmtchar) { |
143 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
143 | + $tokens[$stmtno][] = implode('', $tokarr); |
|
144 | 144 | $stmtno += 1; |
145 | 145 | $tokens[$stmtno] = array(); |
146 | 146 | $intoken = false; |
147 | 147 | $tokarr = array(); |
148 | 148 | break; |
149 | 149 | } |
150 | - $tokens[$stmtno][] = implode('',$tokarr); |
|
150 | + $tokens[$stmtno][] = implode('', $tokarr); |
|
151 | 151 | $tokens[$stmtno][] = $ch; |
152 | 152 | $intoken = false; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | $pos += 1; |
156 | 156 | } |
157 | - if ($intoken) $tokens[$stmtno][] = implode('',$tokarr); |
|
157 | + if ($intoken) $tokens[$stmtno][] = implode('', $tokarr); |
|
158 | 158 | |
159 | 159 | return $tokens; |
160 | 160 | } |
@@ -169,23 +169,23 @@ discard block |
||
169 | 169 | var $addCol = ' ADD'; |
170 | 170 | var $alterCol = ' ALTER COLUMN'; |
171 | 171 | var $dropCol = ' DROP COLUMN'; |
172 | - var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default) |
|
172 | + var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default) |
|
173 | 173 | var $nameRegex = '\w'; |
174 | 174 | var $nameRegexBrackets = 'a-zA-Z0-9_\(\)'; |
175 | 175 | var $schema = false; |
176 | 176 | var $serverInfo = array(); |
177 | 177 | var $autoIncrement = false; |
178 | 178 | var $dataProvider; |
179 | - var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql |
|
180 | - var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob |
|
179 | + var $invalidResizeTypes4 = array('CLOB', 'BLOB', 'TEXT', 'DATE', 'TIME'); // for changetablesql |
|
180 | + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob |
|
181 | 181 | /// in other words, we use a text area for editting. |
182 | 182 | |
183 | - function GetCommentSQL($table,$col) |
|
183 | + function GetCommentSQL($table, $col) |
|
184 | 184 | { |
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
188 | - function SetCommentSQL($table,$col,$cmt) |
|
188 | + function SetCommentSQL($table, $col, $cmt) |
|
189 | 189 | { |
190 | 190 | return false; |
191 | 191 | } |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | return $this->connection->MetaTables(); |
197 | 197 | } |
198 | 198 | |
199 | - function MetaColumns($tab, $upper=true, $schema=false) |
|
199 | + function MetaColumns($tab, $upper = true, $schema = false) |
|
200 | 200 | { |
201 | 201 | if (!$this->connection->IsConnected()) return array(); |
202 | 202 | return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); |
203 | 203 | } |
204 | 204 | |
205 | - function MetaPrimaryKeys($tab,$owner=false,$intkey=false) |
|
205 | + function MetaPrimaryKeys($tab, $owner = false, $intkey = false) |
|
206 | 206 | { |
207 | 207 | if (!$this->connection->IsConnected()) return array(); |
208 | 208 | return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner); |
215 | 215 | } |
216 | 216 | |
217 | - function MetaType($t,$len=-1,$fieldobj=false) |
|
217 | + function MetaType($t, $len = -1, $fieldobj = false) |
|
218 | 218 | { |
219 | - return ADORecordSet::MetaType($t,$len,$fieldobj); |
|
219 | + return ADORecordSet::MetaType($t, $len, $fieldobj); |
|
220 | 220 | } |
221 | 221 | |
222 | - function NameQuote($name = NULL,$allowBrackets=false) |
|
222 | + function NameQuote($name = NULL, $allowBrackets = false) |
|
223 | 223 | { |
224 | 224 | if (!is_string($name)) { |
225 | 225 | return FALSE; |
@@ -227,23 +227,23 @@ discard block |
||
227 | 227 | |
228 | 228 | $name = trim($name); |
229 | 229 | |
230 | - if ( !is_object($this->connection) ) { |
|
230 | + if (!is_object($this->connection)) { |
|
231 | 231 | return $name; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $quote = $this->connection->nameQuote; |
235 | 235 | |
236 | 236 | // if name is of the form `name`, quote it |
237 | - if ( preg_match('/^`(.+)`$/', $name, $matches) ) { |
|
238 | - return $quote . $matches[1] . $quote; |
|
237 | + if (preg_match('/^`(.+)`$/', $name, $matches)) { |
|
238 | + return $quote.$matches[1].$quote; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // if brackets are allowed, quote only the rest, |
242 | 242 | // to allow to limit indexes on colums, eg "column(32)" |
243 | - if ($allowBrackets && preg_match('/^(.*) *(\(\d+\))$/',$name,$matches)) { |
|
244 | - return $quote . $matches[1] . $quote . ' '. $matches[2]; |
|
243 | + if ($allowBrackets && preg_match('/^(.*) *(\(\d+\))$/', $name, $matches)) { |
|
244 | + return $quote.$matches[1].$quote.' '.$matches[2]; |
|
245 | 245 | } |
246 | - return $quote . $name . $quote; |
|
246 | + return $quote.$name.$quote; |
|
247 | 247 | |
248 | 248 | // not used stock ADOdb code, which only quotes names with special chars, |
249 | 249 | // which does not help with column names using reserved words, eg. "timestamp" in phpfreechat |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | // if name contains special characters, quote it |
252 | 252 | $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex; |
253 | 253 | |
254 | - if ( !preg_match('/^[' . $regex . ']+$/', $name) ) { |
|
255 | - return $quote . $name . $quote; |
|
254 | + if (!preg_match('/^['.$regex.']+$/', $name)) { |
|
255 | + return $quote.$name.$quote; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | return $name; |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | |
261 | 261 | function TableName($name) |
262 | 262 | { |
263 | - if ( $this->schema ) { |
|
264 | - return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name); |
|
263 | + if ($this->schema) { |
|
264 | + return $this->NameQuote($this->schema).'.'.$this->NameQuote($name); |
|
265 | 265 | } |
266 | 266 | return $this->NameQuote($name); |
267 | 267 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $rez = 2; |
273 | 273 | $conn = &$this->connection; |
274 | 274 | $saved = $conn->debug; |
275 | - foreach($sql as $line) { |
|
275 | + foreach ($sql as $line) { |
|
276 | 276 | |
277 | 277 | if ($this->debug) $conn->debug = true; |
278 | 278 | $ok = $conn->Execute($line); |
@@ -309,12 +309,12 @@ discard block |
||
309 | 309 | return $meta; |
310 | 310 | } |
311 | 311 | |
312 | - function CreateDatabase($dbname,$options=false) |
|
312 | + function CreateDatabase($dbname, $options = false) |
|
313 | 313 | { |
314 | 314 | $options = $this->_Options($options); |
315 | 315 | $sql = array(); |
316 | 316 | |
317 | - $s = 'CREATE DATABASE ' . $this->NameQuote($dbname); |
|
317 | + $s = 'CREATE DATABASE '.$this->NameQuote($dbname); |
|
318 | 318 | if (isset($options[$this->upperName])) |
319 | 319 | $s .= ' '.$options[$this->upperName]; |
320 | 320 | |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) |
329 | 329 | { |
330 | 330 | if (!is_array($flds)) { |
331 | - $flds = explode(',',$flds); |
|
331 | + $flds = explode(',', $flds); |
|
332 | 332 | } |
333 | 333 | |
334 | - foreach($flds as $key => $fld) { |
|
334 | + foreach ($flds as $key => $fld) { |
|
335 | 335 | # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32) |
336 | - $flds[$key] = $this->NameQuote($fld,$allowBrackets=true); |
|
336 | + $flds[$key] = $this->NameQuote($fld, $allowBrackets = true); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions)); |
340 | 340 | } |
341 | 341 | |
342 | - function DropIndexSQL ($idxname, $tabname = NULL) |
|
342 | + function DropIndexSQL($idxname, $tabname = NULL) |
|
343 | 343 | { |
344 | 344 | return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname))); |
345 | 345 | } |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | |
352 | 352 | function AddColumnSQL($tabname, $flds) |
353 | 353 | { |
354 | - $tabname = $this->TableName ($tabname); |
|
354 | + $tabname = $this->TableName($tabname); |
|
355 | 355 | $sql = array(); |
356 | - list($lines,$pkey) = $this->_GenFields($flds); |
|
357 | - $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; |
|
358 | - foreach($lines as $v) { |
|
359 | - $sql[] = $alter . $v; |
|
356 | + list($lines, $pkey) = $this->_GenFields($flds); |
|
357 | + $alter = 'ALTER TABLE '.$tabname.$this->addCol.' '; |
|
358 | + foreach ($lines as $v) { |
|
359 | + $sql[] = $alter.$v; |
|
360 | 360 | } |
361 | 361 | return $sql; |
362 | 362 | } |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' |
373 | 373 | * @return array with SQL strings |
374 | 374 | */ |
375 | - function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') |
|
375 | + function AlterColumnSQL($tabname, $flds, $tableflds = '', $tableoptions = '') |
|
376 | 376 | { |
377 | - $tabname = $this->TableName ($tabname); |
|
377 | + $tabname = $this->TableName($tabname); |
|
378 | 378 | $sql = array(); |
379 | - list($lines,$pkey) = $this->_GenFields($flds); |
|
380 | - $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; |
|
381 | - foreach($lines as $v) { |
|
382 | - $sql[] = $alter . $v; |
|
379 | + list($lines, $pkey) = $this->_GenFields($flds); |
|
380 | + $alter = 'ALTER TABLE '.$tabname.$this->alterCol.' '; |
|
381 | + foreach ($lines as $v) { |
|
382 | + $sql[] = $alter.$v; |
|
383 | 383 | } |
384 | 384 | return $sql; |
385 | 385 | } |
@@ -394,15 +394,15 @@ discard block |
||
394 | 394 | * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' |
395 | 395 | * @return array with SQL strings |
396 | 396 | */ |
397 | - function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') |
|
397 | + function RenameColumnSQL($tabname, $oldcolumn, $newcolumn, $flds = '') |
|
398 | 398 | { |
399 | - $tabname = $this->TableName ($tabname); |
|
399 | + $tabname = $this->TableName($tabname); |
|
400 | 400 | if ($flds) { |
401 | - list($lines,$pkey) = $this->_GenFields($flds); |
|
401 | + list($lines, $pkey) = $this->_GenFields($flds); |
|
402 | 402 | list(,$first) = each($lines); |
403 | - list(,$column_def) = preg_split("/[\t ]+/",$first,2); |
|
403 | + list(,$column_def) = preg_split("/[\t ]+/", $first, 2); |
|
404 | 404 | } |
405 | - return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); |
|
405 | + return array(sprintf($this->renameColumn, $tabname, $this->NameQuote($oldcolumn), $this->NameQuote($newcolumn), $column_def)); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -416,58 +416,58 @@ discard block |
||
416 | 416 | * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' |
417 | 417 | * @return array with SQL strings |
418 | 418 | */ |
419 | - function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') |
|
419 | + function DropColumnSQL($tabname, $flds, $tableflds = '', $tableoptions = '') |
|
420 | 420 | { |
421 | - $tabname = $this->TableName ($tabname); |
|
422 | - if (!is_array($flds)) $flds = explode(',',$flds); |
|
421 | + $tabname = $this->TableName($tabname); |
|
422 | + if (!is_array($flds)) $flds = explode(',', $flds); |
|
423 | 423 | $sql = array(); |
424 | - $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' '; |
|
425 | - foreach($flds as $v) { |
|
426 | - $sql[] = $alter . $this->NameQuote($v); |
|
424 | + $alter = 'ALTER TABLE '.$tabname.$this->dropCol.' '; |
|
425 | + foreach ($flds as $v) { |
|
426 | + $sql[] = $alter.$this->NameQuote($v); |
|
427 | 427 | } |
428 | 428 | return $sql; |
429 | 429 | } |
430 | 430 | |
431 | 431 | function DropTableSQL($tabname) |
432 | 432 | { |
433 | - return array (sprintf($this->dropTable, $this->TableName($tabname))); |
|
433 | + return array(sprintf($this->dropTable, $this->TableName($tabname))); |
|
434 | 434 | } |
435 | 435 | |
436 | - function RenameTableSQL($tabname,$newname) |
|
436 | + function RenameTableSQL($tabname, $newname) |
|
437 | 437 | { |
438 | - return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); |
|
438 | + return array(sprintf($this->renameTable, $this->TableName($tabname), $this->TableName($newname))); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /* |
442 | 442 | Generate the SQL to create table. Returns an array of sql strings. |
443 | 443 | */ |
444 | - function CreateTableSQL($tabname, $flds, $tableoptions=false) |
|
444 | + function CreateTableSQL($tabname, $flds, $tableoptions = false) |
|
445 | 445 | { |
446 | 446 | if (!$tableoptions) $tableoptions = array(); |
447 | 447 | |
448 | - list($lines,$pkey) = $this->_GenFields($flds, true); |
|
448 | + list($lines, $pkey) = $this->_GenFields($flds, true); |
|
449 | 449 | |
450 | 450 | $taboptions = $this->_Options($tableoptions); |
451 | - $tabname = $this->TableName ($tabname); |
|
452 | - $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); |
|
451 | + $tabname = $this->TableName($tabname); |
|
452 | + $sql = $this->_TableSQL($tabname, $lines, $pkey, $taboptions); |
|
453 | 453 | |
454 | - $tsql = $this->_Triggers($tabname,$taboptions); |
|
455 | - foreach($tsql as $s) $sql[] = $s; |
|
454 | + $tsql = $this->_Triggers($tabname, $taboptions); |
|
455 | + foreach ($tsql as $s) $sql[] = $s; |
|
456 | 456 | |
457 | 457 | return $sql; |
458 | 458 | } |
459 | 459 | |
460 | - function _GenFields($flds,$widespacing=false) |
|
460 | + function _GenFields($flds, $widespacing = false) |
|
461 | 461 | { |
462 | 462 | if (is_string($flds)) { |
463 | 463 | $padding = ' '; |
464 | 464 | $txt = $flds.$padding; |
465 | 465 | $flds = array(); |
466 | - $flds0 = Lens_ParseArgs($txt,','); |
|
466 | + $flds0 = Lens_ParseArgs($txt, ','); |
|
467 | 467 | $hasparam = false; |
468 | - foreach($flds0 as $f0) { |
|
468 | + foreach ($flds0 as $f0) { |
|
469 | 469 | $f1 = array(); |
470 | - foreach($f0 as $token) { |
|
470 | + foreach ($f0 as $token) { |
|
471 | 471 | switch (strtoupper($token)) { |
472 | 472 | case 'CONSTRAINT': |
473 | 473 | case 'DEFAULT': |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $this->autoIncrement = false; |
488 | 488 | $lines = array(); |
489 | 489 | $pkey = array(); |
490 | - foreach($flds as $fld) { |
|
490 | + foreach ($flds as $fld) { |
|
491 | 491 | $fld = _array_change_key_case($fld); |
492 | 492 | |
493 | 493 | $fname = false; |
@@ -506,22 +506,22 @@ discard block |
||
506 | 506 | |
507 | 507 | //----------------- |
508 | 508 | // Parse attributes |
509 | - foreach($fld as $attr => $v) { |
|
509 | + foreach ($fld as $attr => $v) { |
|
510 | 510 | if ($attr == 2 && is_numeric($v)) $attr = 'SIZE'; |
511 | 511 | else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); |
512 | 512 | |
513 | - switch($attr) { |
|
513 | + switch ($attr) { |
|
514 | 514 | case '0': |
515 | 515 | case 'NAME': $fname = $v; break; |
516 | 516 | case '1': |
517 | 517 | case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; |
518 | 518 | |
519 | 519 | case 'SIZE': |
520 | - $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); |
|
520 | + $dotat = strpos($v, '.'); if ($dotat === false) $dotat = strpos($v, ','); |
|
521 | 521 | if ($dotat === false) $fsize = $v; |
522 | 522 | else { |
523 | - $fsize = substr($v,0,$dotat); |
|
524 | - $fprec = substr($v,$dotat+1); |
|
523 | + $fsize = substr($v, 0, $dotat); |
|
524 | + $fprec = substr($v, $dotat + 1); |
|
525 | 525 | } |
526 | 526 | break; |
527 | 527 | case 'UNSIGNED': $funsigned = true; break; |
@@ -568,33 +568,33 @@ discard block |
||
568 | 568 | //-------------------- |
569 | 569 | // CONSTRUCT FIELD SQL |
570 | 570 | if ($fdefts) { |
571 | - if (substr($this->connection->databaseType,0,5) == 'mysql') { |
|
571 | + if (substr($this->connection->databaseType, 0, 5) == 'mysql') { |
|
572 | 572 | $ftype = 'TIMESTAMP'; |
573 | 573 | } else { |
574 | 574 | $fdefault = $this->connection->sysTimeStamp; |
575 | 575 | } |
576 | 576 | } else if ($fdefdate) { |
577 | - if (substr($this->connection->databaseType,0,5) == 'mysql') { |
|
577 | + if (substr($this->connection->databaseType, 0, 5) == 'mysql') { |
|
578 | 578 | $ftype = 'TIMESTAMP'; |
579 | 579 | } else { |
580 | 580 | $fdefault = $this->connection->sysDate; |
581 | 581 | } |
582 | 582 | } else if ($fdefault !== false && !$fnoquote) |
583 | 583 | if ($ty == 'C' or $ty == 'X' or |
584 | - ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) |
|
585 | - if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') |
|
584 | + (substr($fdefault, 0, 1) != "'" && !is_numeric($fdefault))) |
|
585 | + if (strlen($fdefault) != 1 && substr($fdefault, 0, 1) == ' ' && substr($fdefault, strlen($fdefault) - 1) == ' ') |
|
586 | 586 | $fdefault = trim($fdefault); |
587 | 587 | else if (strtolower($fdefault) != 'null') |
588 | 588 | $fdefault = $this->connection->qstr($fdefault); |
589 | - $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); |
|
589 | + $suffix = $this->_CreateSuffix($fname, $ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned); |
|
590 | 590 | |
591 | - if ($widespacing) $fname = str_pad($fname,24); |
|
591 | + if ($widespacing) $fname = str_pad($fname, 24); |
|
592 | 592 | $lines[$fid] = $fname.' '.$ftype.$suffix; |
593 | 593 | |
594 | 594 | if ($fautoinc) $this->autoIncrement = true; |
595 | 595 | } // foreach $flds |
596 | 596 | |
597 | - return array($lines,$pkey); |
|
597 | + return array($lines, $pkey); |
|
598 | 598 | } |
599 | 599 | /* |
600 | 600 | GENERATE THE SIZE PART OF THE DATATYPE |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function _GetSize($ftype, $ty, $fsize, $fprec) |
605 | 605 | { |
606 | - if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) { |
|
606 | + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype, '(') === false) { |
|
607 | 607 | $ftype .= "(".$fsize; |
608 | 608 | if (strlen($fprec)) $ftype .= ",".$fprec; |
609 | 609 | $ftype .= ')'; |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | |
615 | 615 | // return string must begin with space |
616 | - function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) |
|
616 | + function _CreateSuffix($fname, $ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned) |
|
617 | 617 | { |
618 | 618 | $suffix = ''; |
619 | 619 | if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; |
@@ -626,26 +626,26 @@ discard block |
||
626 | 626 | { |
627 | 627 | $sql = array(); |
628 | 628 | |
629 | - if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { |
|
630 | - $sql[] = sprintf ($this->dropIndex, $idxname); |
|
631 | - if ( isset($idxoptions['DROP']) ) |
|
629 | + if (isset($idxoptions['REPLACE']) || isset($idxoptions['DROP'])) { |
|
630 | + $sql[] = sprintf($this->dropIndex, $idxname); |
|
631 | + if (isset($idxoptions['DROP'])) |
|
632 | 632 | return $sql; |
633 | 633 | } |
634 | 634 | |
635 | - if ( empty ($flds) ) { |
|
635 | + if (empty ($flds)) { |
|
636 | 636 | return $sql; |
637 | 637 | } |
638 | 638 | |
639 | 639 | $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; |
640 | 640 | |
641 | - $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; |
|
641 | + $s = 'CREATE'.$unique.' INDEX '.$idxname.' ON '.$tabname.' '; |
|
642 | 642 | |
643 | - if ( isset($idxoptions[$this->upperName]) ) |
|
643 | + if (isset($idxoptions[$this->upperName])) |
|
644 | 644 | $s .= $idxoptions[$this->upperName]; |
645 | 645 | |
646 | - if ( is_array($flds) ) |
|
647 | - $flds = implode(', ',$flds); |
|
648 | - $s .= '(' . $flds . ')'; |
|
646 | + if (is_array($flds)) |
|
647 | + $flds = implode(', ', $flds); |
|
648 | + $s .= '('.$flds.')'; |
|
649 | 649 | $sql[] = $s; |
650 | 650 | |
651 | 651 | return $sql; |
@@ -656,25 +656,25 @@ discard block |
||
656 | 656 | return false; |
657 | 657 | } |
658 | 658 | |
659 | - function _TableSQL($tabname,$lines,$pkey,$tableoptions) |
|
659 | + function _TableSQL($tabname, $lines, $pkey, $tableoptions) |
|
660 | 660 | { |
661 | 661 | $sql = array(); |
662 | 662 | |
663 | 663 | if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) { |
664 | - $sql[] = sprintf($this->dropTable,$tabname); |
|
664 | + $sql[] = sprintf($this->dropTable, $tabname); |
|
665 | 665 | if ($this->autoIncrement) { |
666 | 666 | $sInc = $this->_DropAutoIncrement($tabname); |
667 | 667 | if ($sInc) $sql[] = $sInc; |
668 | 668 | } |
669 | - if ( isset ($tableoptions['DROP']) ) { |
|
669 | + if (isset ($tableoptions['DROP'])) { |
|
670 | 670 | return $sql; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | $s = "CREATE TABLE $tabname (\n"; |
674 | 674 | $s .= implode(",\n", $lines); |
675 | - if (sizeof($pkey)>0) { |
|
675 | + if (sizeof($pkey) > 0) { |
|
676 | 676 | $s .= ",\n PRIMARY KEY ("; |
677 | - $s .= implode(", ",$pkey).")"; |
|
677 | + $s .= implode(", ", $pkey).")"; |
|
678 | 678 | } |
679 | 679 | if (isset($tableoptions['CONSTRAINTS'])) |
680 | 680 | $s .= "\n".$tableoptions['CONSTRAINTS']; |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | GENERATE TRIGGERS IF NEEDED |
694 | 694 | used when table has auto-incrementing field that is emulated using triggers |
695 | 695 | */ |
696 | - function _Triggers($tabname,$taboptions) |
|
696 | + function _Triggers($tabname, $taboptions) |
|
697 | 697 | { |
698 | 698 | return array(); |
699 | 699 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | { |
706 | 706 | if (!is_array($opts)) return array(); |
707 | 707 | $newopts = array(); |
708 | - foreach($opts as $k => $v) { |
|
708 | + foreach ($opts as $k => $v) { |
|
709 | 709 | if (is_numeric($k)) $newopts[strtoupper($v)] = $v; |
710 | 710 | else $newopts[strtoupper($k)] = $v; |
711 | 711 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | if (isset($savem)) $this->connection->SetFetchMode($savem); |
736 | 736 | $ADODB_FETCH_MODE = $save; |
737 | 737 | |
738 | - if ( empty($cols)) { |
|
738 | + if (empty($cols)) { |
|
739 | 739 | return $this->CreateTableSQL($tablename, $flds, $tableoptions); |
740 | 740 | } |
741 | 741 | |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | // if the Metatype and size is exactly the |
746 | 746 | // same, ignore - by Mark Newham |
747 | 747 | $holdflds = array(); |
748 | - foreach($flds as $k=>$v) { |
|
749 | - if ( isset($cols[$k]) && is_object($cols[$k]) ) { |
|
748 | + foreach ($flds as $k=>$v) { |
|
749 | + if (isset($cols[$k]) && is_object($cols[$k])) { |
|
750 | 750 | $c = $cols[$k]; |
751 | 751 | $ml = $c->max_length; |
752 | - $mt = &$this->MetaType($c->type,$ml); |
|
752 | + $mt = &$this->MetaType($c->type, $ml); |
|
753 | 753 | if ($ml == -1) $ml = ''; |
754 | 754 | if ($mt == 'X') $ml = $v['SIZE']; |
755 | - if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { |
|
755 | + if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { |
|
756 | 756 | $holdflds[$k] = $v; |
757 | 757 | } |
758 | 758 | } else { |
@@ -764,21 +764,21 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | // already exists, alter table instead |
767 | - list($lines,$pkey) = $this->_GenFields($flds); |
|
768 | - $alter = 'ALTER TABLE ' . $this->TableName($tablename); |
|
767 | + list($lines, $pkey) = $this->_GenFields($flds); |
|
768 | + $alter = 'ALTER TABLE '.$this->TableName($tablename); |
|
769 | 769 | $sql = array(); |
770 | 770 | |
771 | - foreach ( $lines as $id => $v ) { |
|
772 | - if ( isset($cols[$id]) && is_object($cols[$id]) ) { |
|
771 | + foreach ($lines as $id => $v) { |
|
772 | + if (isset($cols[$id]) && is_object($cols[$id])) { |
|
773 | 773 | |
774 | - $flds = Lens_ParseArgs($v,','); |
|
774 | + $flds = Lens_ParseArgs($v, ','); |
|
775 | 775 | |
776 | 776 | // We are trying to change the size of the field, if not allowed, simply ignore the request. |
777 | - if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue; |
|
777 | + if ($flds && in_array(strtoupper(substr($flds[0][1], 0, 4)), $this->invalidResizeTypes4)) continue; |
|
778 | 778 | |
779 | - $sql[] = $alter . $this->alterCol . ' ' . $v; |
|
779 | + $sql[] = $alter.$this->alterCol.' '.$v; |
|
780 | 780 | } else { |
781 | - $sql[] = $alter . $this->addCol . ' ' . $v; |
|
781 | + $sql[] = $alter.$this->addCol.' '.$v; |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 |
@@ -18,7 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | |
20 | 20 | // security - hide paths |
21 | -if (!defined('ADODB_DIR')) die(); |
|
21 | +if (!defined('ADODB_DIR')) |
|
22 | +{ |
|
23 | + die(); |
|
24 | +} |
|
22 | 25 | |
23 | 26 | function Lens_ParseTest() |
24 | 27 | { |
@@ -31,8 +34,10 @@ discard block |
||
31 | 34 | } |
32 | 35 | |
33 | 36 | |
34 | -if (!function_exists('ctype_alnum')) { |
|
35 | - function ctype_alnum($text) { |
|
37 | +if (!function_exists('ctype_alnum')) |
|
38 | +{ |
|
39 | + function ctype_alnum($text) |
|
40 | + { |
|
36 | 41 | return preg_match('/^[a-z0-9]*$/i', $text); |
37 | 42 | } |
38 | 43 | } |
@@ -62,15 +67,19 @@ discard block |
||
62 | 67 | $max = strlen($args); |
63 | 68 | $quoted = false; |
64 | 69 | |
65 | - while ($pos < $max) { |
|
70 | + while ($pos < $max) |
|
71 | + { |
|
66 | 72 | $ch = substr($args,$pos,1); |
67 | - switch($ch) { |
|
73 | + switch($ch) |
|
74 | + { |
|
68 | 75 | case ' ': |
69 | 76 | case "\t": |
70 | 77 | case "\n": |
71 | 78 | case "\r": |
72 | - if (!$quoted) { |
|
73 | - if ($intoken) { |
|
79 | + if (!$quoted) |
|
80 | + { |
|
81 | + if ($intoken) |
|
82 | + { |
|
74 | 83 | $intoken = false; |
75 | 84 | $tokens[$stmtno][] = implode('',$tokarr); |
76 | 85 | } |
@@ -81,49 +90,78 @@ discard block |
||
81 | 90 | break; |
82 | 91 | |
83 | 92 | case '`': |
84 | - if ($intoken) $tokarr[] = $ch; |
|
93 | + if ($intoken) |
|
94 | + { |
|
95 | + $tokarr[] = $ch; |
|
96 | + } |
|
85 | 97 | case '(': |
86 | 98 | case ')': |
87 | 99 | case '"': |
88 | 100 | case "'": |
89 | 101 | |
90 | - if ($intoken) { |
|
91 | - if (empty($endquote)) { |
|
102 | + if ($intoken) |
|
103 | + { |
|
104 | + if (empty($endquote)) |
|
105 | + { |
|
92 | 106 | $tokens[$stmtno][] = implode('',$tokarr); |
93 | - if ($ch == '(') $endquote = ')'; |
|
94 | - else $endquote = $ch; |
|
107 | + if ($ch == '(') |
|
108 | + { |
|
109 | + $endquote = ')'; |
|
110 | + } |
|
111 | + else { |
|
112 | + $endquote = $ch; |
|
113 | + } |
|
95 | 114 | $quoted = true; |
96 | 115 | $intoken = true; |
97 | 116 | $tokarr = array(); |
98 | - } else if ($endquote == $ch) { |
|
117 | + } |
|
118 | + else if ($endquote == $ch) |
|
119 | + { |
|
99 | 120 | $ch2 = substr($args,$pos+1,1); |
100 | - if ($ch2 == $endquote) { |
|
121 | + if ($ch2 == $endquote) |
|
122 | + { |
|
101 | 123 | $pos += 1; |
102 | 124 | $tokarr[] = $ch2; |
103 | - } else { |
|
125 | + } |
|
126 | + else |
|
127 | + { |
|
104 | 128 | $quoted = false; |
105 | 129 | $intoken = false; |
106 | 130 | $tokens[$stmtno][] = implode('',$tokarr); |
107 | 131 | $endquote = ''; |
108 | 132 | } |
109 | - } else |
|
110 | - $tokarr[] = $ch; |
|
133 | + } |
|
134 | + else { |
|
135 | + $tokarr[] = $ch; |
|
136 | + } |
|
111 | 137 | |
112 | - }else { |
|
138 | + } |
|
139 | + else |
|
140 | + { |
|
113 | 141 | |
114 | - if ($ch == '(') $endquote = ')'; |
|
115 | - else $endquote = $ch; |
|
142 | + if ($ch == '(') |
|
143 | + { |
|
144 | + $endquote = ')'; |
|
145 | + } |
|
146 | + else { |
|
147 | + $endquote = $ch; |
|
148 | + } |
|
116 | 149 | $quoted = true; |
117 | 150 | $intoken = true; |
118 | 151 | $tokarr = array(); |
119 | - if ($ch == '`') $tokarr[] = '`'; |
|
152 | + if ($ch == '`') |
|
153 | + { |
|
154 | + $tokarr[] = '`'; |
|
155 | + } |
|
120 | 156 | } |
121 | 157 | break; |
122 | 158 | |
123 | 159 | default: |
124 | 160 | |
125 | - if (!$intoken) { |
|
126 | - if ($ch == $endstmtchar) { |
|
161 | + if (!$intoken) |
|
162 | + { |
|
163 | + if ($ch == $endstmtchar) |
|
164 | + { |
|
127 | 165 | $stmtno += 1; |
128 | 166 | $tokens[$stmtno] = array(); |
129 | 167 | break; |
@@ -136,10 +174,18 @@ discard block |
||
136 | 174 | |
137 | 175 | } |
138 | 176 | |
139 | - if ($quoted) $tokarr[] = $ch; |
|
140 | - else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; |
|
141 | - else { |
|
142 | - if ($ch == $endstmtchar) { |
|
177 | + if ($quoted) |
|
178 | + { |
|
179 | + $tokarr[] = $ch; |
|
180 | + } |
|
181 | + else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) |
|
182 | + { |
|
183 | + $tokarr[] = $ch; |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
187 | + if ($ch == $endstmtchar) |
|
188 | + { |
|
143 | 189 | $tokens[$stmtno][] = implode('',$tokarr); |
144 | 190 | $stmtno += 1; |
145 | 191 | $tokens[$stmtno] = array(); |
@@ -154,13 +200,17 @@ discard block |
||
154 | 200 | } |
155 | 201 | $pos += 1; |
156 | 202 | } |
157 | - if ($intoken) $tokens[$stmtno][] = implode('',$tokarr); |
|
203 | + if ($intoken) |
|
204 | + { |
|
205 | + $tokens[$stmtno][] = implode('',$tokarr); |
|
206 | + } |
|
158 | 207 | |
159 | 208 | return $tokens; |
160 | 209 | } |
161 | 210 | |
162 | 211 | |
163 | -class ADODB_DataDict { |
|
212 | +class ADODB_DataDict |
|
213 | +{ |
|
164 | 214 | var $connection; |
165 | 215 | var $debug = false; |
166 | 216 | var $dropTable = 'DROP TABLE %s'; |
@@ -192,25 +242,37 @@ discard block |
||
192 | 242 | |
193 | 243 | function MetaTables() |
194 | 244 | { |
195 | - if (!$this->connection->IsConnected()) return array(); |
|
245 | + if (!$this->connection->IsConnected()) |
|
246 | + { |
|
247 | + return array(); |
|
248 | + } |
|
196 | 249 | return $this->connection->MetaTables(); |
197 | 250 | } |
198 | 251 | |
199 | 252 | function MetaColumns($tab, $upper=true, $schema=false) |
200 | 253 | { |
201 | - if (!$this->connection->IsConnected()) return array(); |
|
254 | + if (!$this->connection->IsConnected()) |
|
255 | + { |
|
256 | + return array(); |
|
257 | + } |
|
202 | 258 | return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); |
203 | 259 | } |
204 | 260 | |
205 | 261 | function MetaPrimaryKeys($tab,$owner=false,$intkey=false) |
206 | 262 | { |
207 | - if (!$this->connection->IsConnected()) return array(); |
|
263 | + if (!$this->connection->IsConnected()) |
|
264 | + { |
|
265 | + return array(); |
|
266 | + } |
|
208 | 267 | return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); |
209 | 268 | } |
210 | 269 | |
211 | 270 | function MetaIndexes($table, $primary = false, $owner = false) |
212 | 271 | { |
213 | - if (!$this->connection->IsConnected()) return array(); |
|
272 | + if (!$this->connection->IsConnected()) |
|
273 | + { |
|
274 | + return array(); |
|
275 | + } |
|
214 | 276 | return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner); |
215 | 277 | } |
216 | 278 | |
@@ -221,26 +283,30 @@ discard block |
||
221 | 283 | |
222 | 284 | function NameQuote($name = NULL,$allowBrackets=false) |
223 | 285 | { |
224 | - if (!is_string($name)) { |
|
286 | + if (!is_string($name)) |
|
287 | + { |
|
225 | 288 | return FALSE; |
226 | 289 | } |
227 | 290 | |
228 | 291 | $name = trim($name); |
229 | 292 | |
230 | - if ( !is_object($this->connection) ) { |
|
293 | + if ( !is_object($this->connection) ) |
|
294 | + { |
|
231 | 295 | return $name; |
232 | 296 | } |
233 | 297 | |
234 | 298 | $quote = $this->connection->nameQuote; |
235 | 299 | |
236 | 300 | // if name is of the form `name`, quote it |
237 | - if ( preg_match('/^`(.+)`$/', $name, $matches) ) { |
|
301 | + if ( preg_match('/^`(.+)`$/', $name, $matches) ) |
|
302 | + { |
|
238 | 303 | return $quote . $matches[1] . $quote; |
239 | 304 | } |
240 | 305 | |
241 | 306 | // if brackets are allowed, quote only the rest, |
242 | 307 | // to allow to limit indexes on colums, eg "column(32)" |
243 | - if ($allowBrackets && preg_match('/^(.*) *(\(\d+\))$/',$name,$matches)) { |
|
308 | + if ($allowBrackets && preg_match('/^(.*) *(\(\d+\))$/',$name,$matches)) |
|
309 | + { |
|
244 | 310 | return $quote . $matches[1] . $quote . ' '. $matches[2]; |
245 | 311 | } |
246 | 312 | return $quote . $name . $quote; |
@@ -251,7 +317,8 @@ discard block |
||
251 | 317 | // if name contains special characters, quote it |
252 | 318 | $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex; |
253 | 319 | |
254 | - if ( !preg_match('/^[' . $regex . ']+$/', $name) ) { |
|
320 | + if ( !preg_match('/^[' . $regex . ']+$/', $name) ) |
|
321 | + { |
|
255 | 322 | return $quote . $name . $quote; |
256 | 323 | } |
257 | 324 | |
@@ -260,7 +327,8 @@ discard block |
||
260 | 327 | |
261 | 328 | function TableName($name) |
262 | 329 | { |
263 | - if ( $this->schema ) { |
|
330 | + if ( $this->schema ) |
|
331 | + { |
|
264 | 332 | return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name); |
265 | 333 | } |
266 | 334 | return $this->NameQuote($name); |
@@ -272,14 +340,25 @@ discard block |
||
272 | 340 | $rez = 2; |
273 | 341 | $conn = &$this->connection; |
274 | 342 | $saved = $conn->debug; |
275 | - foreach($sql as $line) { |
|
343 | + foreach($sql as $line) |
|
344 | + { |
|
276 | 345 | |
277 | - if ($this->debug) $conn->debug = true; |
|
346 | + if ($this->debug) |
|
347 | + { |
|
348 | + $conn->debug = true; |
|
349 | + } |
|
278 | 350 | $ok = $conn->Execute($line); |
279 | 351 | $conn->debug = $saved; |
280 | - if (!$ok) { |
|
281 | - if ($this->debug) ADOConnection::outp($conn->ErrorMsg()); |
|
282 | - if (!$continueOnError) return 0; |
|
352 | + if (!$ok) |
|
353 | + { |
|
354 | + if ($this->debug) |
|
355 | + { |
|
356 | + ADOConnection::outp($conn->ErrorMsg()); |
|
357 | + } |
|
358 | + if (!$continueOnError) |
|
359 | + { |
|
360 | + return 0; |
|
361 | + } |
|
283 | 362 | $rez = 1; |
284 | 363 | } |
285 | 364 | } |
@@ -316,7 +395,9 @@ discard block |
||
316 | 395 | |
317 | 396 | $s = 'CREATE DATABASE ' . $this->NameQuote($dbname); |
318 | 397 | if (isset($options[$this->upperName])) |
319 | - $s .= ' '.$options[$this->upperName]; |
|
398 | + { |
|
399 | + $s .= ' '.$options[$this->upperName]; |
|
400 | + } |
|
320 | 401 | |
321 | 402 | $sql[] = $s; |
322 | 403 | return $sql; |
@@ -327,11 +408,13 @@ discard block |
||
327 | 408 | */ |
328 | 409 | function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) |
329 | 410 | { |
330 | - if (!is_array($flds)) { |
|
411 | + if (!is_array($flds)) |
|
412 | + { |
|
331 | 413 | $flds = explode(',',$flds); |
332 | 414 | } |
333 | 415 | |
334 | - foreach($flds as $key => $fld) { |
|
416 | + foreach($flds as $key => $fld) |
|
417 | + { |
|
335 | 418 | # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32) |
336 | 419 | $flds[$key] = $this->NameQuote($fld,$allowBrackets=true); |
337 | 420 | } |
@@ -355,7 +438,8 @@ discard block |
||
355 | 438 | $sql = array(); |
356 | 439 | list($lines,$pkey) = $this->_GenFields($flds); |
357 | 440 | $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; |
358 | - foreach($lines as $v) { |
|
441 | + foreach($lines as $v) |
|
442 | + { |
|
359 | 443 | $sql[] = $alter . $v; |
360 | 444 | } |
361 | 445 | return $sql; |
@@ -378,7 +462,8 @@ discard block |
||
378 | 462 | $sql = array(); |
379 | 463 | list($lines,$pkey) = $this->_GenFields($flds); |
380 | 464 | $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; |
381 | - foreach($lines as $v) { |
|
465 | + foreach($lines as $v) |
|
466 | + { |
|
382 | 467 | $sql[] = $alter . $v; |
383 | 468 | } |
384 | 469 | return $sql; |
@@ -397,7 +482,8 @@ discard block |
||
397 | 482 | function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') |
398 | 483 | { |
399 | 484 | $tabname = $this->TableName ($tabname); |
400 | - if ($flds) { |
|
485 | + if ($flds) |
|
486 | + { |
|
401 | 487 | list($lines,$pkey) = $this->_GenFields($flds); |
402 | 488 | list(,$first) = each($lines); |
403 | 489 | list(,$column_def) = preg_split("/[\t ]+/",$first,2); |
@@ -419,10 +505,14 @@ discard block |
||
419 | 505 | function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') |
420 | 506 | { |
421 | 507 | $tabname = $this->TableName ($tabname); |
422 | - if (!is_array($flds)) $flds = explode(',',$flds); |
|
508 | + if (!is_array($flds)) |
|
509 | + { |
|
510 | + $flds = explode(',',$flds); |
|
511 | + } |
|
423 | 512 | $sql = array(); |
424 | 513 | $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' '; |
425 | - foreach($flds as $v) { |
|
514 | + foreach($flds as $v) |
|
515 | + { |
|
426 | 516 | $sql[] = $alter . $this->NameQuote($v); |
427 | 517 | } |
428 | 518 | return $sql; |
@@ -443,7 +533,10 @@ discard block |
||
443 | 533 | */ |
444 | 534 | function CreateTableSQL($tabname, $flds, $tableoptions=false) |
445 | 535 | { |
446 | - if (!$tableoptions) $tableoptions = array(); |
|
536 | + if (!$tableoptions) |
|
537 | + { |
|
538 | + $tableoptions = array(); |
|
539 | + } |
|
447 | 540 | |
448 | 541 | list($lines,$pkey) = $this->_GenFields($flds, true); |
449 | 542 | |
@@ -452,30 +545,42 @@ discard block |
||
452 | 545 | $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); |
453 | 546 | |
454 | 547 | $tsql = $this->_Triggers($tabname,$taboptions); |
455 | - foreach($tsql as $s) $sql[] = $s; |
|
548 | + foreach($tsql as $s) |
|
549 | + { |
|
550 | + $sql[] = $s; |
|
551 | + } |
|
456 | 552 | |
457 | 553 | return $sql; |
458 | 554 | } |
459 | 555 | |
460 | 556 | function _GenFields($flds,$widespacing=false) |
461 | 557 | { |
462 | - if (is_string($flds)) { |
|
558 | + if (is_string($flds)) |
|
559 | + { |
|
463 | 560 | $padding = ' '; |
464 | 561 | $txt = $flds.$padding; |
465 | 562 | $flds = array(); |
466 | 563 | $flds0 = Lens_ParseArgs($txt,','); |
467 | 564 | $hasparam = false; |
468 | - foreach($flds0 as $f0) { |
|
565 | + foreach($flds0 as $f0) |
|
566 | + { |
|
469 | 567 | $f1 = array(); |
470 | - foreach($f0 as $token) { |
|
471 | - switch (strtoupper($token)) { |
|
568 | + foreach($f0 as $token) |
|
569 | + { |
|
570 | + switch (strtoupper($token)) |
|
571 | + { |
|
472 | 572 | case 'CONSTRAINT': |
473 | 573 | case 'DEFAULT': |
474 | 574 | $hasparam = $token; |
475 | 575 | break; |
476 | 576 | default: |
477 | - if ($hasparam) $f1[$hasparam] = $token; |
|
478 | - else $f1[] = $token; |
|
577 | + if ($hasparam) |
|
578 | + { |
|
579 | + $f1[$hasparam] = $token; |
|
580 | + } |
|
581 | + else { |
|
582 | + $f1[] = $token; |
|
583 | + } |
|
479 | 584 | $hasparam = false; |
480 | 585 | break; |
481 | 586 | } |
@@ -487,7 +592,8 @@ discard block |
||
487 | 592 | $this->autoIncrement = false; |
488 | 593 | $lines = array(); |
489 | 594 | $pkey = array(); |
490 | - foreach($flds as $fld) { |
|
595 | + foreach($flds as $fld) |
|
596 | + { |
|
491 | 597 | $fld = _array_change_key_case($fld); |
492 | 598 | |
493 | 599 | $fname = false; |
@@ -506,20 +612,35 @@ discard block |
||
506 | 612 | |
507 | 613 | //----------------- |
508 | 614 | // Parse attributes |
509 | - foreach($fld as $attr => $v) { |
|
510 | - if ($attr == 2 && is_numeric($v)) $attr = 'SIZE'; |
|
511 | - else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); |
|
615 | + foreach($fld as $attr => $v) |
|
616 | + { |
|
617 | + if ($attr == 2 && is_numeric($v)) |
|
618 | + { |
|
619 | + $attr = 'SIZE'; |
|
620 | + } |
|
621 | + else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) |
|
622 | + { |
|
623 | + $attr = strtoupper($v); |
|
624 | + } |
|
512 | 625 | |
513 | - switch($attr) { |
|
626 | + switch($attr) |
|
627 | + { |
|
514 | 628 | case '0': |
515 | 629 | case 'NAME': $fname = $v; break; |
516 | 630 | case '1': |
517 | 631 | case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; |
518 | 632 | |
519 | 633 | case 'SIZE': |
520 | - $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); |
|
521 | - if ($dotat === false) $fsize = $v; |
|
522 | - else { |
|
634 | + $dotat = strpos($v,'.'); if ($dotat === false) |
|
635 | + { |
|
636 | + $dotat = strpos($v,','); |
|
637 | + } |
|
638 | + if ($dotat === false) |
|
639 | + { |
|
640 | + $fsize = $v; |
|
641 | + } |
|
642 | + else |
|
643 | + { |
|
523 | 644 | $fsize = substr($v,0,$dotat); |
524 | 645 | $fprec = substr($v,$dotat+1); |
525 | 646 | } |
@@ -541,57 +662,97 @@ discard block |
||
541 | 662 | |
542 | 663 | //-------------------- |
543 | 664 | // VALIDATE FIELD INFO |
544 | - if (!strlen($fname)) { |
|
545 | - if ($this->debug) ADOConnection::outp("Undefined NAME"); |
|
665 | + if (!strlen($fname)) |
|
666 | + { |
|
667 | + if ($this->debug) |
|
668 | + { |
|
669 | + ADOConnection::outp("Undefined NAME"); |
|
670 | + } |
|
546 | 671 | return false; |
547 | 672 | } |
548 | 673 | |
549 | 674 | $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname)); |
550 | 675 | $fname = $this->NameQuote($fname); |
551 | 676 | |
552 | - if (!strlen($ftype)) { |
|
553 | - if ($this->debug) ADOConnection::outp("Undefined TYPE for field '$fname'"); |
|
677 | + if (!strlen($ftype)) |
|
678 | + { |
|
679 | + if ($this->debug) |
|
680 | + { |
|
681 | + ADOConnection::outp("Undefined TYPE for field '$fname'"); |
|
682 | + } |
|
554 | 683 | return false; |
555 | - } else { |
|
684 | + } |
|
685 | + else |
|
686 | + { |
|
556 | 687 | $ftype = strtoupper($ftype); |
557 | 688 | } |
558 | 689 | |
559 | 690 | $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec); |
560 | 691 | |
561 | - if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls |
|
692 | + if ($ty == 'X' || $ty == 'X2' || $ty == 'B') |
|
693 | + { |
|
694 | + $fnotnull = false; |
|
695 | + } |
|
696 | + // some blob types do not accept nulls |
|
562 | 697 | |
563 | - if ($fprimary) $pkey[] = $fname; |
|
698 | + if ($fprimary) |
|
699 | + { |
|
700 | + $pkey[] = $fname; |
|
701 | + } |
|
564 | 702 | |
565 | 703 | // some databases do not allow blobs to have defaults |
566 | - if ($ty == 'X') $fdefault = false; |
|
704 | + if ($ty == 'X') |
|
705 | + { |
|
706 | + $fdefault = false; |
|
707 | + } |
|
567 | 708 | |
568 | 709 | //-------------------- |
569 | 710 | // CONSTRUCT FIELD SQL |
570 | - if ($fdefts) { |
|
571 | - if (substr($this->connection->databaseType,0,5) == 'mysql') { |
|
711 | + if ($fdefts) |
|
712 | + { |
|
713 | + if (substr($this->connection->databaseType,0,5) == 'mysql') |
|
714 | + { |
|
572 | 715 | $ftype = 'TIMESTAMP'; |
573 | - } else { |
|
716 | + } |
|
717 | + else |
|
718 | + { |
|
574 | 719 | $fdefault = $this->connection->sysTimeStamp; |
575 | 720 | } |
576 | - } else if ($fdefdate) { |
|
577 | - if (substr($this->connection->databaseType,0,5) == 'mysql') { |
|
721 | + } |
|
722 | + else if ($fdefdate) |
|
723 | + { |
|
724 | + if (substr($this->connection->databaseType,0,5) == 'mysql') |
|
725 | + { |
|
578 | 726 | $ftype = 'TIMESTAMP'; |
579 | - } else { |
|
727 | + } |
|
728 | + else |
|
729 | + { |
|
580 | 730 | $fdefault = $this->connection->sysDate; |
581 | 731 | } |
582 | - } else if ($fdefault !== false && !$fnoquote) |
|
583 | - if ($ty == 'C' or $ty == 'X' or |
|
732 | + } |
|
733 | + else if ($fdefault !== false && !$fnoquote) |
|
734 | + { |
|
735 | + if ($ty == 'C' or $ty == 'X' or |
|
584 | 736 | ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) |
585 | 737 | if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') |
586 | 738 | $fdefault = trim($fdefault); |
739 | + } |
|
587 | 740 | else if (strtolower($fdefault) != 'null') |
588 | - $fdefault = $this->connection->qstr($fdefault); |
|
741 | + { |
|
742 | + $fdefault = $this->connection->qstr($fdefault); |
|
743 | + } |
|
589 | 744 | $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); |
590 | 745 | |
591 | - if ($widespacing) $fname = str_pad($fname,24); |
|
746 | + if ($widespacing) |
|
747 | + { |
|
748 | + $fname = str_pad($fname,24); |
|
749 | + } |
|
592 | 750 | $lines[$fid] = $fname.' '.$ftype.$suffix; |
593 | 751 | |
594 | - if ($fautoinc) $this->autoIncrement = true; |
|
752 | + if ($fautoinc) |
|
753 | + { |
|
754 | + $this->autoIncrement = true; |
|
755 | + } |
|
595 | 756 | } // foreach $flds |
596 | 757 | |
597 | 758 | return array($lines,$pkey); |
@@ -603,9 +764,13 @@ discard block |
||
603 | 764 | */ |
604 | 765 | function _GetSize($ftype, $ty, $fsize, $fprec) |
605 | 766 | { |
606 | - if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) { |
|
767 | + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) |
|
768 | + { |
|
607 | 769 | $ftype .= "(".$fsize; |
608 | - if (strlen($fprec)) $ftype .= ",".$fprec; |
|
770 | + if (strlen($fprec)) |
|
771 | + { |
|
772 | + $ftype .= ",".$fprec; |
|
773 | + } |
|
609 | 774 | $ftype .= ')'; |
610 | 775 | } |
611 | 776 | return $ftype; |
@@ -616,9 +781,18 @@ discard block |
||
616 | 781 | function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) |
617 | 782 | { |
618 | 783 | $suffix = ''; |
619 | - if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; |
|
620 | - if ($fnotnull) $suffix .= ' NOT NULL'; |
|
621 | - if ($fconstraint) $suffix .= ' '.$fconstraint; |
|
784 | + if (strlen($fdefault)) |
|
785 | + { |
|
786 | + $suffix .= " DEFAULT $fdefault"; |
|
787 | + } |
|
788 | + if ($fnotnull) |
|
789 | + { |
|
790 | + $suffix .= ' NOT NULL'; |
|
791 | + } |
|
792 | + if ($fconstraint) |
|
793 | + { |
|
794 | + $suffix .= ' '.$fconstraint; |
|
795 | + } |
|
622 | 796 | return $suffix; |
623 | 797 | } |
624 | 798 | |
@@ -626,13 +800,17 @@ discard block |
||
626 | 800 | { |
627 | 801 | $sql = array(); |
628 | 802 | |
629 | - if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { |
|
803 | + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) |
|
804 | + { |
|
630 | 805 | $sql[] = sprintf ($this->dropIndex, $idxname); |
631 | 806 | if ( isset($idxoptions['DROP']) ) |
632 | - return $sql; |
|
807 | + { |
|
808 | + return $sql; |
|
809 | + } |
|
633 | 810 | } |
634 | 811 | |
635 | - if ( empty ($flds) ) { |
|
812 | + if ( empty ($flds) ) |
|
813 | + { |
|
636 | 814 | return $sql; |
637 | 815 | } |
638 | 816 | |
@@ -641,10 +819,14 @@ discard block |
||
641 | 819 | $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; |
642 | 820 | |
643 | 821 | if ( isset($idxoptions[$this->upperName]) ) |
644 | - $s .= $idxoptions[$this->upperName]; |
|
822 | + { |
|
823 | + $s .= $idxoptions[$this->upperName]; |
|
824 | + } |
|
645 | 825 | |
646 | 826 | if ( is_array($flds) ) |
647 | - $flds = implode(', ',$flds); |
|
827 | + { |
|
828 | + $flds = implode(', ',$flds); |
|
829 | + } |
|
648 | 830 | $s .= '(' . $flds . ')'; |
649 | 831 | $sql[] = $s; |
650 | 832 | |
@@ -660,30 +842,44 @@ discard block |
||
660 | 842 | { |
661 | 843 | $sql = array(); |
662 | 844 | |
663 | - if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) { |
|
845 | + if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) |
|
846 | + { |
|
664 | 847 | $sql[] = sprintf($this->dropTable,$tabname); |
665 | - if ($this->autoIncrement) { |
|
848 | + if ($this->autoIncrement) |
|
849 | + { |
|
666 | 850 | $sInc = $this->_DropAutoIncrement($tabname); |
667 | - if ($sInc) $sql[] = $sInc; |
|
851 | + if ($sInc) |
|
852 | + { |
|
853 | + $sql[] = $sInc; |
|
854 | + } |
|
668 | 855 | } |
669 | - if ( isset ($tableoptions['DROP']) ) { |
|
856 | + if ( isset ($tableoptions['DROP']) ) |
|
857 | + { |
|
670 | 858 | return $sql; |
671 | 859 | } |
672 | 860 | } |
673 | 861 | $s = "CREATE TABLE $tabname (\n"; |
674 | 862 | $s .= implode(",\n", $lines); |
675 | - if (sizeof($pkey)>0) { |
|
863 | + if (sizeof($pkey)>0) |
|
864 | + { |
|
676 | 865 | $s .= ",\n PRIMARY KEY ("; |
677 | 866 | $s .= implode(", ",$pkey).")"; |
678 | 867 | } |
679 | 868 | if (isset($tableoptions['CONSTRAINTS'])) |
680 | - $s .= "\n".$tableoptions['CONSTRAINTS']; |
|
869 | + { |
|
870 | + $s .= "\n".$tableoptions['CONSTRAINTS']; |
|
871 | + } |
|
681 | 872 | |
682 | 873 | if (isset($tableoptions[$this->upperName.'_CONSTRAINTS'])) |
683 | - $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS']; |
|
874 | + { |
|
875 | + $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS']; |
|
876 | + } |
|
684 | 877 | |
685 | 878 | $s .= "\n)"; |
686 | - if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName]; |
|
879 | + if (isset($tableoptions[$this->upperName])) |
|
880 | + { |
|
881 | + $s .= $tableoptions[$this->upperName]; |
|
882 | + } |
|
687 | 883 | $sql[] = $s; |
688 | 884 | |
689 | 885 | return $sql; |
@@ -703,11 +899,20 @@ discard block |
||
703 | 899 | */ |
704 | 900 | function _Options($opts) |
705 | 901 | { |
706 | - if (!is_array($opts)) return array(); |
|
902 | + if (!is_array($opts)) |
|
903 | + { |
|
904 | + return array(); |
|
905 | + } |
|
707 | 906 | $newopts = array(); |
708 | - foreach($opts as $k => $v) { |
|
709 | - if (is_numeric($k)) $newopts[strtoupper($v)] = $v; |
|
710 | - else $newopts[strtoupper($k)] = $v; |
|
907 | + foreach($opts as $k => $v) |
|
908 | + { |
|
909 | + if (is_numeric($k)) |
|
910 | + { |
|
911 | + $newopts[strtoupper($v)] = $v; |
|
912 | + } |
|
913 | + else { |
|
914 | + $newopts[strtoupper($k)] = $v; |
|
915 | + } |
|
711 | 916 | } |
712 | 917 | return $newopts; |
713 | 918 | } |
@@ -724,7 +929,10 @@ discard block |
||
724 | 929 | |
725 | 930 | $save = $ADODB_FETCH_MODE; |
726 | 931 | $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; |
727 | - if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false); |
|
932 | + if ($this->connection->fetchMode !== false) |
|
933 | + { |
|
934 | + $savem = $this->connection->SetFetchMode(false); |
|
935 | + } |
|
728 | 936 | |
729 | 937 | // check table exists |
730 | 938 | $save_handler = $this->connection->raiseErrorFn; |
@@ -732,30 +940,46 @@ discard block |
||
732 | 940 | $cols = $this->MetaColumns($tablename); |
733 | 941 | $this->connection->raiseErrorFn = $save_handler; |
734 | 942 | |
735 | - if (isset($savem)) $this->connection->SetFetchMode($savem); |
|
943 | + if (isset($savem)) |
|
944 | + { |
|
945 | + $this->connection->SetFetchMode($savem); |
|
946 | + } |
|
736 | 947 | $ADODB_FETCH_MODE = $save; |
737 | 948 | |
738 | - if ( empty($cols)) { |
|
949 | + if ( empty($cols)) |
|
950 | + { |
|
739 | 951 | return $this->CreateTableSQL($tablename, $flds, $tableoptions); |
740 | 952 | } |
741 | 953 | |
742 | - if (is_array($flds)) { |
|
954 | + if (is_array($flds)) |
|
955 | + { |
|
743 | 956 | // Cycle through the update fields, comparing |
744 | 957 | // existing fields to fields to update. |
745 | 958 | // if the Metatype and size is exactly the |
746 | 959 | // same, ignore - by Mark Newham |
747 | 960 | $holdflds = array(); |
748 | - foreach($flds as $k=>$v) { |
|
749 | - if ( isset($cols[$k]) && is_object($cols[$k]) ) { |
|
961 | + foreach($flds as $k=>$v) |
|
962 | + { |
|
963 | + if ( isset($cols[$k]) && is_object($cols[$k]) ) |
|
964 | + { |
|
750 | 965 | $c = $cols[$k]; |
751 | 966 | $ml = $c->max_length; |
752 | 967 | $mt = &$this->MetaType($c->type,$ml); |
753 | - if ($ml == -1) $ml = ''; |
|
754 | - if ($mt == 'X') $ml = $v['SIZE']; |
|
755 | - if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { |
|
968 | + if ($ml == -1) |
|
969 | + { |
|
970 | + $ml = ''; |
|
971 | + } |
|
972 | + if ($mt == 'X') |
|
973 | + { |
|
974 | + $ml = $v['SIZE']; |
|
975 | + } |
|
976 | + if (($mt != $v['TYPE']) || $ml != $v['SIZE']) |
|
977 | + { |
|
756 | 978 | $holdflds[$k] = $v; |
757 | 979 | } |
758 | - } else { |
|
980 | + } |
|
981 | + else |
|
982 | + { |
|
759 | 983 | $holdflds[$k] = $v; |
760 | 984 | } |
761 | 985 | } |
@@ -768,16 +992,23 @@ discard block |
||
768 | 992 | $alter = 'ALTER TABLE ' . $this->TableName($tablename); |
769 | 993 | $sql = array(); |
770 | 994 | |
771 | - foreach ( $lines as $id => $v ) { |
|
772 | - if ( isset($cols[$id]) && is_object($cols[$id]) ) { |
|
995 | + foreach ( $lines as $id => $v ) |
|
996 | + { |
|
997 | + if ( isset($cols[$id]) && is_object($cols[$id]) ) |
|
998 | + { |
|
773 | 999 | |
774 | 1000 | $flds = Lens_ParseArgs($v,','); |
775 | 1001 | |
776 | 1002 | // We are trying to change the size of the field, if not allowed, simply ignore the request. |
777 | - if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue; |
|
1003 | + if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) |
|
1004 | + { |
|
1005 | + continue; |
|
1006 | + } |
|
778 | 1007 | |
779 | 1008 | $sql[] = $alter . $this->alterCol . ' ' . $v; |
780 | - } else { |
|
1009 | + } |
|
1010 | + else |
|
1011 | + { |
|
781 | 1012 | $sql[] = $alter . $this->addCol . ' ' . $v; |
782 | 1013 | } |
783 | 1014 | } |
@@ -55,6 +55,10 @@ |
||
55 | 55 | return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; |
56 | 56 | } |
57 | 57 | |
58 | +/** |
|
59 | + * @param string $provider |
|
60 | + * @param string $dbType |
|
61 | + */ |
|
58 | 62 | function adodb_error($provider,$dbType,$errno) |
59 | 63 | { |
60 | 64 | //var_dump($errno); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; |
52 | 52 | else { |
53 | 53 | include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); |
54 | - } |
|
54 | + } |
|
55 | 55 | return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; |
56 | 56 | } |
57 | 57 | |
@@ -91,84 +91,84 @@ discard block |
||
91 | 91 | function adodb_error_pg($errormsg) |
92 | 92 | { |
93 | 93 | if (is_numeric($errormsg)) return (integer) $errormsg; |
94 | - static $error_regexps = array( |
|
95 | - '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
|
96 | - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
|
97 | - '/divide by zero$/' => DB_ERROR_DIVZERO, |
|
98 | - '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, |
|
99 | - '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, |
|
100 | - '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, |
|
101 | - '/referential integrity violation/' => DB_ERROR_CONSTRAINT, |
|
94 | + static $error_regexps = array( |
|
95 | + '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
|
96 | + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
|
97 | + '/divide by zero$/' => DB_ERROR_DIVZERO, |
|
98 | + '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, |
|
99 | + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, |
|
100 | + '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, |
|
101 | + '/referential integrity violation/' => DB_ERROR_CONSTRAINT, |
|
102 | 102 | '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' |
103 | 103 | => DB_ERROR_ALREADY_EXISTS |
104 | - ); |
|
104 | + ); |
|
105 | 105 | reset($error_regexps); |
106 | - while (list($regexp,$code) = each($error_regexps)) { |
|
107 | - if (preg_match($regexp, $errormsg)) { |
|
108 | - return $code; |
|
109 | - } |
|
110 | - } |
|
111 | - // Fall back to DB_ERROR if there was no mapping. |
|
112 | - return DB_ERROR; |
|
106 | + while (list($regexp,$code) = each($error_regexps)) { |
|
107 | + if (preg_match($regexp, $errormsg)) { |
|
108 | + return $code; |
|
109 | + } |
|
110 | + } |
|
111 | + // Fall back to DB_ERROR if there was no mapping. |
|
112 | + return DB_ERROR; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | function adodb_error_odbc() |
116 | 116 | { |
117 | 117 | static $MAP = array( |
118 | - '01004' => DB_ERROR_TRUNCATED, |
|
119 | - '07001' => DB_ERROR_MISMATCH, |
|
120 | - '21S01' => DB_ERROR_MISMATCH, |
|
121 | - '21S02' => DB_ERROR_MISMATCH, |
|
122 | - '22003' => DB_ERROR_INVALID_NUMBER, |
|
123 | - '22008' => DB_ERROR_INVALID_DATE, |
|
124 | - '22012' => DB_ERROR_DIVZERO, |
|
125 | - '23000' => DB_ERROR_CONSTRAINT, |
|
126 | - '24000' => DB_ERROR_INVALID, |
|
127 | - '34000' => DB_ERROR_INVALID, |
|
128 | - '37000' => DB_ERROR_SYNTAX, |
|
129 | - '42000' => DB_ERROR_SYNTAX, |
|
130 | - 'IM001' => DB_ERROR_UNSUPPORTED, |
|
131 | - 'S0000' => DB_ERROR_NOSUCHTABLE, |
|
132 | - 'S0001' => DB_ERROR_NOT_FOUND, |
|
133 | - 'S0002' => DB_ERROR_NOSUCHTABLE, |
|
134 | - 'S0011' => DB_ERROR_ALREADY_EXISTS, |
|
135 | - 'S0012' => DB_ERROR_NOT_FOUND, |
|
136 | - 'S0021' => DB_ERROR_ALREADY_EXISTS, |
|
137 | - 'S0022' => DB_ERROR_NOT_FOUND, |
|
118 | + '01004' => DB_ERROR_TRUNCATED, |
|
119 | + '07001' => DB_ERROR_MISMATCH, |
|
120 | + '21S01' => DB_ERROR_MISMATCH, |
|
121 | + '21S02' => DB_ERROR_MISMATCH, |
|
122 | + '22003' => DB_ERROR_INVALID_NUMBER, |
|
123 | + '22008' => DB_ERROR_INVALID_DATE, |
|
124 | + '22012' => DB_ERROR_DIVZERO, |
|
125 | + '23000' => DB_ERROR_CONSTRAINT, |
|
126 | + '24000' => DB_ERROR_INVALID, |
|
127 | + '34000' => DB_ERROR_INVALID, |
|
128 | + '37000' => DB_ERROR_SYNTAX, |
|
129 | + '42000' => DB_ERROR_SYNTAX, |
|
130 | + 'IM001' => DB_ERROR_UNSUPPORTED, |
|
131 | + 'S0000' => DB_ERROR_NOSUCHTABLE, |
|
132 | + 'S0001' => DB_ERROR_NOT_FOUND, |
|
133 | + 'S0002' => DB_ERROR_NOSUCHTABLE, |
|
134 | + 'S0011' => DB_ERROR_ALREADY_EXISTS, |
|
135 | + 'S0012' => DB_ERROR_NOT_FOUND, |
|
136 | + 'S0021' => DB_ERROR_ALREADY_EXISTS, |
|
137 | + 'S0022' => DB_ERROR_NOT_FOUND, |
|
138 | 138 | 'S1000' => DB_ERROR_NOSUCHTABLE, |
139 | - 'S1009' => DB_ERROR_INVALID, |
|
140 | - 'S1090' => DB_ERROR_INVALID, |
|
141 | - 'S1C00' => DB_ERROR_NOT_CAPABLE |
|
142 | - ); |
|
139 | + 'S1009' => DB_ERROR_INVALID, |
|
140 | + 'S1090' => DB_ERROR_INVALID, |
|
141 | + 'S1C00' => DB_ERROR_NOT_CAPABLE |
|
142 | + ); |
|
143 | 143 | return $MAP; |
144 | 144 | } |
145 | 145 | |
146 | 146 | function adodb_error_ibase() |
147 | 147 | { |
148 | 148 | static $MAP = array( |
149 | - -104 => DB_ERROR_SYNTAX, |
|
150 | - -150 => DB_ERROR_ACCESS_VIOLATION, |
|
151 | - -151 => DB_ERROR_ACCESS_VIOLATION, |
|
152 | - -155 => DB_ERROR_NOSUCHTABLE, |
|
153 | - -157 => DB_ERROR_NOSUCHFIELD, |
|
154 | - -158 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
155 | - -170 => DB_ERROR_MISMATCH, |
|
156 | - -171 => DB_ERROR_MISMATCH, |
|
157 | - -172 => DB_ERROR_INVALID, |
|
158 | - -204 => DB_ERROR_INVALID, |
|
159 | - -205 => DB_ERROR_NOSUCHFIELD, |
|
160 | - -206 => DB_ERROR_NOSUCHFIELD, |
|
161 | - -208 => DB_ERROR_INVALID, |
|
162 | - -219 => DB_ERROR_NOSUCHTABLE, |
|
163 | - -297 => DB_ERROR_CONSTRAINT, |
|
164 | - -530 => DB_ERROR_CONSTRAINT, |
|
165 | - -803 => DB_ERROR_CONSTRAINT, |
|
166 | - -551 => DB_ERROR_ACCESS_VIOLATION, |
|
167 | - -552 => DB_ERROR_ACCESS_VIOLATION, |
|
168 | - -922 => DB_ERROR_NOSUCHDB, |
|
169 | - -923 => DB_ERROR_CONNECT_FAILED, |
|
170 | - -924 => DB_ERROR_CONNECT_FAILED |
|
171 | - ); |
|
149 | + -104 => DB_ERROR_SYNTAX, |
|
150 | + -150 => DB_ERROR_ACCESS_VIOLATION, |
|
151 | + -151 => DB_ERROR_ACCESS_VIOLATION, |
|
152 | + -155 => DB_ERROR_NOSUCHTABLE, |
|
153 | + -157 => DB_ERROR_NOSUCHFIELD, |
|
154 | + -158 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
155 | + -170 => DB_ERROR_MISMATCH, |
|
156 | + -171 => DB_ERROR_MISMATCH, |
|
157 | + -172 => DB_ERROR_INVALID, |
|
158 | + -204 => DB_ERROR_INVALID, |
|
159 | + -205 => DB_ERROR_NOSUCHFIELD, |
|
160 | + -206 => DB_ERROR_NOSUCHFIELD, |
|
161 | + -208 => DB_ERROR_INVALID, |
|
162 | + -219 => DB_ERROR_NOSUCHTABLE, |
|
163 | + -297 => DB_ERROR_CONSTRAINT, |
|
164 | + -530 => DB_ERROR_CONSTRAINT, |
|
165 | + -803 => DB_ERROR_CONSTRAINT, |
|
166 | + -551 => DB_ERROR_ACCESS_VIOLATION, |
|
167 | + -552 => DB_ERROR_ACCESS_VIOLATION, |
|
168 | + -922 => DB_ERROR_NOSUCHDB, |
|
169 | + -923 => DB_ERROR_CONNECT_FAILED, |
|
170 | + -924 => DB_ERROR_CONNECT_FAILED |
|
171 | + ); |
|
172 | 172 | |
173 | 173 | return $MAP; |
174 | 174 | } |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | function adodb_error_ifx() |
177 | 177 | { |
178 | 178 | static $MAP = array( |
179 | - '-201' => DB_ERROR_SYNTAX, |
|
180 | - '-206' => DB_ERROR_NOSUCHTABLE, |
|
181 | - '-217' => DB_ERROR_NOSUCHFIELD, |
|
182 | - '-329' => DB_ERROR_NODBSELECTED, |
|
183 | - '-1204' => DB_ERROR_INVALID_DATE, |
|
184 | - '-1205' => DB_ERROR_INVALID_DATE, |
|
185 | - '-1206' => DB_ERROR_INVALID_DATE, |
|
186 | - '-1209' => DB_ERROR_INVALID_DATE, |
|
187 | - '-1210' => DB_ERROR_INVALID_DATE, |
|
188 | - '-1212' => DB_ERROR_INVALID_DATE |
|
189 | - ); |
|
179 | + '-201' => DB_ERROR_SYNTAX, |
|
180 | + '-206' => DB_ERROR_NOSUCHTABLE, |
|
181 | + '-217' => DB_ERROR_NOSUCHFIELD, |
|
182 | + '-329' => DB_ERROR_NODBSELECTED, |
|
183 | + '-1204' => DB_ERROR_INVALID_DATE, |
|
184 | + '-1205' => DB_ERROR_INVALID_DATE, |
|
185 | + '-1206' => DB_ERROR_INVALID_DATE, |
|
186 | + '-1209' => DB_ERROR_INVALID_DATE, |
|
187 | + '-1210' => DB_ERROR_INVALID_DATE, |
|
188 | + '-1212' => DB_ERROR_INVALID_DATE |
|
189 | + ); |
|
190 | 190 | |
191 | 191 | return $MAP; |
192 | 192 | } |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | { |
196 | 196 | static $MAP = array( |
197 | 197 | 1 => DB_ERROR_ALREADY_EXISTS, |
198 | - 900 => DB_ERROR_SYNTAX, |
|
199 | - 904 => DB_ERROR_NOSUCHFIELD, |
|
200 | - 923 => DB_ERROR_SYNTAX, |
|
201 | - 942 => DB_ERROR_NOSUCHTABLE, |
|
202 | - 955 => DB_ERROR_ALREADY_EXISTS, |
|
203 | - 1476 => DB_ERROR_DIVZERO, |
|
204 | - 1722 => DB_ERROR_INVALID_NUMBER, |
|
205 | - 2289 => DB_ERROR_NOSUCHTABLE, |
|
206 | - 2291 => DB_ERROR_CONSTRAINT, |
|
207 | - 2449 => DB_ERROR_CONSTRAINT |
|
208 | - ); |
|
198 | + 900 => DB_ERROR_SYNTAX, |
|
199 | + 904 => DB_ERROR_NOSUCHFIELD, |
|
200 | + 923 => DB_ERROR_SYNTAX, |
|
201 | + 942 => DB_ERROR_NOSUCHTABLE, |
|
202 | + 955 => DB_ERROR_ALREADY_EXISTS, |
|
203 | + 1476 => DB_ERROR_DIVZERO, |
|
204 | + 1722 => DB_ERROR_INVALID_NUMBER, |
|
205 | + 2289 => DB_ERROR_NOSUCHTABLE, |
|
206 | + 2291 => DB_ERROR_CONSTRAINT, |
|
207 | + 2449 => DB_ERROR_CONSTRAINT |
|
208 | + ); |
|
209 | 209 | |
210 | 210 | return $MAP; |
211 | 211 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | { |
215 | 215 | static $MAP = array( |
216 | 216 | 208 => DB_ERROR_NOSUCHTABLE, |
217 | - 2601 => DB_ERROR_ALREADY_EXISTS |
|
218 | - ); |
|
217 | + 2601 => DB_ERROR_ALREADY_EXISTS |
|
218 | + ); |
|
219 | 219 | |
220 | 220 | return $MAP; |
221 | 221 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | static $MAP = array( |
226 | 226 | 1 => DB_ERROR_SYNTAX |
227 | - ); |
|
227 | + ); |
|
228 | 228 | |
229 | 229 | return $MAP; |
230 | 230 | } |
@@ -232,26 +232,26 @@ discard block |
||
232 | 232 | function adodb_error_mysql() |
233 | 233 | { |
234 | 234 | static $MAP = array( |
235 | - 1004 => DB_ERROR_CANNOT_CREATE, |
|
236 | - 1005 => DB_ERROR_CANNOT_CREATE, |
|
237 | - 1006 => DB_ERROR_CANNOT_CREATE, |
|
238 | - 1007 => DB_ERROR_ALREADY_EXISTS, |
|
239 | - 1008 => DB_ERROR_CANNOT_DROP, |
|
235 | + 1004 => DB_ERROR_CANNOT_CREATE, |
|
236 | + 1005 => DB_ERROR_CANNOT_CREATE, |
|
237 | + 1006 => DB_ERROR_CANNOT_CREATE, |
|
238 | + 1007 => DB_ERROR_ALREADY_EXISTS, |
|
239 | + 1008 => DB_ERROR_CANNOT_DROP, |
|
240 | 240 | 1045 => DB_ERROR_ACCESS_VIOLATION, |
241 | - 1046 => DB_ERROR_NODBSELECTED, |
|
241 | + 1046 => DB_ERROR_NODBSELECTED, |
|
242 | 242 | 1049 => DB_ERROR_NOSUCHDB, |
243 | - 1050 => DB_ERROR_ALREADY_EXISTS, |
|
244 | - 1051 => DB_ERROR_NOSUCHTABLE, |
|
245 | - 1054 => DB_ERROR_NOSUCHFIELD, |
|
246 | - 1062 => DB_ERROR_ALREADY_EXISTS, |
|
247 | - 1064 => DB_ERROR_SYNTAX, |
|
248 | - 1100 => DB_ERROR_NOT_LOCKED, |
|
249 | - 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
250 | - 1146 => DB_ERROR_NOSUCHTABLE, |
|
251 | - 1048 => DB_ERROR_CONSTRAINT, |
|
252 | - 2002 => DB_ERROR_CONNECT_FAILED, |
|
243 | + 1050 => DB_ERROR_ALREADY_EXISTS, |
|
244 | + 1051 => DB_ERROR_NOSUCHTABLE, |
|
245 | + 1054 => DB_ERROR_NOSUCHFIELD, |
|
246 | + 1062 => DB_ERROR_ALREADY_EXISTS, |
|
247 | + 1064 => DB_ERROR_SYNTAX, |
|
248 | + 1100 => DB_ERROR_NOT_LOCKED, |
|
249 | + 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, |
|
250 | + 1146 => DB_ERROR_NOSUCHTABLE, |
|
251 | + 1048 => DB_ERROR_CONSTRAINT, |
|
252 | + 2002 => DB_ERROR_CONNECT_FAILED, |
|
253 | 253 | 2005 => DB_ERROR_CONNECT_FAILED |
254 | - ); |
|
254 | + ); |
|
255 | 255 | |
256 | 256 | return $MAP; |
257 | 257 | } |
@@ -60,25 +60,25 @@ |
||
60 | 60 | //var_dump($errno); |
61 | 61 | if (is_numeric($errno) && $errno == 0) return 0; |
62 | 62 | switch($provider) { |
63 | - case 'mysql': $map = adodb_error_mysql(); break; |
|
63 | + case 'mysql': $map = adodb_error_mysql(); break; |
|
64 | 64 | |
65 | - case 'oracle': |
|
66 | - case 'oci8': $map = adodb_error_oci8(); break; |
|
65 | + case 'oracle': |
|
66 | + case 'oci8': $map = adodb_error_oci8(); break; |
|
67 | 67 | |
68 | - case 'ibase': $map = adodb_error_ibase(); break; |
|
68 | + case 'ibase': $map = adodb_error_ibase(); break; |
|
69 | 69 | |
70 | - case 'odbc': $map = adodb_error_odbc(); break; |
|
70 | + case 'odbc': $map = adodb_error_odbc(); break; |
|
71 | 71 | |
72 | - case 'mssql': |
|
73 | - case 'sybase': $map = adodb_error_mssql(); break; |
|
72 | + case 'mssql': |
|
73 | + case 'sybase': $map = adodb_error_mssql(); break; |
|
74 | 74 | |
75 | - case 'informix': $map = adodb_error_ifx(); break; |
|
75 | + case 'informix': $map = adodb_error_ifx(); break; |
|
76 | 76 | |
77 | - case 'postgres': return adodb_error_pg($errno); break; |
|
77 | + case 'postgres': return adodb_error_pg($errno); break; |
|
78 | 78 | |
79 | - case 'sqlite': return $map = adodb_error_sqlite(); break; |
|
80 | - default: |
|
81 | - return DB_ERROR; |
|
79 | + case 'sqlite': return $map = adodb_error_sqlite(); break; |
|
80 | + default: |
|
81 | + return DB_ERROR; |
|
82 | 82 | } |
83 | 83 | //print_r($map); |
84 | 84 | //var_dump($errno); |
@@ -12,54 +12,54 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | |
15 | -if (!defined("DB_ERROR")) define("DB_ERROR",-1); |
|
15 | +if (!defined("DB_ERROR")) define("DB_ERROR", -1); |
|
16 | 16 | |
17 | 17 | if (!defined("DB_ERROR_SYNTAX")) { |
18 | - define("DB_ERROR_SYNTAX", -2); |
|
19 | - define("DB_ERROR_CONSTRAINT", -3); |
|
20 | - define("DB_ERROR_NOT_FOUND", -4); |
|
21 | - define("DB_ERROR_ALREADY_EXISTS", -5); |
|
22 | - define("DB_ERROR_UNSUPPORTED", -6); |
|
23 | - define("DB_ERROR_MISMATCH", -7); |
|
24 | - define("DB_ERROR_INVALID", -8); |
|
25 | - define("DB_ERROR_NOT_CAPABLE", -9); |
|
26 | - define("DB_ERROR_TRUNCATED", -10); |
|
27 | - define("DB_ERROR_INVALID_NUMBER", -11); |
|
28 | - define("DB_ERROR_INVALID_DATE", -12); |
|
29 | - define("DB_ERROR_DIVZERO", -13); |
|
30 | - define("DB_ERROR_NODBSELECTED", -14); |
|
31 | - define("DB_ERROR_CANNOT_CREATE", -15); |
|
32 | - define("DB_ERROR_CANNOT_DELETE", -16); |
|
33 | - define("DB_ERROR_CANNOT_DROP", -17); |
|
34 | - define("DB_ERROR_NOSUCHTABLE", -18); |
|
35 | - define("DB_ERROR_NOSUCHFIELD", -19); |
|
36 | - define("DB_ERROR_NEED_MORE_DATA", -20); |
|
37 | - define("DB_ERROR_NOT_LOCKED", -21); |
|
18 | + define("DB_ERROR_SYNTAX", -2); |
|
19 | + define("DB_ERROR_CONSTRAINT", -3); |
|
20 | + define("DB_ERROR_NOT_FOUND", -4); |
|
21 | + define("DB_ERROR_ALREADY_EXISTS", -5); |
|
22 | + define("DB_ERROR_UNSUPPORTED", -6); |
|
23 | + define("DB_ERROR_MISMATCH", -7); |
|
24 | + define("DB_ERROR_INVALID", -8); |
|
25 | + define("DB_ERROR_NOT_CAPABLE", -9); |
|
26 | + define("DB_ERROR_TRUNCATED", -10); |
|
27 | + define("DB_ERROR_INVALID_NUMBER", -11); |
|
28 | + define("DB_ERROR_INVALID_DATE", -12); |
|
29 | + define("DB_ERROR_DIVZERO", -13); |
|
30 | + define("DB_ERROR_NODBSELECTED", -14); |
|
31 | + define("DB_ERROR_CANNOT_CREATE", -15); |
|
32 | + define("DB_ERROR_CANNOT_DELETE", -16); |
|
33 | + define("DB_ERROR_CANNOT_DROP", -17); |
|
34 | + define("DB_ERROR_NOSUCHTABLE", -18); |
|
35 | + define("DB_ERROR_NOSUCHFIELD", -19); |
|
36 | + define("DB_ERROR_NEED_MORE_DATA", -20); |
|
37 | + define("DB_ERROR_NOT_LOCKED", -21); |
|
38 | 38 | define("DB_ERROR_VALUE_COUNT_ON_ROW", -22); |
39 | - define("DB_ERROR_INVALID_DSN", -23); |
|
40 | - define("DB_ERROR_CONNECT_FAILED", -24); |
|
41 | - define("DB_ERROR_EXTENSION_NOT_FOUND",-25); |
|
42 | - define("DB_ERROR_NOSUCHDB", -25); |
|
43 | - define("DB_ERROR_ACCESS_VIOLATION", -26); |
|
39 | + define("DB_ERROR_INVALID_DSN", -23); |
|
40 | + define("DB_ERROR_CONNECT_FAILED", -24); |
|
41 | + define("DB_ERROR_EXTENSION_NOT_FOUND", -25); |
|
42 | + define("DB_ERROR_NOSUCHDB", -25); |
|
43 | + define("DB_ERROR_ACCESS_VIOLATION", -26); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function adodb_errormsg($value) |
47 | 47 | { |
48 | -global $ADODB_LANG,$ADODB_LANG_ARRAY; |
|
48 | +global $ADODB_LANG, $ADODB_LANG_ARRAY; |
|
49 | 49 | |
50 | 50 | if (empty($ADODB_LANG)) $ADODB_LANG = 'en'; |
51 | - if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; |
|
51 | + if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG); |
|
52 | 52 | else { |
53 | 53 | include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); |
54 | 54 | } |
55 | 55 | return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; |
56 | 56 | } |
57 | 57 | |
58 | -function adodb_error($provider,$dbType,$errno) |
|
58 | +function adodb_error($provider, $dbType, $errno) |
|
59 | 59 | { |
60 | 60 | //var_dump($errno); |
61 | 61 | if (is_numeric($errno) && $errno == 0) return 0; |
62 | - switch($provider) { |
|
62 | + switch ($provider) { |
|
63 | 63 | case 'mysql': $map = adodb_error_mysql(); break; |
64 | 64 | |
65 | 65 | case 'oracle': |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | function adodb_error_pg($errormsg) |
92 | 92 | { |
93 | - if (is_numeric($errormsg)) return (integer) $errormsg; |
|
93 | + if (is_numeric($errormsg)) return (integer)$errormsg; |
|
94 | 94 | static $error_regexps = array( |
95 | 95 | '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
96 | 96 | '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | => DB_ERROR_ALREADY_EXISTS |
104 | 104 | ); |
105 | 105 | reset($error_regexps); |
106 | - while (list($regexp,$code) = each($error_regexps)) { |
|
106 | + while (list($regexp, $code) = each($error_regexps)) { |
|
107 | 107 | if (preg_match($regexp, $errormsg)) { |
108 | 108 | return $code; |
109 | 109 | } |
@@ -12,9 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | |
15 | -if (!defined("DB_ERROR")) define("DB_ERROR",-1); |
|
15 | +if (!defined("DB_ERROR")) |
|
16 | +{ |
|
17 | + define("DB_ERROR",-1); |
|
18 | +} |
|
16 | 19 | |
17 | -if (!defined("DB_ERROR_SYNTAX")) { |
|
20 | +if (!defined("DB_ERROR_SYNTAX")) |
|
21 | +{ |
|
18 | 22 | define("DB_ERROR_SYNTAX", -2); |
19 | 23 | define("DB_ERROR_CONSTRAINT", -3); |
20 | 24 | define("DB_ERROR_NOT_FOUND", -4); |
@@ -47,9 +51,13 @@ discard block |
||
47 | 51 | { |
48 | 52 | global $ADODB_LANG,$ADODB_LANG_ARRAY; |
49 | 53 | |
50 | - if (empty($ADODB_LANG)) $ADODB_LANG = 'en'; |
|
54 | + if (empty($ADODB_LANG)) |
|
55 | + { |
|
56 | + $ADODB_LANG = 'en'; |
|
57 | + } |
|
51 | 58 | if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; |
52 | - else { |
|
59 | + else |
|
60 | + { |
|
53 | 61 | include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); |
54 | 62 | } |
55 | 63 | return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; |
@@ -58,8 +66,12 @@ discard block |
||
58 | 66 | function adodb_error($provider,$dbType,$errno) |
59 | 67 | { |
60 | 68 | //var_dump($errno); |
61 | - if (is_numeric($errno) && $errno == 0) return 0; |
|
62 | - switch($provider) { |
|
69 | + if (is_numeric($errno) && $errno == 0) |
|
70 | + { |
|
71 | + return 0; |
|
72 | + } |
|
73 | + switch($provider) |
|
74 | + { |
|
63 | 75 | case 'mysql': $map = adodb_error_mysql(); break; |
64 | 76 | |
65 | 77 | case 'oracle': |
@@ -82,7 +94,10 @@ discard block |
||
82 | 94 | } |
83 | 95 | //print_r($map); |
84 | 96 | //var_dump($errno); |
85 | - if (isset($map[$errno])) return $map[$errno]; |
|
97 | + if (isset($map[$errno])) |
|
98 | + { |
|
99 | + return $map[$errno]; |
|
100 | + } |
|
86 | 101 | return DB_ERROR; |
87 | 102 | } |
88 | 103 | |
@@ -90,7 +105,10 @@ discard block |
||
90 | 105 | |
91 | 106 | function adodb_error_pg($errormsg) |
92 | 107 | { |
93 | - if (is_numeric($errormsg)) return (integer) $errormsg; |
|
108 | + if (is_numeric($errormsg)) |
|
109 | + { |
|
110 | + return (integer) $errormsg; |
|
111 | + } |
|
94 | 112 | static $error_regexps = array( |
95 | 113 | '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, |
96 | 114 | '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, |
@@ -103,8 +121,10 @@ discard block |
||
103 | 121 | => DB_ERROR_ALREADY_EXISTS |
104 | 122 | ); |
105 | 123 | reset($error_regexps); |
106 | - while (list($regexp,$code) = each($error_regexps)) { |
|
107 | - if (preg_match($regexp, $errormsg)) { |
|
124 | + while (list($regexp,$code) = each($error_regexps)) |
|
125 | + { |
|
126 | + if (preg_match($regexp, $errormsg)) |
|
127 | + { |
|
108 | 128 | return $code; |
109 | 129 | } |
110 | 130 | } |
@@ -25,6 +25,9 @@ |
||
25 | 25 | |
26 | 26 | private $rs; |
27 | 27 | |
28 | + /** |
|
29 | + * @param ADODB_BASE_RS $rs |
|
30 | + */ |
|
28 | 31 | function __construct($rs) |
29 | 32 | { |
30 | 33 | $this->rs = $rs; |
@@ -23,36 +23,36 @@ discard block |
||
23 | 23 | |
24 | 24 | class ADODB_Iterator implements Iterator { |
25 | 25 | |
26 | - private $rs; |
|
26 | + private $rs; |
|
27 | 27 | |
28 | - function __construct($rs) |
|
28 | + function __construct($rs) |
|
29 | 29 | { |
30 | - $this->rs = $rs; |
|
31 | - } |
|
32 | - function rewind() |
|
30 | + $this->rs = $rs; |
|
31 | + } |
|
32 | + function rewind() |
|
33 | 33 | { |
34 | - $this->rs->MoveFirst(); |
|
35 | - } |
|
34 | + $this->rs->MoveFirst(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | function valid() |
38 | 38 | { |
39 | - return !$this->rs->EOF; |
|
40 | - } |
|
39 | + return !$this->rs->EOF; |
|
40 | + } |
|
41 | 41 | |
42 | - function key() |
|
42 | + function key() |
|
43 | 43 | { |
44 | - return $this->rs->_currentRow; |
|
45 | - } |
|
44 | + return $this->rs->_currentRow; |
|
45 | + } |
|
46 | 46 | |
47 | - function current() |
|
47 | + function current() |
|
48 | 48 | { |
49 | - return $this->rs->fields; |
|
50 | - } |
|
49 | + return $this->rs->fields; |
|
50 | + } |
|
51 | 51 | |
52 | - function next() |
|
52 | + function next() |
|
53 | 53 | { |
54 | - $this->rs->MoveNext(); |
|
55 | - } |
|
54 | + $this->rs->MoveNext(); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | function __call($func, $params) |
58 | 58 | { |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | |
71 | 71 | class ADODB_BASE_RS implements IteratorAggregate { |
72 | - function getIterator() { |
|
73 | - return new ADODB_Iterator($this); |
|
74 | - } |
|
72 | + function getIterator() { |
|
73 | + return new ADODB_Iterator($this); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | /* this is experimental - i don't really know what to return... */ |
77 | 77 | function __toString() |
@@ -77,7 +77,7 @@ |
||
77 | 77 | function __toString() |
78 | 78 | { |
79 | 79 | include_once(ADODB_DIR.'/toexport.inc.php'); |
80 | - return _adodb_export($this,',',',',false,true); |
|
80 | + return _adodb_export($this, ',', ',', false, true); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -21,36 +21,37 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | - class ADODB_Iterator implements Iterator { |
|
24 | + class ADODB_Iterator implements Iterator |
|
25 | + { |
|
25 | 26 | |
26 | 27 | private $rs; |
27 | 28 | |
28 | - function __construct($rs) |
|
29 | - { |
|
29 | + function __construct($rs) |
|
30 | + { |
|
30 | 31 | $this->rs = $rs; |
31 | 32 | } |
32 | - function rewind() |
|
33 | - { |
|
33 | + function rewind() |
|
34 | + { |
|
34 | 35 | $this->rs->MoveFirst(); |
35 | 36 | } |
36 | 37 | |
37 | - function valid() |
|
38 | + function valid() |
|
38 | 39 | { |
39 | 40 | return !$this->rs->EOF; |
40 | 41 | } |
41 | 42 | |
42 | - function key() |
|
43 | - { |
|
43 | + function key() |
|
44 | + { |
|
44 | 45 | return $this->rs->_currentRow; |
45 | 46 | } |
46 | 47 | |
47 | - function current() |
|
48 | - { |
|
48 | + function current() |
|
49 | + { |
|
49 | 50 | return $this->rs->fields; |
50 | 51 | } |
51 | 52 | |
52 | - function next() |
|
53 | - { |
|
53 | + function next() |
|
54 | + { |
|
54 | 55 | $this->rs->MoveNext(); |
55 | 56 | } |
56 | 57 | |
@@ -68,8 +69,10 @@ discard block |
||
68 | 69 | } |
69 | 70 | |
70 | 71 | |
71 | -class ADODB_BASE_RS implements IteratorAggregate { |
|
72 | - function getIterator() { |
|
72 | +class ADODB_BASE_RS implements IteratorAggregate |
|
73 | +{ |
|
74 | + function getIterator() |
|
75 | + { |
|
73 | 76 | return new ADODB_Iterator($this); |
74 | 77 | } |
75 | 78 |