Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
6bd72796
Commit
6bd72796
authored
Aug 13, 2008
by
Richard Mansfield
Browse files
Template drop-down on create view page
parent
6fbf7077
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/view.php
View file @
6bd72796
...
...
@@ -1451,9 +1451,12 @@ class View {
* @param integer $groupid Only return views owned by this group.
* @param string $institution Only return views owned by this institution.
* @param bool $template Only return views marked as templates.
* @param integer $limit
* @param integer $offset
* @param bool $extra
*
*/
public
static
function
view_search
(
$ownerid
=
null
,
$groupid
=
null
,
$institution
=
null
,
$template
=
null
,
$limit
=
10
,
$offset
=
0
)
{
public
static
function
view_search
(
$ownerid
=
null
,
$groupid
=
null
,
$institution
=
null
,
$template
=
null
,
$limit
=
null
,
$offset
=
0
,
$extra
=
true
)
{
global
$USER
;
$admin
=
$USER
->
get
(
'admin'
);
$loggedin
=
$USER
->
is_logged_in
();
...
...
@@ -1477,10 +1480,14 @@ class View {
AND v.institution = ?'
;
$ph
[]
=
$institution
;
}
if
(
$template
==
true
)
{
if
(
$template
)
{
$where
.
=
'
AND v.template = 1'
;
}
else
if
(
$template
===
false
)
{
$where
.
=
'
AND v.template = 0'
;
}
if
(
$admin
)
{
$from
=
'
...
...
@@ -1563,7 +1570,9 @@ class View {
);
if
(
$viewdata
)
{
View
::
get_extra_view_info
(
$viewdata
);
if
(
$extra
)
{
View
::
get_extra_view_info
(
$viewdata
);
}
}
else
{
$viewdata
=
array
();
...
...
htdocs/view/edit.php
View file @
6bd72796
...
...
@@ -46,6 +46,20 @@ if (empty($id)) {
||
$institution
&&
!
$USER
->
can_edit_institution
(
$institution
))
{
throw
new
AccessDeniedException
();
}
// Get templates visible to the user and non-templates owned by
// the owner of the view being created
$templates
=
View
::
view_search
(
null
,
null
,
null
,
true
,
null
,
0
,
false
);
$ownerid
=
(
$group
||
$institution
)
?
null
:
$USER
->
get
(
'id'
);
$nontemplates
=
View
::
view_search
(
$ownerid
,
$group
,
$institution
,
false
,
null
,
0
,
false
);
$templateoptions
=
array
(
0
=>
'None'
);
foreach
(
$templates
->
data
as
$t
)
{
$templateoptions
[
$t
->
id
]
=
$t
->
title
;
}
foreach
(
$nontemplates
->
data
as
$t
)
{
$templateoptions
[
$t
->
id
]
=
$t
->
title
;
}
}
else
{
$view
=
new
View
(
$id
);
...
...
@@ -128,11 +142,6 @@ $editview = array(
'defaultvalue'
=>
isset
(
$view
)
?
$view
->
get
(
'tags'
)
:
null
,
'help'
=>
true
,
),
'submit'
=>
array
(
'type'
=>
'submitcancel'
,
'value'
=>
array
(
empty
(
$new
)
?
get_string
(
'save'
)
:
get_string
(
'next'
),
get_string
(
'cancel'
)),
'confirm'
=>
$new
&&
isset
(
$view
)
?
array
(
null
,
get_string
(
'confirmcancelcreatingview'
,
'view'
))
:
null
,
)
),
);
...
...
@@ -159,6 +168,21 @@ else {
);
}
if
(
$new
&&
count
(
$templateoptions
))
{
$editview
[
'elements'
][
'template'
]
=
array
(
'type'
=>
'select'
,
'title'
=>
get_string
(
'Template'
,
'view'
),
'description'
=>
get_string
(
'createfromtemplatedescription'
,
'view'
),
'options'
=>
$templateoptions
,
);
}
$editview
[
'elements'
][
'submit'
]
=
array
(
'type'
=>
'submitcancel'
,
'value'
=>
array
(
empty
(
$new
)
?
get_string
(
'save'
)
:
get_string
(
'next'
),
get_string
(
'cancel'
)),
'confirm'
=>
$new
&&
isset
(
$view
)
?
array
(
null
,
get_string
(
'confirmcancelcreatingview'
,
'view'
))
:
null
,
);
$editview
=
pieform
(
$editview
);
function
editview_cancel_submit
()
{
...
...
htdocs/view/index.php
View file @
6bd72796
...
...
@@ -32,7 +32,7 @@ define('SECTION_PLUGINNAME', 'view');
define
(
'SECTION_PAGE'
,
'index'
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require_once
(
get_config
(
'
doc
root'
)
.
'
lib/
view.php'
);
require_once
(
get_config
(
'
lib
root'
)
.
'view.php'
);
require_once
(
'pieforms/pieform.php'
);
define
(
'TITLE'
,
get_string
(
'myviews'
,
'view'
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment