Example #1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'plans');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     $blockid = param_integer('block', '');
     $this_instance_id = $instance->get('id');
     if (!$blockid or $blockid and $blockid == $this_instance_id) {
         $offset = param_integer('offset', 0);
         $limit = param_integer('limit', 3);
     } else {
         $offset = 0;
         $limit = 3;
         $blockid = $this_instance_id;
     }
     $tasks = ArtefactTypeTask::get_alltasks($blockid, $offset, $limit);
     $template = 'artefact:plans:alltaskrows.tpl';
     if ($exporter) {
         $pagination = false;
     } else {
         $baseurl = $instance->get_view()->get_url();
         $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
         $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'tasktable_' . $blockid, 'jsonscript' => 'artefact/plans/viewtasks.json.php');
     }
     ArtefactTypeTask::render_tasks($tasks, $template, $configdata, $pagination);
     if ($exporter && $tasks['count'] > $tasks['limit']) {
         $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
         $tasks['pagination'] = '<a href="' . $artefacturl . '">' . get_string('alltasks', 'artefact.plans') . '</a>';
     }
     $smarty->assign('tasks', $tasks);
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:alltasks:content.tpl');
 }
Example #2
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $smarty = smarty_core();
     $filter = param_alpha('filter', 'all');
     $offset = param_integer('offset', 0);
     $limit = 1000;
     //get list online friend
     $result_friend_online_id = get_onlinefriends($limit, $offset);
     $str_eselma_online = implode(',', $result_friend_online_id['data']);
     if ($str_eselma_online) {
         $query_result_friend_online = "\n                SELECT *\n                FROM {usr}\n                WHERE id in ({$str_eselma_online})\n            ";
         $result_friend_online = get_records_sql_array($query_result_friend_online);
     }
     //get list offline friend
     $result_friend_offline_id = get_offlinefriends($limit, $offset);
     $str_eselma_offline = implode(',', $result_friend_offline_id['data']);
     if ($str_eselma_offline) {
         $query_result_friend_offline = "\n                SELECT *\n                FROM {usr}\n                WHERE id in ({$str_eselma_offline})\n            ";
         $result_friend_offline = get_records_sql_array($query_result_friend_offline);
     }
     $smarty->assign('eselma_get_online', $result_friend_online);
     $smarty->assign('eselma_get_offline', $result_friend_offline);
     $smarty->assign('lastminutes', floor(get_config('accessidletimeout') / 60));
     $smarty->assign('eselma_count_online', $result_friend_online_id['count']);
     $smarty->assign('eselma_count_offline', $result_friend_offline_id['count']);
     return $smarty->fetch('blocktype:eselmaonoff:content.tpl');
 }
function deletetopic_submit(Pieform $form, $values)
{
    global $SESSION;
    $topicid = param_integer('id');
    update_record('interaction_forum_topic', array('deleted' => 1), array('id' => $topicid));
    $SESSION->add_ok_msg(get_string('deletetopicsuccess', 'interaction.forum'));
    redirect('/interaction/forum/view.php?id=' . $values['forum']);
}
Example #4
0
function sendmessage_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id;
    $user = get_record('usr', 'id', $id);
    send_user_message($user, $values['message'], param_integer('replyto', null));
    $SESSION->add_ok_msg(get_string('messagesent', 'group'));
    redirect(get_config('wwwroot') . $values['goto']);
}
 public static function instance_config_form($instance)
 {
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     return array('text' => array('type' => 'wysiwyg', 'title' => get_string('blockcontent', 'blocktype.textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => isset($configdata['text']) ? $configdata['text'] : ''));
 }
Example #6
0
/**
 * This function is called to cancel the form submission. It redirects the user
 * back to the blog.
 */
function editblog_cancel_submit(Pieform $form)
{
    $id = param_integer('id');
    if ($data = $form->get_element('institution')) {
        redirect('/artefact/blog/view/index.php?id=' . $id . '&institution=' . $data['value']);
    } else {
        redirect('/artefact/blog/view/index.php?id=' . $id);
    }
}
Example #7
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $CFG;
     $configdata = $instance->get('configdata');
     $result = '';
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : self::$default_width;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : self::$default_height;
     if (isset($configdata['videoid'])) {
         $block = $instance->get('id');
         $configuring = $block == param_integer('blockconfig', 0);
         $result = GcrFileLib::getVideoEmbedHtml($configdata['videoid'], $width, $height);
     }
     return $result;
 }
Example #8
0
File: lib.php Project: kienv/mahara
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     if ($editing) {
         $smarty = smarty_core();
         $smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
         $html = $smarty->fetch('blocktype:comment:comment.tpl');
         return $html;
     }
     // Feedback list pagination requires limit/offset params
     $limit = param_integer('limit', 10);
     $offset = param_integer('offset', 0);
     $showcomment = param_integer('showcomment', null);
     // Create the "make feedback private form" now if it's been submitted
     if (param_variable('make_public_submit', null)) {
         pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
     } else {
         if (param_variable('delete_comment_submit_x', null)) {
             pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
         }
     }
     $view = new View($instance->get('view'));
     $submittedgroup = (int) $view->get('submittedgroup');
     if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
         $releaseform = true;
     } else {
         $releaseform = false;
     }
     // If the view has comments turned off, tutors can still leave
     // comments if the view is submitted to their group.
     if (!empty($releaseform) || $view->user_comments_allowed($USER)) {
         $addfeedbackpopup = true;
     }
     safe_require('artefact', 'comment');
     $commentoptions = ArtefactTypeComment::get_comment_options();
     $commentoptions->limit = $limit;
     $commentoptions->offset = $offset;
     $commentoptions->showcomment = $showcomment;
     $commentoptions->view = $instance->get_view();
     $feedback = ArtefactTypeComment::get_comments($commentoptions);
     $smarty = smarty_core();
     $smarty->assign('feedback', $feedback);
     if (isset($addfeedbackpopup)) {
         $smarty->assign('enablecomments', 1);
         $smarty->assign('addfeedbackpopup', $addfeedbackpopup);
     }
     $html = $smarty->fetch('blocktype:comment:comment.tpl');
     return $html;
 }
