Exemple #1
0
$showInboundNumbers = $userConfig->getUserConfig('hideSources') == '0' && $globalSourceConfig == '1';
// Get tags and counts for user
$tagList = $receivedMessagesDAO->getAllTagsForUser($USER->id);
/*
 * Check to see if inbound messages should be fetched at this point.
 * This should only be used on-demand, or if the user cannot
 * set up XML Push
 */
$fetchErrors = array();
if ($update == 1 || get_config('moodletxt', 'Get_Inbound_On_View') == '1') {
    try {
        $connector = MoodletxtOutboundControllerFactory::getOutboundController(MoodletxtOutboundControllerFactory::$CONTROLLER_TYPE_XML);
        $inboundAccounts = $txttoolsAccountDAO->getAllTxttoolsAccounts(false, false, false, true);
        $inboundMessages = $connector->getInboundMessages($inboundAccounts);
        if (count($inboundMessages) > 0) {
            $inboundMessages = $inboundFilterManager->filterMessages($inboundMessages);
            $receivedMessagesDAO->saveInboundMessages($inboundMessages);
        }
    } catch (MoodletxtRemoteProcessingException $ex) {
        $fetchErrors[$ex->getCode()] = MoodletxtStringHelper::getLanguageStringForRemoteProcessingException($ex);
    }
}
/*
 * Set up page
 */
$PAGE->set_url('/blocks/moodletxt/received.php');
$PAGE->set_title(get_string('titlereceivedmessages', 'block_moodletxt') . ' ' . $USER->lastname . ', ' . $USER->firstname);
$PAGE->set_heading(get_string('headerreceivedmessages', 'block_moodletxt'));
$PAGE->set_pagelayout('incourse');
$PAGE->set_button('');
// Clear editing button
Exemple #2
0
$receivedMessagesDAO = new TxttoolsReceivedMessageDAO();
$inboundFilterManager = new MoodletxtInboundFilterManager();
$key = get_config('moodletxt', 'EK');
$pushUsername = get_config('moodletxt', 'Push_Username');
$pushPassword = $decrypter->decrypt($key, get_config('moodletxt', 'Push_Password'));
// Check credentials against those stored in Moodle
if ($inPushUser === $pushUsername && $inPushPass === $pushPassword) {
    $parsedInboundMessages = array();
    $parsedStatusUpdates = array();
    try {
        $parsedObjects = $parser->parse($inPayload);
    } catch (Exception $ex) {
        // Invalid XML from remote system
        die;
    }
    if (is_array($parsedObjects)) {
        // Filter objects and save accordingly
        foreach ($parsedObjects as $parsedObject) {
            if ($parsedObject instanceof MoodletxtInboundMessage) {
                array_push($parsedInboundMessages, $parsedObject);
            } else {
                if ($parsedObject instanceof MoodletxtOutboundSMSStatus) {
                    array_push($parsedStatusUpdates, $parsedObject);
                }
            }
        }
        $sentMessagesDAO->saveSMSStatusUpdates($parsedStatusUpdates);
        $inboundMessages = $inboundFilterManager->filterMessages($parsedInboundMessages);
        $receivedMessagesDAO->saveInboundMessages($inboundMessages);
    }
}