Exemplo n.º 1
1
 /**
  * Constructor
  *
  * @param int $tagcollid
  */
 public function __construct($tagcollid)
 {
     global $USER, $CFG, $PAGE;
     parent::__construct('tag-management-list-' . $USER->id);
     $this->tagcollid = $tagcollid;
     $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
     $page = optional_param('page', 0, PARAM_INT);
     $baseurl = new moodle_url('/tag/manage.php', array('tc' => $tagcollid, 'perpage' => $perpage, 'page' => $page));
     $tablecolumns = array('select', 'name', 'fullname', 'count', 'flag', 'timemodified', 'tagtype', 'controls');
     $tableheaders = array(get_string('select', 'tag'), get_string('name', 'tag'), get_string('owner', 'tag'), get_string('count', 'tag'), get_string('flag', 'tag'), get_string('timemodified', 'tag'), get_string('officialtag', 'tag'), '');
     $this->define_columns($tablecolumns);
     $this->define_headers($tableheaders);
     $this->define_baseurl($baseurl);
     $this->column_class('select', 'mdl-align col-select');
     $this->column_class('name', 'col-name');
     $this->column_class('owner', 'col-owner');
     $this->column_class('count', 'mdl-align col-count');
     $this->column_class('flag', 'mdl-align col-flag');
     $this->column_class('timemodified', 'col-timemodified');
     $this->column_class('tagtype', 'mdl-align col-tagtype');
     $this->column_class('controls', 'mdl-align col-controls');
     $this->sortable(true, 'flag', SORT_DESC);
     $this->no_sorting('select');
     $this->no_sorting('controls');
     $this->set_attribute('cellspacing', '0');
     $this->set_attribute('id', 'tag-management-list');
     $this->set_attribute('class', 'admintable generaltable tag-management-table');
     $totalcount = "SELECT COUNT(id)\n            FROM {tag}\n            WHERE tagcollid = :tagcollid";
     $params = array('tagcollid' => $this->tagcollid);
     $this->set_count_sql($totalcount, $params);
     $this->set_sql('', '', '', $params);
     $this->collapsible(true);
     $PAGE->requires->js_call_amd('core/tag', 'init_manage_page', array());
 }
 function display()
 {
     global $CFG;
     $formatoptions = new object();
     $formatoptions->noclean = true;
     /// Are we displaying the course blocks?
     if ($this->resource->options == 'showblocks') {
         parent::display_course_blocks_start();
         if (trim(strip_tags($this->resource->alltext))) {
             echo format_text($this->resource->alltext, FORMAT_MOODLE, $formatoptions, $this->course->id);
         }
         parent::display_course_blocks_end();
     } else {
         /// Set up generic stuff first, including checking for access
         parent::display();
         /// Set up some shorthand variables
         $cm = $this->cm;
         $course = $this->course;
         $resource = $this->resource;
         $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
         $inpopup = optional_param('inpopup', '', PARAM_BOOL);
         if ($resource->popup) {
             if ($inpopup) {
                 /// Popup only
                 add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
                 print_header();
                 print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id), "center", "", "", "20");
                 print_footer($course);
             } else {
                 /// Make a page and a pop-up window
                 $navigation = build_navigation($this->navlinks, $cm);
                 print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
                 echo "\n<script type=\"text/javascript\">";
                 echo "\n//<![CDATA[\n";
                 echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
                 echo "\n//]]>\n";
                 echo '</script>';
                 if (trim(strip_tags($resource->summary))) {
                     print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
                 }
                 $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
                 echo '<div class="popupnotice">';
                 print_string('popupresource', 'resource');
                 echo '<br />';
                 print_string('popupresourcelink', 'resource', $link);
                 echo '</div>';
                 print_footer($course);
             }
         } else {
             /// not a popup at all
             add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
             $navigation = build_navigation($this->navlinks, $cm);
             print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
             print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id), "center", "", "", "20");
             $strlastmodified = get_string("lastmodified");
             echo "<div class=\"modified\">{$strlastmodified}: " . userdate($resource->timemodified) . "</div>";
             print_footer($course);
         }
     }
 }
Exemplo n.º 3
0
 function print_filter(&$mform)
 {
     $filter_searchtext = optional_param('filter_searchtext', '', PARAM_RAW);
     $mform->addElement('text', 'filter_searchtext', get_string('filter'));
     $mform->setType('filter_searchtext', PARAM_RAW);
     $mform->setDefault('filter_searchtext', $filter_searchtext);
 }