Example #9
0
 public static function instance_config_form(BlockInstance $instance)
 {
     require_once 'license.php';
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $view = $instance->get_view();
     $text = '';
     if (array_key_exists('text', $configdata)) {
         $text = $configdata['text'];
     }
     $elements = array('text' => array('type' => 'wysiwyg', 'title' => get_string('blockcontent', 'blocktype.text'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)));
     return $elements;
 }
Example #10
0
/**
 * Notify user (if configured), do the masquerading and emit event. Called when
 * no (further) interaction with the admin is needed before the loginas.
 *
 * @param string $why The masquerading reason (if given) or null.
 */
function do_masquerade($why = null)
{
    global $USER, $SESSION;
    $id = param_integer('id');
    $who = display_name($USER, $id);
    $when = format_date(time());
    if (get_config('masqueradingnotified')) {
        $msg = (object) array('subject' => get_string('masqueradenotificationsubject', 'admin'), 'message' => $why === null ? get_string('masqueradenotificationnoreason', 'admin', $who, $when) : get_string('masqueradenotificationreason', 'admin', $who, $when, $why), 'users' => array($id), 'url' => profile_url($USER, false), 'urltext' => $who);
        activity_occurred('maharamessage', $msg);
        $SESSION->add_info_msg(get_string('masqueradenotificationdone', 'admin'));
    }
    $USER->change_identity_to($id);
    // Permissions checking is done in here
    handle_event('loginas', array('who' => $who, 'when' => $when, 'reason' => $why));
    redirect(get_config('wwwroot'));
}
Example #11
0
function denyrequest_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id;
    $loggedinid = $USER->get('id');
    $user = get_record('usr', 'id', $id);
    // friend db record
    $f = new StdClass();
    $f->ctime = db_format_timestamp(time());
    // notification info
    $n = new StdClass();
    $n->url = profile_url($USER, false);
    $n->users = array($user->id);
    $n->fromuser = $USER->get('id');
    $lang = get_user_language($user->id);
    $displayname = display_name($USER, $user);
    $n->urltext = $displayname;
    delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $id);
    $n->subject = get_string_from_language($lang, 'friendrequestrejectedsubject', 'group');
    if (isset($values['reason']) && !empty($values['reason'])) {
        $n->message = get_string_from_language($lang, 'friendrequestrejectedmessagereason', 'group', $displayname) . $values['reason'];
    } else {
        $n->message = get_string_from_language($lang, 'friendrequestrejectedmessage', 'group', $displayname);
    }
    require_once 'activity.php';
    activity_occurred('maharamessage', $n);
    handle_event('removefriendrequest', array('owner' => $loggedinid, 'requester' => $id));
    $SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
    $offset = param_integer('offset', 0);
    switch (param_alpha('returnto', 'myfriends')) {
        case 'find':
            $goto = 'user/find.php';
            break;
        case 'view':
            $goto = profile_url($user, false);
            break;
        default:
            $goto = 'user/myfriends.php';
            break;
    }
    $goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset;
    $goto = get_config('wwwroot') . $goto;
    redirect($goto);
}
function sendmessage_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id;
    $user = get_record('usr', 'id', $id);
    send_user_message($user, $values['message'], param_integer('replyto', null));
    $SESSION->add_ok_msg(get_string('messagesent', 'group'));
    switch (param_alpha('returnto', 'myfriends')) {
        case 'find':
            redirect('/user/find.php');
            break;
        case 'view':
            redirect('/user/view.php?id=' . $id);
            break;
        case 'inbox':
            redirect('/account/activity');
            break;
        default:
            redirect('/user/myfriends.php');
            break;
    }
}
/**
 * Provides a mechanism for choosing one or more artefacts from a list of them.
 *
 * @param Pieform  $form    The form to render the element for
 * @param array    $element The element to render
 * @return string           The HTML for the element
 */
