Exemplo n.º 1
0
function user_institution_graph($type = null)
{
    // Draw a bar graph showing the number of users in each institution
    require_once get_config('libroot') . 'institution.php';
    $institutions = Institution::count_members(false, true);
    if (count($institutions) > 1) {
        $dataarray = array();
        foreach ($institutions as &$i) {
            $dataarray[$i->displayname][get_string('institution')] = $i->members;
        }
        arsort($dataarray);
        // Truncate to avoid trying to fit too many results onto graph
        $dataarray = array_slice($dataarray, 0, 12, true);
        $data['graph'] = $type ? $type : 'bar';
        $data['graph_function_name'] = 'user_institution_graph';
        $data['title'] = get_string('institutionmembers', 'admin');
        $data['labels'] = array_keys($dataarray[$i->displayname]);
        $data['data'] = $dataarray;
        return $data;
    }
}
function build_institutions_html($filter, $showdefault, $query, $limit, $offset, &$count = null)
{
    global $USER;
    $institutions = Institution::count_members($filter, $showdefault, $query, $limit, $offset, $count);
    $smarty = smarty_core();
    $smarty->assign('institutions', $institutions);
    $smarty->assign('siteadmin', $USER->get('admin'));
    $data['tablerows'] = $smarty->fetch('admin/users/institutionsresults.tpl');
    $pagination = build_pagination(array('id' => 'adminstitutionslist_pagination', 'datatable' => 'adminstitutionslist', 'url' => get_config('wwwroot') . 'admin/users/institutions.php' . (!empty($query) ? '?query=' . urlencode($query) : ''), 'jsonscript' => 'admin/users/institutions.json.php', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('institution', 'admin'), 'resultcounttextplural' => get_string('institutions', 'admin')));
    $data['pagination'] = $pagination['html'];
    $data['pagination_js'] = $pagination['javascript'];
    return $data;
}
function user_institution_graph()
{
    // Draw a bar graph showing the number of users in each institution
    require_once get_config('libroot') . 'institution.php';
    $institutions = Institution::count_members(false, true);
    if (count($institutions) > 1) {
        $dataarray = array();
        foreach ($institutions as &$i) {
            $dataarray[$i->displayname] = $i->members;
        }
        arsort($dataarray);
        // Truncate to avoid overlapping labels
        $dataarray = array_slice($dataarray, 0, 25, true);
        require_once get_config('libroot') . "pear/Image/Graph.php";
        $Graph =& Image_Graph::factory('graph', array(300, 300));
        $Font =& $Graph->addNew('font', 'Vera');
        $Font->setSize(9);
        $Graph->setFont($Font);
        $Graph->add(Image_Graph::vertical(Image_Graph::vertical(Image_Graph::factory('title', array(get_string('institutionmembers', 'admin'), 9)), $Plotarea = Image_Graph::factory('plotarea'), 5), $Date = Image_Graph::factory('title', array(format_date(time(), 'strftimew3cdate'), 7)), 96));
        $Date->setAlignment(IMAGE_GRAPH_ALIGN_RIGHT);
        $DateFont =& $Graph->addNew('font', 'Vera');
        $DateFont->setColor('gray@0.8');
        $Date->setFont($DateFont);
        $Dataset =& Image_Graph::factory('dataset', array($dataarray));
        $Plot =& $Plotarea->addNew('bar', array(&$Dataset));
        $Plot->setLineColor('gray');
        $Plot->setSpacing(2);
        $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
        $Plot->setFillStyle($FillArray);
        $FillArray->addColor('blue@0.6');
        $FillArray->addColor('green@0.6');
        $FillArray->addColor('red@0.6');
        $FillArray->addColor('yellow@0.6');
        $FillArray->addColor('orange@0.6');
        $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
        if (count($dataarray) > 4) {
            $AxisX->setFontAngle('vertical');
        }
        $AxisX->setFontSize(8);
        $Graph->done(array('filename' => stats_graph_path('institutions')));
    }
}