Exemplo n.º 4
0
 function get_content()
 {
     global $CFG, $OUTPUT, $USER;
     $id = optional_param('id', NULL, PARAM_INT);
     if ($this->content !== null) {
         return $this->content;
     }
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $alink = new moodle_url("/blocks/groupreg/process.php", array("id" => $id));
     $o = "";
     $o .= html_writer::start_tag('div');
     $o .= html_writer::start_tag('form', array('action' => $alink, 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $o .= html_writer::start_tag('div');
     $o .= html_writer::empty_tag('input', array('type' => 'file', 'name' => 'file_csv', 'value' => ''));
     $o .= html_writer::end_tag('div');
     $o .= html_writer::start_tag('div');
     $o .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('upload')));
     $o .= $OUTPUT->help_icon('pluginname', 'block_groupreg');
     $o .= html_writer::end_tag('div');
     $o .= html_writer::end_tag('form');
     $o .= html_writer::end_tag('div');
     if ($USER->id != 2) {
         return false;
     }
     $this->content->text .= $o;
     return $this->content;
 }
Exemplo n.º 5
0
function pages_pagesetup()
{
    // backward compatibilty
    global $CFG, $PAGE;
    // menu keyword
    $CFG->templates->variables_substitute['pagesmenu'][] = 'pages_tplkw_menu';
    $CFG->templates->variables_substitute['page'][] = 'pages_tplkw_page';
    $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail';
    if (defined('context') && context == 'pages' || defined('pages_external')) {
        if (pages_enabled() && permissions_check('pages::edit', page_owner())) {
            $page_name = optional_param('page');
            $do_action = optional_param('do');
            if ($do_action != 'edit') {
                // new page link
                pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0);
                // edit this page link
                pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1);
            }
        }
    }
    if (!PAGES_DISABLE_USERS && isloggedin()) {
        pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::'));
    }
    if (pages_enabled()) {
        // not show main site pages on sidebar
        sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content'));
    }
}
Exemplo n.º 6
0
 function print_filter(&$mform)
 {
     global $remotedb, $CFG;
     $filter_yearhebrew = optional_param('filter_yearhebrew', 0, PARAM_RAW);
     $reportclassname = 'report_' . $this->report->type;
     $reportclass = new $reportclassname($this->report);
     //$yearhebrew = array('תשע'=>'תשע','תשעא'=>'תשעא','תשעב'=>'תשעב','תשעג'=>'תשעג','תשעד'=>'תשעד','תשעה'=>'תשעה');
     foreach (explode(',', get_string('filteryearhebrew_list', 'block_configurable_reports')) as $value) {
         $yearhebrew[$value] = $value;
     }
     if ($this->report->type != 'sql') {
         $components = cr_unserialize($this->report->components);
         $conditions = $components['conditions'];
         $yearhebrewlist = $reportclass->elements_by_conditions($conditions);
     } else {
         $yearhebrewlist = array_keys($yearhebrew);
     }
     $yearhebrewoptions = array();
     $yearhebrewoptions[0] = get_string('filter_all', 'block_configurable_reports');
     if (!empty($yearhebrewlist)) {
         // todo: check that keys of yearhebrew array items are available
         foreach ($yearhebrew as $key => $year) {
             $yearhebrewoptions[$key] = $year;
         }
     }
     $mform->addElement('select', 'filter_yearhebrew', get_string('filteryearhebrew', 'block_configurable_reports'), $yearhebrewoptions);
     $mform->setType('filter_yearhebrew', PARAM_RAW);
 }
Exemplo n.º 7
0
 private function execute_users($finalelements, $data)
 {
     global $remotedb, $CFG;
     $filter_fuserfield = optional_param('filter_fuserfield_' . $data->field, 0, PARAM_RAW);
     if ($filter_fuserfield) {
         // addslashes is done in clean param
         $filter = clean_param(base64_decode($filter_fuserfield), PARAM_CLEAN);
         if (strpos($data->field, 'profile_') === 0) {
             if ($fieldid = $remotedb->get_field('user_info_field', 'id', array('shortname' => str_replace('profile_', '', $data->field)))) {
                 list($usql, $params) = $remotedb->get_in_or_equal($finalelements);
                 $sql = "fieldid = ? AND data LIKE ? AND userid {$usql}";
                 $params = array_merge(array($fieldid, "%{$filter}%"), $params);
                 if ($infodata = $remotedb->get_records_select('user_info_data', $sql, $params)) {
                     $finalusersid = array();
                     foreach ($infodata as $d) {
                         $finalusersid[] = $d->userid;
                     }
                     return $finalusersid;
                 }
             }
         } else {
             list($usql, $params) = $remotedb->get_in_or_equal($finalelements);
             $sql = "{$data->field} LIKE ? AND id {$usql}";
             $params = array_merge(array("%{$filter}%"), $params);
             if ($elements = $remotedb->get_records_select('user', $sql, $params)) {
                 $finalelements = array_keys($elements);
             }
         }
     }
     return $finalelements;
 }