function pieform_element_artefactchooser(Pieform $form, $element)
{
    global $USER, $pagination_js;
    $value = $form->get_value($element);
    $element['offset'] = param_integer('offset', 0);
    list($html, $pagination, $count) = View::build_artefactchooser_data($element, $form->get_property('viewgroup'), $form->get_property('viewinstitution'));
    $smarty = smarty_core();
    $smarty->assign('datatable', $element['name'] . '_data');
    $smarty->assign('artefacts', $html);
    $smarty->assign('pagination', $pagination['html']);
    $formname = $form->get_name();
    $smarty->assign('blockinstance', substr($formname, strpos($formname, '_') + 1));
    // Save the pagination javascript for later, when it is asked for. This is
    // messy, but can't be helped until Pieforms goes to a more OO way of
    // managing stuff.
    $pagination_js = $pagination['javascript'];
    $baseurl = View::make_base_url();
    $smarty->assign('browseurl', $baseurl);
    $smarty->assign('searchurl', $baseurl . '&s=1');
    $smarty->assign('searchable', !empty($element['search']));
    return $smarty->fetch('form/artefactchooser.tpl');
}
Example #14
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $result = '';
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : self::$default_width;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : self::$default_height;
     if (isset($configdata['videoid'])) {
         // IE seems to wait for all elements on the page to load
         // fully before the onload event goes off.  This means the
         // view editor isn't initialised until all videos have
         // finished loading, and an invalid video URL can stop the
         // editor from loading and result in an uneditable view.
         // Therefore, when this block appears on first load of the
         // view editing page, keep the embed code out of the page
         // initially and add it in after the page has loaded.
         $url = hsc(self::make_video_url($configdata['videoid']));
         $embed = '<object width="' . $width . '" height="' . $height . '">';
         $embed .= '<param name="movie" value="' . $url . '"></param>';
         $embed .= '<param name="wmode" value="transparent"></param>';
         $embed .= '<param name="allowscriptaccess" value="never"></param>';
         $embed .= '<embed src="' . $url . '" ';
         $embed .= 'type="application/x-shockwave-flash" wmode="transparent" width="' . $width . '" ';
         $embed .= 'height="' . $height . '" allowscriptaccess="never"></embed></object>';
         $block = $instance->get('id');
         $configuring = $block == param_integer('blockconfig', 0);
         $result .= '<div class="mediaplayer-container center">';
         $result .= '<div id="vid_' . $block . '" class="mediaplayer" style="width: {$width}px; height: {$height}px; margin: 0 auto;">';
         if (!$editing || $configuring) {
             $result .= $embed;
         }
         $result .= '</div></div>';
         if ($editing && !$configuring) {
             $result .= '<script>';
             $result .= 'addLoadEvent(function() {$(\'vid_' . $block . "').innerHTML = " . json_encode($embed) . ';});';
             $result .= '</script>';
         }
     }
     return $result;
 }
