Commit 20f58600 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow views with a type of portfolio or profile to appear in view listings

parent c28081db
...@@ -58,7 +58,7 @@ class PluginBlocktypeMyviews extends SystemBlocktype { ...@@ -58,7 +58,7 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
// Get viewable views // Get viewable views
$views = array(); $views = array();
if ($allviews = get_records_select_array('view', 'owner = ? AND type = ?', array($userid, 'portfolio'))) { if ($allviews = get_records_select_array('view', 'owner = ? AND type != ?', array($userid, 'profile'))) {
foreach ($allviews as $view) { foreach ($allviews as $view) {
if (can_view_view($view->id)) { if (can_view_view($view->id)) {
$views[$view->id] = $view; $views[$view->id] = $view;
......
...@@ -1515,11 +1515,10 @@ function get_view_from_token($token, $visible=true) { ...@@ -1515,11 +1515,10 @@ function get_view_from_token($token, $visible=true) {
* @param array $users users to fetch views owned by * @param array $users users to fetch views owned by
* @param int $userlooking (optional, defaults to logged in user) * @param int $userlooking (optional, defaults to logged in user)
* @param int $limit grab this many views. (setting this null means get all) * @param int $limit grab this many views. (setting this null means get all)
* @param string $type the type of views to return
* *
* @return array Associative array keyed by userid, of arrays of view ids * @return array Associative array keyed by userid, of arrays of view ids
*/ */
function get_views($users, $userlooking=null, $limit=5, $type='portfolio') { function get_views($users, $userlooking=null, $limit=5, $type=null) {
$userlooking = optional_userid($userlooking); $userlooking = optional_userid($userlooking);
if (is_int($users)) { if (is_int($users)) {
$users = array($users); $users = array($users);
...@@ -1552,8 +1551,10 @@ function get_views($users, $userlooking=null, $limit=5, $type='portfolio') { ...@@ -1552,8 +1551,10 @@ function get_views($users, $userlooking=null, $limit=5, $type='portfolio') {
} }
} }
$typesql = ''; if (is_null($type)) {
if ($type != null) { $typesql = "AND v.type != 'profile'";
}
else {
$typesql = 'AND v.type = ' . db_quote($type); $typesql = 'AND v.type = ' . db_quote($type);
} }
......
...@@ -1711,14 +1711,14 @@ class View { ...@@ -1711,14 +1711,14 @@ class View {
ORDER BY v.title, v.id', array($institution), $offset, $limit); ORDER BY v.title, v.id', array($institution), $offset, $limit);
} }
else { else {
$count = count_records('view', 'owner', $userid, 'type', 'portfolio'); $count = count_records_select('view', 'owner = ? AND type != ?', array($userid, 'profile'));
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, v.template, $viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, v.template,
g.id AS submitgroupid, g.name AS submitgroupname, h.wwwroot AS submithostwwwroot, h.name AS submithostname g.id AS submitgroupid, g.name AS submitgroupname, h.wwwroot AS submithostwwwroot, h.name AS submithostname
FROM {view} v FROM {view} v
LEFT OUTER JOIN {group} g ON (v.submittedgroup = g.id AND g.deleted = 0) LEFT OUTER JOIN {group} g ON (v.submittedgroup = g.id AND g.deleted = 0)
LEFT OUTER JOIN {host} h ON (v.submittedhost = h.wwwroot) LEFT OUTER JOIN {host} h ON (v.submittedhost = h.wwwroot)
WHERE v.owner = ' . $userid . ' WHERE v.owner = ' . $userid . '
AND v.type = \'portfolio\' AND v.type != \'profile\'
ORDER BY v.title, v.id', '', $offset, $limit); ORDER BY v.title, v.id', '', $offset, $limit);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment