Commit cff03585 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Getting the copy a page or collection to sort by collection Bug #1255780"

parents cc98be0e db4bc11b
......@@ -3788,7 +3788,7 @@ class View {
$orderby .= "COALESCE(sg.name, si.displayname, CASE WHEN su.preferredname IS NOT NULL AND su.preferredname != '' THEN su.preferredname ELSE su.firstname || ' ' || su.lastname END)";
}
else {
$orderby .= 'v.' . $item['column'];
$orderby .= (!empty($item['tablealias']) ? $item['tablealias'] : 'v') . '.' . $item['column'];
}
if ($item['desc']) {
......@@ -4126,7 +4126,7 @@ class View {
}
}
public static function set_nav($group, $institution, $share=false) {
public static function set_nav($group, $institution, $share=false, $collection=false) {
if ($group) {
define('MENUITEM', $share ? 'groups/share' : 'groups/views');
define('GROUP', $group);
......@@ -4139,6 +4139,9 @@ class View {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', $share ? 'manageinstitutions/share' : 'manageinstitutions/institutionviews');
}
else if ($collection) {
define('MENUITEM', 'myportfolio/collection');
}
else {
define('MENUITEM', $share ? 'myportfolio/share' : 'myportfolio/views');
}
......@@ -4257,7 +4260,8 @@ class View {
public static function get_templatesearch_data(&$search) {
require_once(get_config('libroot') . 'pieforms/pieform.php');
$results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, null, null, true);
$search->sort = (isset($search->sort)) ? $search->sort : null; // for backwards compatibility
$results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, $search->sort, null, true);
foreach ($results->data as &$r) {
$r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id'], $r['collid']));
......@@ -4276,6 +4280,9 @@ class View {
if (!empty($search->institution)) {
$params['institution'] = $search->institution;
}
if (!empty($search->collection)) {
$params['searchcollection'] = $search->collection;
}
$params['viewlimit'] = $search->limit;
$smarty = smarty_core();
......
......@@ -17,7 +17,7 @@
<input type="hidden" name="viewoffset" value="0">
{if $views->group}<input type="hidden" name="group" value="{$views->group}">{/if}
{if $views->institution}<input type="hidden" name="institution" value="{$views->institution}">{/if}
{if $views->collection}<input type="hidden" name="searchcollection" value="{$views->collection}">{/if}
<span id="searchowners"><label>{str tag="searchowners" section="view"}:</label>
<input type="text" name="ownerquery" id="ownerquery" class="query" value="{$owners->query}">
<button class="query-button" type="submit">{str tag="go"}</button></span>
......
......@@ -18,8 +18,8 @@ require_once(get_config('libroot') . 'group.php');
$owner = param_integer('owner', 0);;
$groupid = param_integer('group', null);
$institution = param_alphanum('institution', null);
View::set_nav($groupid, $institution);
$searchcollection = param_integer('searchcollection', false);
View::set_nav($groupid, $institution, false, $searchcollection);
if ($usetemplate = param_integer('usetemplate', null)) {
// If a form has been submitted, build it now and pieforms will
......@@ -65,6 +65,17 @@ else {
$views->copyableby->owner = $USER->get('id');
$helptext = get_string('choosetemplatepageandcollectiondescription', 'view');
}
$sort[] = array('column' => 'title',
'desc' => 0,
);
if ($searchcollection) {
array_unshift($sort, array('column' => 'collection',
'desc' => 0,
'tablealias' => 'cv'
));
$views->collection = $searchcollection;
}
$views->sort = (object) $sort;
View::get_templatesearch_data($views);
$strpreview = json_encode(get_string('Preview','view'));
......
......@@ -28,7 +28,18 @@ $views->copyableby = (object) array('group' => $group, 'institution' => $institu
if (!($group || $institution)) {
$views->copyableby->owner = $USER->get('id');
}
$searchcollection = param_integer('searchcollection', null);
$sort[] = array('column' => 'title',
'desc' => 0,
);
if ($searchcollection) {
array_unshift($sort, array('column' => 'collection',
'desc' => 0,
'tablealias' => 'cv'
));
$views->collection = $searchcollection;
}
$views->sort = (object) $sort;
View::get_templatesearch_data($views);
json_reply(false, array(
......
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