示例#1
0
 /**
  * Returns the string to display for the help icon.
  *
  * @param string $type the type we are displaying the help icon for (either rule or subscription).
  * @param int $id the id of the type.
  * @param boolean $ajax Whether this help is called from an AJAX script.
  *      This is used to influence text formatting and determines which format to output the doclink in.
  * @return string|object|array $a An object, string or number that can be used within translation strings
  */
 public static function get_help_string_parameters($type, $id, $ajax = false)
 {
     if ($type == 'rule') {
         $rule = \tool_monitor\rule_manager::get_rule($id);
         $langstring = new \stdClass();
         $langstring->eventname = $rule->get_event_name();
         $langstring->eventcomponent = $rule->get_plugin_name();
         $langstring->frequency = $rule->frequency;
         $langstring->minutes = $rule->timewindow / MINSECS;
         return get_formatted_help_string('rulehelp', 'tool_monitor', $ajax, $langstring);
     }
     // Must be a subscription.
     $sub = \tool_monitor\subscription_manager::get_subscription($id);
     $langstring = new \stdClass();
     $langstring->eventname = $sub->get_event_name();
     $langstring->moduleinstance = $sub->get_instance_name();
     $langstring->frequency = $sub->frequency;
     $langstring->minutes = $sub->timewindow / MINSECS;
     return get_formatted_help_string('subhelp', 'tool_monitor', $ajax, $langstring);
 }
示例#2
0
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Displays help via AJAX call.
 *
 * @copyright 2014 Mark Nelson <*****@*****.**>
 * @package tool_monitor
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('NO_MOODLE_COOKIES', true);
define('AJAX_SCRIPT', true);
require_once '../../../config.php';
$type = required_param('type', PARAM_ALPHA);
$id = required_param('id', PARAM_INT);
$lang = optional_param('lang', 'en', PARAM_LANG);
// We don't actually modify the session here as we have NO_MOODLE_COOKIES set.
$SESSION->lang = $lang;
$PAGE->set_url('/admin/tool/monitor/help_ajax.php');
if ($type == 'rule') {
    $item = \tool_monitor\rule_manager::get_rule($id);
} else {
    // Must be a subscription.
    $item = \tool_monitor\subscription_manager::get_subscription($id);
}
if ($item->courseid) {
    $PAGE->set_context(context_course::instance($item->courseid));
} else {
    // Must be system context.
    $PAGE->set_context(context_system::instance());
}
echo json_encode(tool_monitor\output\helpicon\renderable::get_help_string_parameters($type, $id, true));
示例#3
0
文件: lib.php 项目: evltuma/moodle
 /**
  * Function to generate subscription data.
  *
  * @throws coding_exception if $record->ruleid or $record->userid not present.
  * @param \stdClass|array $record data to insert as subscription entry.
  *
  * @return \tool_monitor\subscription An instance of the subscription class.
  */
 public function create_subscription($record = null)
 {
     if (!isset($record->timecreated)) {
         $record->timecreated = time();
     }
     if (!isset($record->courseid)) {
         $record->courseid = 0;
     }
     if (!isset($record->ruleid)) {
         throw new coding_exception('$record->ruleid must be present in tool_monitor_generator::create_subscription()');
     }
     if (!isset($record->cmid)) {
         $record->cmid = 0;
     }
     if (!isset($record->userid)) {
         throw new coding_exception('$record->userid must be present in tool_monitor_generator::create_subscription()');
     }
     $sid = \tool_monitor\subscription_manager::create_subscription($record->ruleid, $record->courseid, $record->cmid, $record->userid);
     return \tool_monitor\subscription_manager::get_subscription($sid);
 }
示例#4
0
文件: index.php 项目: grug/moodle
            echo $OUTPUT->notification(get_string('subcreatesuccess', 'tool_monitor'), 'notifysuccess');
            break;
        case 'unsubscribe':
            // If the subscription does not exist, then redirect back as the subscription must have already been deleted.
            if (!($subscription = $DB->record_exists('tool_monitor_subscriptions', array('id' => $subscriptionid)))) {
                redirect(new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $courseid)));
            }
            // Set the URLs.
            $confirmurl = new moodle_url('/admin/tool/monitor/index.php', array('subscriptionid' => $subscriptionid, 'courseid' => $courseid, 'action' => 'unsubscribe', 'confirm' => true, 'sesskey' => sesskey()));
            $cancelurl = new moodle_url('/admin/tool/monitor/index.php', array('subscriptionid' => $subscriptionid, 'courseid' => $courseid, 'sesskey' => sesskey()));
            if ($confirm) {
                \tool_monitor\subscription_manager::delete_subscription($subscriptionid);
                echo $OUTPUT->header();
                echo $OUTPUT->notification(get_string('subdeletesuccess', 'tool_monitor'), 'notifysuccess');
            } else {
                $subscription = \tool_monitor\subscription_manager::get_subscription($subscriptionid);
                echo $OUTPUT->header();
                echo $OUTPUT->confirm(get_string('subareyousure', 'tool_monitor', $subscription->get_name($coursecontext)), $confirmurl, $cancelurl);
                echo $OUTPUT->footer();
                exit;
            }
            break;
        default:
    }
} else {
    echo $OUTPUT->header();
}
$renderer = $PAGE->get_renderer('tool_monitor', 'managesubs');
// Render the course selector.
$totalrules = \tool_monitor\rule_manager::count_rules_by_courseid($courseid);
$rules = new \tool_monitor\output\managesubs\rules('toolmonitorrules', $indexurl, $courseid);