Exemplo n.º 1
0
/**
 * Notify the site admins about pending approvals
 *
 * @return void
 */
function uservalidationbyadmin_notify_admins()
{
    $notify_admins = uservalidationbyadmin_get_admin_notification_setting();
    if (!empty($notify_admins) && $notify_admins != "none") {
        // make sure we can see every user
        $hidden = access_get_show_hidden_status();
        access_show_hidden_entities(true);
        // get selection options
        $options = uservalidationbyadmin_get_selection_options(true);
        $user_count = elgg_get_entities_from_relationship($options);
        if (!empty($user_count)) {
            $site = elgg_get_site_entity();
            // there are unvalidated users, now find the admins to notify
            $admin_options = array("type" => "user", "limit" => false, "site_guids" => false, "relationship" => "member_of_site", "relationship_guid" => $site->getGUID(), "inverse_relationship" => true, "joins" => array("JOIN " . elgg_get_config("dbprefix") . "users_entity ue ON e.guid = ue.guid"), "wheres" => array("ue.admin = 'yes'"));
            $admins = elgg_get_entities_from_relationship($admin_options);
            // trigger hook to adjust the admin list
            $params = array("admins" => $admins, "user_count" => $user_count);
            $admins = elgg_trigger_plugin_hook("notify_admin", "uservalidationbyadmin", $params, $admins);
            // notify the admins
            if (!empty($admins)) {
                foreach ($admins as $admin) {
                    // does the admin have notifications disabled
                    if (elgg_get_plugin_user_setting("notify", $admin->getGUID(), "uservalidationbyadmin") != "no") {
                        $subject = elgg_echo("uservalildationbyadmin:notify:admin:subject");
                        $msg = elgg_echo("uservalildationbyadmin:notify:admin:message", array($admin->name, $user_count, $site->name, $site->url . "admin/users/pending_approval"));
                        notify_user($admin->getGUID(), $site->getGUID(), $subject, $msg, null, "email");
                    }
                }
            }
        }
        // restore hidden setting
        access_show_hidden_entities($hidden);
    }
}
<?php

elgg_require_js('uservalidationbyadmin/admin');
// make sure we can see everything
$hidden = access_get_show_hidden_status();
access_show_hidden_entities(true);
echo "<div class='mbm'>" . elgg_echo("uservalidationbyadmin:pending_approval:description") . "</div>";
$title = elgg_echo("uservalidationbyadmin:pending_approval:title");
$options = uservalidationbyadmin_get_selection_options();
$body = elgg_list_entities($options, "elgg_get_entities_from_relationship", "uservalidationbyadmin_view_users_list");
if (!empty($body)) {
    // we need to add some bulk actions to the title
    $check_all = elgg_view("input/checkbox", array("name" => "check_all", "id" => "uservalidationbyadmin-check-all", "value" => 1, "class" => "mrs"));
    $bulk_actions = "<span class='float-alt'>";
    $bulk_actions .= elgg_view("output/url", array("text" => elgg_echo("uservalidationbyadmin:validate"), "href" => "action/uservalidationbyadmin/bulk_action?do=validate", "id" => "uservalidationbyadmin-bulk-validate", "confirm" => true));
    $bulk_actions .= " | ";
    $bulk_actions .= elgg_view("output/url", array("text" => elgg_echo("delete"), "href" => "action/uservalidationbyadmin/bulk_action?do=delete", "id" => "uservalidationbyadmin-bulk-delete", "confirm" => elgg_echo("deleteconfirm:plural")));
    $bulk_actions .= "</span>";
    // make new title
    $title = $check_all . $title . $bulk_actions;
} else {
    // no content
    $body = elgg_echo("notfound");
}
echo elgg_view_module("inline", $title, $body, array("id" => "uservalidationbyadmin-wrapper"));
// restore access settings
access_show_hidden_entities($hidden);