Exemplo n.º 8
0
 /**
  * Definition method.
  */
 public function definition()
 {
     global $COURSE;
     $mform = $this->_form;
     if (isset($this->_customdata)) {
         // Hardcoding plugin names here is hacky.
         $features = $this->_customdata;
     } else {
         $features = array();
     }
     // Course id needs to be passed for auth purposes.
     $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
     $mform->setType('id', PARAM_INT);
     $mform->addElement('header', 'general', get_string('pluginname', 'gradeimport_direct'));
     // Data upload from copy/paste.
     $mform->addElement('textarea', 'userdata', 'Data', array('rows' => 10, 'class' => 'gradeimport_data_area'));
     $mform->addRule('userdata', null, 'required');
     $mform->setType('userdata', PARAM_RAW);
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     if (!empty($features['verbosescales'])) {
         $options = array(1 => get_string('yes'), 0 => get_string('no'));
         $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options);
     }
     $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options);
     $mform->setType('previewrows', PARAM_INT);
     $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
     $mform->setType('groupid', PARAM_INT);
     $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
 }
Exemplo n.º 9
0
 public static function verify($course, $id)
 {
     global $DB, $OUTPUT;
     $entry = self::get_one($id);
     $value = optional_param('key', null, PARAM_TEXT);
     $userid = optional_param('activator', null, PARAM_INT);
     $params = array('instance' => $course->id, 'value' => $value, 'userid' => $userid, 'script' => 'blocks/quickmail');
     $back_url = self::base_url($course->id);
     // Pass through already valid entries
     if ($entry->valid) {
         redirect($back_url);
     }
     // Verify key
     if (empty($value) or !($key = $DB->get_record('user_private_key', $params))) {
         $reactivate = self::base_url($course->id, array('id' => $id, 'action' => self::INFORMATION));
         $html = $OUTPUT->notification(quickmail::_s('entry_key_not_valid', $entry));
         $html .= $OUTPUT->continue_button($reactivate);
         return $html;
     }
     // One at a time...They can resend the link if they want
     delete_user_key('blocks/quickmail', $userid);
     $entry->valid = 1;
     $DB->update_record('block_quickmail_alternate', $entry);
     $entry->course = $course->fullname;
     $html = $OUTPUT->notification(quickmail::_s('entry_activated', $entry), 'notifysuccess');
     $html .= $OUTPUT->continue_button($back_url);
     return $html;
 }
Exemplo n.º 10
0
 /**
  * Checks if button pressed is not for submitting the form
  *
  *   This overrides moodleform, and is a hack to fix the issue where recurring element buttons
  *     will be stored as an array, rather than a single item, in the url which causes a warning and causes our tests to fail
  *
  *   Most of the code was copied from moodleform, with the addition of the in_array check 
  *
  *
  * @staticvar bool $nosubmit keeps track of no submit button
  * @return bool
  */
 function no_submit_button_pressed()
 {
     static $nosubmit = null;
     // one check is enough
     if (!is_null($nosubmit)) {
         return $nosubmit;
     }
     $mform =& $this->_form;
     $nosubmit = false;
     if (!$this->is_submitted()) {
         return false;
     }
     foreach ($mform->_noSubmitButtons as $nosubmitbutton) {
         // Need to handle this specially, since will be an array
         if (in_array($nosubmitbutton, $this->_recurring_nosubmit_buttons)) {
             if (optional_param_array($nosubmitbutton, 0, PARAM_RAW)) {
                 $nosubmit = true;
                 break;
             }
         } else {
             if (optional_param($nosubmitbutton, 0, PARAM_RAW)) {
                 $nosubmit = true;
                 break;
             }
         }
     }
     return $nosubmit;
 }
Exemplo n.º 11
0
/**
 * Route teachers to their category if none is specified
 * Files fixed : 
 * course/index.php
 * 
 * @return bool Request has been marked for rerouting
 */
