@@ -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 | } |
@@ -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,65 +322,65 @@ 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->From = $activeMailProfile['ident_email']; |
|
| 360 | - $mailObject->FromName = $mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile,false)); |
|
| 358 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 359 | + $mailObject->From = $activeMailProfile['ident_email']; |
|
| 360 | + $mailObject->FromName = $mailObject->EncodeHeader(mail_bo::generateIdentityString($activeMailProfile, false)); |
|
| 361 | 361 | $mailObject->AddCustomHeader('X-Mailer: mail-Activesync'); |
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 365 | 365 | // to |
| 366 | 366 | |
| 367 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 367 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 368 | 368 | if (!$addressObject->valid) continue; |
| 369 | - if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) ); |
|
| 369 | + if ($this->debugLevel > 0) debugLog("Header Sentmail To: ".array2string($addressObject)); |
|
| 370 | 370 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 371 | 371 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 372 | 372 | } |
| 373 | 373 | // CC |
| 374 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 374 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 375 | 375 | if (!$addressObject->valid) continue; |
| 376 | - if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) ); |
|
| 376 | + if ($this->debugLevel > 0) debugLog("Header Sentmail CC: ".array2string($addressObject)); |
|
| 377 | 377 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 378 | 378 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 379 | 379 | } |
| 380 | 380 | // BCC |
| 381 | - foreach(emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 381 | + foreach (emailadmin_imapbase::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
| 382 | 382 | if (!$addressObject->valid) continue; |
| 383 | - if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 383 | + if ($this->debugLevel > 0) debugLog("Header Sentmail BCC: ".array2string($addressObject)); |
|
| 384 | 384 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 385 | 385 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 386 | 386 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $use_orgbody = false; |
| 390 | 390 | |
| 391 | 391 | $k = 'Content-Type'; |
| 392 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 392 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 393 | 393 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 394 | 394 | // if the message is a multipart message, then we should use the sent body |
| 395 | 395 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -409,26 +409,26 @@ discard block |
||
| 409 | 409 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 410 | 410 | $use_orgbody = true; |
| 411 | 411 | } |
| 412 | - $Body = $AltBody = ""; |
|
| 412 | + $Body = $AltBody = ""; |
|
| 413 | 413 | // get body of the transmitted message |
| 414 | 414 | // if this is a simple message, no structure at all |
| 415 | 415 | if (preg_match("/text/i", $ContentType)) |
| 416 | 416 | { |
| 417 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 417 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 418 | 418 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 419 | - $body = $bodyObj ?$bodyObj->getContents() : null; |
|
| 420 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $body); |
|
| 421 | - if ($simpleBodyType == "text/plain") |
|
| 419 | + $body = $bodyObj ? $bodyObj->getContents() : null; |
|
| 420 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $body); |
|
| 421 | + if ($simpleBodyType == "text/plain") |
|
| 422 | 422 | { |
| 423 | 423 | $Body = $body; |
| 424 | 424 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 425 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 425 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 426 | 426 | } |
| 427 | 427 | else |
| 428 | 428 | { |
| 429 | 429 | $AltBody = $body; |
| 430 | - $Body = trim(translation::convertHTMLToText($body)); |
|
| 431 | - if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 430 | + $Body = trim(translation::convertHTMLToText($body)); |
|
| 431 | + if ($this->debugLevel > 1) debugLog("IMAP-Sendmail: fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | else |
@@ -437,60 +437,60 @@ discard block |
||
| 437 | 437 | $Body = ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null; |
| 438 | 438 | $AltBody = ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null; |
| 439 | 439 | // prefer plain over html |
| 440 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $Body); |
|
| 441 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $AltBody); |
|
| 440 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $Body); |
|
| 441 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $AltBody); |
|
| 442 | 442 | } |
| 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); |
|
| 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); |
|
| 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 | 448 | if ($use_orgbody) { |
| 449 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: use_orgbody = true ContentType:".$ContentType); |
|
| 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 | - if (stripos($ContentType,'text/calendar') !== false ) |
|
| 451 | + if (stripos($ContentType, 'text/calendar') !== false) |
|
| 452 | 452 | { |
| 453 | 453 | $body = ($text_body = $mailObject->findBody('calendar')) ? $text_body->getContents() : null; |
| 454 | 454 | $Body = $body; |
| 455 | 455 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 456 | - if ($this->debugLevel>0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
| 456 | + if ($this->debugLevel > 0) debugLog("IMAP-Sendmail: we have a Client Side Meeting Request"); |
|
| 457 | 457 | // try figuring out the METHOD -> [ContentType] => text/calendar; name=meeting.ics; method=REQUEST |
| 458 | - $tA = explode(' ',$ContentType); |
|
| 459 | - foreach ((array)$tA as $k => $p) if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); |
|
| 458 | + $tA = explode(' ', $ContentType); |
|
| 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)); |
| 466 | - foreach((array)$toMailAddr as $address) { |
|
| 467 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 468 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 469 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; |
|
| 466 | + foreach ((array)$toMailAddr as $address) { |
|
| 467 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 468 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 469 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress, (isset($cSMRMethod) ? $cSMRMethod : 'REQUEST'))) continue; |
|
| 470 | 470 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
| 471 | 471 | $toCount++; |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | $ccCount = 0; |
| 475 | - foreach((array)$ccMailAddr as $address) { |
|
| 476 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 477 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 475 | + foreach ((array)$ccMailAddr as $address) { |
|
| 476 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 477 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 478 | 478 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 479 | 479 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 480 | 480 | $ccCount++; |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | $bccCount = 0; |
| 484 | - foreach((array)$bccMailAddr as $address) { |
|
| 485 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 486 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 484 | + foreach ((array)$bccMailAddr as $address) { |
|
| 485 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 486 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 487 | 487 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 488 | 488 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 489 | 489 | $bccCount++; |
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | - if ($toCount+$ccCount+$bccCount == 0) return 0; // noone to send mail to |
|
| 493 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 492 | + if ($toCount + $ccCount + $bccCount == 0) return 0; // noone to send mail to |
|
| 493 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 494 | 494 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 495 | 495 | /* |
| 496 | 496 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -498,29 +498,29 @@ discard block |
||
| 498 | 498 | if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
| 499 | 499 | */ |
| 500 | 500 | // add signature!! ----------------------------------------------------------------- |
| 501 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 501 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 502 | 502 | try |
| 503 | 503 | { |
| 504 | 504 | $acc = emailadmin_account::read($this->mail->icServer->ImapServerId); |
| 505 | 505 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 506 | - $_signature = emailadmin_account::read_identity($acc['ident_id'],true); |
|
| 506 | + $_signature = emailadmin_account::read_identity($acc['ident_id'], true); |
|
| 507 | 507 | } |
| 508 | 508 | catch (Exception $e) |
| 509 | 509 | { |
| 510 | - $_signature=array(); |
|
| 510 | + $_signature = array(); |
|
| 511 | 511 | } |
| 512 | 512 | $signature = $_signature['ident_signature']; |
| 513 | 513 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
| 514 | 514 | $preferencesArray['disableRulerForSignatureSeparation']) || |
| 515 | - empty($signature) || trim(translation::convertHTMLToText($signature)) =='') |
|
| 515 | + empty($signature) || trim(translation::convertHTMLToText($signature)) == '') |
|
| 516 | 516 | { |
| 517 | 517 | $disableRuler = true; |
| 518 | 518 | } |
| 519 | 519 | $beforePlain = $beforeHtml = ""; |
| 520 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 521 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 522 | - $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); |
|
| 520 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 521 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 522 | + $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); |
|
| 524 | 524 | $sigTextHtml = $beforeHtml.$sigText; |
| 525 | 525 | $sigTextPlain = $beforePlain.translation::convertHTMLToText($sigText); |
| 526 | 526 | $isreply = $isforward = false; |
@@ -532,26 +532,26 @@ discard block |
||
| 532 | 532 | { |
| 533 | 533 | // now get on, and fetch the original mail |
| 534 | 534 | $uid = $smartdata['itemid']; |
| 535 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 535 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 536 | 536 | $this->splitID($smartdata['folderid'], $account, $folder); |
| 537 | 537 | |
| 538 | 538 | $this->mail->reopen($folder); |
| 539 | 539 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 540 | - $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')) { |
|
| 540 | + $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')) { |
|
| 543 | 543 | // may be html |
| 544 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 544 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 545 | 545 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 546 | 546 | $isreply = true; |
| 547 | 547 | } |
| 548 | 548 | // plain text Message part |
| 549 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
| 549 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
| 550 | 550 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 551 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 552 | - $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); |
|
| 551 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 552 | + $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); |
|
| 555 | 555 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 556 | 556 | $isreply = true; |
| 557 | 557 | } |
@@ -559,12 +559,12 @@ discard block |
||
| 559 | 559 | { |
| 560 | 560 | $isreply = true; |
| 561 | 561 | $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); |
|
| 562 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | // how to forward and other prefs |
| 567 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 567 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 568 | 568 | |
| 569 | 569 | // forward ------------------------------------------------------------------------- |
| 570 | 570 | if ($smartdata['task'] == 'forward' && isset($smartdata['itemid']) && |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | { |
| 575 | 575 | //force the default for the forwarding -> asmail |
| 576 | 576 | if (is_array($preferencesArray)) { |
| 577 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 577 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 578 | 578 | || !isset($preferencesArray['message_forwarding']) |
| 579 | 579 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 580 | 580 | } else { |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | } |
| 583 | 583 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 584 | 584 | $uid = $smartdata['itemid']; |
| 585 | - if ($this->debugLevel>0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 585 | + if ($this->debugLevel > 0) debugLog("IMAP Smartfordward is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 586 | 586 | $this->splitID($smartdata['folderid'], $account, $folder); |
| 587 | 587 | |
| 588 | 588 | $this->mail->reopen($folder); |
| 589 | 589 | // receive entire mail (header + body) |
| 590 | 590 | // get message headers for specified message |
| 591 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 591 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 592 | 592 | // build a new mime message, forward entire old mail as file |
| 593 | 593 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 594 | 594 | { |
| 595 | - $rawHeader=''; |
|
| 596 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID,$folder); |
|
| 597 | - $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID,$folder); |
|
| 595 | + $rawHeader = ''; |
|
| 596 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata['itemid'], $_partID, $folder); |
|
| 597 | + $rawBody = $this->mail->getMessageRawBody($smartdata['itemid'], $_partID, $folder); |
|
| 598 | 598 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 599 | 599 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 600 | 600 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -604,49 +604,49 @@ discard block |
||
| 604 | 604 | { |
| 605 | 605 | // now get on, and fetch the original mail |
| 606 | 606 | $uid = $smartdata['itemid']; |
| 607 | - if ($this->debugLevel>0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 607 | + if ($this->debugLevel > 0) debugLog("IMAP Smartreply is called with FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 608 | 608 | $this->splitID($smartdata['folderid'], $account, $folder); |
| 609 | 609 | |
| 610 | 610 | $this->mail->reopen($folder); |
| 611 | 611 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 612 | - $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')) { |
|
| 612 | + $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')) { |
|
| 615 | 615 | // may be html |
| 616 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 616 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 617 | 617 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 618 | 618 | $isforward = true; |
| 619 | 619 | } |
| 620 | 620 | // plain text Message part |
| 621 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
| 621 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text:'); |
|
| 622 | 622 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 623 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 624 | - $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); |
|
| 623 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 624 | + $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); |
|
| 627 | 627 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 628 | 628 | $isforward = true; |
| 629 | 629 | } |
| 630 | 630 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 631 | 631 | { |
| 632 | 632 | $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); |
|
| 633 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 634 | 634 | $isforward = true; |
| 635 | 635 | } |
| 636 | 636 | // get all the attachments and add them too. |
| 637 | 637 | // start handle Attachments |
| 638 | 638 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 639 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
| 639 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 640 | 640 | $attachmentNames = false; |
| 641 | - if (is_array($attachments) && count($attachments)>0) |
|
| 641 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 642 | 642 | { |
| 643 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 644 | - foreach((array)$attachments as $key => $attachment) |
|
| 643 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 644 | + foreach ((array)$attachments as $key => $attachment) |
|
| 645 | 645 | { |
| 646 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 646 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 647 | 647 | $attachmentNames .= $attachment['name']."\n"; |
| 648 | 648 | $attachmentData = ''; |
| 649 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 649 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 650 | 650 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
| 651 | 651 | //debugLog(__METHOD__.__LINE__.' added part with number:'.$x); |
| 652 | 652 | } |
@@ -662,18 +662,18 @@ discard block |
||
| 662 | 662 | // now set the body |
| 663 | 663 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 664 | 664 | { |
| 665 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 666 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 665 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 666 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 667 | 667 | } |
| 668 | 668 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 669 | 669 | { |
| 670 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
| 671 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 670 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__.' -> '.$Body); |
|
| 671 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 672 | 672 | } |
| 673 | 673 | //advanced debugging |
| 674 | 674 | // Horde SMTP Class uses utf-8 by default. |
| 675 | 675 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 676 | - if ($this->debugLevel>2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
| 676 | + if ($this->debugLevel > 2) debugLog("IMAP-SendMail: MailObject:".array2string($mailObject)); |
|
| 677 | 677 | |
| 678 | 678 | // set a higher timeout for big messages |
| 679 | 679 | @set_time_limit(120); |
@@ -683,15 +683,15 @@ discard block |
||
| 683 | 683 | try { |
| 684 | 684 | $mailObject->Send(); |
| 685 | 685 | } |
| 686 | - catch(phpmailerException $e) { |
|
| 687 | - debugLog("The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 686 | + catch (phpmailerException $e) { |
|
| 687 | + debugLog("The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 688 | 688 | $send = false; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - if (( $smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
| 691 | + if (($smartdata['task'] == 'reply' || $smartdata['task'] == 'forward') && $send == true) |
|
| 692 | 692 | { |
| 693 | 693 | $uid = $smartdata['itemid']; |
| 694 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 694 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' tASK:'.$smartdata['task']." FolderID:".$smartdata['folderid'].' and ItemID:'.$smartdata['itemid']); |
|
| 695 | 695 | $this->splitID($smartdata['folderid'], $account, $folder); |
| 696 | 696 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 697 | 697 | $this->mail->reopen($folder); |
@@ -699,25 +699,25 @@ discard block |
||
| 699 | 699 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 700 | 700 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 701 | 701 | { |
| 702 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 702 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 703 | 703 | } else { |
| 704 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 705 | - if ($smartdata['task']== "forward") |
|
| 704 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 705 | + if ($smartdata['task'] == "forward") |
|
| 706 | 706 | { |
| 707 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 707 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - $asf = ($send ? true:false); // initalize accordingly |
|
| 713 | - if (($smartdata['saveinsentitems']==1 || !isset($smartdata['saveinsentitems'])) && $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 712 | + $asf = ($send ? true : false); // initalize accordingly |
|
| 713 | + if (($smartdata['saveinsentitems'] == 1 || !isset($smartdata['saveinsentitems'])) && $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 714 | 714 | { |
| 715 | 715 | $asf = false; |
| 716 | 716 | $sentFolder = $this->mail->getSentFolder(); |
| 717 | 717 | if ($this->_sentID) { |
| 718 | 718 | $folderArray[] = $this->_sentID; |
| 719 | 719 | } |
| 720 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 720 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 721 | 721 | { |
| 722 | 722 | $folderArray[] = $sentFolder; |
| 723 | 723 | } |
@@ -729,43 +729,43 @@ discard block |
||
| 729 | 729 | $asf = true; |
| 730 | 730 | } |
| 731 | 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) { |
|
| 734 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 732 | + foreach ((array)$bccMailAddr as $address) { |
|
| 733 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 734 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 735 | 735 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 736 | 736 | } |
| 737 | 737 | } |
| 738 | - $BCCmail=''; |
|
| 739 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
| 740 | - foreach($folderArray as $folderName) { |
|
| 741 | - if($this->mail->isSentFolder($folderName)) { |
|
| 738 | + $BCCmail = ''; |
|
| 739 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
| 740 | + foreach ($folderArray as $folderName) { |
|
| 741 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 742 | 742 | $flags = '\\Seen'; |
| 743 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 743 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 744 | 744 | $flags = '\\Draft'; |
| 745 | 745 | } else { |
| 746 | 746 | $flags = ''; |
| 747 | 747 | } |
| 748 | 748 | $asf = true; |
| 749 | 749 | //debugLog(__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 750 | - $this->mail->openConnection(self::$profileID,false); |
|
| 750 | + $this->mail->openConnection(self::$profileID, false); |
|
| 751 | 751 | if ($this->mail->folderExists($folderName)) { |
| 752 | 752 | try |
| 753 | 753 | { |
| 754 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 754 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 755 | 755 | $flags); |
| 756 | 756 | } |
| 757 | 757 | catch (egw_exception_wrong_userinput $e) |
| 758 | 758 | { |
| 759 | 759 | //$asf = false; |
| 760 | - 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 | + 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())); |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | else |
| 764 | 764 | { |
| 765 | 765 | //$asf = false; |
| 766 | - debugLog(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 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 | } |
@@ -779,8 +779,8 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | else |
| 781 | 781 | { |
| 782 | - debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 783 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 782 | + debugLog(__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 783 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | } |
@@ -792,39 +792,39 @@ discard block |
||
| 792 | 792 | * |
| 793 | 793 | * @see activesync_plugin_read::GetMessage() |
| 794 | 794 | */ |
| 795 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
| 795 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
| 796 | 796 | { |
| 797 | 797 | //$this->debugLevel=4; |
| 798 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 798 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
| 799 | 799 | debugLog(__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
| 800 | - $rv = $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 800 | + $rv = $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 801 | 801 | $this->mail->reopen($_folderName); |
| 802 | 802 | $stat = $this->StatMessage($folderid, $id); |
| 803 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
| 803 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($stat)); |
|
| 804 | 804 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 805 | 805 | if ($stat) |
| 806 | 806 | { |
| 807 | 807 | debugLog(__METHOD__.__LINE__." Message $id with stat ".array2string($stat)); |
| 808 | 808 | // initialize the object |
| 809 | 809 | $output = new SyncMail(); |
| 810 | - $headers = $this->mail->getMessageHeader($id,'',true,true,$_folderName); |
|
| 810 | + $headers = $this->mail->getMessageHeader($id, '', true, true, $_folderName); |
|
| 811 | 811 | if (empty($headers)) |
| 812 | 812 | { |
| 813 | 813 | 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)); |
| 814 | - return $output;//empty object |
|
| 814 | + return $output; //empty object |
|
| 815 | 815 | } |
| 816 | 816 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 817 | 817 | // simple style |
| 818 | 818 | // 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)); |
|
| 819 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 820 | 820 | if ($bodypreference === false) { |
| 821 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 822 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 821 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 822 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 823 | 823 | //$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 |
|
| 824 | + if (stripos($body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part |
|
| 825 | 825 | // remove all other html |
| 826 | 826 | $body = strip_tags($body); |
| 827 | - if(strlen($body) > $truncsize) { |
|
| 827 | + if (strlen($body) > $truncsize) { |
|
| 828 | 828 | $body = utf8_truncate($body, $truncsize); |
| 829 | 829 | $output->bodytruncated = 1; |
| 830 | 830 | } |
@@ -838,60 +838,60 @@ discard block |
||
| 838 | 838 | else // style with bodypreferences |
| 839 | 839 | { |
| 840 | 840 | if (isset($bodypreference[1]) && !isset($bodypreference[1]["TruncationSize"])) |
| 841 | - $bodypreference[1]["TruncationSize"] = 1024*1024; |
|
| 841 | + $bodypreference[1]["TruncationSize"] = 1024 * 1024; |
|
| 842 | 842 | if (isset($bodypreference[2]) && !isset($bodypreference[2]["TruncationSize"])) |
| 843 | - $bodypreference[2]["TruncationSize"] = 1024*1024; |
|
| 843 | + $bodypreference[2]["TruncationSize"] = 1024 * 1024; |
|
| 844 | 844 | if (isset($bodypreference[3]) && !isset($bodypreference[3]["TruncationSize"])) |
| 845 | - $bodypreference[3]["TruncationSize"] = 1024*1024; |
|
| 845 | + $bodypreference[3]["TruncationSize"] = 1024 * 1024; |
|
| 846 | 846 | if (isset($bodypreference[4]) && !isset($bodypreference[4]["TruncationSize"])) |
| 847 | - $bodypreference[4]["TruncationSize"] = 1024*1024; |
|
| 847 | + $bodypreference[4]["TruncationSize"] = 1024 * 1024; |
|
| 848 | 848 | // set the protocoll class |
| 849 | 849 | $output->airsyncbasebody = new SyncAirSyncBaseBody(); |
| 850 | - if ($this->debugLevel>0) debugLog("airsyncbasebody!"); |
|
| 850 | + if ($this->debugLevel > 0) debugLog("airsyncbasebody!"); |
|
| 851 | 851 | // fetch the body (try to gather data only once) |
| 852 | - $css =''; |
|
| 853 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 854 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 855 | - $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')) { |
|
| 852 | + $css = ''; |
|
| 853 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 854 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 855 | + $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')) { |
|
| 858 | 858 | // may be html |
| 859 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
| 859 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
| 860 | 860 | $css = $this->mail->getStyles($bodyStruct); |
| 861 | - $output->airsyncbasenativebodytype=2; |
|
| 861 | + $output->airsyncbasenativebodytype = 2; |
|
| 862 | 862 | } else { |
| 863 | 863 | // plain text Message |
| 864 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 865 | - $output->airsyncbasenativebodytype=1; |
|
| 866 | - $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)); |
|
| 868 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 869 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 864 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 865 | + $output->airsyncbasenativebodytype = 1; |
|
| 866 | + $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)); |
|
| 868 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 869 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 870 | 870 | } |
| 871 | 871 | // whatever format decode (using the correct encoding) |
| 872 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype==2?' html ':' plain ').$body); |
|
| 872 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__."MIME Body".' Type:'.($output->airsyncbasenativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 873 | 873 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 874 | 874 | // prepare plaintextbody |
| 875 | 875 | if ($output->airsyncbasenativebodytype == 2) |
| 876 | 876 | { |
| 877 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 878 | - if($bodyStructplain[0]['error']==1) |
|
| 877 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 878 | + if ($bodyStructplain[0]['error'] == 1) |
|
| 879 | 879 | { |
| 880 | 880 | $plainBody = translation::convertHTMLToText($body); // always display with preserved HTML |
| 881 | 881 | } |
| 882 | 882 | else |
| 883 | 883 | { |
| 884 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 884 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | //if ($this->debugLevel>0) debugLog("MIME Body".$body); |
| 888 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 888 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 889 | 889 | // remove all other html |
| 890 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 890 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 891 | 891 | $plainBody = strip_tags($plainBody); |
| 892 | - if ($this->debugLevel>3 && $output->airsyncbasenativebodytype==1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 892 | + if ($this->debugLevel > 3 && $output->airsyncbasenativebodytype == 1) debugLog(__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 893 | 893 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 894 | - if (isset($bodypreference[4]) && ($mimesupport==2 || ($mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false))) |
|
| 894 | + if (isset($bodypreference[4]) && ($mimesupport == 2 || ($mimesupport == 1 && stristr($headers['CONTENT-TYPE'], 'signed') !== false))) |
|
| 895 | 895 | { |
| 896 | 896 | debugLog(__METHOD__.__LINE__." bodypreference 4 requested"); |
| 897 | 897 | $output->airsyncbasebody->type = 4; |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | // we create a complete new rfc822 message here to pass a clean one to the client. |
| 904 | 904 | // this strips a lot of information, but ... |
| 905 | 905 | $Header = $Body = ''; |
| 906 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
| 906 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject."); |
|
| 907 | 907 | //if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__." Using data from ".$rawHeaders.$rawBody); |
| 908 | 908 | //$this->mail->parseRawMessageIntoMailObject($mailObject,$rawHeaders.$rawBody,$Header,$Body); |
| 909 | 909 | //debugLog(__METHOD__.__LINE__.array2string($headers)); |
@@ -916,33 +916,33 @@ discard block |
||
| 916 | 916 | $mailObject->Subject = $headers['SUBJECT']; |
| 917 | 917 | $mailObject->MessageID = $headers['MESSAGE-ID']; |
| 918 | 918 | // from |
| 919 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) { |
|
| 919 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['FROM']) : $headers['FROM'])) as $addressObject) { |
|
| 920 | 920 | //debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
| 921 | 921 | if (!$addressObject->valid) continue; |
| 922 | - $mailObject->From = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 922 | + $mailObject->From = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 923 | 923 | $mailObject->FromName = $addressObject->personal; |
| 924 | 924 | //error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); |
| 925 | 925 | } |
| 926 | 926 | // to |
| 927 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) { |
|
| 927 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['TO']) : $headers['TO'])) as $addressObject) { |
|
| 928 | 928 | //debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject)); |
| 929 | 929 | if (!$addressObject->valid) continue; |
| 930 | - $mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
| 930 | + $mailObject->AddAddress($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
| 931 | 931 | } |
| 932 | 932 | // CC |
| 933 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) { |
|
| 933 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['CC']) : $headers['CC'])) as $addressObject) { |
|
| 934 | 934 | //debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject)); |
| 935 | 935 | if (!$addressObject->valid) continue; |
| 936 | - $mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
| 936 | + $mailObject->AddCC($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
| 937 | 937 | } |
| 938 | 938 | // AddReplyTo |
| 939 | - foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) { |
|
| 939 | + foreach (emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc() ? stripslashes($headers['REPLY-TO']) : $headers['REPLY-TO'])) as $addressObject) { |
|
| 940 | 940 | //debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject)); |
| 941 | 941 | if (!$addressObject->valid) continue; |
| 942 | - $mailObject->AddReplyTo($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
|
| 942 | + $mailObject->AddReplyTo($addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''), $addressObject->personal); |
|
| 943 | 943 | } |
| 944 | 944 | $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."); |
|
| 945 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__." Creation of Mailobject succeeded."); |
|
| 946 | 946 | } |
| 947 | 947 | catch (egw_exception_assertion_failed $e) |
| 948 | 948 | { |
@@ -950,9 +950,9 @@ discard block |
||
| 950 | 950 | $Header = $Body = ''; |
| 951 | 951 | } |
| 952 | 952 | |
| 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"); |
|
| 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"); |
|
| 956 | 956 | $html = '<html>'. |
| 957 | 957 | '<head>'. |
| 958 | 958 | '<meta name="Generator" content="Z-Push">'. |
@@ -960,30 +960,30 @@ discard block |
||
| 960 | 960 | $css. |
| 961 | 961 | '</head>'. |
| 962 | 962 | '<body>'. |
| 963 | - str_replace("\n","<BR>",str_replace("\r","", str_replace("\r\n","<BR>",$body))). |
|
| 963 | + str_replace("\n", "<BR>", str_replace("\r", "", str_replace("\r\n", "<BR>", $body))). |
|
| 964 | 964 | '</body>'. |
| 965 | 965 | '</html>'; |
| 966 | - $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
|
| 967 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
| 968 | - $mailObject->setBody(empty($plainBody)?strip_tags($body):$plainBody); |
|
| 966 | + $mailObject->setHtmlBody(str_replace("\n", "\r\n", str_replace("\r", "", $html)), null, false); |
|
| 967 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
| 968 | + $mailObject->setBody(empty($plainBody) ? strip_tags($body) : $plainBody); |
|
| 969 | 969 | } |
| 970 | - if ($output->airsyncbasenativebodytype==1) { //plain |
|
| 971 | - if ($this->debugLevel>0) debugLog("Plain Body with requested pref 4"); |
|
| 970 | + if ($output->airsyncbasenativebodytype == 1) { //plain |
|
| 971 | + if ($this->debugLevel > 0) debugLog("Plain Body with requested pref 4"); |
|
| 972 | 972 | $mailObject->setBody($plainBody); |
| 973 | 973 | } |
| 974 | 974 | // we still need the attachments to be added ( if there are any ) |
| 975 | 975 | // start handle Attachments |
| 976 | 976 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 977 | - $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true , $_folderName); |
|
| 978 | - if (is_array($attachments) && count($attachments)>0) |
|
| 977 | + $attachments = $this->mail->getMessageAttachments($id, null, null, true, false, true, $_folderName); |
|
| 978 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 979 | 979 | { |
| 980 | 980 | debugLog(__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$id.' found:'.count($attachments)); |
| 981 | 981 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 982 | - foreach((array)$attachments as $key => $attachment) |
|
| 982 | + foreach ((array)$attachments as $key => $attachment) |
|
| 983 | 983 | { |
| 984 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 984 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 985 | 985 | $attachmentData = ''; |
| 986 | - $attachmentData = $this->mail->getAttachment($id, $attachment['partID'],0,false,false,$_folderName); |
|
| 986 | + $attachmentData = $this->mail->getAttachment($id, $attachment['partID'], 0, false, false, $_folderName); |
|
| 987 | 987 | $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
| 988 | 988 | } |
| 989 | 989 | } |
@@ -991,13 +991,13 @@ discard block |
||
| 991 | 991 | $Header = $mailObject->getMessageHeader(); |
| 992 | 992 | //debugLog(__METHOD__.__LINE__.' MailObject-Header:'.array2string($Header)); |
| 993 | 993 | $Body = trim($mailObject->getMessageBody()); // philip thinks this is needed, so lets try if it does any good/harm |
| 994 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
| 995 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
| 994 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
| 995 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
| 996 | 996 | $output->airsyncbasebody->data = $Header.self::$LE.self::$LE.$Body; |
| 997 | 997 | } |
| 998 | 998 | else if (isset($bodypreference[2])) |
| 999 | 999 | { |
| 1000 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
| 1000 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 2"); |
|
| 1001 | 1001 | // Send HTML if requested and native type was html |
| 1002 | 1002 | $output->airsyncbasebody->type = 2; |
| 1003 | 1003 | $htmlbody = '<html>'. |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | $css. |
| 1008 | 1008 | '</head>'. |
| 1009 | 1009 | '<body>'; |
| 1010 | - if ($output->airsyncbasenativebodytype==2) |
|
| 1010 | + if ($output->airsyncbasenativebodytype == 2) |
|
| 1011 | 1011 | { |
| 1012 | 1012 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1013 | 1013 | $htmlbody .= $body; |
@@ -1015,14 +1015,14 @@ discard block |
||
| 1015 | 1015 | else |
| 1016 | 1016 | { |
| 1017 | 1017 | // html requested but got only plaintext, so fake html |
| 1018 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 1018 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | $htmlbody .= '</body>'. |
| 1021 | 1021 | '</html>'; |
| 1022 | 1022 | |
| 1023 | - if(isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
| 1023 | + if (isset($bodypreference[2]["TruncationSize"]) && strlen($html) > $bodypreference[2]["TruncationSize"]) |
|
| 1024 | 1024 | { |
| 1025 | - $htmlbody = utf8_truncate($htmlbody,$bodypreference[2]["TruncationSize"]); |
|
| 1025 | + $htmlbody = utf8_truncate($htmlbody, $bodypreference[2]["TruncationSize"]); |
|
| 1026 | 1026 | $output->airsyncbasebody->truncated = 1; |
| 1027 | 1027 | } |
| 1028 | 1028 | $output->airsyncbasebody->data = $htmlbody; |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | else |
| 1031 | 1031 | { |
| 1032 | 1032 | // Send Plaintext as Fallback or if original body is plainttext |
| 1033 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
| 1033 | + if ($this->debugLevel > 0) debugLog("Plaintext Body:".$plainBody); |
|
| 1034 | 1034 | /* we use plainBody (set above) instead |
| 1035 | 1035 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1036 | 1036 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | //$plain = str_replace("\n","\r\n",str_replace("\r","",$plain)); |
| 1040 | 1040 | */ |
| 1041 | 1041 | $output->airsyncbasebody->type = 1; |
| 1042 | - if(isset($bodypreference[1]["TruncationSize"]) && |
|
| 1042 | + if (isset($bodypreference[1]["TruncationSize"]) && |
|
| 1043 | 1043 | strlen($plainBody) > $bodypreference[1]["TruncationSize"]) |
| 1044 | 1044 | { |
| 1045 | 1045 | $plainBody = utf8_truncate($plainBody, $bodypreference[1]["TruncationSize"]); |
@@ -1060,21 +1060,20 @@ discard block |
||
| 1060 | 1060 | debugLog(__METHOD__.__LINE__.' gather Header info:'.$headers['SUBJECT'].' from:'.$headers['DATE']); |
| 1061 | 1061 | $output->read = $stat["flags"]; |
| 1062 | 1062 | $output->subject = $this->messages[$id]['subject']; |
| 1063 | - $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : |
|
| 1064 | - ($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'] |
|
| 1063 | + $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : ($this->messages[$id]['priority'] < 3 ? 2 : 1); |
|
| 1064 | + $output->datereceived = $this->mail->_strtotime($headers['DATE'], 'ts', true); |
|
| 1065 | + $output->displayto = ($headers['TO'] ? $headers['TO'] : null); //$stat['FETCHED_HEADER']['to_name'] |
|
| 1067 | 1066 | // $output->to = $this->messages[$id]['to_address']; //$stat['FETCHED_HEADER']['to_name'] |
| 1068 | 1067 | // $output->from = $this->messages[$id]['sender_address']; //$stat['FETCHED_HEADER']['sender_name'] |
| 1069 | 1068 | //error_log(__METHOD__.__LINE__.' To:'.$headers['TO']); |
| 1070 | 1069 | $output->to = $headers['TO']; |
| 1071 | 1070 | //error_log(__METHOD__.__LINE__.' From:'.$headers['FROM']); |
| 1072 | 1071 | $output->from = $headers['FROM']; |
| 1073 | - $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
| 1074 | - $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
| 1072 | + $output->cc = ($headers['CC'] ? $headers['CC'] : null); |
|
| 1073 | + $output->reply_to = ($headers['REPLY_TO'] ? $headers['REPLY_TO'] : null); |
|
| 1075 | 1074 | $output->messageclass = "IPM.Note"; |
| 1076 | - if (stripos($this->messages[$id]['mimetype'],'multipart')!== false && |
|
| 1077 | - stripos($this->messages[$id]['mimetype'],'signed')!== false) |
|
| 1075 | + if (stripos($this->messages[$id]['mimetype'], 'multipart') !== false && |
|
| 1076 | + stripos($this->messages[$id]['mimetype'], 'signed') !== false) |
|
| 1078 | 1077 | { |
| 1079 | 1078 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1080 | 1079 | } |
@@ -1089,61 +1088,61 @@ discard block |
||
| 1089 | 1088 | } |
| 1090 | 1089 | |
| 1091 | 1090 | $output->internetcpid = 65001; |
| 1092 | - $output->contentclass="urn:content-classes:message"; |
|
| 1091 | + $output->contentclass = "urn:content-classes:message"; |
|
| 1093 | 1092 | // end AS12 Stuff |
| 1094 | 1093 | |
| 1095 | 1094 | // start handle Attachments (include text/calendar multipart alternative) |
| 1096 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1097 | - if (is_array($attachments) && count($attachments)>0) |
|
| 1095 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1096 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 1098 | 1097 | { |
| 1099 | 1098 | debugLog(__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
| 1100 | 1099 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1101 | 1100 | foreach ($attachments as $key => $attach) |
| 1102 | 1101 | { |
| 1103 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1102 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1104 | 1103 | |
| 1105 | 1104 | // pass meeting requests to calendar plugin |
| 1106 | 1105 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1107 | 1106 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1108 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1107 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1109 | 1108 | ($output->meetingrequest = calendar_activesync::meetingRequest($attachment['attachment']))) |
| 1110 | 1109 | { |
| 1111 | 1110 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1112 | - continue; // do NOT add attachment as attachment |
|
| 1111 | + continue; // do NOT add attachment as attachment |
|
| 1113 | 1112 | } |
| 1114 | - if(isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
| 1113 | + if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
| 1115 | 1114 | $attachment = new SyncAttachment(); |
| 1116 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1115 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1117 | 1116 | $attachment = new SyncAirSyncBaseAttachment(); |
| 1118 | 1117 | } |
| 1119 | 1118 | $attachment->attsize = $attach['size']; |
| 1120 | 1119 | $attachment->displayname = $attach['name']; |
| 1121 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1120 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1122 | 1121 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1123 | 1122 | $attachment->attmethod = 1; |
| 1124 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1125 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1123 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1124 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1126 | 1125 | { |
| 1127 | - $attachment->isinline=true; |
|
| 1128 | - $attachment->attmethod=6; |
|
| 1129 | - $attachment->contentid= $attach['cid']; |
|
| 1126 | + $attachment->isinline = true; |
|
| 1127 | + $attachment->attmethod = 6; |
|
| 1128 | + $attachment->contentid = $attach['cid']; |
|
| 1130 | 1129 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1131 | 1130 | $attachment->contenttype = trim($attach['mimeType']); |
| 1132 | 1131 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1133 | 1132 | } else { |
| 1134 | - $attachment->attmethod=1; |
|
| 1133 | + $attachment->attmethod = 1; |
|
| 1135 | 1134 | } |
| 1136 | 1135 | |
| 1137 | 1136 | if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
| 1138 | 1137 | array_push($output->attachments, $attachment); |
| 1139 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1138 | + } else if (isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1140 | 1139 | array_push($output->airsyncbaseattachments, $attachment); |
| 1141 | 1140 | } |
| 1142 | 1141 | } |
| 1143 | 1142 | } |
| 1144 | 1143 | //$this->debugLevel=0; |
| 1145 | 1144 | // end handle Attachments |
| 1146 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
| 1145 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
| 1147 | 1146 | return $output; |
| 1148 | 1147 | } |
| 1149 | 1148 | return false; |
@@ -1173,16 +1172,16 @@ discard block |
||
| 1173 | 1172 | return false; |
| 1174 | 1173 | } |
| 1175 | 1174 | $ret = false; |
| 1176 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1175 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1177 | 1176 | { |
| 1178 | 1177 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1179 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1178 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1180 | 1179 | { |
| 1181 | 1180 | debugLog(__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
| 1182 | 1181 | |
| 1183 | 1182 | // calling backend again with iCal attachment, to let calendar add the event |
| 1184 | 1183 | if (($ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1185 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1184 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1186 | 1185 | $response, $calendarid))) |
| 1187 | 1186 | { |
| 1188 | 1187 | $ret = $calendarid; |
@@ -1204,17 +1203,17 @@ discard block |
||
| 1204 | 1203 | * @param string $attname - should contain (folder)id |
| 1205 | 1204 | * @return true, prints the content of the attachment |
| 1206 | 1205 | */ |
| 1207 | - function GetAttachmentData($fid,$attname) { |
|
| 1206 | + function GetAttachmentData($fid, $attname) { |
|
| 1208 | 1207 | debugLog("getAttachmentData: $fid (attname: '$attname')"); |
| 1209 | 1208 | error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1210 | 1209 | list($folderid, $id, $part) = explode(":", $attname); |
| 1211 | 1210 | |
| 1212 | 1211 | $this->splitID($folderid, $account, $folder); |
| 1213 | 1212 | |
| 1214 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1213 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
| 1215 | 1214 | |
| 1216 | 1215 | $this->mail->reopen($folder); |
| 1217 | - $attachment = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
| 1216 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
| 1218 | 1217 | print $attachment['attachment']; |
| 1219 | 1218 | unset($attachment); |
| 1220 | 1219 | return true; |
@@ -1230,17 +1229,17 @@ discard block |
||
| 1230 | 1229 | * @param string $attname - should contain (folder)id |
| 1231 | 1230 | * @return SyncAirSyncBaseFileAttachment-object |
| 1232 | 1231 | */ |
| 1233 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1232 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1234 | 1233 | debugLog("ItemOperationsGetAttachmentData: (attname: '$attname')"); |
| 1235 | 1234 | |
| 1236 | 1235 | list($folderid, $id, $part) = explode(":", $attname); |
| 1237 | 1236 | |
| 1238 | 1237 | $this->splitID($folderid, $account, $folder); |
| 1239 | 1238 | |
| 1240 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
| 1239 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
| 1241 | 1240 | |
| 1242 | 1241 | $this->mail->reopen($folder); |
| 1243 | - $att = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
|
| 1242 | + $att = $this->mail->getAttachment($id, $part, 0, false, false, $folder); |
|
| 1244 | 1243 | $attachment = new SyncAirSyncBaseFileAttachment(); |
| 1245 | 1244 | /* |
| 1246 | 1245 | debugLog(__METHOD__.__LINE__.array2string($att)); |
@@ -1302,17 +1301,17 @@ discard block |
||
| 1302 | 1301 | $this->splitID($folderid, $account, $srcFolder); |
| 1303 | 1302 | $this->splitID($newfolderid, $account, $destFolder); |
| 1304 | 1303 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1305 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1304 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
| 1306 | 1305 | $this->mail->reopen($destFolder); |
| 1307 | 1306 | $status = $this->mail->getFolderStatus($destFolder); |
| 1308 | 1307 | $uidNext = $status['uidnext']; |
| 1309 | 1308 | $this->mail->reopen($srcFolder); |
| 1310 | 1309 | |
| 1311 | 1310 | // move message |
| 1312 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1311 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1313 | 1312 | debugLog(__METHOD__.__LINE__.array2string($rv)); // this may be true, so try using the nextUID value by examine |
| 1314 | 1313 | // return the new id "as string"" |
| 1315 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1314 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1316 | 1315 | } |
| 1317 | 1316 | |
| 1318 | 1317 | /** |
@@ -1320,86 +1319,86 @@ discard block |
||
| 1320 | 1319 | * |
| 1321 | 1320 | * @ToDo loop over available email accounts |
| 1322 | 1321 | */ |
| 1323 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1322 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1324 | 1323 | { |
| 1325 | 1324 | static $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)); |
|
| 1325 | + if (!empty($cutoffdate) && $cutoffdate > 0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
| 1326 | + debugLog(__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
| 1328 | 1327 | if (empty($cutdate)) |
| 1329 | 1328 | { |
| 1330 | - $cutdate = egw_time::to('now','ts')-(3600*24*28*3); |
|
| 1329 | + $cutdate = egw_time::to('now', 'ts') - (3600 * 24 * 28 * 3); |
|
| 1331 | 1330 | debugLog(__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate)); |
| 1332 | 1331 | } |
| 1333 | 1332 | return $this->fetchMessages($folderid, $cutdate); |
| 1334 | 1333 | } |
| 1335 | 1334 | |
| 1336 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
|
| 1335 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL) |
|
| 1337 | 1336 | { |
| 1338 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1337 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1339 | 1338 | //debugLog(__METHOD__.__LINE__); |
| 1340 | 1339 | $rv_messages = array(); |
| 1341 | 1340 | // if the message is still available within the class, we use it instead of fetching it again |
| 1342 | - if (is_array($_id) && count($_id)==1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
| 1341 | + if (is_array($_id) && count($_id) == 1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
| 1343 | 1342 | { |
| 1344 | 1343 | //debugLog(__METHOD__.__LINE__." the message ".$_id[0]." is still available within the class, we use it instead of fetching it again"); |
| 1345 | 1344 | $rv_messages = array('header'=>array($this->messages[$_id[0]])); |
| 1346 | 1345 | } |
| 1347 | 1346 | if (empty($rv_messages)) |
| 1348 | 1347 | { |
| 1349 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1348 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1350 | 1349 | $this->_connect($this->account); |
| 1351 | - if ($this->debugLevel>1) |
|
| 1350 | + if ($this->debugLevel > 1) |
|
| 1352 | 1351 | { |
| 1353 | 1352 | $endtime = microtime(true) - $starttime; |
| 1354 | - debugLog(__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1353 | + debugLog(__METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1355 | 1354 | } |
| 1356 | 1355 | $messagelist = array(); |
| 1357 | 1356 | // if not connected, any further action must fail |
| 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) |
|
| 1357 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'type'=>"SINCE", 'string'=> date("d-M-Y", $cutoffdate)); |
|
| 1358 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1359 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1360 | + if ($this->debugLevel > 1) |
|
| 1362 | 1361 | { |
| 1363 | 1362 | $endtime = microtime(true) - $starttime; |
| 1364 | - debugLog(__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1363 | + debugLog(__METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1365 | 1364 | } |
| 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) |
|
| 1365 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1366 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1367 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1368 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1369 | + if ($this->debugLevel > 1) |
|
| 1371 | 1370 | { |
| 1372 | 1371 | $endtime = microtime(true) - $starttime; |
| 1373 | - debugLog(__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1372 | + debugLog(__METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1374 | 1373 | } |
| 1375 | 1374 | } |
| 1376 | - if ($_id == NULL && $this->debugLevel>1) debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
| 1375 | + if ($_id == NULL && $this->debugLevel > 1) debugLog(__METHOD__." found :".count($rv_messages['header'])); |
|
| 1377 | 1376 | //debugLog(__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1378 | 1377 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1379 | 1378 | { |
| 1380 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1379 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1381 | 1380 | $this->messages[$vars['uid']] = $vars; |
| 1382 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1381 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1383 | 1382 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1384 | 1383 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1385 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1384 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1386 | 1385 | $mess["mod"] = $vars['date']; |
| 1387 | 1386 | $mess["id"] = $vars['uid']; |
| 1388 | 1387 | // 'seen' aka 'read' is the only flag we want to know about |
| 1389 | 1388 | $mess["flags"] = 0; |
| 1390 | 1389 | // outlook supports additional flags, set them to 0 |
| 1391 | 1390 | $mess["olflags"] = 0; |
| 1392 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1393 | - if($vars["flagged"]) $mess["olflags"] = 2; |
|
| 1394 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
| 1391 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1392 | + if ($vars["flagged"]) $mess["olflags"] = 2; |
|
| 1393 | + if ($this->debugLevel > 3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
| 1395 | 1394 | $messagelist[$vars['uid']] = $mess; |
| 1396 | 1395 | unset($mess); |
| 1397 | 1396 | } |
| 1398 | 1397 | |
| 1399 | - if ($this->debugLevel>1) |
|
| 1398 | + if ($this->debugLevel > 1) |
|
| 1400 | 1399 | { |
| 1401 | 1400 | $endtime = microtime(true) - $gstarttime; |
| 1402 | - debugLog(__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1401 | + debugLog(__METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1403 | 1402 | } |
| 1404 | 1403 | return $messagelist; |
| 1405 | 1404 | } |
@@ -1413,7 +1412,7 @@ discard block |
||
| 1413 | 1412 | public function getSearchResultsMailbox($searchquery) |
| 1414 | 1413 | { |
| 1415 | 1414 | if (!is_array($searchquery)) return array(); |
| 1416 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1415 | + if ($this->debugLevel > 0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1417 | 1416 | // 19.10.2011 16:28:59 [24502] mail_activesync::getSearchResultsMailbox1408 |
| 1418 | 1417 | //Array( |
| 1419 | 1418 | // [query] => Array( |
@@ -1437,22 +1436,22 @@ discard block |
||
| 1437 | 1436 | } else { |
| 1438 | 1437 | $rebuildresults = false; |
| 1439 | 1438 | } |
| 1440 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1439 | + if ($this->debugLevel > 0) debugLog('RebuildResults ['.$rebuildresults.']'); |
|
| 1441 | 1440 | |
| 1442 | 1441 | if (isset($searchquery['deeptraversal'])) { |
| 1443 | 1442 | $deeptraversal = $searchquery['deeptraversal']; |
| 1444 | 1443 | } else { |
| 1445 | 1444 | $deeptraversal = false; |
| 1446 | 1445 | } |
| 1447 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1446 | + if ($this->debugLevel > 0) debugLog('DeepTraversal ['.$deeptraversal.']'); |
|
| 1448 | 1447 | |
| 1449 | 1448 | if (isset($searchquery['range'])) { |
| 1450 | - $range = explode("-",$searchquery['range']); |
|
| 1449 | + $range = explode("-", $searchquery['range']); |
|
| 1451 | 1450 | $limit = $range[1] - $range[0] + 1; |
| 1452 | 1451 | } else { |
| 1453 | 1452 | $range = false; |
| 1454 | 1453 | } |
| 1455 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
| 1454 | + if ($this->debugLevel > 0) debugLog('Range ['.print_r($range, true).']'); |
|
| 1456 | 1455 | |
| 1457 | 1456 | //foreach($searchquery['query'] as $k => $value) { |
| 1458 | 1457 | // $query = $value; |
@@ -1464,38 +1463,38 @@ discard block |
||
| 1464 | 1463 | // other types may be possible - we support quicksearch first (freeText in subject and from (or TO in Sent Folder)) |
| 1465 | 1464 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
| 1466 | 1465 | { |
| 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; |
|
| 1466 | + 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); |
|
| 1467 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] = true; |
|
| 1469 | 1468 | } |
| 1470 | 1469 | |
| 1471 | 1470 | if (isset($searchquery['query'][0]['value']['Search:FreeText'])) |
| 1472 | 1471 | { |
| 1473 | - $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'); |
|
| 1472 | + $type = (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'); |
|
| 1474 | 1473 | $searchText = $searchquery['query'][0]['value']['Search:FreeText']; |
| 1475 | 1474 | } |
| 1476 | 1475 | if (!$folderid) |
| 1477 | 1476 | { |
| 1478 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1479 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1477 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1478 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1480 | 1479 | } |
| 1481 | 1480 | //if ($searchquery['query'][0]['value'][subquery][0][op]=='Search:GreaterThan'); |
| 1482 | 1481 | //if (isset($searchquery['query'][0]['value'][subquery][0][value][POOMMAIL:DateReceived])); |
| 1483 | 1482 | //if ($searchquery['query'][0]['value'][subquery][1][op]=='Search:LessThan'); |
| 1484 | 1483 | //if (isset($searchquery['query'][0]['value'][subquery][1][value][POOMMAIL:DateReceived])); |
| 1485 | 1484 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1486 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1485 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1487 | 1486 | $this->_connect($account); |
| 1488 | - $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]?'quick':'subject'), |
|
| 1487 | + $_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID] ? 'quick' : 'subject'), |
|
| 1489 | 1488 | 'string'=> $searchText, |
| 1490 | 1489 | 'status'=>'any', |
| 1491 | 1490 | ); |
| 1492 | 1491 | |
| 1493 | 1492 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 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); |
|
| 1493 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1494 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1496 | 1495 | //debugLog(__METHOD__.__LINE__.array2string($rv_messages)); |
| 1497 | - $list=array(); |
|
| 1498 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1496 | + $list = array(); |
|
| 1497 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1499 | 1498 | { |
| 1500 | 1499 | $list[] = array( |
| 1501 | 1500 | "uniqueid" => $folderid.':'.$vars['uid'], |
@@ -1506,7 +1505,7 @@ discard block |
||
| 1506 | 1505 | } |
| 1507 | 1506 | //error_log(__METHOD__.__LINE__.array2string($list)); |
| 1508 | 1507 | //debugLog(__METHOD__.__LINE__.array2string($list)); |
| 1509 | - return $list;//array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
| 1508 | + return $list; //array('rows'=>$list,'status'=>1,'global_search_status'=>1);//array(); |
|
| 1510 | 1509 | } |
| 1511 | 1510 | |
| 1512 | 1511 | /** |
@@ -1516,20 +1515,20 @@ discard block |
||
| 1516 | 1515 | * @param string $folder |
| 1517 | 1516 | * @return string |
| 1518 | 1517 | */ |
| 1519 | - private function getParentID($account,$folder) |
|
| 1518 | + private function getParentID($account, $folder) |
|
| 1520 | 1519 | { |
| 1521 | 1520 | $this->_connect($account); |
| 1522 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1521 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1523 | 1522 | |
| 1524 | 1523 | $mailFolder = $this->folders[$folder]; |
| 1525 | 1524 | if (!isset($mailFolder)) return false; |
| 1526 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1527 | - $parent = explode($delimiter,$folder); |
|
| 1525 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1526 | + $parent = explode($delimiter, $folder); |
|
| 1528 | 1527 | array_pop($parent); |
| 1529 | - $parent = implode($delimiter,$parent); |
|
| 1528 | + $parent = implode($delimiter, $parent); |
|
| 1530 | 1529 | |
| 1531 | 1530 | $id = $parent ? $this->createID($account, $parent) : '0'; |
| 1532 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1531 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1533 | 1532 | return $id; |
| 1534 | 1533 | } |
| 1535 | 1534 | |
@@ -1548,48 +1547,48 @@ discard block |
||
| 1548 | 1547 | try { |
| 1549 | 1548 | $this->splitID($id, $account, $folder); |
| 1550 | 1549 | } |
| 1551 | - catch(Exception $e) { |
|
| 1550 | + catch (Exception $e) { |
|
| 1552 | 1551 | debugLog(__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
| 1553 | - return $folderObj=false; |
|
| 1552 | + return $folderObj = false; |
|
| 1554 | 1553 | } |
| 1555 | 1554 | $this->_connect($account); |
| 1556 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1555 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1557 | 1556 | |
| 1558 | 1557 | $mailFolder = $this->folders[$folder]; |
| 1559 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1558 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1560 | 1559 | |
| 1561 | 1560 | $folderObj = new SyncFolder(); |
| 1562 | 1561 | $folderObj->serverid = $id; |
| 1563 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1562 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1564 | 1563 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1565 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1564 | + if ($this->debugLevel > 1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1566 | 1565 | // get folder-type |
| 1567 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1566 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1568 | 1567 | if ($folder == $inbox) |
| 1569 | 1568 | { |
| 1570 | 1569 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1571 | 1570 | } |
| 1572 | - elseif($this->mail->isDraftFolder($folder, false)) |
|
| 1571 | + elseif ($this->mail->isDraftFolder($folder, false)) |
|
| 1573 | 1572 | { |
| 1574 | 1573 | //debugLog(__METHOD__.' isDraft'); |
| 1575 | 1574 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1576 | 1575 | $folderObj->parentid = 0; // required by devices |
| 1577 | 1576 | } |
| 1578 | - elseif($this->mail->isTrashFolder($folder, false)) |
|
| 1577 | + elseif ($this->mail->isTrashFolder($folder, false)) |
|
| 1579 | 1578 | { |
| 1580 | 1579 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1581 | 1580 | $this->_wasteID = $folder; |
| 1582 | 1581 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1583 | 1582 | $folderObj->parentid = 0; // required by devices |
| 1584 | 1583 | } |
| 1585 | - elseif($this->mail->isSentFolder($folder, false)) |
|
| 1584 | + elseif ($this->mail->isSentFolder($folder, false)) |
|
| 1586 | 1585 | { |
| 1587 | 1586 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1588 | 1587 | $folderObj->parentid = 0; // required by devices |
| 1589 | 1588 | $this->_sentID = $folder; |
| 1590 | 1589 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1591 | 1590 | } |
| 1592 | - elseif($this->mail->isOutbox($folder, false)) |
|
| 1591 | + elseif ($this->mail->isOutbox($folder, false)) |
|
| 1593 | 1592 | { |
| 1594 | 1593 | //debugLog(__METHOD__.' isOutbox'); |
| 1595 | 1594 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1601,7 +1600,7 @@ discard block |
||
| 1601 | 1600 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1602 | 1601 | } |
| 1603 | 1602 | |
| 1604 | - if ($this->debugLevel>1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1603 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1605 | 1604 | return $folderObj; |
| 1606 | 1605 | } |
| 1607 | 1606 | |
@@ -1648,18 +1647,18 @@ discard block |
||
| 1648 | 1647 | if (is_numeric($account)) $type = 'mail'; |
| 1649 | 1648 | if ($type != 'mail') return false; |
| 1650 | 1649 | |
| 1651 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1650 | + if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID, true, false, true); |
|
| 1652 | 1651 | |
| 1653 | 1652 | $changes = array(); |
| 1654 | - debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
|
| 1653 | + debugLog("AlterPingChanges on $folderid ($folder) stat: ".$syncstate); |
|
| 1655 | 1654 | $this->mail->reopen($folder); |
| 1656 | 1655 | |
| 1657 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
| 1656 | + $status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true); |
|
| 1658 | 1657 | if (!$status) { |
| 1659 | 1658 | debugLog("AlterPingChanges: could not stat folder $folder "); |
| 1660 | 1659 | return false; |
| 1661 | 1660 | } else { |
| 1662 | - $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1661 | + $newstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1663 | 1662 | |
| 1664 | 1663 | // message number is different - change occured |
| 1665 | 1664 | if ($syncstate != $newstate) { |
@@ -1718,7 +1717,7 @@ discard block |
||
| 1718 | 1717 | $error = $e->getMessage(); |
| 1719 | 1718 | debugLog(__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1720 | 1719 | // if the server thinks the message does not exist report deletion as success |
| 1721 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1720 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1722 | 1721 | return false; |
| 1723 | 1722 | } |
| 1724 | 1723 | |
@@ -1748,8 +1747,8 @@ discard block |
||
| 1748 | 1747 | |
| 1749 | 1748 | $_messageUID = (array)$id; |
| 1750 | 1749 | $this->_connect($this->account); |
| 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); |
|
| 1750 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1751 | + debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1753 | 1752 | |
| 1754 | 1753 | return $rv; |
| 1755 | 1754 | } |
@@ -1800,8 +1799,8 @@ discard block |
||
| 1800 | 1799 | $_messageUID = (array)$id; |
| 1801 | 1800 | $this->_connect($this->account); |
| 1802 | 1801 | $this->splitID($folderid, $account, $folder); |
| 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); |
|
| 1802 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 1803 | + debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1805 | 1804 | |
| 1806 | 1805 | return $rv; |
| 1807 | 1806 | } |
@@ -1815,17 +1814,17 @@ discard block |
||
| 1815 | 1814 | * @return string |
| 1816 | 1815 | * @throws egw_exception_wrong_parameter |
| 1817 | 1816 | */ |
| 1818 | - private function createID($account,$folder,$id=0) |
|
| 1817 | + private function createID($account, $folder, $id = 0) |
|
| 1819 | 1818 | { |
| 1820 | 1819 | if (!is_numeric($folder)) |
| 1821 | 1820 | { |
| 1822 | 1821 | // convert string $folder in numeric id |
| 1823 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 1822 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 1824 | 1823 | } |
| 1825 | 1824 | |
| 1826 | 1825 | $str = $this->backend->createID($account, $folder, $id); |
| 1827 | 1826 | |
| 1828 | - if ($this->debugLevel>1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1827 | + if ($this->debugLevel > 1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 1829 | 1828 | |
| 1830 | 1829 | return $str; |
| 1831 | 1830 | } |
@@ -1839,14 +1838,14 @@ discard block |
||
| 1839 | 1838 | * @param int &$id=null |
| 1840 | 1839 | * @throws egw_exception_wrong_parameter |
| 1841 | 1840 | */ |
| 1842 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
| 1841 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
| 1843 | 1842 | { |
| 1844 | 1843 | $this->backend->splitID($str, $account, $folder, $id); |
| 1845 | 1844 | |
| 1846 | 1845 | // convert numeric folder-id back to folder name |
| 1847 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 1846 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 1848 | 1847 | |
| 1849 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
| 1848 | + if ($this->debugLevel > 1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
| 1850 | 1849 | } |
| 1851 | 1850 | |
| 1852 | 1851 | /** |
@@ -1863,9 +1862,9 @@ discard block |
||
| 1863 | 1862 | * @param string $folder |
| 1864 | 1863 | * @return int |
| 1865 | 1864 | */ |
| 1866 | - private function folder2hash($account,$folder) |
|
| 1865 | + private function folder2hash($account, $folder) |
|
| 1867 | 1866 | { |
| 1868 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1867 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1869 | 1868 | |
| 1870 | 1869 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 1871 | 1870 | { |
@@ -1886,9 +1885,9 @@ discard block |
||
| 1886 | 1885 | * @param int $index |
| 1887 | 1886 | * @return string NULL if not used so far |
| 1888 | 1887 | */ |
| 1889 | - private function hash2folder($account,$index) |
|
| 1888 | + private function hash2folder($account, $index) |
|
| 1890 | 1889 | { |
| 1891 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1890 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 1892 | 1891 | |
| 1893 | 1892 | return $this->folderHashes[$account][$index]; |
| 1894 | 1893 | } |
@@ -1903,9 +1902,9 @@ discard block |
||
| 1903 | 1902 | if (file_exists($file = $this->hashFile()) && |
| 1904 | 1903 | ($hashes = file_get_contents($file))) |
| 1905 | 1904 | { |
| 1906 | - $this->folderHashes = json_decode($hashes,true); |
|
| 1905 | + $this->folderHashes = json_decode($hashes, true); |
|
| 1907 | 1906 | // fallback in case hashes have been serialized instead of being json-encoded |
| 1908 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 1907 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 1909 | 1908 | { |
| 1910 | 1909 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 1911 | 1910 | $this->folderHashes = unserialize($hashes); |
@@ -1925,7 +1924,7 @@ discard block |
||
| 1925 | 1924 | private function storeFolderHashes() |
| 1926 | 1925 | { |
| 1927 | 1926 | // make sure $this->folderHashes is an array otherwise json_encode may fail on decode for string,integer,float or boolean |
| 1928 | - return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes)?$this->folderHashes:array($this->folderHashes)))); |
|
| 1927 | + return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes) ? $this->folderHashes : array($this->folderHashes)))); |
|
| 1929 | 1928 | } |
| 1930 | 1929 | |
| 1931 | 1930 | /** |
@@ -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,9 +1242,18 @@ 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 | $html = '<html>'. |
| 957 | 1258 | '<head>'. |
| 958 | 1259 | '<meta name="Generator" content="Z-Push">'. |
@@ -964,11 +1265,19 @@ discard block |
||
| 964 | 1265 | '</body>'. |
| 965 | 1266 | '</html>'; |
| 966 | 1267 | $mailObject->setHtmlBody(str_replace("\n","\r\n", str_replace("\r","",$html)),null,false); |
| 967 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
| 1268 | + if ($this->debugLevel>2) |
|
| 1269 | + { |
|
| 1270 | + debugLog(__METHOD__.__LINE__." MIME Body (constructed)-> ".$mailObject->findBody('html')->getContents()); |
|
| 1271 | + } |
|
| 968 | 1272 | $mailObject->setBody(empty($plainBody)?strip_tags($body):$plainBody); |
| 969 | 1273 | } |
| 970 | - if ($output->airsyncbasenativebodytype==1) { //plain |
|
| 971 | - if ($this->debugLevel>0) debugLog("Plain Body with requested pref 4"); |
|
| 1274 | + if ($output->airsyncbasenativebodytype==1) |
|
| 1275 | + { |
|
| 1276 | +//plain |
|
| 1277 | + if ($this->debugLevel>0) |
|
| 1278 | + { |
|
| 1279 | + debugLog("Plain Body with requested pref 4"); |
|
| 1280 | + } |
|
| 972 | 1281 | $mailObject->setBody($plainBody); |
| 973 | 1282 | } |
| 974 | 1283 | // we still need the attachments to be added ( if there are any ) |
@@ -981,7 +1290,10 @@ discard block |
||
| 981 | 1290 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 982 | 1291 | foreach((array)$attachments as $key => $attachment) |
| 983 | 1292 | { |
| 984 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 1293 | + if ($this->debugLevel>0) |
|
| 1294 | + { |
|
| 1295 | + debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 1296 | + } |
|
| 985 | 1297 | $attachmentData = ''; |
| 986 | 1298 | $attachmentData = $this->mail->getAttachment($id, $attachment['partID'],0,false,false,$_folderName); |
| 987 | 1299 | $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
@@ -991,13 +1303,22 @@ discard block |
||
| 991 | 1303 | $Header = $mailObject->getMessageHeader(); |
| 992 | 1304 | //debugLog(__METHOD__.__LINE__.' MailObject-Header:'.array2string($Header)); |
| 993 | 1305 | $Body = trim($mailObject->getMessageBody()); // philip thinks this is needed, so lets try if it does any good/harm |
| 994 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
| 995 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
| 1306 | + if ($this->debugLevel>3) |
|
| 1307 | + { |
|
| 1308 | + debugLog(__METHOD__.__LINE__.' MailObject:'.array2string($mailObject)); |
|
| 1309 | + } |
|
| 1310 | + if ($this->debugLevel>2) |
|
| 1311 | + { |
|
| 1312 | + debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Header.self::$LE.self::$LE.$Body); |
|
| 1313 | + } |
|
| 996 | 1314 | $output->airsyncbasebody->data = $Header.self::$LE.self::$LE.$Body; |
| 997 | 1315 | } |
| 998 | 1316 | else if (isset($bodypreference[2])) |
| 999 | 1317 | { |
| 1000 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
| 1318 | + if ($this->debugLevel>0) |
|
| 1319 | + { |
|
| 1320 | + debugLog("HTML Body with requested pref 2"); |
|
| 1321 | + } |
|
| 1001 | 1322 | // Send HTML if requested and native type was html |
| 1002 | 1323 | $output->airsyncbasebody->type = 2; |
| 1003 | 1324 | $htmlbody = '<html>'. |
@@ -1030,7 +1351,10 @@ discard block |
||
| 1030 | 1351 | else |
| 1031 | 1352 | { |
| 1032 | 1353 | // Send Plaintext as Fallback or if original body is plainttext |
| 1033 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
| 1354 | + if ($this->debugLevel>0) |
|
| 1355 | + { |
|
| 1356 | + debugLog("Plaintext Body:".$plainBody); |
|
| 1357 | + } |
|
| 1034 | 1358 | /* we use plainBody (set above) instead |
| 1035 | 1359 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1036 | 1360 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1100,7 +1424,10 @@ discard block |
||
| 1100 | 1424 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1101 | 1425 | foreach ($attachments as $key => $attach) |
| 1102 | 1426 | { |
| 1103 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1427 | + if ($this->debugLevel>0) |
|
| 1428 | + { |
|
| 1429 | + debugLog(__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1430 | + } |
|
| 1104 | 1431 | |
| 1105 | 1432 | // pass meeting requests to calendar plugin |
| 1106 | 1433 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1111,9 +1438,12 @@ discard block |
||
| 1111 | 1438 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1112 | 1439 | continue; // do NOT add attachment as attachment |
| 1113 | 1440 | } |
| 1114 | - if(isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
| 1441 | + if(isset($output->_mapping['POOMMAIL:Attachments'])) |
|
| 1442 | + { |
|
| 1115 | 1443 | $attachment = new SyncAttachment(); |
| 1116 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1444 | + } |
|
| 1445 | + else if(isset($output->_mapping['AirSyncBase:Attachments'])) |
|
| 1446 | + { |
|
| 1117 | 1447 | $attachment = new SyncAirSyncBaseAttachment(); |
| 1118 | 1448 | } |
| 1119 | 1449 | $attachment->attsize = $attach['size']; |
@@ -1130,20 +1460,28 @@ discard block |
||
| 1130 | 1460 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1131 | 1461 | $attachment->contenttype = trim($attach['mimeType']); |
| 1132 | 1462 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1133 | - } else { |
|
| 1463 | + } |
|
| 1464 | + else |
|
| 1465 | + { |
|
| 1134 | 1466 | $attachment->attmethod=1; |
| 1135 | 1467 | } |
| 1136 | 1468 | |
| 1137 | - if (isset($output->_mapping['POOMMAIL:Attachments'])) { |
|
| 1469 | + if (isset($output->_mapping['POOMMAIL:Attachments'])) |
|
| 1470 | + { |
|
| 1138 | 1471 | array_push($output->attachments, $attachment); |
| 1139 | - } else if(isset($output->_mapping['AirSyncBase:Attachments'])) { |
|
| 1472 | + } |
|
| 1473 | + else if(isset($output->_mapping['AirSyncBase:Attachments'])) |
|
| 1474 | + { |
|
| 1140 | 1475 | array_push($output->airsyncbaseattachments, $attachment); |
| 1141 | 1476 | } |
| 1142 | 1477 | } |
| 1143 | 1478 | } |
| 1144 | 1479 | //$this->debugLevel=0; |
| 1145 | 1480 | // end handle Attachments |
| 1146 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($output)); |
|
| 1481 | + if ($this->debugLevel>3) |
|
| 1482 | + { |
|
| 1483 | + debugLog(__METHOD__.__LINE__.array2string($output)); |
|
| 1484 | + } |
|
| 1147 | 1485 | return $output; |
| 1148 | 1486 | } |
| 1149 | 1487 | return false; |
@@ -1204,14 +1542,18 @@ discard block |
||
| 1204 | 1542 | * @param string $attname - should contain (folder)id |
| 1205 | 1543 | * @return true, prints the content of the attachment |
| 1206 | 1544 | */ |
| 1207 | - function GetAttachmentData($fid,$attname) { |
|
| 1545 | + function GetAttachmentData($fid,$attname) |
|
| 1546 | + { |
|
| 1208 | 1547 | debugLog("getAttachmentData: $fid (attname: '$attname')"); |
| 1209 | 1548 | error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1210 | 1549 | list($folderid, $id, $part) = explode(":", $attname); |
| 1211 | 1550 | |
| 1212 | 1551 | $this->splitID($folderid, $account, $folder); |
| 1213 | 1552 | |
| 1214 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1553 | + if (!isset($this->mail)) |
|
| 1554 | + { |
|
| 1555 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1556 | + } |
|
| 1215 | 1557 | |
| 1216 | 1558 | $this->mail->reopen($folder); |
| 1217 | 1559 | $attachment = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
@@ -1230,14 +1572,18 @@ discard block |
||
| 1230 | 1572 | * @param string $attname - should contain (folder)id |
| 1231 | 1573 | * @return SyncAirSyncBaseFileAttachment-object |
| 1232 | 1574 | */ |
| 1233 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1575 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
| 1576 | + { |
|
| 1234 | 1577 | debugLog("ItemOperationsGetAttachmentData: (attname: '$attname')"); |
| 1235 | 1578 | |
| 1236 | 1579 | list($folderid, $id, $part) = explode(":", $attname); |
| 1237 | 1580 | |
| 1238 | 1581 | $this->splitID($folderid, $account, $folder); |
| 1239 | 1582 | |
| 1240 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
| 1583 | + if (!isset($this->mail)) |
|
| 1584 | + { |
|
| 1585 | + $this->mail = mail_bo::getInstance(false, self::$profileID,true,false,true); |
|
| 1586 | + } |
|
| 1241 | 1587 | |
| 1242 | 1588 | $this->mail->reopen($folder); |
| 1243 | 1589 | $att = $this->mail->getAttachment($id,$part,0,false,false,$folder); |
@@ -1249,7 +1595,8 @@ discard block |
||
| 1249 | 1595 | return $attachment; |
| 1250 | 1596 | } |
| 1251 | 1597 | */ |
| 1252 | - if (is_array($att)) { |
|
| 1598 | + if (is_array($att)) |
|
| 1599 | + { |
|
| 1253 | 1600 | $attachment->_data = $att['attachment']; |
| 1254 | 1601 | $attachment->contenttype = trim($att['type']); |
| 1255 | 1602 | } |
@@ -1297,12 +1644,16 @@ discard block |
||
| 1297 | 1644 | * at all on the source folder, and the destination folder will show the new message |
| 1298 | 1645 | * |
| 1299 | 1646 | */ |
| 1300 | - function MoveMessage($folderid, $id, $newfolderid) { |
|
| 1647 | + function MoveMessage($folderid, $id, $newfolderid) |
|
| 1648 | + { |
|
| 1301 | 1649 | debugLog("IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1302 | 1650 | $this->splitID($folderid, $account, $srcFolder); |
| 1303 | 1651 | $this->splitID($newfolderid, $account, $destFolder); |
| 1304 | 1652 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1305 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1653 | + if (!isset($this->mail)) |
|
| 1654 | + { |
|
| 1655 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 1656 | + } |
|
| 1306 | 1657 | $this->mail->reopen($destFolder); |
| 1307 | 1658 | $status = $this->mail->getFolderStatus($destFolder); |
| 1308 | 1659 | $uidNext = $status['uidnext']; |
@@ -1323,7 +1674,10 @@ discard block |
||
| 1323 | 1674 | public function GetMessageList($folderid, $cutoffdate=NULL) |
| 1324 | 1675 | { |
| 1325 | 1676 | static $cutdate; |
| 1326 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
| 1677 | + if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) |
|
| 1678 | + { |
|
| 1679 | + $cutdate = $cutoffdate; |
|
| 1680 | + } |
|
| 1327 | 1681 | debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
| 1328 | 1682 | if (empty($cutdate)) |
| 1329 | 1683 | { |
@@ -1335,7 +1689,10 @@ discard block |
||
| 1335 | 1689 | |
| 1336 | 1690 | private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
| 1337 | 1691 | { |
| 1338 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1692 | + if ($this->debugLevel>1) |
|
| 1693 | + { |
|
| 1694 | + $gstarttime = microtime (true); |
|
| 1695 | + } |
|
| 1339 | 1696 | //debugLog(__METHOD__.__LINE__); |
| 1340 | 1697 | $rv_messages = array(); |
| 1341 | 1698 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1346,7 +1703,10 @@ discard block |
||
| 1346 | 1703 | } |
| 1347 | 1704 | if (empty($rv_messages)) |
| 1348 | 1705 | { |
| 1349 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1706 | + if ($this->debugLevel>1) |
|
| 1707 | + { |
|
| 1708 | + $starttime = microtime (true); |
|
| 1709 | + } |
|
| 1350 | 1710 | $this->_connect($this->account); |
| 1351 | 1711 | if ($this->debugLevel>1) |
| 1352 | 1712 | { |
@@ -1355,16 +1715,28 @@ discard block |
||
| 1355 | 1715 | } |
| 1356 | 1716 | $messagelist = array(); |
| 1357 | 1717 | // if not connected, any further action must fail |
| 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); |
|
| 1718 | + if (!empty($cutoffdate)) |
|
| 1719 | + { |
|
| 1720 | + $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
| 1721 | + } |
|
| 1722 | + if ($this->debugLevel>1) |
|
| 1723 | + { |
|
| 1724 | + $starttime = microtime (true); |
|
| 1725 | + } |
|
| 1360 | 1726 | $rv = $this->splitID($folderid,$account,$_folderName,$id); |
| 1361 | 1727 | if ($this->debugLevel>1) |
| 1362 | 1728 | { |
| 1363 | 1729 | $endtime = microtime(true) - $starttime; |
| 1364 | 1730 | debugLog(__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
| 1365 | 1731 | } |
| 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); |
|
| 1732 | + if ($this->debugLevel>1) |
|
| 1733 | + { |
|
| 1734 | + debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1735 | + } |
|
| 1736 | + if ($this->debugLevel>1) |
|
| 1737 | + { |
|
| 1738 | + $starttime = microtime (true); |
|
| 1739 | + } |
|
| 1368 | 1740 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
| 1369 | 1741 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
| 1370 | 1742 | if ($this->debugLevel>1) |
@@ -1373,25 +1745,54 @@ discard block |
||
| 1373 | 1745 | debugLog(__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
| 1374 | 1746 | } |
| 1375 | 1747 | } |
| 1376 | - if ($_id == NULL && $this->debugLevel>1) debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
| 1748 | + if ($_id == NULL && $this->debugLevel>1) |
|
| 1749 | + { |
|
| 1750 | + debugLog(__METHOD__." found :". count($rv_messages['header'])); |
|
| 1751 | + } |
|
| 1377 | 1752 | //debugLog(__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1378 | 1753 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1379 | 1754 | { |
| 1380 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1755 | + if ($this->debugLevel>3) |
|
| 1756 | + { |
|
| 1757 | + debugLog(__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1758 | + } |
|
| 1381 | 1759 | $this->messages[$vars['uid']] = $vars; |
| 1382 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1383 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
| 1384 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
| 1385 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1760 | + if ($this->debugLevel>3) |
|
| 1761 | + { |
|
| 1762 | + debugLog(__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1763 | + } |
|
| 1764 | + if (!empty($vars['deleted'])) |
|
| 1765 | + { |
|
| 1766 | + continue; |
|
| 1767 | + } |
|
| 1768 | + // cut of deleted messages |
|
| 1769 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
| 1770 | + { |
|
| 1771 | + continue; |
|
| 1772 | + } |
|
| 1773 | + // message is out of range for cutoffdate, ignore it |
|
| 1774 | + if ($this->debugLevel>0) |
|
| 1775 | + { |
|
| 1776 | + debugLog(__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1777 | + } |
|
| 1386 | 1778 | $mess["mod"] = $vars['date']; |
| 1387 | 1779 | $mess["id"] = $vars['uid']; |
| 1388 | 1780 | // 'seen' aka 'read' is the only flag we want to know about |
| 1389 | 1781 | $mess["flags"] = 0; |
| 1390 | 1782 | // outlook supports additional flags, set them to 0 |
| 1391 | 1783 | $mess["olflags"] = 0; |
| 1392 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1393 | - if($vars["flagged"]) $mess["olflags"] = 2; |
|
| 1394 | - if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
| 1784 | + if($vars["seen"]) |
|
| 1785 | + { |
|
| 1786 | + $mess["flags"] = 1; |
|
| 1787 | + } |
|
| 1788 | + if($vars["flagged"]) |
|
| 1789 | + { |
|
| 1790 | + $mess["olflags"] = 2; |
|
| 1791 | + } |
|
| 1792 | + if ($this->debugLevel>3) |
|
| 1793 | + { |
|
| 1794 | + debugLog(__METHOD__.__LINE__.array2string($mess)); |
|
| 1795 | + } |
|
| 1395 | 1796 | $messagelist[$vars['uid']] = $mess; |
| 1396 | 1797 | unset($mess); |
| 1397 | 1798 | } |
@@ -1412,8 +1813,14 @@ discard block |
||
| 1412 | 1813 | */ |
| 1413 | 1814 | public function getSearchResultsMailbox($searchquery) |
| 1414 | 1815 | { |
| 1415 | - if (!is_array($searchquery)) return array(); |
|
| 1416 | - if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1816 | + if (!is_array($searchquery)) |
|
| 1817 | + { |
|
| 1818 | + return array(); |
|
| 1819 | + } |
|
| 1820 | + if ($this->debugLevel>0) |
|
| 1821 | + { |
|
| 1822 | + debugLog(__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1823 | + } |
|
| 1417 | 1824 | // 19.10.2011 16:28:59 [24502] mail_activesync::getSearchResultsMailbox1408 |
| 1418 | 1825 | //Array( |
| 1419 | 1826 | // [query] => Array( |
@@ -1432,27 +1839,45 @@ discard block |
||
| 1432 | 1839 | // [rebuildresults] => 1 |
| 1433 | 1840 | // [deeptraversal] => |
| 1434 | 1841 | // [range] => 0-999) |
| 1435 | - if (isset($searchquery['rebuildresults'])) { |
|
| 1842 | + if (isset($searchquery['rebuildresults'])) |
|
| 1843 | + { |
|
| 1436 | 1844 | $rebuildresults = $searchquery['rebuildresults']; |
| 1437 | - } else { |
|
| 1845 | + } |
|
| 1846 | + else |
|
| 1847 | + { |
|
| 1438 | 1848 | $rebuildresults = false; |
| 1439 | 1849 | } |
| 1440 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1850 | + if ($this->debugLevel>0) |
|
| 1851 | + { |
|
| 1852 | + debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1853 | + } |
|
| 1441 | 1854 | |
| 1442 | - if (isset($searchquery['deeptraversal'])) { |
|
| 1855 | + if (isset($searchquery['deeptraversal'])) |
|
| 1856 | + { |
|
| 1443 | 1857 | $deeptraversal = $searchquery['deeptraversal']; |
| 1444 | - } else { |
|
| 1858 | + } |
|
| 1859 | + else |
|
| 1860 | + { |
|
| 1445 | 1861 | $deeptraversal = false; |
| 1446 | 1862 | } |
| 1447 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1863 | + if ($this->debugLevel>0) |
|
| 1864 | + { |
|
| 1865 | + debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1866 | + } |
|
| 1448 | 1867 | |
| 1449 | - if (isset($searchquery['range'])) { |
|
| 1868 | + if (isset($searchquery['range'])) |
|
| 1869 | + { |
|
| 1450 | 1870 | $range = explode("-",$searchquery['range']); |
| 1451 | 1871 | $limit = $range[1] - $range[0] + 1; |
| 1452 | - } else { |
|
| 1872 | + } |
|
| 1873 | + else |
|
| 1874 | + { |
|
| 1453 | 1875 | $range = false; |
| 1454 | 1876 | } |
| 1455 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
| 1877 | + if ($this->debugLevel>0) |
|
| 1878 | + { |
|
| 1879 | + debugLog( 'Range ['.print_r($range, true).']' ); |
|
| 1880 | + } |
|
| 1456 | 1881 | |
| 1457 | 1882 | //foreach($searchquery['query'] as $k => $value) { |
| 1458 | 1883 | // $query = $value; |
@@ -1465,7 +1890,10 @@ discard block |
||
| 1465 | 1890 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
| 1466 | 1891 | { |
| 1467 | 1892 | 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; |
|
| 1893 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID])) |
|
| 1894 | + { |
|
| 1895 | + emailadmin_imapbase::$supportsORinQuery[$this->mail->profileID]=true; |
|
| 1896 | + } |
|
| 1469 | 1897 | } |
| 1470 | 1898 | |
| 1471 | 1899 | if (isset($searchquery['query'][0]['value']['Search:FreeText'])) |
@@ -1491,7 +1919,10 @@ discard block |
||
| 1491 | 1919 | ); |
| 1492 | 1920 | |
| 1493 | 1921 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1494 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1922 | + if ($this->debugLevel>1) |
|
| 1923 | + { |
|
| 1924 | + debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1925 | + } |
|
| 1495 | 1926 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
| 1496 | 1927 | //debugLog(__METHOD__.__LINE__.array2string($rv_messages)); |
| 1497 | 1928 | $list=array(); |
@@ -1519,17 +1950,26 @@ discard block |
||
| 1519 | 1950 | private function getParentID($account,$folder) |
| 1520 | 1951 | { |
| 1521 | 1952 | $this->_connect($account); |
| 1522 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1953 | + if (!isset($this->folders)) |
|
| 1954 | + { |
|
| 1955 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1956 | + } |
|
| 1523 | 1957 | |
| 1524 | 1958 | $mailFolder = $this->folders[$folder]; |
| 1525 | - if (!isset($mailFolder)) return false; |
|
| 1959 | + if (!isset($mailFolder)) |
|
| 1960 | + { |
|
| 1961 | + return false; |
|
| 1962 | + } |
|
| 1526 | 1963 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
| 1527 | 1964 | $parent = explode($delimiter,$folder); |
| 1528 | 1965 | array_pop($parent); |
| 1529 | 1966 | $parent = implode($delimiter,$parent); |
| 1530 | 1967 | |
| 1531 | 1968 | $id = $parent ? $this->createID($account, $parent) : '0'; |
| 1532 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1969 | + if ($this->debugLevel>1) |
|
| 1970 | + { |
|
| 1971 | + debugLog(__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1972 | + } |
|
| 1533 | 1973 | return $id; |
| 1534 | 1974 | } |
| 1535 | 1975 | |
@@ -1543,7 +1983,10 @@ discard block |
||
| 1543 | 1983 | { |
| 1544 | 1984 | static $last_id; |
| 1545 | 1985 | static $folderObj; |
| 1546 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
| 1986 | + if (isset($last_id) && $last_id === $id) |
|
| 1987 | + { |
|
| 1988 | + return $folderObj; |
|
| 1989 | + } |
|
| 1547 | 1990 | |
| 1548 | 1991 | try { |
| 1549 | 1992 | $this->splitID($id, $account, $folder); |
@@ -1553,18 +1996,30 @@ discard block |
||
| 1553 | 1996 | return $folderObj=false; |
| 1554 | 1997 | } |
| 1555 | 1998 | $this->_connect($account); |
| 1556 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1999 | + if (!isset($this->folders)) |
|
| 2000 | + { |
|
| 2001 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2002 | + } |
|
| 1557 | 2003 | |
| 1558 | 2004 | $mailFolder = $this->folders[$folder]; |
| 1559 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 2005 | + if (!isset($mailFolder)) |
|
| 2006 | + { |
|
| 2007 | + return $folderObj=false; |
|
| 2008 | + } |
|
| 1560 | 2009 | |
| 1561 | 2010 | $folderObj = new SyncFolder(); |
| 1562 | 2011 | $folderObj->serverid = $id; |
| 1563 | 2012 | $folderObj->parentid = $this->getParentID($account,$folder); |
| 1564 | 2013 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1565 | - if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2014 | + if ($this->debugLevel>1) |
|
| 2015 | + { |
|
| 2016 | + debugLog(__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2017 | + } |
|
| 1566 | 2018 | // get folder-type |
| 1567 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 2019 | + foreach($this->folders as $inbox => $mailFolder) |
|
| 2020 | + { |
|
| 2021 | + break; |
|
| 2022 | + } |
|
| 1568 | 2023 | if ($folder == $inbox) |
| 1569 | 2024 | { |
| 1570 | 2025 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1601,7 +2056,10 @@ discard block |
||
| 1601 | 2056 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1602 | 2057 | } |
| 1603 | 2058 | |
| 1604 | - if ($this->debugLevel>1) debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2059 | + if ($this->debugLevel>1) |
|
| 2060 | + { |
|
| 2061 | + debugLog(__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2062 | + } |
|
| 1605 | 2063 | return $folderObj; |
| 1606 | 2064 | } |
| 1607 | 2065 | |
@@ -1645,24 +2103,37 @@ discard block |
||
| 1645 | 2103 | { |
| 1646 | 2104 | debugLog(__METHOD__.' called with '.$folderid); |
| 1647 | 2105 | $this->splitID($folderid, $account, $folder); |
| 1648 | - if (is_numeric($account)) $type = 'mail'; |
|
| 1649 | - if ($type != 'mail') return false; |
|
| 2106 | + if (is_numeric($account)) |
|
| 2107 | + { |
|
| 2108 | + $type = 'mail'; |
|
| 2109 | + } |
|
| 2110 | + if ($type != 'mail') |
|
| 2111 | + { |
|
| 2112 | + return false; |
|
| 2113 | + } |
|
| 1650 | 2114 | |
| 1651 | - if (!isset($this->mail)) $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 2115 | + if (!isset($this->mail)) |
|
| 2116 | + { |
|
| 2117 | + $this->mail = mail_bo::getInstance(false,self::$profileID,true,false,true); |
|
| 2118 | + } |
|
| 1652 | 2119 | |
| 1653 | 2120 | $changes = array(); |
| 1654 | 2121 | debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate); |
| 1655 | 2122 | $this->mail->reopen($folder); |
| 1656 | 2123 | |
| 1657 | 2124 | $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
| 1658 | - if (!$status) { |
|
| 2125 | + if (!$status) |
|
| 2126 | + { |
|
| 1659 | 2127 | debugLog("AlterPingChanges: could not stat folder $folder "); |
| 1660 | 2128 | return false; |
| 1661 | - } else { |
|
| 2129 | + } |
|
| 2130 | + else |
|
| 2131 | + { |
|
| 1662 | 2132 | $newstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
| 1663 | 2133 | |
| 1664 | 2134 | // message number is different - change occured |
| 1665 | - if ($syncstate != $newstate) { |
|
| 2135 | + if ($syncstate != $newstate) |
|
| 2136 | + { |
|
| 1666 | 2137 | $syncstate = $newstate; |
| 1667 | 2138 | debugLog("AlterPingChanges: Change FOUND!"); |
| 1668 | 2139 | // build a dummy change |
@@ -1718,7 +2189,10 @@ discard block |
||
| 1718 | 2189 | $error = $e->getMessage(); |
| 1719 | 2190 | debugLog(__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1720 | 2191 | // if the server thinks the message does not exist report deletion as success |
| 1721 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 2192 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
| 2193 | + { |
|
| 2194 | + return true; |
|
| 2195 | + } |
|
| 1722 | 2196 | return false; |
| 1723 | 2197 | } |
| 1724 | 2198 | |
@@ -1825,7 +2299,10 @@ discard block |
||
| 1825 | 2299 | |
| 1826 | 2300 | $str = $this->backend->createID($account, $folder, $id); |
| 1827 | 2301 | |
| 1828 | - if ($this->debugLevel>1) debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2302 | + if ($this->debugLevel>1) |
|
| 2303 | + { |
|
| 2304 | + debugLog(__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2305 | + } |
|
| 1829 | 2306 | |
| 1830 | 2307 | return $str; |
| 1831 | 2308 | } |
@@ -1846,7 +2323,10 @@ discard block |
||
| 1846 | 2323 | // convert numeric folder-id back to folder name |
| 1847 | 2324 | $folder = $this->hash2folder($account,$f=$folder); |
| 1848 | 2325 | |
| 1849 | - if ($this->debugLevel>1) debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2326 | + if ($this->debugLevel>1) |
|
| 2327 | + { |
|
| 2328 | + debugLog(__METHOD__."('$str','$account','$folder',$id)"); |
|
| 2329 | + } |
|
| 1850 | 2330 | } |
| 1851 | 2331 | |
| 1852 | 2332 | /** |
@@ -1865,7 +2345,10 @@ discard block |
||
| 1865 | 2345 | */ |
| 1866 | 2346 | private function folder2hash($account,$folder) |
| 1867 | 2347 | { |
| 1868 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2348 | + if(!isset($this->folderHashes)) |
|
| 2349 | + { |
|
| 2350 | + $this->readFolderHashes(); |
|
| 2351 | + } |
|
| 1869 | 2352 | |
| 1870 | 2353 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 1871 | 2354 | { |
@@ -1888,7 +2371,10 @@ discard block |
||
| 1888 | 2371 | */ |
| 1889 | 2372 | private function hash2folder($account,$index) |
| 1890 | 2373 | { |
| 1891 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2374 | + if(!isset($this->folderHashes)) |
|
| 2375 | + { |
|
| 2376 | + $this->readFolderHashes(); |
|
| 2377 | + } |
|
| 1892 | 2378 | |
| 1893 | 2379 | return $this->folderHashes[$account][$index]; |
| 1894 | 2380 | } |
@@ -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 | |