$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'; } else { $sortsharedviewsby = 'v.mtime DESC'; } // For group members, display a list of views that others have // shared to the group if (empty($configdata['showsharedviews'])) { $sharedviews = array('data' => array(), 'count' => 0, 'limit' => $limit, 'offset' => 0); } else { $sharedviews = (array) View::get_sharedviews_data($limit, $offset, $groupid, $configdata['showsharedviews'] == 2 ? false : true, $sortsharedviewsby); foreach ($sharedviews['data'] as &$view) { if (!$editing && isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form($group, null, $view->id)); } } } if (!empty($configdata['showsharedviews'])) { $baseurl = $group_homepage_view->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid . '&editing=' . $editing; $pagination = array('baseurl' => $baseurl, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewlist', 'jsonscript' => 'blocktype/groupviews/sharedviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); PluginBlocktypeGroupViews::render_items($sharedviews, 'blocktype:groupviews:sharedviews.tpl', $configdata, $pagination); } json_reply(false, array('data' => $sharedviews));
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; }
INNER JOIN {interaction_forum_post} pt ON (pt.topic = p.topic AND pt.parent IS NULL) WHERE i.group = ? AND i.deleted = 0 AND t.deleted = 0 AND p.deleted = 0 ORDER BY p.ctime DESC LIMIT 5; ', array($group->id)); } $smarty = smarty(); $smarty->assign('group', $group); $smarty->assign('groupid', $group->id); $smarty->assign('foruminfo', $foruminfo); $smarty->assign('membercount', count_records('group_member', 'group', $group->id)); $smarty->assign('viewcount', count_records('view', 'group', $group->id)); $smarty->assign('filecount', $filecounts->files); $smarty->assign('foldercount', $filecounts->folders); if ($role) { // For group members, display a list of views that others have // shared to the group $viewdata = View::get_sharedviews_data(null, 0, $group->id); $smarty->assign('sharedviews', $viewdata->data); if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) { // Display a list of views submitted to the group $smarty->assign('submittedviews', View::get_submitted_views($group->id)); } } $smarty->assign('role', $role); $smarty->display('group/view.tpl');
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; }
define('TITLE', get_string('report', 'group')); define('MENUITEM', 'groups/report'); define('GROUP', param_integer('group')); $wwwroot = get_config('wwwroot'); $needsubdomain = get_config('cleanurlusersubdomains'); $setlimit = true; $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $sort = param_variable('sort', 'title'); $direction = param_variable('direction', 'asc'); $group = group_current_group(); $role = group_user_access($group->id); if (!group_role_can_access_report($group, $role)) { throw new AccessDeniedException(); } $sharedviews = View::get_sharedviews_data(0, null, $group->id); $sharedviewscount = $sharedviews->count; $sharedviews = $sharedviews->data; foreach ($sharedviews as &$data) { if (isset($data['group'])) { $data['groupname'] = get_field('group', 'name', 'id', $data['group']); } $view = new View($data['id']); $comments = ArtefactTypeComment::get_comments(0, 0, null, $view); $extcommenters = 0; $membercommenters = 0; $extcomments = 0; $membercomments = 0; $commenters = array(); foreach ($comments->data as $c) { if (empty($c->author)) {
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; }
/** Code copied from blocktype::groupviews **/ public static function get_data($groupid, $offset = 0, $limit = 20) { global $USER; $texttitletrim = 20; $items2 = null; 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 // Params for get_sharedviews_data is $limit=0,$offset=0, $groupid $data['sharedviews'] = View::get_sharedviews_data($limit, $offset, $group->id); /* foreach ($data['sharedviews']->data as &$view) { if (isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form($group, null, $view->id)); } } */ //the array that is returned from View::get_sharedviews_data($limit, $offset, $group->id) //contains a few other things but we just wanted to focus on sharedviews //the foreach below will loop through all views shared with the group foreach ($data['sharedviews'] as $aView) { if (is_array($aView)) { //20140909 JW sort the array returned by View::get_sharedviews_data($limit, $offset, $group->id) //by ctime, this requires the query within get_sharedviews_data to have ctime in its select string $aView = self::array_msort($aView, array('ctime' => SORT_DESC)); //the foreach below will loop through all the properties for a view (returned by get_data method) and assigns them to the required variables foreach ($aView as $aViewProperty) { //get the view $viewID = $aViewProperty['id']; //the page shared $fullurl = $aViewProperty['fullurl']; //full url of the page shared $viewTitle = str_shorten_text($aViewProperty['displaytitle'], $texttitletrim, true); //view's title //get the owner of the view $viewOwnerName = $aViewProperty['user']->firstname . " " . $aViewProperty['user']->lastname; //owner of the view's name $userobj = new User(); $userobj->find_by_id($aViewProperty['user']->id); $profileurl = profile_url($userobj); //owner of the view's proflie page $avatarurl = profile_icon_url($aViewProperty['user']->id, 50, 50); //owner of the view's profile picture //get the artefact id of an image in the view $theView = new View($aViewProperty['id']); //create the view $artefactInView = $theView->get_artefact_metadata(); //get all artefacts in the view foreach ($artefactInView as $anArtefact) { //for each artefact if ($anArtefact->artefacttype == 'image') { $artefactID = $anArtefact->id; //if it is an image artefact assign the id and break the loop break; } //20150331 JW added that if page contains a folder with images (galleries count as folders) //it will pull an image from that folder and use it as the cover if ($anArtefact->artefacttype == 'folder') { $query = "SELECT id FROM {artefact} where parent = ? AND artefacttype = 'image'"; $imagesInAFolder = get_records_sql_array($query, array($anArtefact->id)); //only assign the id of an image if the folder contains at least 1 image if (!empty($imagesInAFolder)) { $artefactID = $imagesInAFolder[0]->id; break; } } //20140903 JW if there are no images on the page then set to artefactID to 0 //this way, when display each page, instead of a blank box it will show a place holder image $artefactID = 0; } //the items variable below requires the contents array to be in this format $contents['photos'][] = array("image" => array("id" => $artefactID, "view" => $viewID), "type" => "photo", "page" => array("url" => $fullurl, "title" => $viewTitle), "owner" => array("name" => $viewOwnerName, "profileurl" => $profileurl, "avatarurl" => $avatarurl)); } } } //20150723 JW added the if statement to check if $content is set, if not then skip if (isset($contents)) { $items2 = array('count' => $data['sharedviews']->count, 'data' => $contents, 'offset' => $offset, 'limit' => $limit); } } //$data['group'] = $group; return $items2; }
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'; $offset = param_integer('offset', 0); $groupid = param_integer('group'); $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; $sharedviews = (array) View::get_sharedviews_data($limit, $offset, $groupid); foreach ($sharedviews['data'] as &$view) { if (isset($view['template']) && $view['template']) { $view['form'] = pieform(create_view_form($group_homepage_view, null, $view->id)); } } if (!empty($configdata['showsharedviews']) && isset($sharedviews)) { $baseurl = $group_homepage_view->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid; $pagination = array('baseurl' => $baseurl, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewlist', 'jsonscript' => 'blocktype/groupviews/sharedviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); PluginBlocktypeGroupViews::render_items($sharedviews, 'blocktype:groupviews:sharedviews.tpl', $configdata, $pagination); } json_reply(false, array('data' => $sharedviews));