Exemple #1
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 curr_admin tree, or 0 if none
 * @param   int             $parent_curriculum_id  The last curriculum passed going down the curr_admin 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_curr_admin_load_menu_children_course($id, $parent_cluster_id, $parent_curriculum_id, $num_block_icons, $parent_path = '')
{
    global $CFG;
    // page dependencies
    require_once $CFG->dirroot . '/curriculum/cmclasspage.class.php';
    $result_items = array();
    /*****************************************
     * Course - Class Associations
     *****************************************/
    $class_css_class = block_curr_admin_get_item_css_class('class_instance');
    // permissions filter
    $class_contexts = cmclasspage::get_contexts('block/curr_admin:class:view');
    $listing = cmclass_get_listing('crsname', 'asc', 0, $num_block_icons, '', '', $id, false, $class_contexts, $parent_cluster_id);
    if (!empty($listing)) {
        foreach ($listing as $item) {
            $item->clsname = $item->idnumber;
            $params = array('id' => $item->id, 'action' => 'view');
            $result_items[] = block_curr_admin_get_menu_item('cmclass', $item, 'root', $class_css_class, $parent_cluster_id, $parent_curriculum_id, $params, false, $parent_path);
        }
    }
    //summary item
    $num_records = cmclass_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_curr_admin_get_menu_summary_item('cmclass', $class_css_class, $num_records - $num_block_icons, $params, '', $parent_path);
    }
    return $result_items;
}
 function action_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' => get_string('class_course', 'block_curr_admin'), 'idnumber' => get_string('class_idnumber', 'block_curr_admin'), 'moodlecourse' => get_string('class_moodle_course', 'block_curr_admin'), 'startdate' => get_string('class_startdate', 'block_curr_admin'), 'enddate' => get_string('class_enddate', 'block_curr_admin'), 'starttime' => get_string('class_starttime', 'block_curr_admin'), 'endtime' => get_string('class_endtime', 'block_curr_admin'), 'maxstudents' => get_string('class_maxstudents', 'block_curr_admin'), 'envname' => get_string('environment', 'block_curr_admin'));
     $items = cmclass_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, $id, false, cmclasspage::get_contexts('block/curr_admin:class:view'), $parent_clusterid);
     $numitems = cmclass_count_records($namesearch, $alpha, $id, false, cmclasspage::get_contexts('block/curr_admin:class:view'), $parent_clusterid);
     cmclasspage::get_contexts('block/curr_admin:class:edit');
     cmclasspage::get_contexts('block/curr_admin:class:delete');
     if (!empty($id)) {
         $coursepage = new coursepage(array('id' => $id));
         $coursepage->print_tabs('cmclasspage', array('id' => $id));
     }
     $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true);
 }