Пример #1
0
function group_get_groupinfo_data($group)
{
    safe_require('artefact', 'file');
    safe_require('interaction', 'forum');
    $group->admins = group_get_admins(array($group->id));
    $group->settingsdescription = group_display_settings($group);
    if (get_config('allowgroupcategories')) {
        $group->categorytitle = $group->category ? get_field('group_category', 'title', 'id', $group->category) : '';
    }
    if (group_can_list_members($group, group_user_access($group->id))) {
        $group->membercount = count_records('group_member', 'group', $group->id);
    }
    $group->viewcount = count_records('view', 'group', $group->id);
    $group->filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
    $group->forumcounts = PluginInteractionForum::count_group_forums($group->id);
    $group->topiccounts = PluginInteractionForum::count_group_topics($group->id);
    $group->postcounts = PluginInteractionForum::count_group_posts($group->id);
    return $group;
}
Пример #2
0
 protected static function get_data($groupid)
 {
     global $USER;
     if (!defined('GROUP')) {
         define('GROUP', $groupid);
     }
     // get the currently requested group
     $group = group_current_group();
     $group->ctime = strftime(get_string('strftimedate'), $group->ctime);
     // if the user isn't logged in an the group isn't public don't show anything
     if (!is_logged_in() && !$group->public) {
         throw new AccessDeniedException();
     }
     // find the group administrators
     $group->admins = get_column_sql("SELECT \"member\"\n            FROM {group_member}\n            WHERE \"group\" = ?\n            AND \"role\" = 'admin'", array($group->id));
     $role = group_user_access($group->id);
     $group->role = $role;
     // logged in user can do stuff
     if (is_logged_in()) {
         $afterjoin = param_variable('next', 'view');
         if ($role) {
             if ($role == 'admin') {
                 $group->membershiptype = 'admin';
                 $group->requests = count_records('group_member_request', 'group', $group->id);
             } else {
                 $group->membershiptype = 'member';
             }
             $group->canleave = group_user_can_leave($group->id);
         } else {
             if ($group->jointype == 'invite' and $invite = get_record('group_member_invite', 'group', $group->id, 'member', $USER->get('id'))) {
                 $group->membershiptype = 'invite';
                 $group->invite = group_get_accept_form('invite', $group->id, $afterjoin);
             } else {
                 if ($group->jointype == 'request' and $request = get_record('group_member_request', 'group', $group->id, 'member', $USER->get('id'))) {
                     $group->membershiptype = 'request';
                 } else {
                     if ($group->jointype == 'open') {
                         $group->groupjoin = group_get_join_form('joingroup', $group->id, $afterjoin);
                     }
                 }
             }
         }
     }
     $group->settingsdescription = group_display_settings($group);
     if (get_config('allowgroupcategories')) {
         $group->categorytitle = $group->category ? get_field('group_category', 'title', 'id', $group->category) : '';
     }
     $filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
     return array('group' => $group, 'filecounts' => $filecounts);
 }
Пример #3
0
    } else {
        if ($group->jointype == 'invite' and $invite = get_record('group_member_invite', 'group', $group->id, 'member', $USER->get('id'))) {
            $group->membershiptype = 'invite';
            $group->invite = group_get_accept_form('invite', $group->id, $afterjoin);
        } else {
            if ($group->jointype == 'request' and $request = get_record('group_member_request', 'group', $group->id, 'member', $USER->get('id'))) {
                $group->membershiptype = 'request';
            } else {
                if ($group->jointype == 'open') {
                    $group->groupjoin = group_get_join_form('joingroup', $group->id, $afterjoin);
                }
            }
        }
    }
}
$filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
// Latest forums posts
// NOTE: it would be nicer if there was some generic way to get information
// from any installed interaction. But the only interaction plugin is forum,
// and group info pages might be replaced with views anyway...
$foruminfo = null;
if ($role || $group->public) {
    $foruminfo = get_records_sql_array('
        SELECT
            p.id, p.subject, p.body, p.poster, p.topic, t.forum, pt.subject AS topicname
        FROM
            {interaction_forum_post} p
            INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic)
            INNER JOIN {interaction_instance} i ON (i.id = t.forum)
            INNER JOIN {interaction_forum_post} pt ON (pt.topic = p.topic AND pt.parent IS NULL)
        WHERE