Exemple #1
0
 public function definition()
 {
     $mform =& $this->_form;
     // ensure the user is allowed to view the classes being listed
     $user_classes = pmclass_get_listing('crsname', 'ASC', 0, 11, '', '', 0, false, pmclasspage::get_contexts('local/elisprogram:class_view'));
     if (empty($user_classes)) {
         // show a default label
         $mform->addElement('static', 'static_name', get_string('no_courses', 'block_courserequest'));
     } else {
         // we have classes to list
         $mform->addElement('static', 'static_title', get_string('current_classes', 'block_courserequest'));
         foreach ($user_classes as $uc) {
             $context = \local_elisprogram\context\pmclass::instance($uc->id);
             // this points to the page that displays the specific class
             $target = new pmclasspage(array('id' => $uc->id, 'action' => 'view'));
             $mform->addElement('static', 'course' . $uc->id, '', "<a href=\"{$target->url}\">{$uc->idnumber}</a>");
         }
         // use a "More" link if there are more than ten classes
         if (count($user_classes) > 10) {
             $target = new pmclasspage(array());
             // TBV
             $more = "<a href=\"{$target->url}\">" . get_string('moreclasses', 'block_courserequest') . '</a>';
             $mform->addElement('static', '' . $uc->id, '', $more);
         }
     }
     // button for creating a new request
     $mform->addElement('submit', 'add', get_string('request', 'block_courserequest'));
 }
Exemple #2
0
/**
 * Dynamically loads child menu items for a course entity
 *
 * @param   int             $id                    The entity id
 * @param   int             $parent_cluster_id     The last cluster passed going down the elisadmin tree, or 0 if none
 * @param   int             $parent_curriculum_id  The last curriculum passed going down the elisadmin tree, or 0 if none
 * @param   int             $num_block_icons       Max number of entries to display
 * @param   string          $parent_path           Path of parent curriculum elements in the tree
 * @return  menuitem array                         The appropriate child items
 */
