Exemple #1
0
function westorElggMan_init()
{
    global $CONFIG;
    $adminOnlyOption = westorElggMan_get_plugin_setting('adminOnlyOption', 'westorElggMan');
    $isAdmin = method_exists($_SESSION['user'], "isAdmin") ? $_SESSION['user']->isAdmin() : $_SESSION['user']->admin || $_SESSION['user']->siteadmin;
    if ($adminOnlyOption == 'yes' && !$isAdmin) {
        return;
    }
    if (westorElggMan_isloggedin()) {
        if (file_exists($CONFIG->path . "mod/westorElggMan/source/index.php")) {
            westorElggMan_menu_add(elgg_echo('ElggMan_'), $CONFIG->wwwroot . "mod/westorElggMan/source/index.php");
        } else {
            westorElggMan_menu_add(elgg_echo('ElggMan_'), $CONFIG->wwwroot . "mod/westorElggMan/build/index.php");
        }
    }
    // register cron avaery minute task
    westorElggMan_register_plugin_hook('cron', 'minute', 'westorElggMan_cron_handler');
    // override permissions for the myaccess context
    westorElggMan_register_plugin_hook('container_permissions_check', 'all', 'westorElggMan_permissions_check');
    westorElggMan_register_plugin_hook('permissions_check', 'all', 'westorElggMan_permissions_check');
}
 $body = '<script type="text/javascript">';
 $body .= 'var ElggMan_service_url="' . $CONFIG->url . 'mod/westorElggMan/services/";';
 $body .= 'var ElggMan_service_name="qooxdoo.elggMan";';
 $body .= 'var ElggMan_mod_dir="' . $CONFIG->url . 'mod/westorElggMan/";';
 $body .= 'var ElggMan_uid="' . $_SESSION['user']->username . '";';
 $body .= 'var ElggMan_Theme="' . (westorElggMan_get_plugin_setting('theme', 'westorElggMan') ? westorElggMan_get_plugin_setting('theme', 'westorElggMan') : "dark") . '";';
 $body .= 'var ElggMan_PluginWidth=' . (westorElggMan_get_plugin_setting('pluginWidth', 'westorElggMan') ? westorElggMan_get_plugin_setting('pluginWidth', 'westorElggMan') : '920') . ';';
 $body .= 'var ElggMan_PollingInterval=' . (westorElggMan_get_plugin_setting('pollingInterval', 'westorElggMan') ? westorElggMan_get_plugin_setting('pollingInterval', 'westorElggMan') : '20') . ';';
 //			$body .= 'var ElggMan_PluginWidth="980";';
 // if ($_SESSION['user']->admin || $_SESSION['user']->siteadmin) {  // this is only a display option, security will be checked at backend
 if ($isAdmin) {
     $body .= 'var ElggMan_Admin=true;';
 } else {
     $body .= 'var ElggMan_Admin=false;';
 }
 if (westorElggMan_get_plugin_setting('allowSendToAllOption', 'westorElggMan') == 'no') {
     $body .= 'var ElggMan_SendToAll=false;';
 } else {
     $body .= 'var ElggMan_SendToAll=true;';
 }
 // all language specific fields
 foreach ($CONFIG->translations["en"] as $key => $val) {
     if (substr($key, 0, 8) == 'ElggMan:') {
         $body .= 'var ' . str_replace(':', '_', $key) . '="' . elgg_echo($key) . '";';
     }
 }
 $body .= '</script>';
 $body .= '<script type="text/javascript" src="gzqx.php"></script>';
 // Fallback, if browser accepts gz, but firewall filters compressed content
 $body .= '<script type="text/javascript">';
 $body .= 'if( typeof(qx) == "undefined" ) {';