Example #15
0
/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'groups');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
require_once 'group.php';
$groupid = param_integer('id');
$userid = param_integer('user');
define('GROUP', $groupid);
$group = group_current_group();
$user = get_record('usr', 'id', $userid, 'deleted', 0);
if (!$user) {
    throw new UserNotFoundException(get_string('usernotfound', 'group', $userid));
}
$role = group_user_access($groupid);
if ($role != 'admin' && !group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
    if (!$group->invitefriends || !is_friend($user->id, $USER->get('id'))) {
        throw new AccessDeniedException(get_string('cannotinvitetogroup', 'group'));
    }
}
if (record_exists('group_member', 'group', $groupid, 'member', $userid) || record_exists('group_member_invite', 'group', $groupid, 'member', $userid)) {
    throw new UserException(get_string('useralreadyinvitedtogroup', 'group'));
}
Example #16
0
 * @package    mahara
 * @subpackage artefact-blog
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
define('PUBLIC', 1);
require dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php';
safe_require('artefact', 'blog');
json_headers();
$id = param_integer('id');
$limit = param_integer('limit', ArtefactTypeBlog::pagination);
$offset = param_integer('offset', 0);
$options = json_decode(param_variable('options'));
$viewid = isset($options->viewid) ? $options->viewid : null;
if ($viewid) {
    if (!can_view_view($viewid)) {
        throw new AccessDeniedException();
    }
} else {
    if (!$USER->is_logged_in()) {
        throw new AccessDeniedException();
    }
    if (!$viewid && get_field('artefact', 'owner', 'id', $id) != $USER->get('id')) {
        throw new AccessDeniedException();
    }
}
list($count, $data) = ArtefactTypeBlogPost::render_posts(FORMAT_ARTEFACT_RENDERFULL, $options, $id, $limit, $offset);
Example #17
0
            $artefact = artefact_instance_from_type($type);
        } catch (Exception $e) {
            $artefact = new $classname(0, array('owner' => $USER->get('id')));
            $artefact->commit();
        }
    } else {
        throw new ArtefactNotFoundException(get_string('cannotfindcreateartefact', 'artefact.resume'));
    }
}
if ($artefact->get('owner') != $USER->get('id')) {
    throw new AccessDeniedException(get_string('notartefactowner', 'error'));
}
$folder = param_integer('folder', 0);
$browse = (int) param_variable('browse', 0);
$highlight = null;
if ($file = param_integer('file', 0)) {
    $highlight = array($file);
}
$form = pieform(array('name' => 'editgoalsandskills', 'method' => 'post', 'jsform' => true, 'newiframeonsubmit' => true, 'jssuccesscallback' => 'editgoalsandskills_callback', 'jserrorcallback' => 'editgoalsandskills_callback', 'plugintype' => 'artefact', 'pluginname' => 'resume', 'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'), 'elements' => array('description' => array('type' => 'wysiwyg', 'title' => get_string('description', 'artefact.resume'), 'rows' => 20, 'cols' => 65, 'defaultvalue' => $artefact->get('description'), 'rules' => array('maxlength' => 65536)), 'filebrowser' => array('type' => 'filebrowser', 'title' => get_string('attachments', 'artefact.blog'), 'folder' => $folder, 'highlight' => $highlight, 'browse' => $browse, 'page' => get_config('wwwroot') . 'artefact/resume/editgoalsandskills.php?id=' . $artefact->get('id') . '&browse=1', 'browsehelp' => 'browsemyfiles', 'config' => array('upload' => true, 'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'), 'resizeonuploaduseroption' => get_config_plugin('artefact', 'file', 'resizeonuploaduseroption'), 'resizeonuploaduserdefault' => $USER->get_account_preference('resizeonuploaduserdefault'), 'createfolder' => false, 'edit' => false, 'select' => true), 'defaultvalue' => $artefact->attachment_id_list(), 'selectlistcallback' => 'artefact_get_records_by_id', 'selectcallback' => 'add_resume_attachment', 'unselectcallback' => 'delete_resume_attachment'), 'artefacttype' => array('type' => 'hidden', 'value' => $artefact->get('artefacttype')), 'submitform' => array('type' => 'submitcancel', 'class' => 'btn-success', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/resume/goalsandskills.php'))));
/*
 * Javascript specific to this page.  Creates the list of files
 * attached to the resume goals or skills.
 */
$wwwroot = get_config('wwwroot');
$noimagesmessage = json_encode(get_string('noimageshavebeenattachedtothispost', 'artefact.blog'));
$javascript = <<<EOF
function editgoalsandskills_callback(form, data) {
    editgoalsandskills_filebrowser.callback(form, data);
};
EOF;
$smarty = smarty(array(), array(), array(), array('tinymceconfig' => '
/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('PUBLIC', 1);
define('INTERNAL', 1);
define('MENUITEM', 'groups/members');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'group.php';
require_once 'pieforms/pieform.php';
define('GROUP', param_integer('id'));
$group = group_current_group();
if (!is_logged_in() && !$group->public) {
    throw new AccessDeniedException();
}
$role = group_user_access($group->id);
if ($role != 'admin') {
    throw new AccessDeniedException();
}
if ($group->jointype != 'controlled') {
    redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP);
}
define('TITLE', $group->name . ' - ' . get_string('addmembers', 'group'));
$form = pieform(array('name' => 'addmembers', 'elements' => array('users' => array('type' => 'userlist', 'lefttitle' => get_string('potentialmembers', 'group'), 'righttitle' => get_string('userstobeadded', 'group'), 'searchscript' => 'group/membersearchresults.json.php', 'defaultvalue' => array(), 'searchparams' => array('id' => GROUP, 'limit' => 100, 'html' => 0, 'membershiptype' => 'nonmember')), 'submit' => array('type' => 'submit', 'value' => get_string('submit')))));
$smarty = smarty();
$smarty->assign('subheading', get_string('addmembers', 'group'));
Example #19
0
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'groups/forums');
define('SECTION_PLUGINTYPE', 'interaction');
define('SECTION_PLUGINNAME', 'forum');
define('SECTION_PAGE', 'deletepost');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('interaction', 'forum');
require_once 'group.php';
require_once get_config('docroot') . 'interaction/lib.php';
require_once 'pieforms/pieform.php';
$postid = param_integer('id');
$post = get_record_sql('SELECT p.subject, p.body, p.topic, p.parent, p.poster, ' . db_format_tsfield('p.ctime', 'ctime') . ', m.user AS moderator, t.forum, p2.subject AS topicsubject, f.group, f.title AS forumtitle, g.name AS groupname, COUNT(p3.id)
    FROM {interaction_forum_post} p
    INNER JOIN {interaction_forum_topic} t ON (p.topic = t.id AND t.deleted != 1)
    INNER JOIN {interaction_forum_post} p2 ON (p2.topic = t.id AND p2.parent IS NULL)
    INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1)
    INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?)
    LEFT JOIN (
        SELECT m.forum, m.user
        FROM {interaction_forum_moderator} m
        INNER JOIN {usr} u ON (m.user = u.id AND u.deleted = 0)
    ) m ON (m.forum = f.id AND m.user = p.poster)
    INNER JOIN {interaction_forum_post} p3 ON (p.poster = p3.poster AND p3.deleted != 1)
    INNER JOIN {interaction_forum_topic} t2 ON (t2.deleted != 1 AND p3.topic = t2.id)
    INNER JOIN {interaction_instance} f2 ON (t2.forum = f2.id AND f2.deleted != 1 AND f2.group = f.group)
    WHERE p.id = ?
Example #20
0
 *
 * @package    mahara
 * @subpackage module-multirecipientnotification
 * @author     David Ballhausen, Tobias Zeuch
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once dirname(__FILE__) . '/lib/multirecipientnotification.php';
require_once get_config('docroot') . '/lib/searchlib.php';
global $USER;
$request = param_variable('q');
$page = param_integer('page');
if ($page < 1) {
    $page = 1;
}
$usersperpage = 10;
$more = true;
$tmpuser = array();
while ($more && count($tmpuser) < $usersperpage) {
    $users = search_user($request, $usersperpage, $usersperpage * ($page - 1));
    $more = $users['count'] > $usersperpage * $page;
    if (!$users['data']) {
        $users['data'] = array();
    }
    foreach ($users['data'] as $user) {
        if (count($tmpuser) >= $usersperpage) {
            $more = true;
Example #21
0
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage artefact-cpds
 * @author     James Kerrigan
 * @author     Geoffrey Rowland
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'content/cpds');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'cpds');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'cpds');
$id = param_integer('id', 0);
if ($id) {
    $cpd = new ArtefactTypeCPD($id);
    if (!$USER->can_edit_artefact($cpd)) {
        throw new AccessDeniedException(get_string('accessdenied', 'error'));
    }
    define('TITLE', get_string('newactivity', 'artefact.cpds'));
    $form = ArtefactTypeActivity::get_form($id);
} else {
    define('TITLE', get_string('newcpd', 'artefact.cpds'));
    $form = ArtefactTypeCPD::get_form();
}
$smarty =& smarty();
$smarty->assign_by_ref('form', $form);
$smarty->assign_by_ref('PAGEHEADING', hsc(TITLE));
$smarty->display('artefact:cpds:new.tpl');
Example #22
0
/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
define('INSTITUTIONALADMIN', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'pieforms/pieform/elements/bytes.php';
$instid = param_integer('instid');
$disabled = param_boolean('disabled', false);
$definst = get_field('auth_instance', 'id', 'institution', 'mahara');
$record = get_record_sql('SELECT i.name, i.defaultquota FROM {institution} i JOIN {auth_instance} ai ON (i.name = ai.institution) WHERE ai.id = ?', array($instid));
if (!$USER->get('admin') && !$USER->is_institutional_admin($record->name)) {
    json_reply(true, 'You are not an administrator for institution ' . $record->name);
    return;
}
if ($definst && $instid == $definst) {
    $quota = get_config_plugin('artefact', 'file', 'defaultquota');
} else {
    $quota = $record->defaultquota;
    if (!$quota) {
        $quota = get_config_plugin('artefact', 'file', 'defaultquota');
    }
}
Example #23
0
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
/**
 * returns shared views in a given group id
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('blocktype', 'groupviews');
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
require_once get_config('libroot') . 'pieforms/pieform.php';
$offset = param_integer('offset', 0);
$groupid = param_integer('group');
$editing = param_boolean('editing', false);
$group_homepage_view = group_get_homepage_view($groupid);
$bi = group_get_homepage_view_groupview_block($groupid);
if (!can_view_view($group_homepage_view)) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$configdata = $bi->get('configdata');
if (!isset($configdata['showsharedviews'])) {
    $configdata['showsharedviews'] = 1;
}
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
// Find out what order to sort them by (default is titles)
if (!isset($configdata['sortsharedviewsby']) || $configdata['sortsharedviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) {
    $sortsharedviewsby = 'v.title';
Example #24
0
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'groups');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
require 'group.php';
$groupid = param_integer('id');
$returnto = param_alpha('returnto', 'mygroups');
define('GROUP', $groupid);
$group = group_current_group();
define('TITLE', $group->name);
if (!group_user_access($group->id)) {
    throw new AccessDeniedException(get_string('notamember', 'group'));
}
if (!group_user_can_leave($group)) {
    throw new AccessDeniedException(get_string('cantleavegroup', 'group'));
}
$goto = get_config('wwwroot') . 'group/' . $returnto . '.php' . ($returnto == 'view' ? '?id=' . $groupid : '');
$views = count_records_sql('SELECT COUNT(*)
    FROM {view} v
    INNER JOIN {view_access_group} a
    ON a.group = ?
Example #25
0
/**
 * This function handles filebrowser actions, such as uploading files, deleting files, creating folders, etc.
 * It piggybacks on the surrounding pieform but bypasses the normal Pieforms validation process.
 *
 * @param Pieform $form
 * @param array $element
 * @return mixed
 */
function pieform_element_filebrowser_doupdate(Pieform $form, $element)
{
    require_once 'license.php';
    $result = null;
    $prefix = $form->get_name() . '_' . $element['name'];
    // Since this is executed before normal pieforms validation, we'll redundantly call the validation here
    try {
        $sesskey = param_variable('sesskey', null);
        pieform_validate($form, array('sesskey' => $sesskey));
    } catch (Exception $e) {
        return array('error' => true, 'message' => $e->getMessage());
    }
    $delete = param_variable($prefix . '_delete', null);
    if (is_array($delete)) {
        $keys = array_keys($delete);
        return pieform_element_filebrowser_delete($form, $element, (int) $keys[0]);
    }
    $resizeonuploaduserenable = param_variable($prefix . '_resizeonuploaduserenable', null);
    if (!empty($resizeonuploaduserenable)) {
        $resizeimage = 1;
    } else {
        $resizeimage = 0;
    }
    $update = param_variable($prefix . '_update', null);
    if (is_array($update)) {
        $keys = array_keys($update);
        $artefactid = (int) $keys[0];
        $edit_title = param_variable($prefix . '_edit_title');
        $namelength = strlen($edit_title);
        if (!$namelength) {
            return array('edit' => $artefactid, 'error' => true, 'message' => get_string('filenamefieldisrequired1', 'artefact.file'));
        } else {
            if ($namelength > 1024) {
                return array('edit' => $artefactid, 'error' => true, 'message' => get_string('nametoolong', 'artefact.file'));
            }
        }
        $data = array('artefact' => $artefactid, 'title' => $edit_title, 'description' => param_variable($prefix . '_edit_description'), 'tags' => param_variable($prefix . '_edit_tags'), 'folder' => $element['folder'], 'allowcomments' => param_boolean($prefix . '_edit_allowcomments'));
        if (get_config('licensemetadata')) {
            $data = array_merge($data, array('license' => license_coalesce(null, param_variable($prefix . '_edit_license'), param_variable($prefix . '_edit_license_other', null)), 'licensor' => param_variable($prefix . '_edit_licensor'), 'licensorurl' => param_variable($prefix . '_edit_licensorurl')));
        }
        if ($form->get_property('group')) {
            $data['permissions'] = array('admin' => (object) array('view' => true, 'edit' => true, 'republish' => true));
            foreach ($_POST as $k => $v) {
                if (preg_match('/^' . $prefix . '_permission:([a-z]+):([a-z]+)$/', $k, $m)) {
                    if (!isset($data['permissions'][$m[1]])) {
                        $data['permissions'][$m[1]] = new stdClass();
                    }
                    $data['permissions'][$m[1]]->{$m[2]} = (bool) $v;
                }
            }
        }
        return pieform_element_filebrowser_update($form, $element, $data);
    }
    $move = param_variable($prefix . '_move', null);
    if (!empty($move)) {
        return pieform_element_filebrowser_move($form, $element, array('artefact' => (int) $move, 'newparent' => param_integer($prefix . '_moveto'), 'folder' => $element['folder']));
    }
    $createfolder = param_variable($prefix . '_createfolder', null);
    if (!empty($createfolder)) {
        $createfolder_name = param_variable($prefix . '_createfolder_name');
        $namelength = strlen($createfolder_name);
        if (!$namelength) {
            return array('error' => true, 'message' => get_string('foldernamerequired', 'artefact.file'));
        } else {
            if ($namelength > 1024) {
                return array('error' => true, 'message' => get_string('nametoolong', 'artefact.file'));
            }
        }
        return pieform_element_filebrowser_createfolder($form, $element, array('title' => $createfolder_name, 'folder' => $element['folder']));
    }
    // {$prefix}_upload is set in all browsers except safari when javascript is
    // on (and set in all browsers when it's not)
    $upload = param_variable($prefix . '_upload', null);
    if (!empty($upload)) {
        if (empty($_FILES['userfile']['name'])) {
            return array('error' => true, 'message' => get_string('filenamefieldisrequired', 'artefact.file'), 'browse' => 1);
        } else {
            if (is_array($_FILES['userfile']['name'])) {
                foreach ($_FILES['userfile']['name'] as $filename) {
                    if (empty($filename)) {
                        // TODO, how to specify which file is in error...
                        return array('error' => true, 'message' => get_string('filenamefieldisrequired', 'artefact.file'), 'browse' => 1);
                    }
                }
            }
        }
    }
    if (!empty($_FILES['userfile']['name'])) {
        if (!is_array($_FILES['userfile']['name'])) {
            if (!empty($_POST['_userfile']) && is_array($_POST['_userfile'])) {
                // renaming file for drag and drop
                $_FILES['userfile']['name'] = $_POST['_userfile']['name'];
                $_FILES['userfile']['type'] = $_POST['_userfile']['type'];
            }
            if (strlen($_FILES['userfile']['name']) > 1024) {
                return array('error' => true, 'message' => get_string('nametoolong', 'artefact.file'));
            } else {
                if ($element['config']['uploadagreement'] && !param_boolean($prefix . '_notice', false)) {
                    return array('error' => true, 'message' => get_string('youmustagreetothecopyrightnotice', 'artefact.file'), 'browse' => 1);
                }
            }
            $data = array('userfile' => $_FILES['userfile'], 'uploadnumber' => param_integer($prefix . '_uploadnumber'), 'uploadfolder' => $element['folder'] ? $element['folder'] : null, 'uploadfoldername' => param_variable($prefix . '_foldername'), 'resizeonuploaduserenable' => $resizeimage);
            if (get_config('licensemetadata') && param_variable('dropzone')) {
                $data = array_merge($data, array('license' => license_coalesce(null, param_variable($prefix . '_license'), param_variable($prefix . '_license_other', null)), 'licensor' => param_variable($prefix . '_licensor'), 'licensorurl' => param_variable($prefix . '_licensorurl')));
            } else {
                if (get_config('licensemetadata')) {
                    $data = array_merge($data, array('license' => license_coalesce(null, param_variable($prefix . '_edit_license'), param_variable($prefix . '_edit_license_other', null)), 'licensor' => param_variable($prefix . '_edit_licensor'), 'licensorurl' => param_variable($prefix . '_edit_licensorurl')));
                }
            }
            $result = pieform_element_filebrowser_upload($form, $element, $data);
            // If it's a non-js upload, automatically select the newly uploaded file.
            $result['browse'] = 1;
            if (!$form->submitted_by_js() && !$result['error'] && !empty($element['config']['select'])) {
                if (isset($element['selectcallback']) && is_callable($element['selectcallback'])) {
                    $element['selectcallback']($result['highlight']);
                } else {
                    $result['select'] = $result['highlight'];
                }
            }
            return $result;
        } else {
            if (!empty($_FILES['userfile']['name'][0])) {
                if ($element['config']['uploadagreement'] && !param_boolean($prefix . '_notice', false)) {
                    return array('error' => true, 'message' => get_string('youmustagreetothecopyrightnotice', 'artefact.file'), 'browse' => 1);
                }
                $result = array('multiuploads' => array());
                $size = sizeof($_FILES['userfile']['name']);
                for ($i = 0; $i < $size; $i++) {
                    if (strlen($_FILES['userfile']['name'][$i]) > 1024) {
                        return array('error' => true, 'message' => get_string('nametoolong', 'artefact.file'));
                    }
                    $data = array('userfile' => $_FILES['userfile'], 'userfileindex' => $i, 'uploadnumber' => param_integer($prefix . '_uploadnumber') - ($size - $i - 1), 'uploadfolder' => $element['folder'] ? $element['folder'] : null, 'uploadfoldername' => param_variable($prefix . '_foldername'), 'resizeonuploaduserenable' => $resizeimage);
                    if (get_config('licensemetadata')) {
                        $data = array_merge($data, array('license' => license_coalesce(null, param_variable($prefix . '_license'), param_variable($prefix . '_license_other', null)), 'licensor' => param_variable($prefix . '_licensor'), 'licensorurl' => param_variable($prefix . '_licensorurl')));
                    }
                    $result['multiuploads'][$i] = pieform_element_filebrowser_upload($form, $element, $data);
                    // TODO, what to do here...
                    // If it's a non-js upload, automatically select the newly uploaded file.
                    $result['multiuploads'][$i]['browse'] = 1;
                    if (!$form->submitted_by_js() && !$result['multiuploads'][$i]['error'] && !empty($element['config']['select'])) {
                        if (isset($element['selectcallback']) && is_callable($element['selectcallback'])) {
                            $element['selectcallback']($result['multiuploads'][$i]['highlight']);
                        } else {
                            $result['multiuploads'][$i]['select'] = $result['multiuploads'][$i]['highlight'];
                        }
                    }
                    $result['multiuploads'][$i]['folder'] = $element['folder'];
                }
                return $result;
            }
        }
    }
    if (!$form->submitted_by_js()) {
        $select = param_variable($prefix . '_select', null);
        if (is_array($select)) {
            $keys = array_keys($select);
            $add = (int) $keys[0];
            if (isset($element['selectcallback']) && is_callable($element['selectcallback'])) {
                try {
                    $element['selectcallback']($add);
                } catch (ArtefactNotFoundException $e) {
                    $result = array('error' => true, 'message' => get_string('selectingfailed', 'artefact.file'));
                    return $result;
                }
            } else {
                $result['select'] = $add;
            }
            $result['message'] = get_string('fileadded', 'artefact.file');
            $result['browse'] = 1;
            return $result;
        }
        $unselect = param_variable($prefix . '_unselect', null);
        if (is_array($unselect)) {
            $keys = array_keys($unselect);
            $del = (int) $keys[0];
            if (isset($element['unselectcallback']) && is_callable($element['unselectcallback'])) {
                try {
                    $element['unselectcallback']($del);
                } catch (ArtefactNotFoundException $e) {
                    $result = array('error' => true, 'message' => get_string('removingfailed', 'artefact.file'));
                    return $result;
                }
            } else {
                $result['unselect'] = $del;
            }
            $result['message'] = get_string('fileremoved', 'artefact.file');
            return $result;
        }
        $edit = param_variable($prefix . '_edit', null);
        if (is_array($edit)) {
            $keys = array_keys($edit);
            $result['edit'] = (int) $keys[0];
            return $result;
        }
        if (param_variable('browse', 0) && !param_variable($prefix . '_cancelbrowse', 0)) {
            $result['browse'] = 1;
            return $result;
        }
    }
    $changeowner = param_variable($prefix . '_changeowner', null);
    if (!empty($changeowner)) {
        $result = pieform_element_filebrowser_changeowner($form, $element);
        $result['browse'] = 1;
        return $result;
    }
    $newfolder = param_variable($prefix . '_changefolder', null);
    if (!is_null($newfolder) && is_numeric($newfolder)) {
        $result = pieform_element_filebrowser_changefolder($form, $element, $newfolder);
        $result['browse'] = 1;
        $result['folder'] = $newfolder;
        return $result;
    }
}
Example #26
0
require_once 'collection.php';
$new = param_boolean('new', 0);
$copy = param_boolean('copy', 0);
if ($new) {
    // if creating a new collection
    $owner = null;
    $groupid = param_integer('group', 0);
    $institutionname = param_alphanum('institution', false);
    if (empty($groupid) && empty($institutionname)) {
        $owner = $USER->get('id');
    }
    $collection = new Collection(null, array('owner' => $owner, 'group' => $groupid, 'institution' => $institutionname));
    define('SUBTITLE', get_string('edittitleanddesc', 'collection'));
} else {
    // if editing an existing or copied collection
    $id = param_integer('id');
    $collection = new Collection($id);
    $owner = $collection->get('owner');
    $groupid = $collection->get('group');
    $institutionname = $collection->get('institution');
    define('SUBTITLE', $collection->get('name') . ': ' . get_string('edittitleanddesc', 'collection'));
}
if ($collection->is_submitted()) {
    $submitinfo = $collection->submitted_to();
    throw new AccessDeniedException(get_string('canteditsubmitted', 'collection', $submitinfo->name));
}
$urlparams = array();
if (!empty($groupid)) {
    define('MENUITEM', 'groups/collections');
    define('GROUP', $groupid);
    $group = group_current_group();
Example #27
0
$TRANSPORTER = null;
$IMPORTER = null;
// Check if leap import plugin is enabled
$importplugins = plugins_installed('import');
if (!$importplugins) {
    die_info(get_string('noimportpluginsenabled', 'import'));
}
if (!array_key_exists('leap', $importplugins)) {
    die_info(get_string('noleapimportpluginsenabled', 'import'));
}
// Check if unzip is available
// This is required for extracting leap2a zip file
if (!is_executable(get_config('pathtounzip'))) {
    die_info(get_string('unzipnotinstalled', 'admin'));
}
$action = param_integer('action', PRINTUPLOADFORM_ACT);
switch ($action) {
    case PRINTUPLOADFORM_ACT:
    default:
        print_upload_form();
        break;
    case PRINTIMPORTITEMSFORM_ACT:
        print_import_items_form();
        break;
    case DOIMPORT_ACT:
        db_begin();
        if (isset($_POST['import_submit'])) {
            save_decisions();
            // Do import and print the results
            do_import();
        } else {
Example #28
0
 * @package    mahara
 * @subpackage core
 * @author     Stacey Walker
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'actionregistration');
require_once 'pieforms/pieform.php';
require_once 'institution.php';
$id = param_integer('r');
$action = param_alpha('action');
if (!is_logged_in()) {
    throw new AccessDeniedException();
}
if (!($registration = get_record_select('usr_registration', '"id" = ? AND pending = 1', array($id)))) {
    die_info(get_string('registrationnosuchid', 'auth.internal'));
}
if (!($inst = get_record('institution', 'name', $registration->institution))) {
    die_info(get_string('nosuchinstitution', 'admin'));
}
if ($action == 'approve') {
    $message = get_string('approveregistrationmessage', 'admin', $inst->displayname);
    $submitbtn = get_string('approve', 'admin');
    define('TITLE', get_string('approveregistrationfor2', 'admin', $registration->firstname, $registration->lastname, $registration->email));
    if ($registration->institution != 'mahara') {
Example #29
0
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(__FILE__)) . '/init.php';
json_headers();
$data = new StdClass();
$data->view = param_integer('view');
$data->artefact = param_integer('artefact', null);
$data->message = param_variable('message');
$data->public = param_boolean('public') ? 1 : 0;
$data->attachment = param_integer('attachment', null);
$data->author = $USER->get('id');
$data->ctime = db_format_timestamp(time());
if ($data->artefact) {
    $table = 'artefact_feedback';
} else {
    $table = 'view_feedback';
}
if (!insert_record($table, $data, 'id', true)) {
    json_reply('local', get_string('addfeedbackfailed', 'view'));
}
require_once 'activity.php';
activity_occurred('feedback', $data);
json_reply(false, get_string('feedbacksubmitted', 'view'));
/**
 * used by user/myfriends.php and user/find.php to get the data (including pieforms etc) for display
 * @param $userlist the ids separated by commas
 * @return array containing the users in the order from $userlist
 */
function get_users_data($userlist, $getviews = true)
{
    global $USER;
    // $userlist is only used by build_userlist_html() in this file and is sanitised there
    $sql = 'SELECT u.id, u.username, u.preferredname, u.firstname, u.lastname, u.admin, u.staff, u.deleted,
                u.profileicon, u.email,
                0 AS pending, ap.value AS hidenamepref,
                COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'messages\'), \'allow\') AS messages,
                COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'friendscontrol\'), \'auth\') AS friendscontrol,
                (SELECT 1 FROM {usr_friend} WHERE ((usr1 = ? AND usr2 = u.id) OR (usr2 = ? AND usr1 = u.id))) AS friend,
                (SELECT 1 FROM {usr_friend_request} fr WHERE fr.requester = ? AND fr.owner = u.id) AS requestedfriendship,
                (SELECT title FROM {artefact} WHERE artefacttype = \'introduction\' AND owner = u.id) AS introduction,
                NULL AS message
                FROM {usr} u
                LEFT JOIN {usr_account_preference} ap ON (u.id = ap.usr AND ap.field = \'hiderealname\')
                WHERE u.id IN (' . $userlist . ')
            UNION
            SELECT u.id, u.username, u.preferredname, u.firstname, u.lastname, u.admin, u.staff, u.deleted,
                u.profileicon, u.email,
                1 AS pending, ap.value AS hidenamepref,
                COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'messages\'), \'allow\') AS messages,
                NULL AS friendscontrol,
                NULL AS friend,
                NULL AS requestedfriendship,
                (SELECT title FROM {artefact} WHERE artefacttype = \'introduction\' AND owner = u.id) AS introduction,
                message
                FROM {usr} u
                LEFT JOIN {usr_account_preference} ap ON (u.id = ap.usr AND ap.field = \'hiderealname\')
                JOIN {usr_friend_request} fr ON fr.requester = u.id
                WHERE fr.owner = ?
                AND u.id IN (' . $userlist . ')';
    $userid = $USER->get('id');
    $data = get_records_sql_assoc($sql, array($userid, $userid, $userid, $userid));
    $allowhidename = get_config('userscanhiderealnames');
    $showusername = get_config('searchusernames');
    foreach ($data as &$record) {
        $record->messages = $record->messages == 'allow' || $record->friend && $record->messages == 'friends' || $USER->get('admin') ? 1 : 0;
        $record->institutions = get_institution_string_for_user($record->id);
        $record->display_name = display_name($record, null, false, !$allowhidename || !$record->hidenamepref, $showusername);
    }
    if (!$data || !$getviews || !($views = get_views(array_keys($data), null, null))) {
        $views = array();
    }
    if ($getviews) {
        $viewcount = array_map('count', $views);
        // since php is so special and inconsistent, we can't use array_map for this because it breaks the top level indexes.
        $cleanviews = array();
        foreach ($views as $userindex => $viewarray) {
            $cleanviews[$userindex] = array_slice($viewarray, 0, 5);
            // Don't reveal any more about the view than necessary
            foreach ($cleanviews as $userviews) {
                foreach ($userviews as &$view) {
                    foreach (array_keys(get_object_vars($view)) as $key) {
                        if ($key != 'id' && $key != 'title') {
                            unset($view->{$key});
                        }
                    }
                }
            }
        }
    }
    foreach ($data as $friend) {
        if ($getviews && isset($cleanviews[$friend->id])) {
            $friend->views = $cleanviews[$friend->id];
        }
        if ($friend->pending) {
            $friend->accept = pieform(array('name' => 'acceptfriend' . $friend->id, 'successcallback' => 'acceptfriend_submit', 'renderer' => 'div', 'autofocus' => 'false', 'elements' => array('submit' => array('type' => 'submit', 'value' => get_string('approverequest', 'group')), 'id' => array('type' => 'hidden', 'value' => $friend->id))));
        }
        if (!$friend->friend && !$friend->pending && !$friend->requestedfriendship && $friend->friendscontrol == 'auto') {
            $friend->makefriend = pieform(array('name' => 'addfriend' . $friend->id, 'successcallback' => 'addfriend_submit', 'renderer' => 'div', 'autofocus' => 'false', 'elements' => array('submit' => array('type' => 'submit', 'value' => get_string('addtofriendslist', 'group')), 'id' => array('type' => 'hidden', 'value' => $friend->id), 'query' => array('type' => 'hidden', 'value' => param_variable('query', '')), 'offset' => array('type' => 'hidden', 'value' => param_integer('offset', 0)))));
        }
    }
    $order = explode(',', $userlist);
    $ordereddata = array();
    foreach ($order as $id) {
        if (isset($data[$id])) {
            $ordereddata[] = $data[$id];
        }
    }
    return $ordereddata;
}