Ejemplo n.º 1
0
 * it has a settings page that allow you to configure the messages
 * send.
 *
 * @package    local
 * @subpackage welcome
 * @copyright  2015 Bas Brands, basbrands.nl, bas@sonsbeekmedia.nl
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/local/welcome/locallib.php';
$context = context_system::instance();
require_login();
if (!is_siteadmin()) {
    return '';
}
$welcome = new local_welcome();
$PAGE->set_context($context);
$PAGE->set_url('/local/welcome/index.php.php');
$PAGE->set_heading($SITE->fullname);
$PAGE->set_pagelayout('admin');
$PAGE->set_title(get_string('pluginname', 'local_welcome'));
$PAGE->navbar->add(get_string('pluginname', 'local_welcome'));
$tableheader = array(get_string('fieldname', 'local_welcome'), get_string('yourvalue', 'local_welcome'));
$customfields = $welcome->customfields;
$customvalues = $welcome->get_user_custom_values($USER);
// Custom profile Fields
$tablecustom = new html_table();
$tablecustom->head = $tableheader;
foreach ($customfields as $field) {
    $tablecustom->data[] = array('[[' . $field . ']]', $customvalues[$field]);
}
Ejemplo n.º 2
-1
/**
 * This plugin sends users a welcome message after logging in
 * and notify a moderator a new user has been added
 * it has a settings page that allow you to configure the messages
 * send.
 *
 * @package    local
 * @subpackage welcome
 * @copyright  2015 Bas Brands, basbrands.nl, bas@sonsbeekmedia.nl
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function send_welcome($user)
{
    global $CFG, $SITE;
    require_once $CFG->dirroot . '/local/welcome/locallib.php';
    $sender = get_admin();
    if (!empty($user->email)) {
        $config = get_config('local_welcome');
        $moderator = clone $sender;
        if (!empty($config->auth_plugins)) {
            $auths = explode(',', $config->auth_plugins);
            if (!in_array($user->auth, $auths)) {
                return '';
            }
        } else {
            return '';
        }
        $moderator->email = $config->moderator_email;
        $sender->email = $config->sender_email;
        $sender->firstname = $config->sender_firstname;
        $sender->lastname = $config->sender_lastname;
        $message_user_enabled = $config->message_user_enabled;
        $message_user = $config->message_user;
        $message_user_subject = $config->message_user_subject;
        $message_moderator_enabled = $config->message_moderator_enabled;
        $message_moderator = $config->message_moderator;
        $message_moderator_subject = $config->message_moderator_subject;
        $welcome = new local_welcome();
        $message_user = $welcome->replace_values($user, $message_user);
        $message_user_subject = $welcome->replace_values($user, $message_user_subject);
        $message_moderator = $welcome->replace_values($user, $message_moderator);
        $message_moderator_subject = $welcome->replace_values($user, $message_moderator_subject);
        if (!empty($message_user) && !empty($sender->email) && $message_user_enabled) {
            email_to_user($user, $sender, $message_user_subject, html_to_text($message_user), $message_user);
        }
        if (!empty($message_moderator) && !empty($sender->email) && $message_moderator_enabled) {
            email_to_user($moderator, $sender, $message_moderator_subject, html_to_text($message_moderator), $message_moderator);
        }
    }
}