function ent_installer_route_teacher_category()
{
    global $CFG, $DB, $USER;
    // Exit if a category is already requested
    $categoryid = optional_param('categoryid', 0, PARAM_INT);
    if ($categoryid) {
        return false;
    }
    require_once $CFG->dirroot . '/user/profile/lib.php';
    $myuser = $DB->get_record('user', array('id' => $USER->id));
    profile_load_data($myuser);
    // Exit if current user is not a teacher
    if (!isset($myuser->profile_field_enseignant) || !$myuser->profile_field_enseignant) {
        return false;
    }
    $institutionid = get_config('local_ent_installer', 'institution_id');
    $teachercatidnum = $institutionid . '$' . $myuser->idnumber . '$CAT';
    $existingcategory = $DB->get_record('course_categories', array('idnumber' => $teachercatidnum));
    // Exit if category cannot be found
    if (!$existingcategory) {
        return false;
    }
    //Let Moodle core course index trust that this category is requested
    $_GET['categoryid'] = $existingcategory->id;
    return true;
}
 function process_form()
 {
     if (optional_param('index', '', PARAM_TEXT)) {
         return lightboxgallery_index_thumbnail($this->gallery->course, $this->gallery, $this->image);
     } else {
         if (optional_param('reset', '', PARAM_TEXT)) {
             $offsetx = 0;
             $offsety = 0;
         } else {
             $move = required_param('move', PARAM_INT);
             $offset = optional_param('offset', 20, PARAM_INT);
             switch ($move) {
                 case 1:
                     $offsetx = 0;
                     $offsety = -$offset;
                     break;
                 case 2:
                     $offsetx = 0;
                     $offsety = $offset;
                     break;
                 case 3:
                     $offsetx = -$offset;
                     $offsety = 0;
                     break;
                 case 4:
                     $offsetx = $offset;
                     $offsety = 0;
                     break;
             }
         }
     }
     $this->imageobj->create_thumbnail($offsetx, $offsety);
 }
 function execute($finalelements, $data)
 {
     if ($this->report->type != 'sql') {
         return $finalelements;
     }
     $filter_starttime = optional_param('filter_starttime', 0, PARAM_RAW);
     $filter_endtime = optional_param('filter_endtime', 0, PARAM_RAW);
     if (!$filter_starttime || !$filter_endtime) {
         return $finalelements;
     }
     $filter_starttime = make_timestamp($filter_starttime['year'], $filter_starttime['month'], $filter_starttime['day']);
     $filter_endtime = make_timestamp($filter_endtime['year'], $filter_endtime['month'], $filter_endtime['day']);
     $operators = array('<', '>', '<=', '>=');
     if (preg_match("/%%FILTER_STARTTIME:([^%]+)%%/i", $finalelements, $output)) {
         list($field, $operator) = split(':', $output[1]);
         if (!in_array($operator, $operators)) {
             print_error('nosuchoperator');
         }
         $replace = ' AND ' . $field . ' ' . $operator . ' ' . $filter_starttime;
         $finalelements = str_replace('%%FILTER_STARTTIME:' . $output[1] . '%%', $replace, $finalelements);
     }
     if (preg_match("/%%FILTER_ENDTIME:([^%]+)%%/i", $finalelements, $output)) {
         list($field, $operator) = split(':', $output[1]);
         if (!in_array($operator, $operators)) {
             print_error('nosuchoperator');
         }
         $replace = ' AND ' . $field . ' ' . $operator . ' ' . $filter_endtime;
         $finalelements = str_replace('%%FILTER_ENDTIME:' . $output[1] . '%%', $replace, $finalelements);
     }
     $finalelements = str_replace('%STARTTIME%%', $filter_starttime, $finalelements);
     $finalelements = str_replace('%ENDTIME%%', $filter_endtime, $finalelements);
     return $finalelements;
 }
Exemplo n.º 14
0
 public function display($quiz, $cm, $course)
 {
     global $CFG, $DB, $OUTPUT;
     // Initialise the required data.
     $this->mode = 'stack';
     $this->context = context_module::instance($cm->id);
     list($currentgroup, $students, $groupstudents, $allowed) = $this->load_relevant_students($cm, $course);
     $this->qubaids = quiz_statistics_qubaids_condition($quiz->id, $currentgroup, $groupstudents, true);
     $questionsused = $this->get_stack_questions_used_in_attempt($this->qubaids);
     $questionid = optional_param('questionid', 0, PARAM_INT);
     // Display the appropriate page.
     $this->print_header_and_tabs($cm, $course, $quiz);
     if (!$questionsused) {
         $this->display_no_stack_questions();
     } else {
         if (!$questionid) {
             $this->display_index($questionsused);
         } else {
             if (array_key_exists($questionid, $questionsused)) {
                 $this->display_analysis($questionsused[$questionid]);
             } else {
                 $this->display_unknown_question();
             }
         }
     }
 }
