Exemplo n.º 1
0
function build_userlist_html(&$data, $page, $admingroups)
{
    if ($data['data']) {
        $userlist = join(',', array_map(create_function('$u', 'return (int)$u[\'id\'];'), $data['data']));
        $userdata = get_users_data($userlist, $page == 'myfriends');
    }
    $smarty = smarty_core();
    $smarty->assign('data', isset($userdata) ? $userdata : null);
    $smarty->assign('page', $page);
    if (isset($data['query'])) {
        $smarty->assign('query', $data['query']);
        $params = '?query=' . $data['query'];
        $resultcounttextsingular = get_string('user', 'group');
        $resultcounttextplural = get_string('users', 'group');
    } elseif (isset($data['filter'])) {
        $smarty->assign('filter', $data['filter']);
        $params = '?filter=' . $data['filter'];
        $resultcounttextsingular = get_string('friend', 'group');
        $resultcounttextplural = get_string('friends', 'group');
    }
    $smarty->assign('admingroups', $admingroups);
    $data['tablerows'] = $smarty->fetch('user/userresults.tpl');
    $pagination = build_pagination(array('id' => 'friendslist_pagination', 'url' => get_config('wwwroot') . 'user/' . $page . '.php' . $params, 'jsonscript' => 'json/friendsearch.php', 'datatable' => 'friendslist', 'count' => $data['count'], 'limit' => $data['limit'], 'offset' => $data['offset'], 'resultcounttextsingular' => $resultcounttextsingular, 'resultcounttextplural' => $resultcounttextplural, 'extradata' => array('page' => $page)));
    $data['pagination'] = $pagination['html'];
    $data['pagination_js'] = $pagination['javascript'];
}
Exemplo n.º 2
0
/**
 * Build the html for a list of staff information
 *
 * @param object $data
 * @param string $page
 * @param string $listtype
 * @param string $institution
 */
function build_stafflist_html(&$data, $page, $listtype, $inst = 'mahara')
{
    global $USER;
    if ($data) {
        $data = get_users_data($data, false);
    }
    $smarty = smarty_core();
    $smarty->assign('page', $page);
    $smarty->assign('listtype', $listtype);
    $smarty->assign('inst', $inst);
    $smarty->assign('USER', $USER);
    if (count($data) > 5) {
        $split = ceil(count($data) / 2);
        $columns = array_chunk($data, $split);
    }
    if (isset($columns) && count($columns) == 2) {
        $smarty->assign('columnleft', $columns[0]);
        $smarty->assign('columnright', $columns[1]);
    } else {
        $smarty->assign('data', isset($data) ? $data : null);
    }
    safe_require('module', 'multirecipientnotification');
    $smarty->assign('mrmoduleactive', PluginModuleMultirecipientnotification::is_active());
    $data['tablerows'] = $smarty->fetch('institution/stafflist.tpl');
}
Exemplo n.º 3
0
/**
 * Build the html for a list of staff information
 *
 * @param object $data
 * @param string $page
 * @param string $listtype
 * @param string $institution
 */
