protected static function get_data($groupid, $editing = false) { global $USER; if (!defined('GROUP')) { define('GROUP', $groupid); } // get the currently requested group $group = group_current_group(); $role = group_user_access($group->id); $bi = group_get_homepage_view_groupview_block($group->id); $configdata = $bi->get('configdata'); if (!isset($configdata['sortsubmittedby']) || $configdata['sortsubmittedby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) { $sortsubmittedby = 'c.name, v.title'; } else { $sortsubmittedby = 'c.submittedtime DESC, v.submittedtime DESC'; } if ($role) { $limit = isset($configdata['count']) ? intval($configdata['count']) : 5; $limit = $limit > 0 ? $limit : 5; // Get all views created in the group // Sortorder: Group homepage should be first, then sort by sortorder $sort = array(array('column' => "type='grouphomepage'", 'desc' => true)); // Find out what order to sort them by (default is titles) if (!isset($configdata['sortgroupviewsby']) || $configdata['sortgroupviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) { $sort[] = array('column' => 'title'); } else { $sort[] = array('column' => 'mtime', 'desc' => true); } $data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, 0, true, $sort); foreach ($data['groupviews']->data as &$view) { if (!$editing && isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form(null, null, $view['id'])); } } // Find out what order to sort them by (default is titles) if (!isset($configdata['sortsharedviewsby']) || $configdata['sortsharedviewsby'] == PluginBlocktypeGroupViews::SORTBY_TITLE) { $sortsharedviewsby = 'v.title'; $sortsharedcollectionsby = array(array('column' => 'c.name')); } else { $sortsharedviewsby = 'v.mtime DESC'; $sortsharedcollectionsby = array(array('column' => 'GREATEST(c.mtime, (SELECT MAX(v.mtime) FROM {view} v INNER JOIN {collection_view} cv ON v.id=cv.view WHERE cv.collection=c.id))', 'desc' => true)); } // For group members, display a list of views that others have // shared to the group if (empty($configdata['showsharedviews'])) { $data['sharedviews'] = (object) array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0); } else { $data['sharedviews'] = View::get_sharedviews_data($limit, 0, $group->id, $configdata['showsharedviews'] == 2 ? false : true, $sortsharedviewsby); foreach ($data['sharedviews']->data as &$view) { if (!$editing && isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form($group, null, $view->id)); } } } if (empty($configdata['showsharedcollections'])) { $data['sharedcollections'] = (object) array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0); } else { $data['sharedcollections'] = View::get_sharedcollections_data($limit, 0, $group->id, $configdata['showsharedcollections'] == 2 ? false : true, $sortsharedcollectionsby); } if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) { // Display a list of views submitted to the group list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id, $sortsubmittedby); $allsubmitted = array_merge(array_values($collections), array_values($views)); $data['allsubmitted'] = array('data' => array_slice($allsubmitted, 0, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => 0); } } if ($group->submittableto) { require_once 'pieforms/pieform.php'; // A user can submit more than one view to the same group, but no view can be // submitted to more than one group. // Display a list of views this user has submitted to this group, and a submission // form containing drop-down of their unsubmitted views. list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id, $sortsubmittedby); $data['mysubmitted'] = array_merge(array_values($collections), array_values($views)); // Only render the submission form in viewing mode if (!$editing) { $data['group_view_submission_form'] = group_view_submission_form($group->id); } } $data['group'] = $group; return $data; }
protected static function get_data($groupid, $editing = false) { global $USER; if (!defined('GROUP')) { define('GROUP', $groupid); } // get the currently requested group $group = group_current_group(); $role = group_user_access($group->id); if ($role) { $bi = group_get_homepage_view_groupview_block($group->id); $configdata = $bi->get('configdata'); $limit = isset($configdata['count']) ? intval($configdata['count']) : 5; $limit = $limit > 0 ? $limit : 5; // Get all views created in the group $sort = array(array('column' => 'type=\'grouphomepage\'', 'desc' => true)); $data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, 0, true, $sort); foreach ($data['groupviews']->data as &$view) { if (!$editing && isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form(null, null, $view['id'])); } } // For group members, display a list of views that others have // shared to the group $data['sharedviews'] = View::get_sharedviews_data($limit, 0, $group->id); foreach ($data['sharedviews']->data as &$view) { if (!$editing && isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form($group, null, $view->id)); } } $data['sharedcollections'] = View::get_sharedcollections_data($limit, 0, $group->id); if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) { // Display a list of views submitted to the group list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id); $allsubmitted = array_merge(array_values($collections), array_values($views)); $data['allsubmitted'] = array('data' => array_slice($allsubmitted, 0, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => 0); } } if ($group->submittableto) { require_once 'pieforms/pieform.php'; // A user can submit more than one view to the same group, but no view can be // submitted to more than one group. // Display a list of views this user has submitted to this group, and a submission // form containing drop-down of their unsubmitted views. list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id); $data['mysubmitted'] = array_merge(array_values($collections), array_values($views)); // Only render the submission form in viewing mode if (!$editing) { $data['group_view_submission_form'] = group_view_submission_form($group->id); } } $data['group'] = $group; return $data; }
protected static function get_data($groupid) { global $USER; if (!defined('GROUP')) { define('GROUP', $groupid); } // get the currently requested group $group = group_current_group(); $role = group_user_access($group->id); if ($role) { // For group members, display a list of views that others have // shared to the group $data['sharedviews'] = View::get_sharedviews_data(null, 0, $group->id); if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) { // Display a list of views submitted to the group $data['allsubmittedviews'] = View::get_submitted_views($group->id); } } if (group_allows_submission($group->grouptype) && ($userviewdata = View::get_user_views())) { // A user can submit more than one view to the same group, but no view can be // submitted to more than one group. // Display a list of views this user has submitted to this group, and a submission // form containing drop-down of their unsubmitted views. $data['mysubmittedviews'] = View::get_submitted_views($group->id, $USER->get('id')); if (!empty($data['mysubmittedviews'])) { foreach ($data['mysubmittedviews'] as &$v) { $url = get_config('wwwroot') . 'view/view.php?id=' . $v['id']; if ($v['submittedtime']) { $v['strsubmitted'] = get_string('youhavesubmittedon', 'view', $url, $v['title'], format_date($v['submittedtime'])); } else { $v['strsubmitted'] = get_string('youhavesubmitted', 'view', $url, $v['title']); } } } $data['group_view_submission_form'] = group_view_submission_form($group->id, $userviewdata); } $data['group'] = $group; return $data; }