function block_elisadmin_load_menu_children_course($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path = '')
{
    global $CFG;
    //page dependencies
    require_once elispm::file('pmclasspage.class.php');
    $result_items = array();
    /*****************************************
     * Course - Class Associations
     *****************************************/
    $class_css_class = block_elisadmin_get_item_css_class('class_instance');
    //permissions filter
    $class_contexts = pmclasspage::get_contexts('local/elisprogram:class_view');
    $listing = pmclass_get_listing('crsname', 'asc', 0, $num_block_icons, '', '', $id, false, $class_contexts, $parent_cluster_id);
    foreach ($listing as $item) {
        $item->clsname = $item->idnumber;
        $params = array('id' => $item->id, 'action' => 'view');
        $result_items[] = block_elisadmin_get_menu_item('pmclass', $item, 'root', $class_css_class, $parent_cluster_id, $parent_curriculum_id, $params, false, $parent_path);
    }
    unset($listing);
    //summary item
    $num_records = pmclass_count_records('', '', $id, false, $class_contexts, $parent_cluster_id);
    if ($num_block_icons < $num_records) {
        $params = array('action' => 'default', 'id' => $id);
        //add extra param if appropriate
        if (!empty($parent_cluster_id)) {
            $params['parent_clusterid'] = $parent_cluster_id;
        }
        $result_items[] = block_elisadmin_get_menu_summary_item('pmclass', $class_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    return $result_items;
}
Exemple #3
0
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/contexts.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
if (!isloggedin() || isguestuser()) {
    mtrace("ERROR: must be logged in!");
    exit;
}
$ids = array();
if (array_key_exists('id', $_REQUEST)) {
    $dirtyids = $_REQUEST['id'];
    if (is_array($dirtyids)) {
        foreach ($dirtyids as $dirty) {
            $ids[] = clean_param($dirty, PARAM_INT);
        }
    } else {
        $ids[] = clean_param($dirtyids, PARAM_INT);
    }
} else {
    $ids[] = 0;
}
// Must have blank value as the default here (instead of zero) or it breaks the gas guage report
$choices_array = array(array('', get_string('anyvalue', 'filters')));
if (!empty($ids)) {
    $contexts = get_contexts_by_capability_for_user('class', 'local/elisreports:view', $USER->id);
    $records = pmclass_get_listing('idnumber', 'ASC', 0, 0, '', '', $ids, false, $contexts);
    foreach ($records as $record) {
        $choices_array[] = array($record->id, $record->idnumber);
    }
    unset($records);
}
echo json_encode($choices_array);
 function display_add()
 {
     // action_add
     global $OUTPUT;
     $crsid = cm_get_param('crsid', 0);
     $sort = $this->optional_param('sort', 'startdate', PARAM_ALPHA);
     $dir = $this->optional_param('dir', 'ASC', PARAM_ALPHA);
     if ($sort == 'timeofday') {
         $sort = 'starttimehour';
     }
     $this->include_js();
     $classes = pmclass_get_listing($sort, $dir, 0, 0, '', '', $crsid, true);
     if ($classes->valid() === true) {
         echo html_writer::tag('div', '', array('id' => 'chooseclass', 'style' => 'overflow: auto'));
         $table = new addclasstable($classes, new moodle_url(htmlspecialchars_decode($this->url)));
         $table->print_yui_table('chooseclass');
     } else {
         echo $OUTPUT->heading(get_string('no_classes_available', 'local_elisprogram'));
     }
     unset($classes);
 }
 /**
  * Specifies available report filters
  * (empty by default but can be implemented by child class)
  *
  * @param   boolean  $init_data  If true, signal the report to load the
  *                               actual content of the filter objects
  *
  * @return  array                The list of available filters
  */
 function get_filters($init_data = true)
 {
     global $CFG;
     // Fetch array of allowed classes
     $classes_array = array();
     $contexts = get_contexts_by_capability_for_user('class', $this->access_capability, $this->userid);
     $cmclasses = pmclass_get_listing('crsname', 'ASC', 0, 0, '', '', 0, false, $contexts);
     foreach ($cmclasses as $cmclass) {
         $classes_array[$cmclass->id] = $cmclass->crsname . ' - ' . $cmclass->idnumber;
     }
     unset($cmclasses);
     $class_filter = new generalized_filter_entry('classid', 'cls', 'id', get_string('filter_course_class', $this->lang_file), false, 'courseclassselect', array('default' => NULL, 'isrequired' => true, 'report_path' => $CFG->wwwroot . '/local/elisreports/instances/class_roster/', 'help' => array('class_roster_courseclass', get_string('filter_course_class', $this->lang_file), $this->lang_file)));
     //columns checkboxes
     $userset_label = get_string('column_option_cluster', $this->lang_file);
     $idnumber_label = get_string('column_option_idnumber', $this->lang_file);
     $username_label = get_string('column_option_username', $this->lang_file);
     $mi_label = get_string('column_option_mi', $this->lang_file);
     $email2_label = get_string('column_option_email2', $this->lang_file);
     $address_label = get_string('column_option_address', $this->lang_file);
     $address2_label = get_string('column_option_address2', $this->lang_file);
     $city_label = get_string('column_option_city', $this->lang_file);
     $state_label = get_string('column_option_state', $this->lang_file);
     $postalcode_label = get_string('column_option_postalcode', $this->lang_file);
     $country_label = get_string('column_option_country', $this->lang_file);
     $phone_label = get_string('column_option_phone', $this->lang_file);
     $phone2_label = get_string('column_option_phone2', $this->lang_file);
     $fax_label = get_string('column_option_fax', $this->lang_file);
     $birthdate_label = get_string('column_option_birthdate', $this->lang_file);
     $gender_label = get_string('column_option_gender', $this->lang_file);
     $language_label = get_string('column_option_language', $this->lang_file);
     $transfercredits_label = get_string('column_option_transfercredits', $this->lang_file);
     $comments_label = get_string('column_option_comments', $this->lang_file);
     $notes_label = get_string('column_option_notes', $this->lang_file);
     $inactive_label = get_string('column_option_inactive', $this->lang_file);
     $heading_label = get_string('columns_options_heading', $this->lang_file);
     $choices = array('cluster' => $userset_label, 'idnumber' => $idnumber_label, 'username' => $username_label, 'mi' => $mi_label, 'email2' => $email2_label, 'address' => $address_label, 'address2' => $address2_label, 'city' => $city_label, 'state' => $state_label, 'postalcode' => $postalcode_label, 'country' => $country_label, 'phone' => $phone_label, 'phone2' => $phone2_label, 'fax' => $fax_label, 'birthdate' => $birthdate_label, 'gender' => $gender_label, 'language' => $language_label, 'transfercredits' => $transfercredits_label, 'comments' => $comments_label, 'notes' => $notes_label);
     if (elis::$config->local_elisprogram->legacy_show_inactive_users) {
         $choices['inactive'] = $inactive_label;
     }
     $checked = array();
     $advanced = array('cluster', 'idnumber', 'username', 'mi', 'email2', 'address', 'address2', 'city', 'state', 'postalcode', 'country', 'phone', 'phone2', 'fax', 'birthdate', 'gender', 'language', 'transfercredits', 'comments', 'notes');
     if (elis::$config->local_elisprogram->legacy_show_inactive_users) {
         $advanced[] = 'inactive';
     }
     $columns_options = array('choices' => $choices, 'checked' => $checked, 'advanced' => $advanced, 'allowempty' => true, 'heading' => $heading_label, 'nofilter' => true, 'help' => array('class_roster_options', get_string('filter_options', $this->lang_file), $this->lang_file));
     //columns checkboxes
     $columns_heading = get_string('columns_options_heading', $this->lang_file);
     $columns_filter = new generalized_filter_entry('columns', '', '', $columns_heading, false, 'checkboxes', $columns_options);
     return array($class_filter, $columns_filter);
 }
Exemple #6
0
 function display_default()
 {
     // Get parameters
     $sort = optional_param('sort', 'crsname', PARAM_ALPHA);
     $dir = optional_param('dir', 'ASC', PARAM_ALPHA);
     $page = optional_param('page', 0, PARAM_INT);
     $perpage = optional_param('perpage', 30, PARAM_INT);
     // how many per page
     $namesearch = trim(optional_param('search', '', PARAM_TEXT));
     $alpha = optional_param('alpha', '', PARAM_ALPHA);
     $id = $this->get_cm_id();
     //this parameter signifies a required relationship between a class and a track
     //through a cluster
     $parent_clusterid = $this->optional_param('parent_clusterid', 0, PARAM_INT);
     // Define columns
     $columns = array('crsname' => array('header' => get_string('class_course', 'local_elisprogram')), 'idnumber' => array('header' => get_string('class_idnumber', 'local_elisprogram')), 'moodlecourse' => array('header' => get_string('class_moodle_course', 'local_elisprogram')), 'startdate' => array('header' => get_string('class_startdate', 'local_elisprogram')), 'enddate' => array('header' => get_string('class_enddate', 'local_elisprogram')), 'starttime' => array('header' => get_string('class_starttime', 'local_elisprogram')), 'endtime' => array('header' => get_string('class_endtime', 'local_elisprogram')), 'maxstudents' => array('header' => get_string('class_maxstudents', 'local_elisprogram')));
     //set the column data needed to maintain and display current sort
     if ($dir !== 'DESC') {
         $dir = 'ASC';
     }
     if (isset($columns[$sort])) {
         $columns[$sort]['sortable'] = $dir;
     }
     $contexts = pmclasspage::get_contexts('local/elisprogram:class_view');
     $items = pmclass_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, false, $contexts, $parent_clusterid);
     $numitems = pmclass_count_records($namesearch, $alpha, $id, false, $contexts, $parent_clusterid);
     pmclasspage::get_contexts('local/elisprogram:class_edit');
     pmclasspage::get_contexts('local/elisprogram:class_delete');
     if (!empty($id)) {
         $coursepage = new coursepage(array('id' => $id));
         $coursepage->print_tabs('pmclasspage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
     unset($items);
 }
Exemple #7
0
 /**
  * Override this method to return the main pulldown option
  * @return array List of options keyed on id
  */
 function get_main_options()
 {
     global $USER;
     $courses_array = array('0' => get_string('selectacourse', 'local_elisprogram'));
     // Fetch array of allowed classes
     $contexts = get_contexts_by_capability_for_user('class', 'local/elisreports:view', $USER->id);
     $records = pmclass_get_listing('crsname', 'ASC', 0, 0, '', '', 0, false, $contexts);
     if ($records->valid() === true) {
         $allowed_courses = array();
         foreach ($records as $record) {
             if (!in_array($record->courseid, $allowed_courses)) {
                 $allowed_courses[] = $record->courseid;
             }
         }
         sort($allowed_courses);
         // Fetch array of all courses
         $course_list = course_get_listing('name', 'ASC', 0, 0, '', '');
         foreach ($course_list as $course_obj) {
             // Only show courses that are associated with an allowed class
             if (in_array($course_obj->id, $allowed_courses)) {
                 $courses_array[$course_obj->id] = strlen($course_obj->name) > 80 ? substr($course_obj->name, 0, 80) . '...' : $course_obj->name;
             }
         }
     }
     unset($records);
     return $courses_array;
 }