/** * Receives a message event object from moodletxt+ * and sens an SMS to the destination user as per their * preferences * @param object $messageObject Message event object * @version 2012062401 * @since 2012062401 */ function send_moodletxt_plus_message($messageObject) { $accountDAO = new TxttoolsAccountDAO(); $userDAO = new MoodletxtMoodleUserDAO(); $messageDAO = new TxttoolsSentMessageDAO(); // moodletxt requires a ConnectTxt account to be specified // for this message to transition via $defaultAccountId = (int) get_config('moodletxt', 'Event_Messaging_Account'); if ($defaultAccountId > 0) { $connectTxtAccount = $accountDAO->getTxttoolsAccountById($defaultAccountId); // Check that the specified account has outbound enabled if ($connectTxtAccount->isOutboundEnabled()) { $sender = $userDAO->getUserById($messageObject->from_id); $recipient = $userDAO->getUserById($messageObject->to_id); $message = new MoodletxtOutboundMessage($connectTxtAccount, $sender, $messageObject->smallmessage, time(), MoodletxtOutboundMessage::$MESSAGE_CHARGE_TYPE_BULK); $message->addMessageRecipient($recipient); $message->setEventCreated(true); // Send message to ConnectTxt try { $connector = MoodletxtOutboundControllerFactory::getOutboundController(MoodletxtOutboundControllerFactory::$CONTROLLER_TYPE_XML); $message->setSentSMSMessages($connector->sendMessage($message)); $messageDAO->saveSentMessage($message); } catch (MoodletxtRemoteProcessingException $ex) { // Die silently, for now } } } }
$instanceId = required_param('instance', PARAM_INT); $replyType = optional_param('replyType', '', PARAM_ALPHA); $replyValue = optional_param('replyValue', '', PARAM_RAW_TRIMMED); if ($replyType == 'additional' && !MoodletxtPhoneNumber::validatePhoneNumber($replyValue)) { $replyType = ''; $replyValue = ''; } require_login($courseId, false); $blockcontext = context_block::instance($instanceId); require_capability('block/moodletxt:sendmessages', $blockcontext, $USER->id); // OK, so you're legit. Let's load DAOs and required DB data $templateDAO = new MoodletxtTemplatesDAO(); $accountDAO = new TxttoolsAccountDAO(); $addressbookDAO = new MoodletxtAddressbookDAO(); $userDAO = new MoodletxtMoodleUserDAO(); $messageDAO = new TxttoolsSentMessageDAO(); $statsDAO = new MoodletxtUserStatsDAO(); $course = $DB->get_record('course', array('id' => $courseId)); $notifications = ''; // Set up the page for rendering $PAGE->set_url('/blocks/moodletxt/send.php'); $PAGE->set_title(get_string('titlesend', 'block_moodletxt') . ' ' . $course->fullname); $PAGE->set_heading(get_string('headersend', 'block_moodletxt')); $PAGE->set_pagelayout('incourse'); $PAGE->set_button(''); // Clear editing button $PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt'); $PAGE->navbar->add(get_string('navsent', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt'); $PAGE->requires->strings_for_js(array('errorlabel', 'errornonumber', 'errornofirstname', 'errornolastname', 'errornorecipientsselected', 'errornomessage'), 'block_moodletxt'); $PAGE->requires->jquery(); $PAGE->requires->jquery_plugin('ui');
$download = optional_param('download', '', PARAM_ALPHA); $includeEvents = optional_param('events', TxttoolsSentMessageDAO::$EVENT_QUERY_DISCARD, PARAM_INT); $userToView = optional_param('user', $USER->id, PARAM_INT); $MESSAGES_PER_PAGE = 25; require_login($courseId, false); $blockcontext = context_block::instance($instanceId); require_capability('block/moodletxt:sendmessages', $blockcontext, $USER->id); // Make sure that the user has the ability to change the // ID of the user whose messages are being shown $canAdminUsers = has_capability('block/moodletxt:adminusers', $blockcontext, $USER->id); if (!$canAdminUsers && $userToView != $USER->id) { $userToView = $USER->id; } // Naughty user, don't try that again. // OK, so you're legit. Let's load DAOs $sentMessagesDAO = new TxttoolsSentMessageDAO(); $userDAO = new MoodletxtMoodleUserDAO(); // Set up the page for rendering $pageParams = '?course=' . $courseId . '&instance=' . $instanceId . '&events=' . $includeEvents; $pageParams .= $canAdminUsers ? '&user='******''; $PAGE->set_url('/blocks/moodletxt/sent.php' . $pageParams); $PAGE->set_title(get_string('titlesent', 'block_moodletxt') . ' ' . $USER->lastname . ', ' . $USER->firstname); $PAGE->set_heading(get_string('headersent', 'block_moodletxt')); $PAGE->set_pagelayout('incourse'); $PAGE->set_button(''); // Clear editing button $PAGE->navbar->add(get_string('navmoodletxt', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt'); $PAGE->navbar->add(get_string('navsent', 'block_moodletxt'), null, navigation_node::TYPE_CUSTOM, 'moodletxt'); $output = $PAGE->get_renderer('block_moodletxt'); /* * Create results table
* @license http://www.gnu.org/licenses/gpl.html GNU General Public Licence v3 (See code header for additional terms) * @version 2015062901 * @since 2011042601 */ require_once '../../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/tablelib.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsAccountDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsSentMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/forms/TxttoolsAccountEditForm.php'; require_once $CFG->dirroot . '/blocks/moodletxt/forms/TxttoolsAccountRestrictionsForm.php'; require_login(); require_capability('block/moodletxt:adminsettings', context_system::instance()); // OK, so you're legit. Let's load DAOs $accountDAO = new TxttoolsAccountDAO(); $sentMessageDAO = new TxttoolsSentMessageDAO(); // Grab account details - if there are no accounts to see, // send the user to the new installation screen $accountList = $accountDAO->getAllTxttoolsAccounts(); if (count($accountList) == 0) { redirect($CFG->wwwroot . '/blocks/moodletxt/settings_accounts_new.php', get_string('redirectnoaccountsfound', 'block_moodletxt')); } // Account IDs are passed to JS for AJAX transactions // Shifted up to match onscreen table rows $accountIds = array(); // To further complicate things, Moodle 2.4 and above // actually render tables correctly, with <tbody> tags // and everything, so the index is different $accountTableIndex = $CFG->version >= 2012120300 ? 1 : 2; foreach ($accountList as $accountId => $account) { $accountIds[$accountTableIndex++] = $accountId;
* @since 2012101001 */ require_once '../../config.php'; require_once $CFG->dirroot . '/blocks/moodletxt/lib/MoodletxtEncryption.php'; require_once $CFG->dirroot . '/blocks/moodletxt/connect/xml/MoodletxtXMLParser.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsSentMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsReceivedMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/inbound/MoodletxtInboundFilterManager.php'; // Read in POST variables $inPushUser = required_param('u', PARAM_ALPHANUM); $inPushPass = required_param('p', PARAM_ALPHANUM); $inPayload = required_param('x', PARAM_RAW); // Assuming we have the right params, set up for parsing $parser = new MoodletxtXMLParser(); $decrypter = new MoodletxtEncryption(); $sentMessagesDAO = new TxttoolsSentMessageDAO(); $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; }
require_once $CFG->libdir . '/tablelib.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsSentMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/connect/MoodletxtOutboundControllerFactory.php'; require_once $CFG->dirroot . '/blocks/moodletxt/util/MoodletxtStringHelper.php'; require_once $CFG->dirroot . '/blocks/moodletxt/util/MoodletxtStatusIconFactory.php'; $courseId = required_param('course', PARAM_INT); $instanceId = required_param('instance', PARAM_INT); $messageId = required_param('message', PARAM_INT); $download = optional_param('download', '', PARAM_ALPHA); $update = optional_param('update', 0, PARAM_INT); $STATUSES_PER_PAGE = 25; require_login($courseId, false); $blockcontext = context_block::instance($instanceId); require_capability('block/moodletxt:sendmessages', $blockcontext, $USER->id); // OK, so you're legit. Let's load DAOs $sentMessagesDAO = new TxttoolsSentMessageDAO(); // Check that message ID passed in is legit // (Don't get statuses here - we get those separately later) $messageObject = $sentMessagesDAO->getSentMessageById($messageId); if ($messageObject == null) { print_error('errorbadmessageid', 'block_moodletxt'); } else { if ($messageObject->getUser()->getId() != $USER->id && !has_capability('block/moodletxt:adminusers', $blockcontext, $USER->id)) { print_error('errornopermissionmessage', 'block_moodletxt'); } } // Set up the page for rendering $PAGE->set_url('/blocks/moodletxt/status.php'); $PAGE->set_title(get_string('titlestatus', 'block_moodletxt') . ' ' . $USER->lastname . ', ' . $USER->firstname); $PAGE->set_heading(get_string('headerstatus', 'block_moodletxt')); $PAGE->set_pagelayout('incourse');