Exemple #1
0
 function sendList($list)
 {
     // send jabber message
     global $loader, $intl, $site, $conf;
     if ($conf['Messaging']['jabber'] == true) {
         $loader->import('ext.Jabber');
         $jabber = new Jabber();
         $jabber->resource = 'Sitellite CMS ' . SITELLITE_VERSION;
         $jabber->server = $conf['Messaging']['jabber_server'];
         $jabber->port = $conf['Messaging']['jabber_port'];
         $jabber->username = $conf['Messaging']['jabber_username'];
         $jabber->password = $conf['Messaging']['jabber_password'];
         $jabber->enable_logging = true;
         if (!$jabber->Connect()) {
             $this->error = $jabber->log_array[count($jabber->log_array) - 1];
             return false;
         }
         if (!$jabber->SendAuth()) {
             $this->error = $jabber->log_array[count($jabber->log_array) - 1];
             return false;
         }
         foreach ($list as $item) {
             if (strtoupper($item->type) == 'TASK') {
                 $id = 'T' . $item->id;
             } elseif (strtoupper($item->type) == 'MESSAGE') {
                 $id = 'M' . $item->id;
             } else {
                 $id = strtoupper(substr($item->type, 0, 1)) . $item->id;
             }
             if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_SUBJECT')) {
                 $subject = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($item->name) . '_SUBJECT'), $item->struct);
             } else {
                 $subject = '[' . $id . '] ' . $item->subject;
             }
             if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY')) {
                 $body = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY'), $item->struct);
             } else {
                 $body = $item->body;
             }
             if (!$jabber->SendMessage($item->address, $item->priority, null, array('thread' => $id, 'subject' => $subject, 'body' => $body))) {
                 $this->error = $jabber->log_array[count($jabber->log_array) - 1];
                 return false;
             }
             //echo 'fdsa';
         }
         $jabber->enable_logging = false;
         $jabber->Disconnect();
         return true;
     } else {
         $this->error = 'Jabber server info not configured';
         return false;
     }
 }
Exemple #2
0
function util_send_jabber($to, $subject, $body)
{
    if (!$GLOBALS['sys_use_jabber']) {
        return;
    }
    $JABBER = new Jabber();
    if (!$JABBER->Connect()) {
        echo '<br />Unable to connect';
        return false;
    }
    //$JABBER->SendAuth();
    //$JABBER->AccountRegistration();
    if (!$JABBER->SendAuth()) {
        echo '<br />Auth Failure';
        $JABBER->Disconnect();
        return false;
        //or die("Couldn't authenticate!");
    }
    $JABBER->SendPresence(NULL, NULL, "online");
    $body = htmlspecialchars($body);
    $to_arr = explode(',', $to);
    for ($i = 0; $i < count($to_arr); $i++) {
        if ($to_arr[$i]) {
            //echo '<br />Sending Jabbers To: '.$to_arr[$i];
            if (!$JABBER->SendMessage($to_arr[$i], "normal", NULL, array("body" => $body, "subject" => $subject))) {
                echo '<br />Error Sending to ' . $to_arr[$i];
            }
        }
    }
    $JABBER->CruiseControl(2);
    $JABBER->Disconnect();
}
Exemple #3
0
if (empty($conf['Messaging']['jabber_server'])) {
    return;
}
loader_import('ext.Jabber');
loader_import('cms.Workspace.Message');
//loader_import ('cms.Workspace.Task');
$m = new WorkspaceMessage();
//$wtsk = new WorkspaceTask ();
$j = new Jabber();
$j->resource = 'Sitellite CMS ' . SITELLITE_VERSION;
$j->server = $conf['Messaging']['jabber_server'];
$j->port = $conf['Messaging']['jabber_port'];
$j->username = $conf['Messaging']['jabber_username'];
$j->password = $conf['Messaging']['jabber_password'];
$j->enable_logging = true;
if (!$j->Connect()) {
    echo $j->log_array[count($j->log_array) - 1] . NEWLINE;
    return;
}
if (!$j->SendAuth()) {
    echo $j->log_array[count($j->log_array) - 1] . NEWLINE;
    return;
}
$j->SendPresence('available');
sleep(2);
$j->Listen();
foreach ($j->packet_queue as $message) {
    set_time_limit(30);
    if (!array($message) || key($message) != 'message') {
        continue;
    }