*/
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;
}
/*
 * Set up page
Exemple #2
0
 * @package uk.co.moodletxt
 * @author Greg J Preece <*****@*****.**>
 * @copyright Copyright &copy; 2014 Blackboard Connect. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public Licence v3 (See code header for additional terms)
 * @version 2015062901
 * @since 2011041701
 */
defined('MOODLE_INTERNAL') || die('File cannot be accessed directly.');
// Not really supposed to do this kind of thing here, but I need the account list
require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsAccountDAO.php';
require_once $CFG->dirroot . '/blocks/moodletxt/settings/admin_setting_password_unmask_encrypted.php';
// Grab current ConnectTxt accounts from database, fo sho
$accountDAO = new TxttoolsAccountDAO();
$accountSet = array();
try {
    $accountSet = $accountDAO->getAllTxttoolsAccounts(false, false, true, false);
    // Check outbound is active
} catch (dml_read_exception $ex) {
    /* We're not really supposed to have database code in the settings file
       but we need it here to get a list of accounts. Valid use case, certainly.
       However, if the block is in place at Moodle install time, this file
       may be run before the database tables are in place, so we need this
       try-catch to stop the installation from failing! */
    // Do nothing - fail silently and allow installation to continue
}
$accountList = array(0 => get_string('adminselecteventsdisabled', 'block_moodletxt'));
foreach ($accountSet as $account) {
    $accountList[$account->getId()] = $account->getUsername() . ' (' . $account->getDescription() . ')';
}
// I would define this as a constant. However, Moodle
// tries to define the exact same constant later on in
Exemple #3
0
// Get user's inbox preferences
$globalSourceConfig = get_config('moodletxt', 'Show_Inbound_Numbers');
$userConfig = $userDAO->getUserConfig($USER->id);
$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'));