function build_stafflist_html(&$data, $page, $listtype, $inst = 'mahara')
{
    global $USER;
    if ($data) {
        $data = get_users_data($data, false);
    }
    $smarty = smarty_core();
    $smarty->assign('page', $page);
    $smarty->assign('listtype', $listtype);
    $smarty->assign('inst', $inst);
    $smarty->assign('USER', $USER);
    if (count($data) > 5) {
        $split = ceil(count($data) / 2);
        $columns = array_chunk($data, $split);
    }
    if (isset($columns) && count($columns) == 2) {
        $smarty->assign('columnleft', $columns[0]);
        $smarty->assign('columnright', $columns[1]);
    } else {
        $smarty->assign('data', isset($data) ? $data : null);
    }
    $data['tablerows'] = $smarty->fetch('institution/stafflist.tpl');
}
Exemplo n.º 4
0
            SELECT requester AS id, \'1\' AS status FROM {usr_friend_request} WHERE owner = ?
            UNION SELECT usr2 AS id, \'2\' AS status FROM {usr_friend} WHERE usr1 = ?
            UNION SELECT usr1 AS id, \'2\' AS status FROM {usr_friend} WHERE usr2 = ?
        ) f
        JOIN {usr} u ON (f.id = u.id AND u.deleted = 0)
        ORDER BY status, firstname, lastname, u.id
        LIMIT ?
        OFFSET ?', array($userid, $userid, $userid, $limit, $offset));
        if (!$data || !($views = get_views(array_keys($data), null, null))) {
            $views = array();
        }
    }
}
if ($data) {
    $userlist = join(',', $data);
    $data = get_users_data($userlist);
}
$filterform = pieform(array('name' => 'filter', 'renderer' => 'oneline', 'elements' => array('filter' => array('type' => 'select', 'options' => array('all' => get_string('allfriends', 'group'), 'current' => get_string('currentfriends', 'group'), 'pending' => get_string('pendingfriends', 'group')), 'defaultvalue' => $filter), 'submit' => array('type' => 'submit', 'value' => get_string('filter')))));
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'user/myfriends.php?filter=' . $filter, 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('friend', 'group'), 'resultcounttextplural' => get_string('friends', 'group')));
if (!$data) {
    if ($filter == 'pending') {
        $message = get_string('nobodyawaitsfriendapproval', 'group');
    } else {
        $message = get_string('trysearchingforfriends', 'group', '<a href="' . get_config('wwwroot') . 'user/find.php">', '</a>');
    }
}
function filter_submit(Pieform $form, $values)
{
    redirect('/user/myfriends.php?filter=' . $values['filter']);
}
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(friends_control_sideblock())));
Exemplo n.º 5
0
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'groups/findfriends');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
define('TITLE', get_string('findfriends'));
require 'searchlib.php';
safe_require('search', 'internal');
$query = param_variable('query', '');
$offset = param_integer('offset', 0);
$limit = 10;
$data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id')));
if ($data['data']) {
    $userlist = join(',', array_map(create_function('$u', 'return $u[\'id\'];'), $data['data']));
    $data['data'] = get_users_data($userlist);
}
$searchform = pieform(array('name' => 'search', 'renderer' => 'oneline', 'elements' => array('query' => array('type' => 'text', 'defaultvalue' => $query), 'submit' => array('type' => 'submit', 'value' => get_string('search')))));
$pagination = build_pagination(array('url' => get_config('wwwroot') . 'user/find.php?query=' . $query, 'count' => $data['count'], 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('user', 'group'), 'resultcounttextplural' => get_string('users', 'group')));
if ($query && !$data['count']) {
    // Search run, no results
    $message = get_string('nosearchresultsfound', 'group');
}
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(friends_control_sideblock('find'))));
$smarty->assign('heading', TITLE);
$smarty->assign('users', $data['data']);
$smarty->assign('form', $searchform);
$smarty->assign('pagination', $pagination['html']);
if (isset($message)) {
    $smarty->assign('message', $message);
}
Exemplo n.º 6
0
        if ($comments[$i]['id'] == $HTTP_GET_VARS['parent_id']) {
            $crop_rest = true;
        }
    }
    $smarty->assign('comments', $comments);
}
$smarty->assign('cat_id', $HTTP_GET_VARS['cat_id']);
//there is no usefull title_name...
//$smarty->assign('title_name','');
if ($HTTP_GET_VARS['mode'] == "add") {
    $smarty->assign('parent_id', $HTTP_GET_VARS['parent_id']);
    $smarty->assign('title_page', $lang['add_comment']);
}
if ($HTTP_GET_VARS['mode'] == 'edit_comment') {
    if ($userdata['user_level'] == ADMIN) {
        $smarty->assign('users_data', get_users_data('user_id,username'));
    }
    if ($HTTP_GET_VARS['type'] == 'content') {
        $comment = new content_comment();
    } else {
        $comment = new cat_comment();
    }
    $comment->generate_from_id($id);
    $smarty->assign('text', $comment->get_feedback());
    $smarty->assign('user_id', $comment->get_user_id());
    $smarty->assign('poster_name', $comment->get_poster_name());
    $smarty->assign('topic', $comment->get_topic());
    $smarty->assign('title_page', $lang['edit_comment']);
    $smarty->assign('title_name', $comment->get_topic());
    // parent id is just as id here
    $smarty->assign('parent_id', $id);