Skip to content
GitLab
Menu
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
8f59da12
Commit
8f59da12
authored
Jan 22, 2008
by
Clare Lenihan
Committed by
Clare Lenihan
Jan 22, 2008
Browse files
new myviews pages
parent
cacb0270
Changes
5
Hide whitespace changes
Inline
Side-by-side
htdocs/theme/default/templates/view/delete.tpl
0 → 100644
View file @
8f59da12
{
include
file
=
"header.tpl"
}
{
include
file
=
"sidebar.tpl"
}
{
include
file
=
"columnleftstart.tpl"
}
<h2>
{
$heading
|
escape
}
</h2>
{
$form
}
{
include
file
=
"columnleftend.tpl"
}
{
include
file
=
"footer.tpl"
}
htdocs/theme/default/templates/view/myviews.tpl
0 → 100644
View file @
8f59da12
{
include
file
=
"header.tpl"
}
{
include
file
=
"sidebar.tpl"
}
{
include
file
=
"columnleftstart.tpl"
}
<h2>
My Views
</h2>
<div
class=
"fr"
><span
class=
"addicon"
><a
href=
"
{
$WWWROOT
}
view/edit.php"
>
{
str
tag
=
"createview"
section
=
"view"
}
</a></span></div>
<br>
{
if
$views
}
<table>
{
foreach
from
=
$views
item
=
view
}
<tr
class=
"
{
cycle
values
=
r0
,
r1
}
"
>
<td>
{
if
!
$view.submittedto
}
<button
class=
"fr"
type=
"button"
><strong>
{
str
tag
=
"deletethisview"
section
=
"view"
}
</strong></button>
<button
class=
"fr"
type=
"button"
><strong>
{
str
tag
=
"editthisview"
section
=
"view"
}
</strong></button>
{/
if
}
<h3><a
href=
"
{
$WWWROOT
}
view/view.php?id=
{
$view.id
}
"
>
{
$view.title
|
escape
}
</a></h3>
{
if
$view.description
}
{
$view.description
}
{/
if
}
{
if
!
$view.submittedto
}
<button
type=
"button"
>
{
str
tag
=
"editviewnameanddescription"
section
=
"view"
}
</button>
{/
if
}
<ul>
{
if
$view.artefacts
}
<li>
{
str
tag
=
"artefactsinthisview"
section
=
"view"
}
:
{
foreach
from
=
$view.artefacts
item
=
artefact
name
=
artefacts
}
<a
href=
"
{
$WWWROOT
}
view/artefact.php?artefact=
{
$artefact.id
}
&view=
{
$view.id
}
"
>
{
$artefact.title
|
escape
}
</a>
{
if
!
$smarty.foreach.artefacts.last
}
,
{/
if
}
{/
foreach
}
</li>
{/
if
}
<li>
{
if
$view.access
}
{
$view.access
}
<br>
{/
if
}
{
if
$view.accessgroups
}
{
str
tag
=
"whocanseethisview"
section
=
"view"
}
:
{
foreach
from
=
$view.accessgroups
item
=
accessgroup
name
=
artefacts
}
{
if
$accessgroup.accesstype
==
'loggedin'
}
{
str
tag
=
"loggedin"
section
=
"view"
}{
elseif
$accessgroup.accesstype
==
'public'
}
{
str
tag
=
"public"
section
=
"view"
}{
elseif
$accessgroup.accesstype
==
'friends'
}
<a
href=
"
{
$WWWROOT
}
user/"
>
{
str
tag
=
"friends"
section
=
"view"
}
</a>
{
elseif
$accessgroup.accesstype
==
'group'
}
<a
href=
"
{
$WWWROOT
}
group/view.php?id=
{
$accessgroup.id
}
"
>
{
$accessgroup.name
|
escape
}
</a>
{
elseif
$accessgroup.accesstype
==
'tutorgroup'
}
<a
href=
"
{
$WWWROOT
}
group/view.php?id=
{
$accessgroup.id
}
"
>
{
$accessgroup.name
|
escape
}
(
{
str
tag
=
"tutors"
section
=
"view"
}
)
</a>
{
elseif
$accessgroup.accesstype
==
'user'
}
<a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$accessgroup.id
}
"
>
{
$accessgroup.id
|
display_name
|
escape
}
</a>
{/
if
}{
if
!
$smarty.foreach.artefacts.last
}
,
{/
if
}
{/
foreach
}
{
else
}
{
str
tag
=
"nobodycanseethisview"
section
=
"view"
}
{/
if
}
<button
type=
"button"
>
{
str
tag
=
"editviewaccess"
section
=
"view"
}
</button>
</li>
{
if
$view.submittedto
}
<li>
{
$view.submittedto
}
</li>
{/
if
}
</ul>
{
if
$view.submitto
}
{
$view.submitto
}
{/
if
}
</td>
</tr>
{/
foreach
}
</table>
<div
class=
"center"
>
{
$pagination
}
</div>
{
else
}
{
str
tag
=
"noviews"
section
=
"views"
}
{/
if
}
{
include
file
=
"columnleftend.tpl"
}
{
include
file
=
"footer.tpl"
}
htdocs/theme/default/templates/view/submit.tpl
0 → 100644
View file @
8f59da12
{
include
file
=
"header.tpl"
}
{
include
file
=
"sidebar.tpl"
}
{
include
file
=
"columnleftstart.tpl"
}
<h2>
{
$heading
|
escape
}
</h2>
{
$form
}
{
include
file
=
"columnleftend.tpl"
}
{
include
file
=
"footer.tpl"
}
htdocs/view/myviews.php
0 → 100644
View file @
8f59da12
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2007 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'MENUITEM'
,
'myportfolio/views'
);
define
(
'SECTION_PLUGINTYPE'
,
'core'
);
define
(
'SECTION_PLUGINNAME'
,
'view'
);
define
(
'SECTION_PAGE'
,
'index'
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require
(
'pieforms/pieform.php'
);
define
(
'TITLE'
,
get_string
(
'myviews'
,
'view'
));
$limit
=
param_integer
(
'limit'
,
5
);
$offset
=
param_integer
(
'offset'
,
0
);
$userid
=
$USER
->
get
(
'id'
);
$count
=
count_records
(
'view'
,
'owner'
,
$userid
);
/* Get $limit views from the view table, then get all these views'
associated artefacts */
/* Do this in one query sometime */
$viewdata
=
get_records_sql_array
(
'SELECT v.id,v.title,v.startdate,v.stopdate,v.description, g.id AS group, g.name
FROM {view} v
LEFT OUTER JOIN {group} g ON (v.submittedto = g.id AND g.deleted = 0)
WHERE v.owner = '
.
$userid
.
'
ORDER BY v.title, v.id'
,
''
,
$offset
,
$limit
);
if
(
$viewdata
)
{
$viewidlist
=
implode
(
', '
,
array_map
(
create_function
(
'$a'
,
'return $a->id;'
),
$viewdata
));
$artefacts
=
get_records_sql_array
(
'SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN ('
.
$viewidlist
.
')
GROUP BY 1, 2, 3, 4, 5
ORDER BY a.title, va.artefact'
,
''
);
$accessgroups
=
get_records_sql_array
(
'SELECT view, accesstype, id, name, startdate, stopdate
FROM (
SELECT view, \'group\' AS accesstype, g.id, g.name, startdate, stopdate
FROM view_access_group vg
INNER JOIN "group" g ON g.id = vg.group AND g.deleted = 0
WHERE vg.tutoronly = 0
UNION SELECT view, \'tutorgroup\' AS accesstype, g.id, g.name, startdate, stopdate
FROM view_access_group vg
INNER JOIN "group" g ON g.id = vg.group AND g.deleted = 0
WHERE vg.tutoronly = 1
UNION SELECT view, \'user\' AS accesstype, usr AS id, \'\' AS name, startdate, stopdate
FROM view_access_usr vu
UNION SELECT view, accesstype, 0 AS id, \'\' AS name, startdate, stopdate
FROM view_access va
) AS a
WHERE view in ('
.
$viewidlist
.
')
ORDER BY view, accesstype, name, id
'
,
array
());
}
$data
=
array
();
if
(
$viewdata
)
{
for
(
$i
=
0
;
$i
<
count
(
$viewdata
);
$i
++
)
{
$index
[
$viewdata
[
$i
]
->
id
]
=
$i
;
$data
[
$i
][
'id'
]
=
$viewdata
[
$i
]
->
id
;
$data
[
$i
][
'title'
]
=
$viewdata
[
$i
]
->
title
;
$data
[
$i
][
'description'
]
=
$viewdata
[
$i
]
->
description
;
if
(
$viewdata
[
$i
]
->
name
)
{
$data
[
$i
][
'submittedto'
]
=
array
(
'name'
=>
$viewdata
[
$i
]
->
name
,
'id'
=>
$viewdata
[
$i
]
->
group
);
}
$data
[
$i
][
'artefacts'
]
=
array
();
$data
[
$i
][
'accessgroups'
]
=
array
();
if
(
$viewdata
[
$i
]
->
startdate
&&
$viewdata
[
$i
]
->
stopdate
)
{
$data
[
$i
][
'access'
]
=
get_string
(
'accessbetweendates'
,
'view'
,
format_date
(
strtotime
(
$viewdata
[
$i
]
->
startdate
),
'strftimedate'
),
format_date
(
strtotime
(
$viewdata
[
$i
]
->
stopdate
),
'strftimedate'
));
}
else
if
(
$viewdata
[
$i
]
->
startdate
)
{
$data
[
$i
][
'access'
]
=
get_string
(
'accessfromdate'
,
'view'
,
format_date
(
strtotime
(
$viewdata
[
$i
]
->
startdate
),
'strftimedate'
));
}
else
if
(
$viewdata
[
$i
]
->
stopdate
)
{
$data
[
$i
][
'access'
]
=
get_string
(
'accessuntildate'
,
'view'
,
format_date
(
strtotime
(
$viewdata
[
$i
]
->
stopdate
),
'strftimedate'
));
}
}
// Go through all the artefact records and put them in with the
// views they belong to.
if
(
$artefacts
)
{
foreach
(
$artefacts
as
$artefactrec
)
{
safe_require
(
'artefact'
,
$artefactrec
->
plugin
);
// Perhaps I shouldn't have to construct the entire
// artefact object to render the name properly.
$classname
=
generate_artefact_class_name
(
$artefactrec
->
artefacttype
);
$artefactobj
=
new
$classname
(
0
,
array
(
'title'
=>
$artefactrec
->
title
));
$artefactobj
->
set
(
'dirty'
,
false
);
$artname
=
$artefactobj
->
get_name
();
$data
[
$index
[
$artefactrec
->
view
]][
'artefacts'
][]
=
array
(
'id'
=>
$artefactrec
->
artefact
,
'title'
=>
$artname
);
}
}
if
(
$accessgroups
)
{
foreach
(
$accessgroups
as
$access
)
{
$data
[
$index
[
$access
->
view
]][
'accessgroups'
][]
=
array
(
'accesstype'
=>
$access
->
accesstype
,
// friends, group, loggedin, public, tutorsgroup, user
'id'
=>
$access
->
id
,
'name'
=>
$access
->
name
,
'startdate'
=>
$access
->
startdate
,
'stopdate'
=>
$access
->
stopdate
);
}
}
}
/* Get a list of groups that the user belongs to which also have
a tutor member. This is the list of groups that the user is
able to submit views to. */
if
(
!
$tutorgroupdata
=
@
get_records_sql_array
(
'SELECT g.id, g.name
FROM {group_member} u
INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
INNER JOIN {group_member} t ON t.group = g.id
WHERE u.member = ?
AND t.tutor = 1
AND t.member != ?
GROUP BY g.id, g.name
ORDER BY g.name'
,
array
(
$userid
,
$userid
)))
{
$tutorgroupdata
=
array
();
}
else
{
$options
=
array
();
foreach
(
$tutorgroupdata
as
$group
)
{
$options
[
$group
->
id
]
=
$group
->
name
;
}
$i
=
0
;
foreach
(
$data
as
&
$view
)
{
if
(
empty
(
$view
[
'submittedto'
]))
{
$view
[
'submitto'
]
=
pieform
(
array
(
'name'
=>
'submitto'
.
$i
++
,
'method'
=>
'post'
,
'renderer'
=>
'oneline'
,
'autofocus'
=>
false
,
'successcallback'
=>
'submitto_submit'
,
'elements'
=>
array
(
'text1'
=>
array
(
'type'
=>
'html'
,
'value'
=>
'Submit this view to '
),
'options'
=>
array
(
'type'
=>
'select'
,
'collapseifoneoption'
=>
false
,
'options'
=>
$options
,
),
'text2'
=>
array
(
'type'
=>
'html'
,
'value'
=>
' for assessment'
,
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)
),
'view'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$view
[
'id'
]
)
),
));
}
else
{
$view
[
'submittedto'
]
=
get_string
(
'viewsubmittedtogroup'
,
'view'
,
$viewdata
[
$i
]
->
group
,
$viewdata
[
$i
]
->
name
);
}
}
}
$pagination
=
build_pagination
(
array
(
'url'
=>
get_config
(
'wwwroot'
)
.
'view/myviews.php?'
,
'count'
=>
$count
,
'limit'
=>
$limit
,
'offset'
=>
$offset
,
'resultcounttextsingular'
=>
get_string
(
'view'
,
'view'
),
'resultcounttextplural'
=>
get_string
(
'views'
,
'view'
)
));
function
submitto_submit
(
Pieform
$form
,
$values
)
{
redirect
(
'/view/submit.php?id='
.
$values
[
'view'
]
.
'&group='
.
$values
[
'options'
]);
}
$smarty
=
smarty
();
$smarty
->
assign
(
'views'
,
$data
);
$smarty
->
assign
(
'pagination'
,
$pagination
[
'html'
]);
$smarty
->
display
(
'view/myviews.tpl'
);
?>
\ No newline at end of file
htdocs/view/submit.php
0 → 100644
View file @
8f59da12
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2007 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Clare Lenihan <clare@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'MENUITEM'
,
'myportfolio/views'
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require_once
(
'pieforms/pieform.php'
);
require_once
(
'view.php'
);
$viewid
=
param_integer
(
'id'
);
$groupid
=
param_integer
(
'group'
);
$view
=
get_record
(
'view'
,
'id'
,
$viewid
,
'owner'
,
$USER
->
get
(
'id'
));
$group
=
get_record_sql
(
'SELECT g.id, g.name
FROM {group_member} u
INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
INNER JOIN {group_member} t ON t.group = g.id
WHERE u.member = ?
AND t.tutor = 1
AND t.member != u.member
AND g.id = ?
GROUP BY g.id, g.name'
,
array
(
$USER
->
get
(
'id'
),
$groupid
)
);
if
(
!
$view
||
!
$group
||
$view
->
submittedto
)
{
log_debug
(
$view
);
log_debug
(
$group
);
throw
new
AccessDeniedException
(
get_string
(
'cantsubmitviewtogroup'
,
'view'
));
}
define
(
'TITLE'
,
get_string
(
'submitviewtogroup'
,
'view'
,
$view
->
title
,
$group
->
name
));
$form
=
pieform
(
array
(
'name'
=>
'submitview'
,
'autofocus'
=>
false
,
'method'
=>
'post'
,
'elements'
=>
array
(
'submit'
=>
array
(
'type'
=>
'submitcancel'
,
'title'
=>
get_string
(
'submitviewconfirm'
,
'view'
,
$view
->
title
,
$group
->
name
),
'value'
=>
array
(
get_string
(
'yes'
),
get_string
(
'no'
)),
'goto'
=>
get_config
(
'wwwroot'
)
.
'view/temp.php'
)
),
));
$smarty
=
smarty
();
$smarty
->
assign
(
'heading'
,
TITLE
);
$smarty
->
assign
(
'form'
,
$form
);
$smarty
->
display
(
'view/submit.tpl'
);
function
submitview_submit
(
Pieform
$form
,
$values
)
{
global
$SESSION
,
$viewid
,
$groupid
;
update_record
(
'view'
,
array
(
'submittedto'
=>
$groupid
),
array
(
'id'
=>
$viewid
));
$SESSION
->
add_ok_msg
(
get_string
(
'submitview'
,
'view'
));
redirect
(
'/view/temp.php'
);
}
?>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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