Example #1
0
/**
 * Post a discussion
 * 
 * @param string $subject   Subject of the message
 * @param string $message   Content of message
 * @param int    $recipient Recipient GUID
 * @param string $sender    User GUID
 *
 * @return SuccessResult|ErrorResult
 */
function ws_pack_send_message($subject, $message, $recipient, $sender)
{
    $result = false;
    $user = elgg_get_logged_in_user_entity();
    $api_application = ws_pack_get_current_api_application();
    if (!empty($user) && !empty($api_application)) {
        $send_message = messages_send($subject, $message, $recipient, $user->guid);
        if ($send_message !== false) {
            $result = new SuccessResult($send_message);
        }
    }
    if ($result === false) {
        $result = new ErrorResult(elgg_echo("ws_pack:error:notfound"));
    }
    return $result;
}
Example #2
0
function admin_delete_photo($user_id, $image_id)
{
    global $hp_includepath;
    require_once $hp_includepath . 'message-functions.php';
    deletePhoto($user_id, $image_id);
    $title = 'En bild i ditt fotoalbum har tagits bort';
    $message = 'Bild nummer ' . intval($image_id + 1) . ' i ditt fotoalbum har raderats av en administratör.' . "\n";
    $message .= 'Det kan finnas många anledningar till att en bild tas bort, men oftast beror det på något av följande:' . "\n";
    $message .= '* Bilden innehöll rasistisk eller nazistisk propaganda.' . "\n";
    $message .= '* Bilden var pornografisk.' . "\n";
    $message .= '* Bilden var rent ut sagt äcklig eller vidrig, och kunde verka obehaglig för våra yngre medlemmar.' . "\n";
    $message .= '* Bilden var kränkande.' . "\n";
    $message .= "\n\n";
    $message .= 'Vi som arbetar med hamsterpaj vill göra siten till en så trevlig webbplats som möjligt, därför är behöver vi';
    $message .= ' ibland ta bort bilder. Vi hoppas att du förstår varför bilden togs bort och önskar dig en trevlig tid här på hamsterpaj.';
    $message .= "\n\n\n" . 'Med vänliga hälsningar, hamsterpaj.net administrations-team.';
    messages_send(2348, $user_id, $title, $message);
    //log_admin_event('deleted photo', $message , $_SESSION['login']['id'], $user_id, $image_id);
    //loggning görs i deletePhoto()
}
function refuse_image($userid, $validator)
{
    if ($userid == 17505 || $userid == 573633 || $userid == 625747 || $userid == 68767) {
        die('Man kan inte ta bort denna bild...');
        exit;
    }
    global $hp_path;
    $query = 'UPDATE userinfo SET image = "3", image_validator = "' . $validator . '" ';
    $query .= ' WHERE userid = "' . $userid . '" LIMIT 1';
    mysql_query($query) or die;
    if (unlink(PATHS_IMAGES . 'users/full/' . $userid . '.jpg') && unlink(PATHS_IMAGES . 'users/thumb/' . $userid . '.jpg')) {
        messages_send(2348, $userid, '', $_POST['message'], 0, 7);
    } else {
        echo '<script language="javascript">alert("Ett fel uppstod när ' . $userid . '.jpg skulle tas bort!");</script>';
    }
    admin_report_event($_SESSION['login']['username'], 'Refused avatar', $userid);
    log_admin_event('avatar validated', 'denied', $validator, $userid, 0);
    //image id not available here
    admin_action_count($_SESSION['login']['id'], 'avatar_denied');
}
 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $reply_to = get_entity($params->guid);
     $from = elgg_get_logged_in_user_entity();
     $subject = strip_tags($params->subject);
     $message = $params->message;
     if (elgg_is_active_plugin('hypeInbox')) {
         if (!$reply_to instanceof InboxMessage) {
             throw new GraphException('Can not instantiate the message');
         }
         $action = new SendMessage();
         $action->entity = $reply_to;
         $action->subject = $params->subject;
         $action->body = $params->message;
         $action->attachment_guids = array();
         $action->sender_guid = $from->guid;
         $action->recipient_guids = $reply_to->getParticipantGuids();
         $attachment_uids = (array) $params->attachment_uids;
         foreach ($attachment_uids as $uid) {
             $attachment = $this->graph->get($uid);
             if ($attachment && $attachment->origin == 'graph' && $attachment->access_id == ACCESS_PRIVATE) {
                 $action->attachment_guids[] = $attachment->guid;
             } else {
                 hypeGraph()->logger->log("Can not use node {$uid} as attachment. Only resources uploaded via Graph API with private access can be attached.", "ERROR");
             }
         }
         try {
             if ($action->validate() !== false) {
                 $action->execute();
             }
             $message = $action->entity;
             if (!$message) {
                 throw new Exception(implode(', ', $action->getResult()->getErrors()));
             }
         } catch (Exception $ex) {
             throw new GraphException($ex->getMessage());
         }
         return array('nodes' => array($message));
     } else {
         $id = messages_send($subject, $message, $reply_to->fromId, $from->guid, $reply_to->guid);
         return array('nodes' => array(get_entity($id)));
     }
 }