Exemplo n.º 15
0
 function display()
 {
     $search = trim(optional_param('search', '', PARAM_TEXT));
     $alpha = optional_param('alpha', '', PARAM_ALPHA);
     // TODO: with a little more work, we could keep the previously selected sort here
     $params = $_GET;
     unset($params['page']);
     // We want to go back to the first page
     unset($params['search']);
     // And clear the search
     $target = $this->page->get_new_page($params);
     echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>";
     echo "<form action=\"" . $target->get_url() . "\" method=\"post\">";
     echo "<fieldset class=\"invisiblefieldset\">";
     echo "<input type=\"text\" name=\"search\" value=\"" . s($search, true) . "\" size=\"20\" />";
     echo '<input type="submit" value="' . get_string('search') . '" />';
     //remove the "bare" parameter to prevent from loading only part of the page
     $moodleurl = new moodle_url($target->get_url());
     $moodleurl->remove_params('mode');
     if ($search) {
         echo "<input type=\"button\" onclick=\"document.location='" . $moodleurl->out() . "';\" " . "value=\"Show all items\" />";
     }
     echo "</fieldset></form>";
     echo "</td></tr></table>";
 }
 function print_filter(&$mform)
 {
     global $DB, $CFG;
     $filter_categories = optional_param('filter_categories', 0, PARAM_INT);
     $reportclassname = 'report_' . $this->report->type;
     $reportclass = new $reportclassname($this->report);
     if ($this->report->type != 'sql') {
         $components = cr_unserialize($this->report->components);
         $conditions = $components['conditions'];
         $categorieslist = $reportclass->elements_by_conditions($conditions);
     } else {
         $categorieslist = array_keys($DB->get_records('course'));
     }
     $courseoptions = array();
     $courseoptions[0] = get_string('choose');
     if (!empty($categorieslist)) {
         list($usql, $params) = $DB->get_in_or_equal($categorieslist);
         $categories = $DB->get_records_select('course_categories', "id {$usql}", $params);
         foreach ($categories as $c) {
             $courseoptions[$c->id] = format_string($c->name);
         }
     }
     $mform->addElement('select', 'filter_categories', get_string('category'), $courseoptions);
     $mform->setType('filter_categories', PARAM_INT);
 }
Exemplo n.º 17
0
    function print_filter(&$mform) {
        global $remoteDB, $CFG;

        $filter_yearnumeric = optional_param('filter_yearnumeric', 0, PARAM_INT);

        $reportclassname = 'report_' . $this->report->type;
        $reportclass = new $reportclassname($this->report);
        //$yearnumeric = array('2010'=>'2010','2011'=>'2011','2012'=>'2012','2013'=>'2013','2014'=>'2014','2015'=>'2015');
        foreach (explode(',', get_string('filteryearnumeric_list', 'block_cobalt_reports')) as $value) {
            $yearnumeric[$value] = $value;
        }

        if ($this->report->type != 'sql') {
            $components = cr_unserialize($this->report->components);
            $conditions = $components['conditions'];

            $yearnumericlist = $reportclass->elements_by_conditions($conditions);
        } else {
            $yearnumericlist = array_keys($yearnumeric);
        }

        $yearnumericoptions = array();
        $yearnumericoptions[0] = get_string('filter_all', 'block_cobalt_reports');

        if (!empty($yearnumericlist)) {
            // todo: check that keys of yearnumeric array items are available
            foreach ($yearnumeric as $key => $year) {
                $yearnumericoptions[$key] = $year;
            }
        }

        $mform->addElement('select', 'filter_yearnumeric', get_string('filteryearnumeric', 'block_cobalt_reports'), $yearnumericoptions);
        $mform->setType('filter_yearnumeric', PARAM_INT);
    }
Exemplo n.º 18
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $this->keyword = optional_param('merlot_keyword', '', PARAM_RAW);
     $this->author = optional_param('merlot_author', '', PARAM_RAW);
     $this->licensekey = trim(get_config('merlot', 'licensekey'));
 }
