Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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();
}
Ejemplo n.º 3
0
        if (!in_array($from_user, $list)) {
            continue;
            // can't send if you didn't receive
        }
    } else {
        foreach ($from_user as $u) {
            if (in_array($u->user, $list)) {
                $from_user = $u->user;
                break;
            }
        }
    }
    // remove self, add $res->from_user
    foreach ($list as $k => $v) {
        if ($v == $from_user) {
            unset($list[$k]);
        }
    }
    $list = array_unique($list);
    // - subject based on subject of M{id}
    $subject = Workspace::createResponseSubject($res->subject);
    // send message
    $res = $m->send($subject, $body, $list, array(), $msg_id, 'normal', $from_user);
    if (!$res) {
        echo $m->error . NEWLINE;
    }
}
// end foreach
$j->enable_logging = false;
$j->Disconnect();