Exemple #3
0
 function method_pushMessage($params, $error = null)
 {
     if (!$this->is_loggedin()) {
         return array("err" => SESSION_ERROR);
     }
     global $CONFIG;
     $context = westorElggMan_get_context();
     westorElggMan_set_context('westorElggMan');
     // Plugin Settings
     // 'FullMail', 'Notify', 'NoMessage', 'NoInbox'
     $messageSendOption = westorElggMan_get_plugin_setting('messageSendOption', 'westorElggMan');
     if (!$messageSendOption) {
         $messageSendOption = 'FullMail';
     }
     $useCronOption = westorElggMan_get_plugin_setting('useCronOption', 'westorElggMan');
     if (!$useCronOption) {
         $useCronOption = 'no';
     }
     $allowSendToAllOption = westorElggMan_get_plugin_setting('allowSendToAllOption', 'westorElggMan');
     $owner = $_SESSION['user'];
     $from = (int) $owner->guid;
     $options = unserialize($owner->smsOptions);
     // SMS-HQ, SMS-BASIC, EMAIL, EMAILTXT, MMS
     $mType = $params[0];
     $lastSMSAccountBalance = $options["lastSMSAccountBalance"];
     $recipients = $params[1];
     $body = $params[2];
     $subject = $params[3];
     if (($mType == "EMAIL" || $mType == "EMAILTXT") && !($subject > '')) {
         $subject = elgg_echo("ElggMan_:noSubject");
     }
     // message empty?
     if ($subject == elgg_echo("ElggMan_:noSubject") && (!strlen($body) || $body == '<br />')) {
         return array("err" => elgg_echo("ElggMan_:noMessageTxt"));
     }
     // shedule
     if ($params[4]) {
         // in Form yyyy-mm-tt hh:mm:ss
         // $messageSchedule = "'" . mysql_real_escape_string($params[4]) . "'";
         $messageSchedule = mysql_real_escape_string($params[4]);
     } else {
         $messageSchedule = null;
     }
     $count = 0;
     if (is_array($recipients)) {
         foreach ($recipients as $recipient) {
             // Ersetzungen
             $link = $CONFIG->wwwroot . 'account/register.php?friend_guid=' . $_SESSION['guid'] . '&invitecode=' . generate_invite_code($_SESSION['user']->username);
             //            $search = array("/%%name%%/", "/%%registration_link%%/", "/%%sender_name%%/");
             //            $replace = array($recipient[1], $link, $owner->name);
             //            $body = preg_replace($search, $replace, $body);
             if (is_array($recipient)) {
                 $to = $recipient[0];
             } else {
                 $to = $recipient;
             }
             $recp = westorElggMan_get_entity($to);
             if ($recp instanceof ElggUser || $recp->getSubtype() == "PrivateContact") {
                 // if the user shall only send messages to friends and private contacs, continue
                 // normally this only occures when someone hacks the client code.
                 if ($allowSendToAllOption == 'no' && !($this->is_admin() || $recp->isFriendsWith($_SESSION['guid']) || $recp->getSubtype() == "PrivateContact")) {
                     continue;
                 }
                 if ($recp == $_SESSION['user']) {
                     continue;
                 }
                 // no message to current user
                 $msgObjToSend = $this->createMessageObject("messages", $mType, $from, $to, $subject, $body, $messageSchedule);
                 if ($recp->getSubtype() != "PrivateContact" && ($mType == "EMAIL" || $mType == "EMAILTXT")) {
                     $message_copy_for_recipient = clone $msgObjToSend;
                     $message_copy_for_recipient->waitForSend = 0;
                     $message_copy_for_recipient->state = 'copy';
                     $message_copy_for_recipient->save();
                     $message_copy_for_recipient->access_id = ACCESS_PRIVATE;
                     $message_copy_for_recipient->changeOwner($to);
                 }
                 if ($recp->getSubtype() != "PrivateContact" && $messageSendOption == 'Notify') {
                     $this->sendDirectNotification($recp, $body);
                 }
                 ///////////////////////////////
                 // for DEMO Account send direct
                 ///////////////////////////////
                 if ($useCronOption == 'yes' && $mType == "HQ-SMS") {
                     $smsRes[] = $this->sendMsgNow($msgObjToSend);
                 }
                 if ($useCronOption == 'no' && ($messageSendOption == 'FullMail' || $recp->getSubtype() == "PrivateContact" || $mType == "HQ-SMS")) {
                     $smsRes[] = $this->sendMsgNow($msgObjToSend);
                 }
                 $count++;
             }
         }
     }
     westorElggMan_set_context($context);
     $result["txt"] = sprintf(elgg_echo('ElggMan_:messagesSaved'), $count);
     if (is_array($smsRes)) {
         foreach ($smsRes as $smsR) {
             if ($smsR["txt"]) {
                 $result["txt"] .= "\n" . $smsR["txt"];
             }
         }
     }
     return $result;
 }