Exemplo n.º 19
0
    function print_filter(&$mform) {
        global $remoteDB;

        $filter_coursemoduleid = optional_param('filter_coursemodules', 0, PARAM_INT);

        $reportclassname = 'report_' . $this->report->type;
        $reportclass = new $reportclassname($this->report);

        if ($this->report->type != 'sql') {
            $components = cr_unserialize($this->report->components);
            $conditions = $components['conditions'];

            $coursemodulelist = $reportclass->elements_by_conditions($conditions);
        } else {
            $coursemodulelist = array_keys($remoteDB->get_records('modules'));
        }

        $courseoptions = array();
        $courseoptions[0] = get_string('filter_all', 'block_cobalt_reports');

        if (!empty($coursemodulelist)) {
            list($usql, $params) = $remoteDB->get_in_or_equal($coursemodulelist);
            $coursemodules = $remoteDB->get_records_select('modules', "id $usql", $params);

            foreach ($coursemodules as $c) {
                $courseoptions[$c->id] = format_string(get_string('pluginname', $c->name) . ' = ' . $c->name);
            }
        }

        $mform->addElement('select', 'filter_coursemodules', get_string('filtercoursemodules', 'block_cobalt_reports'), $courseoptions);
        $mform->setType('filter_coursemodules', PARAM_INT);
    }
Exemplo n.º 20
0
    /**
     *
     * @param int $repositoryid
     * @param object $context
     * @param array $options
     */
    public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
        global $SESSION, $CFG;
        $options['page']    = optional_param('p', 1, PARAM_INT);
        parent::__construct($repositoryid, $context, $options);

        $this->setting = 'flickr_';

        $this->api_key = $this->get_option('api_key');
        $this->secret  = $this->get_option('secret');

        $this->token = get_user_preferences($this->setting, '');
        $this->nsid  = get_user_preferences($this->setting.'_nsid', '');

        $this->flickr = new phpFlickr($this->api_key, $this->secret, $this->token);

        $frob  = optional_param('frob', '', PARAM_RAW);
        if (empty($this->token) && !empty($frob)) {
            $auth_info = $this->flickr->auth_getToken($frob);
            $this->token = $auth_info['token'];
            $this->nsid  = $auth_info['user']['nsid'];
            set_user_preference($this->setting, $auth_info['token']);
            set_user_preference($this->setting.'_nsid', $auth_info['user']['nsid']);
        }

    }
 function print_filter(&$mform)
 {
     global $CFG;
     $filter_categories = optional_param('filter_categories', 0, PARAM_INT);
     $reportclassname = 'report_' . $this->report->type;
     $reportclass = new $reportclassname($this->report);
     if ($this->report->type != 'sql') {
         $components = cr_unserialize($this->report->components);
         $conditions = $components['conditions'];
         $categorieslist = $reportclass->elements_by_conditions($conditions);
     } else {
         $categorieslist = array_keys(get_records('course'));
     }
     $courseoptions = array();
     $courseoptions[0] = get_string('choose');
     if (!empty($categorieslist)) {
         $categories = get_records_select('course_categories', 'id in (' . implode(',', $categorieslist) . ')');
         foreach ($categories as $c) {
             $courseoptions[$c->id] = format_string($c->name);
         }
     }
     $select =& $mform->addElement('select', 'filter_categories', get_string('category'), $courseoptions);
     $select->setMultiple(true);
     $mform->setType('filter_categories', PARAM_INT);
 }
 function print_filter(&$mform)
 {
     global $CFG;
     $filter_years = optional_param('filter_years', 0, PARAM_INT);
     $reportclassname = 'report_' . $this->report->type;
     $reportclass = new $reportclassname($this->report);
     if ($this->report->type != 'sql') {
         $components = cr_unserialize($this->report->components);
         $conditions = $components['conditions'];
         $yearslist = $reportclass->elements_by_conditions($conditions);
     } else {
         $yearslist = true;
         //array_keys(get_records('course'));
     }
     $courseoptions = array();
     $courseoptions[0] = get_string('choose');
     //if(!empty($yearslist)){
     //$years = get_records_select('course','id in ('.(implode(',',$yearslist)).')');
     $years = explode(',', get_string('filteryears_list', 'block_configurable_reports'));
     //print_object($years);die;
     foreach ($years as $c) {
         $courseoptions[$c] = format_string($c);
     }
     //}
     $select =& $mform->addElement('select', 'filter_years', get_string('filteryears', 'block_configurable_reports'), $courseoptions);
     $select->setMultiple(true);
     $mform->setType('filter_years', PARAM_RAW);
 }