$_SESSION['msg_title'] = $title;
$_SESSION['msg_contents'] = $message_contents;
if (empty($send_to)) {
    register_error(elgg_echo("messages:user:blank"));
    forward("mod/messages/send.php");
}
$user = get_user($send_to);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("mod/messages/send.php");
}
// Make sure the message field, send to field and title are not blank
if (empty($message_contents) || empty($title)) {
    register_error(elgg_echo("messages:blank"));
    forward("mod/messages/send.php");
}
// Otherwise, 'send' the message
$result = messages_send($title, $message_contents, $send_to, 0, $reply);
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("mod/messages/send.php");
}
// successful so uncache form values
unset($_SESSION['msg_to']);
unset($_SESSION['msg_title']);
unset($_SESSION['msg_contents']);
// Success message
system_message(elgg_echo("messages:posted"));
// Forward to the users inbox
forward('mod/messages/sent.php');
Example #6
0
/**
 * Web service to send a message
 *
 * @param string $subject (required)
 * @param string $body (required)
 * @param int $send_to (required)
 * @param int $reply (optional), Default 0
 *
 * @return Success/Fail
 */
function message_send($subject, $body, $send_to, $reply = 0)
{
    $recipient = get_user_by_username($send_to);
    $recipient_guid = $recipient->guid;
    $result = messages_send($subject, $body, $recipient_guid, 0, $reply);
    return $result;
}
Example #7
0
$original_msg_guid = (int) get_input('original_guid');
elgg_make_sticky_form('messages');
if (empty($recipients)) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
}
$recipient = (int) elgg_extract(0, $recipients);
if ($recipient == elgg_get_logged_in_user_guid()) {
    register_error(elgg_echo("messages:user:self"));
    forward("messages/compose");
}
$user = get_user($recipient);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("messages/compose");
}
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
// Otherwise, 'send' the message
$result = messages_send($subject, $body, $user->guid, 0, $original_msg_guid);
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username);
Example #8
0
$message_option = get_input('message_option');
$message = get_input('message');
$event = get_entity($guid);
if (elgg_instanceof($event, 'object', 'event_calendar') && $event->canEdit()) {
    $guids = array();
    $invitees = event_poll_get_invitees($guid);
    if ($message_option == 'all') {
        foreach ($invitees as $user) {
            $guids[] = $user->guid;
        }
    } else {
        $voted_guids = event_poll_get_voted_guids($guid);
        foreach ($invitees as $user) {
            if (!in_array($user->guid, voted_guids)) {
                $guids[] = $user->guid;
            }
        }
    }
    $subject = elgg_echo('event_poll:schedule_message:subject', array($event->title));
    $body = $message . "\n\n" . elgg_get_site_url() . 'event_poll/vote/' . $guid;
    $sender_guid = elgg_get_logged_in_user_guid();
    notify_user($guids, $sender_guid, $subject, $body, array(), 'email');
    foreach ($guids as $guid) {
        messages_send($subject, $body, $guid, $sender_guid, 0, false, false);
    }
    system_message(elgg_echo('event_poll:schedule_message:response'));
    forward($event->getURL());
} else {
    register_error(elgg_echo('event_poll:error_event_poll_edit'));
    forward();
}
Example #9
0
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
elgg_make_sticky_form('messages');
// Send to collection of friends
if (!empty($collection_guid)) {
    $collection = get_members_of_access_collection($collection_guid, false);
    foreach ($collection as $member) {
        if (!$member->isBanned()) {
            $result += messages_send($subject, $body, $member->guid, $from, $reply, true, true);
        }
    }
}
if (!empty($recipient_guid)) {
    $user = get_user($recipient_guid);
    if (!$user) {
        register_error(elgg_echo("messages:user:nonexist"));
        forward("messages/compose");
    }
    $result = messages_send($subject, $body, $recipient_guid, $from, $reply, true, true);
}
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username);
Example #10
0
    $user = get_user($user_guid);
}
$trip = get_entity($trip_guid);
elgg_set_page_owner_guid($trip->guid);
if ($user && elgg_instanceof($trip, 'trip')) {
    if ($trip->getOwnerGUID() != elgg_get_logged_in_user_guid()) {
        system_message(elgg_echo("mytrips:PreOrderCorrect"));
        //eliminar de follower
        //copio en variable local
        $follower = $trip->follower;
        //busco posición del user a borrar
        $clave = array_search($user->guid, $follower);
        //lo borro
        unset($follower[$clave]);
        //vuelvo a asignar
        $trip->follower = $follower;
        //añadir en preorder
        //copio en variable local
        $preorder = $trip->preorder;
        //añado al usuario
        array_push($preorder, $user->guid);
        //vuelvo a copiar el array
        $trip->preorder = $preorder;
        messages_send(elgg_echo('mytrips:manageOrders:preorderOk:subjet', array($trip->name)), elgg_echo('mytrips:manageOrders:preorderOk:message', array("<a href=\"" . $user->getURL() . "\">" . $user->name . "</a>", "<a href=\"" . $trip->getURL() . "\">" . $trip->name . "</a>")), $trip->owner_guid, 0, $user->guid);
    } else {
        register_error(elgg_echo("mytrips:cantleave"));
    }
} else {
    register_error(elgg_echo("mytrips:cantleave"));
}
forward(REFERER);
Example #11
0
function event_poll_resend_invitations($event)
{
    $subject = elgg_echo('event_poll:reschedule_subject', array($event->title));
    $body = elgg_echo('event_poll:reschedule_body');
    $invitees = event_poll_get_invitees($event->guid);
    $guids = array();
    foreach ($invitees as $invitee) {
        $guids[] = $invitee->guid;
    }
    $sender_guid = elgg_get_logged_in_user_guid();
    $body .= "\n\n" . elgg_get_site_url() . 'event_poll/vote/' . $event->guid;
    if (is_array($invitees) && count($invitees) > 0) {
        // email invitees
        notify_user($guids, $sender_guid, $subject, $body, array(), 'email');
        foreach ($guids as $guid) {
            messages_send($subject, $body, $guid, $sender_guid, 0, false, false);
        }
    }
    return true;
}
Example #12
0
$trip->summaryPreOrderUserGuid = $summaryPreOrderUserGuid;
$trip->summaryPreOrderTrayecto = $summaryPreOrderTrayecto;
$trip->summaryPreOrderBultos = $summaryPreOrderBultos;
$trip->summaryPreOrderConfirmed = $summaryPreOrderConfirmed;
//Rosana
$linktotrip = "<a href=\"" . $trip->getURL() . "\">" . $trip->name . "</a>";
$trayecto = elgg_echo($trip->trayecto, array(), $user->language);
//El mensaje se traduce segun el receiver.
$linktoforum = "<a href='" . elgg_get_site_url() . "discussion/owner/" . $trip->guid . "'>" . elgg_echo('mytrips:forum', array(), $user->language) . "</a>";
$subject = elgg_echo('mytrips:manageOrders:desconfirmadoOk:subjet', array($trip->name), $user->language);
$owner = $trip->getOwnerGUID();
$owner = get_entity($owner);
$body = elgg_echo('mytrips:manageOrders:desconfirmadoOk:message', array($owner->name, $linktotrip, $trayecto, $trip->aportacionViajero, $linktoforum), $user->language);
//no tengo claro quien es el sender en esta llamada
//Antonio                       MANDAR A:        DE PARTE DE:
messages_send($subject, $body, $userguid, 0, $trip->owner_guid);
/*
$result = messages_send(elgg_echo('mytrips:manageOrders:desconfirmadoOk:subjet',array($trip->name)), elgg_echo('mytrips:manageOrders:desconfirmadoOk:message'), $trip->owner_guid, 0,$user->guid);
if (!$result) {
	register_error(elgg_echo("messages:error"));
}
else {
	system_message(elgg_echo("messages:posted"));	
}*/
/*

if ($user && elgg_instanceof($trip, 'trip')
{
	if ($trip->getOwnerGUID() != elgg_get_logged_in_user_guid()) 
	{
		if ($trip->leave($user)) {
Example #13
0
File: send.php Project: nogsus/Elgg
* @package ElggMessages
*/
$subject = strip_tags(get_input('subject'));
$body = get_input('body');
$recipient_username = get_input('recipient_username');
elgg_make_sticky_form('messages');
//$reply = get_input('reply',0); // this is the guid of the message replying to
if (!$recipient_username) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
}
$user = get_user_by_username($recipient_username);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("messages/compose");
}
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
// Otherwise, 'send' the message
$result = messages_send($subject, $body, $user->guid, 0, $reply);
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username);
Example #14
0
function group_invite_member($groupid, $username)
{
    global $hp_url;
    $query = 'SELECT id FROM login WHERE username = "******" LIMIT 1';
    $result = mysql_query($query) or die(report_sql_error($query));
    if (mysql_num_rows($result) == 0) {
        jscript_alert('Personen du ville bjuda in finns inte');
        jscript_location($_SERVER['PHP_SELF'] . '?action=goto&groupid=' . $groupid);
        exit;
    }
    $data = mysql_fetch_assoc($result);
    $userid = $data['id'];
    $selectquery = 'SELECT COUNT(*) AS added FROM groups_members WHERE userid = ' . $userid . ' AND groupid = ' . $groupid;
    $result = mysql_query($selectquery) or die(report_sql_error($query));
    $data = mysql_fetch_assoc($result);
    if ($data['added'] == 0) {
        $query = 'SELECT name, owner FROM groups_list WHERE groupid = ' . $groupid;
        $result = mysql_query($query) or die(report_sql_error($query));
        $data = mysql_fetch_assoc($result);
        $groupname = $data['name'];
        $owner = $data['owner'];
        $url = $hp_url . 'traffa/groups.php?action=invited_member&amp;groupid=' . $groupid . '&userid=' . $userid;
        $title = 'Inbjudan att gå med i gruppen: ' . $groupname;
        $message = 'Du har blivit inbjuden till gruppen: ' . $groupname . '<br />';
        $message .= 'Om du vill gå med i min grupp trycker du bara på länken här nedanför<br />';
        $message .= '<a href="' . $url . '">[Bli medlem i gruppen]</a><br />';
        $query = 'INSERT INTO groups_members (groupid, userid, approved) VALUES (' . $groupid . ',' . $userid . ', 3)';
        mysql_query($query) or die(report_sql_error($query));
        messages_send($owner, $userid, $title, $message, $allowhtml = 1);
    } else {
        jscript_alert("Du kan inte bjuda in denna person");
    }
}
            $body = elgg_echo('mytrips:manageOrders:preorderOk:msgViajero:requestType', array("<a href=\"" . $user->getURL() . "\">" . $user->name . "</a>", elgg_echo($summaryPreOrderTrayecto[$clave]), $aportacionFinal, $bultos));
            //al usuario
            messages_send($subjet, $body, $user->guid, $trip->owner_guid);
            break;
        case "2":
            //Sólo Maleta
            array_push($summaryPreOrderUserGuid, $user->guid);
            array_push($summaryPreOrderTrayecto, -1);
            array_push($summaryPreOrderBultos, $bultos);
            array_push($summaryPreOrderConfirmed, 0);
            $body = elgg_echo('mytrips:manageOrders:preorderOk:Maleta', array("<a href=\"" . $user->getURL() . "\">" . $user->name . "</a>", $aportacionFinal, $bultos, "<a href=\"" . $trip->getURL() . "\">" . $trip->name . "</a>"));
            //al conductor
            messages_send($subjet, $body, $trip->owner_guid, 0, $user->guid);
            $body = elgg_echo('mytrips:manageOrders:preorderOk:msgViajero:Maleta', array("<a href=\"" . $user->getURL() . "\">" . $user->name . "</a>", $aportacionFinal, $bultos));
            //al usuario
            messages_send($subjet, $body, $user->guid, $trip->owner_guid);
            break;
    }
    //messages_send($subject, $body, $recipient_guid, $sender_guid)
    $trip->summaryPreOrderUserGuid = $summaryPreOrderUserGuid;
    $trip->summaryPreOrderTrayecto = $summaryPreOrderTrayecto;
    $trip->summaryPreOrderBultos = $summaryPreOrderBultos;
    $trip->summaryPreOrderConfirmed = $summaryPreOrderConfirmed;
    system_messages(elgg_echo('mytrips:manageOrders:saved'));
}
forward($trip->getUrl());
//Buscar clave en un array multidimensional
/*function search($array, $key, $value)
{
    $results = array();
Example #16
0
     if (!messages_compose($_GET['recipient_id'], $_GET['recipient_username'], $_GET['title'], $_GET['discussion'])) {
         jscript_alert('Ett fel uppstod, det verkar som om mottagaren inte finns!');
         jscript_go_back();
         die;
     }
     if (isset($_GET['quote'])) {
         if (!messages_view($_GET['message_id'], $_SESSION['login']['id'], 1)) {
             jscript_alert('Ett problem uppstod när meddelandet skulle visas. Du kanske inte kan läsa detta meddelande.');
             jscript_location($_SERVER['PHP_SELF']);
         }
     }
     break;
 case 'send':
     $can_send = messages_can_send($_SESSION['login']['id'], $_POST['recipient'], $_POST['title'], $_POST['message'], $_POST['discussion']);
     if (strlen($can_send) < 2) {
         messages_send($_SESSION['login']['id'], $_POST['recipient'], $_POST['title'], $_POST['message'], $_POST['discussion']);
         jscript_location($_SERVER['PHP_SELF']);
     } else {
         jscript_alert(str_replace("\n", ' ', $can_send));
         jscript_go_back();
     }
     break;
 case 'delete':
     if (!messages_delete($_POST, $_SESSION['login']['id'])) {
         jscript_alert('Ett fel uppstod när meddelandena skulle tas bort!');
     }
     jscript_go_back();
     break;
 case 'read':
     traffa_draw_user_div($_SESSION['login']['id'], $_SESSION);
     if (!messages_view($_GET['message_id'], $_SESSION['login']['id']) || !is_numeric($_GET['message_id'])) {
Example #17
0
function pleio_api_send_message($contact_id = 0, $message_title, $message_content, $reply = 0)
{
    $user = elgg_get_logged_in_user_entity();
    $user_id = $user !== false ? $user->guid : 0;
    $subject = strip_tags($message_title);
    if (!$contact_id) {
        return new ErrorResult(elgg_echo("messages:user:blank"));
    }
    if ($contact_id == $user_id) {
        return new ErrorResult(elgg_echo("messages:error"));
    }
    $user = get_user($contact_id);
    if (!$user) {
        return new ErrorResult(elgg_echo("messages:user:nonexist"));
    }
    if (!$message_content || !$subject) {
        return new ErrorResult(elgg_echo("messages:blank"));
    }
    $result = messages_send($subject, $message_content, $contact_id, $user_id, $reply, null, 1);
    if (!$result) {
        return new ErrorResult(elgg_echo("messages:error"));
    }
    return new SuccessResult(elgg_echo("messages:posted"));
}
Example #18
0
* @package ElggMessages
*/
$subject = strip_tags(get_input('subject'));
$body = get_input('body');
$recipient_guid = get_input('recipient_guid');
elgg_make_sticky_form('messages');
//$reply = get_input('reply',0); // this is the guid of the message replying to
if (!$recipient_guid) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
}
$user = get_user($recipient_guid);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("messages/compose");
}
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
// Otherwise, 'send' the message
$result = messages_send($subject, $body, $recipient_guid, 0, $reply);
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username);
Example #19
0
            } else {
                register_error(elgg_echo("faq:answer:error:no_cat"));
            }
        } else {
            // Do not add to FAQ, just answer to the User
            $user = get_user($faq->owner_guid);
            $user_language = $user->language ? $user->language : (($site_language = elgg_get_config('language')) ? $site_language : 'en');
            if ($question == $orgQuestion) {
                $subject = elgg_echo("faq:answer:notify:subject", array(), $user_language);
                $body = elgg_echo("faq:answer:notify:not_added:same", array($question, $answer), $user_language);
            } else {
                $subject = elgg_echo("faq:answer:notify:subject", array(), $user_language);
                $body = elgg_echo("faq:answer:notify:not_added:adjusted", array($orgQuestion, $question, $answer), $user_language);
            }
            $result = array();
            $result[$user->guid]['message'] = messages_send($subject, $body, $user->guid, elgg_get_logged_in_user_guid(), 0, false, false);
            $result[] = notify_user($user->guid, elgg_get_logged_in_user_guid(), $subject, $body, array(), 'email');
            $faq->delete();
            if (in_array(true, $result)) {
                system_message(elgg_echo("faq:answer:success:not_added:send"));
            } else {
                register_error(elgg_echo("faq:answer:error:not_added:not_send"));
            }
        }
    } else {
        register_error(elgg_echo("faq:answer:error:no_faq"));
    }
} else {
    register_error(elgg_echo("faq:answer:error:input"));
}
forward(REFERER);
Example #20
0
} else {
    $action = 'start';
}
ui_top($ui_options);
switch ($action) {
    case 'create':
        $suggestion = $_POST;
        $suggestion['display_level'] = is_privilegied('suggestion_admin') ? $_POST['display_level'] : 'normal';
        suggestion_create($suggestion);
        echo '<h1>Tack för ditt förslag</h1>' . "\n";
        echo '<a href="/hamsterpaj/suggestions.php">Tillbaks till förslags-sidan</a>' . "\n";
        // Ace
        require_once PATHS_INCLUDE . 'message-functions.php';
        $title = 'Förslag: ' . $_POST['category'] . ': ' . substr($suggestion['text'], 0, 30);
        $message = 'Räkmacka på Umba!\\n\\n\\n' . $suggestion['text'];
        messages_send(2348, 57100, $title, $message);
        break;
    case 'compose':
        if (login_checklogin()) {
            suggestion_form();
        } else {
            echo '<h1>Bara inloggade medlemmar kan skicka förslag!</h1>' . "\n";
            echo '<script>womAdd("tiny_reg_form_show();");</script>' . "\n";
        }
        break;
    case 'edit':
        $fetch['id'] = array($_GET['id']);
        $suggestions = suggestion_fetch($fetch);
        $suggestion = array_pop($suggestions);
        suggestion_form($suggestion);
        break;
Example #21
0
/**
 * Web service to send a message
 *
 * @param string $subject (required)
 * @param string $body (required)
 * @param int $send_to (required)
 * @param int $reply (optional), Default 0
 * @return Success /Fail
 * @throws InvalidParameterException
 */
function message_send($subject, $body, $send_to, $reply = 0)
{
    $recipient = get_user_by_username($send_to);
    if (!$recipient) {
        throw new InvalidParameterException('registration:usernamenotvalid');
    }
    $recipient_guid = $recipient->guid;
    $result = messages_send($subject, $body, $recipient_guid, 0, $reply);
    if ($result) {
        $response['guid'] = $result;
    } else {
        $response['guid'] = 0;
    }
    return $response;
}
Example #22
0
File: ask.php Project: Facyla/faq
$guid = (int) get_input("userGuid");
if (!empty($question) && !empty($guid)) {
    $user = get_user($guid);
    if (!empty($user)) {
        $faq = new FAQObject();
        $faq->container_guid = $user->guid;
        $faq->owner_guid = $user->guid;
        $faq->question = $question;
        $faq->userQuestion = true;
        if ($faq->save()) {
            $admins = elgg_get_admins(array('order_by' => 'time_created asc'));
            $notify = array();
            $user_language = $user->language ? $user->language : (($site_language = elgg_get_config('language')) ? $site_language : 'en');
            $subject = elgg_echo("faq:ask:new_question:subject", array(), $user_language);
            $message = elgg_echo("faq:ask:new_question:message", array($question), $user_language);
            $notify[$user->guid]['message'] = messages_send($subject, $message, $user->guid, $admins[0]->guid, 0, false, false);
            $notify[] = notify_user($user->guid, $admins[0]->guid, $subject, $message, array(), 'email');
            $admins_notified = notifyAdminNewQuestion();
            if (in_array(true, $notify)) {
                system_message(elgg_echo("faq:ask:new_question:send"));
            } else {
                register_error(elgg_echo("faq:ask:error:not_send"));
            }
        } else {
            register_error("faq:ask:error:save");
        }
    } else {
        register_error("faq:ask:error:no_user");
    }
} else {
    register_error("faq:ask:error:input");
function messages_site_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
{
    global $CONFIG;
    if (!$from) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));
    }
    if (!$to) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));
    }
    global $messages_pm;
    if (!$messages_pm) {
        return messages_send($subject, $message, $to->guid, $from->guid, 0, false, false);
    } else {
        return true;
    }
}
Example #24
0
*/
$subject = strip_tags(get_input('subject'));
$body = get_input('body');
$recipient_guid = get_input('recipient_guid');
$original_msg_guid = (int) get_input('original_guid');
elgg_make_sticky_form('messages');
//$reply = get_input('reply',0); // this is the guid of the message replying to
if (!$recipient_guid) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
}
$user = get_user($recipient_guid);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("messages/compose");
}
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
// Otherwise, 'send' the message
$result = messages_send($subject, $body, $recipient_guid, 0, $original_msg_guid);
// Save 'send' the message
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username);