| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id$ |
| 3 |
$_webmail_plus_config = NULL; |
$_webmail_plus_config = NULL; |
| 4 |
|
$_webmail_plus_connection = NULL; |
| 5 |
|
|
| 6 |
|
|
| 7 |
/** |
/** |
| 460 |
return $preferences; |
return $preferences; |
| 461 |
} |
} |
| 462 |
|
|
| 463 |
|
|
| 464 |
|
/** |
| 465 |
|
* establishes a connection to mail api |
| 466 |
|
*/ |
| 467 |
|
function webmail_plus_connect() { |
| 468 |
|
global $user, $_webmail_plus_config, $_webmail_plus_connection; |
| 469 |
|
|
| 470 |
|
// do not even bother for anonymous users |
| 471 |
|
if ($user->uid<=0) return FALSE; |
| 472 |
|
|
| 473 |
|
// no need to establish a connection if it's already established |
| 474 |
|
if ($_webmail_plus_connection) { |
| 475 |
|
return TRUE; |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
$_webmail_plus_connection = mail_api_connect($_webmail_plus_config->domain, $user->name, $_webmail_plus_config->password, $folder); |
| 479 |
|
|
| 480 |
|
|
| 481 |
|
if($_mail_api_connection) { |
| 482 |
|
drupal_set_message('connected'); |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
return TRUE; |
| 486 |
|
} |
| 487 |
/* |
/* |
| 488 |
* connects to the mail_api connection and fetches messages |
* connects to the mail_api connection and fetches messages |
| 489 |
*/ |
*/ |
| 490 |
function webmail_plus_update_messages($folder="") { |
function webmail_plus_update_messages($folder="") { |
| 491 |
global $user, $_webmail_plus_config; |
global $user, $_webmail_plus_config, $_webmail_plus_connection; |
| 492 |
|
|
| 493 |
|
|
| 494 |
|
|
| 498 |
|
|
| 499 |
$message_count = db_result(db_query("SELECT COUNT(*) FROM {webmail_plus_user_headers} WHERE uid=%d AND folder='%s'", $user->uid, $folder)); |
$message_count = db_result(db_query("SELECT COUNT(*) FROM {webmail_plus_user_headers} WHERE uid=%d AND folder='%s'", $user->uid, $folder)); |
| 500 |
|
|
| 501 |
$mail_api_connection = mail_api_connect($_webmail_plus_config->domain, $user->name, $_webmail_plus_config->password, $folder); |
$mail_api_connection = webmail_plus_connect(); |
| 502 |
$check = mail_api_check(); |
$check = mail_api_check(); |
| 503 |
|
|
| 504 |
//print_r($check); |
//print_r($check); |