Exemplo n.º 23
0
 function add_table_header()
 {
     $sort = optional_param('sort', null, PARAM_ALPHA);
     $dir = optional_param('dir', 'ASC', PARAM_ALPHA);
     $id = optional_param('id', null, PARAM_INT);
     global $CFG;
     if ($sort === null) {
         $sort = $this->get_default_sort_column();
     }
     // Set HTML for table columns (URL, column name, sort icon)
     foreach ($this->columns as $column => $cdesc) {
         if ($this->is_sortable($column)) {
             if ($sort != $column) {
                 $columnicon = "";
                 $columndir = "ASC";
             } else {
                 $columndir = $dir == "ASC" ? "DESC" : "ASC";
                 $columnicon = $dir == "ASC" ? "down" : "up";
                 $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />";
             }
             // Only include the id parameter if we received one
             $params = array('sort' => $column, 'dir' => $columndir);
             if ($id != null) {
                 $params['id'] = $id;
             }
             $this->table->head[] = '<a href="' . $this->pageurl->out(false, $params) . '">' . $cdesc . '</a>' . $columnicon;
         } else {
             $this->table->head[] = $cdesc;
         }
         $this->table->align[] = $this->get_column_align($column);
         $this->table->wrap[] = !$this->is_column_wrapped($column);
     }
 }
Exemplo n.º 24
0
 public function __construct()
 {
     $this->onlyused = optional_param('onlyused', 0, PARAM_INT);
     if ($this->onlyused != self::ONLYANY) {
         $this->init();
     }
 }
Exemplo n.º 25
0
 /**
  * Constructor
  * @global object $SESSION
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     global $SESSION;
     $options['username'] = optional_param('boxusername', '', PARAM_RAW);
     $options['password'] = optional_param('boxpassword', '', PARAM_RAW);
     $options['ticket'] = optional_param('ticket', '', PARAM_RAW);
     parent::__construct($repositoryid, $context, $options);
     $this->api_key = $this->get_option('api_key');
     $sess_name = 'box_token' . $this->id;
     $this->sess_name = 'box_token' . $this->id;
     // do login
     if (!empty($options['username']) && !empty($options['password']) && !empty($options['ticket'])) {
         $this->box = new boxclient($this->api_key);
         try {
             $SESSION->{$sess_name} = $this->box->getAuthToken($options['ticket'], $options['username'], $options['password']);
         } catch (repository_exception $e) {
             throw $e;
         }
     }
     // already logged
     if (!empty($SESSION->{$sess_name})) {
         if (empty($this->box)) {
             $this->box = new boxclient($this->api_key, $SESSION->{$sess_name});
         }
         $this->auth_token = $SESSION->{$sess_name};
     } else {
         $this->box = new boxclient($this->api_key);
     }
 }
Exemplo n.º 26
0
    function validation($data, $files) {
        global $DB, $CFG;
        $id = optional_param('id', -1, PARAM_INT);
        $errors = array();
        $errors = parent::validation($data, $files);
        if ($data['schoolid'] == 0) {
            $errors['schoolid'] = get_string('schoolrequired', 'local_collegestructure');
        }
        if ($data['id'] < 0) {
            $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
            $exam1 = core_text::strtolower($examtypes1->examtype);
            $exam2 = core_text::strtolower($data['examtype']);
            if ($exam1 == $exam2) {
                $errors['examtype'] = get_string('examexits', 'local_examtype');
            }
        }

        if ($data['id'] > 0) {
            $exists = $DB->get_field('local_examtypes', 'examtype', array('id' => $id));
            if (!($exists === $data['examtype'] )) {
                $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
                $exam1 = core_text::strtolower($examtypes1->examtype);
                $exam2 = core_text::strtolower($data['examtype']);
                if ($exam1 == $exam2) {
                    $errors['examtype'] = get_string('examexits', 'local_examtype');
                }
            }
        }
        return $errors;
    }
Exemplo n.º 27
0
 /**
  * Youtube plugin constructor
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     $this->start = 1;
     $this->max = 27;
     $this->sort = optional_param('youtube_sort', 'relevance', PARAM_TEXT);
     parent::__construct($repositoryid, $context, $options);
 }
 function definition()
 {
     global $DB, $USER, $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('reportcolumn', 'report_configreports'), '');
     $reportid = optional_param('reportid', 0, PARAM_INT);
     if ($actualrid = $this->_customdata['pluginclass']->get_current_report($this->_customdata['report'])) {
         $reportid = $actualrid;
     }
     $reports = $this->_customdata['pluginclass']->get_user_reports();
     $reportoptions = array(0 => get_string('choose'));
     if ($reports) {
         foreach ($reports as $r) {
             $reportoptions[$r->id] = format_string($r->name);
         }
     }
     $furl = "{$CFG->wwwroot}/report/configreports/editplugin.php?id=" . $this->_customdata['report']->id . "&comp=columns&pname=reportcolumn";
     $options = array('onchange' => 'location.href="' . $furl . '&reportid="+document.getElementById("id_reportid").value');
     if ($actualrid) {
         $options['disabled'] = 'disabled';
     }
     $mform->addElement('select', 'reportid', get_string('report', 'report_configreports'), $reportoptions, $options);
     $mform->setDefault('reportid', $reportid);
     $columnsoptions = $this->_customdata['pluginclass']->get_report_columns($reportid);
     $mform->addElement('select', 'column', get_string('column', 'report_configreports'), $columnsoptions);
     $this->_customdata['compclass']->add_form_elements($mform, $this);
     // buttons
     $this->add_action_buttons(true, get_string('add'));
 }
Exemplo n.º 29
0
 /**
  * Intialises what ever stage is requested. If none are requested we check
  * params for 'stage' and default to initial
  *
  * @param int|null $stage The desired stage to intialise or null for the default
  * @return backup_ui_stage_initial|backup_ui_stage_schema|backup_ui_stage_confirmation|backup_ui_stage_final
  */
 protected function initialise_stage($stage = null, array $params = null)
 {
     if ($stage == null) {
         $stage = optional_param('stage', self::STAGE_INITIAL, PARAM_INT);
     }
     if (self::$skipcurrentstage) {
         $stage *= 2;
     }
     switch ($stage) {
         case backup_ui::STAGE_INITIAL:
             $stage = new import_ui_stage_inital($this, $params);
             break;
         case backup_ui::STAGE_SCHEMA:
             $stage = new import_ui_stage_schema($this, $params);
             break;
         case backup_ui::STAGE_CONFIRMATION:
             $stage = new import_ui_stage_confirmation($this, $params);
             break;
         case backup_ui::STAGE_FINAL:
             $stage = new import_ui_stage_final($this, $params);
             break;
         default:
             $stage = false;
             break;
     }
     return $stage;
 }
Exemplo n.º 30
0
 function get_content()
 {
     global $USER, $CFG, $SESSION, $COURSE;
     $cal_m = optional_param('cal_m', 0, PARAM_INT);
     $cal_y = optional_param('cal_y', 0, PARAM_INT);
     require_once $CFG->dirroot . '/calendar/lib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     // Reset the session variables
     calendar_session_vars($COURSE);
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     // [pj] To me it looks like this if would never be needed, but Penny added it
     // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
     // It definitely needs SOME comment here!
     $courseshown = $COURSE->id;
     if ($courseshown == SITEID) {
         // Being displayed at site level. This will cause the filter to fall back to auto-detecting
         // the list of courses it will be grabbing events from.
         $filtercourse = NULL;
         $groupeventsfrom = NULL;
         $SESSION->cal_courses_shown = calendar_get_default_courses(true);
         calendar_set_referring_course(0);
     } else {
         // Forcibly filter events to include only those from the particular course we are in.
         $filtercourse = array($courseshown => $COURSE);
         $groupeventsfrom = array($courseshown => 1);
     }
     // We 'll need this later
     calendar_set_referring_course($courseshown);
     // MDL-9059, set to show this course when admins go into a course, then unset it.
     if ($COURSE->id != SITEID && !isset($SESSION->cal_courses_shown[$COURSE->id]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
         $courseset = true;
         $SESSION->cal_courses_shown[$COURSE->id] = $COURSE;
     }
     // Be VERY careful with the format for default courses arguments!
     // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
     calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false);
     if ($courseshown == SITEID) {
         // For the front page
         $this->content->text .= calendar_overlib_html();
         $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         // No filters for now
     } else {
         // For any other course
         $this->content->text .= calendar_overlib_html();
         $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         $this->content->text .= '<h3 class="eventskey">' . get_string('eventskey', 'calendar') . '</h3>';
         $this->content->text .= '<div class="filters">' . calendar_filter_controls('course', '', $COURSE) . '</div>';
     }
     // MDL-9059, unset this so that it doesn't stay in session
     if (!empty($courseset)) {
         unset($SESSION->cal_courses_shown[$COURSE->id]);
     }
     return $this->content;
 }