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
9e5fce6d
Commit
9e5fce6d
authored
Nov 19, 2014
by
Robert Lyon
Committed by
Gerrit Code Review
Nov 19, 2014
Browse files
Merge "Altering how get_comments() works (Bug #1037531)"
parents
0a98082e
535c66d4
Changes
9
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/artefact.php
View file @
9e5fce6d
...
...
@@ -127,7 +127,13 @@ if (!empty($rendered['javascript'])) {
$content
.
=
$rendered
[
'html'
];
// Feedback
$feedback
=
ArtefactTypeComment
::
get_comments
(
$limit
,
$offset
,
$showcomment
,
$view
,
$artefact
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
limit
=
$limit
;
$commentoptions
->
offset
=
$offset
;
$commentoptions
->
showcomment
=
$showcomment
;
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$artefact
;
$feedback
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$inlinejavascript
=
<<<EOF
var viewid = {$viewid};
...
...
htdocs/artefact/blog/lib.php
View file @
9e5fce6d
...
...
@@ -643,7 +643,10 @@ class ArtefactTypeBlogPost extends ArtefactType {
safe_require
(
'artefact'
,
'comment'
);
require_once
(
get_config
(
'docroot'
)
.
'lib/view.php'
);
$view
=
new
View
(
$options
[
'viewid'
]);
$comments
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
,
$this
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$this
;
$comments
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$smarty
->
assign
(
'commentcount'
,
isset
(
$comments
->
count
)
?
$comments
->
count
:
0
);
}
}
...
...
@@ -817,7 +820,10 @@ class ArtefactTypeBlogPost extends ArtefactType {
require_once
(
get_config
(
'docroot'
)
.
'lib/view.php'
);
$view
=
new
View
(
$viewoptions
[
'viewid'
]);
$artefact
=
artefact_instance_from_id
(
$post
->
id
);
$comments
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
,
$artefact
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$artefact
;
$comments
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$post
->
commentcount
=
isset
(
$comments
->
count
)
?
$comments
->
count
:
0
;
}
}
...
...
htdocs/artefact/comment/blocktype/comment/lib.php
View file @
9e5fce6d
...
...
@@ -63,7 +63,12 @@ class PluginBlocktypeComment extends SystemBlocktype {
$addfeedbackpopup
=
true
;
}
safe_require
(
'artefact'
,
'comment'
);
$feedback
=
ArtefactTypeComment
::
get_comments
(
$limit
,
$offset
,
$showcomment
,
$instance
->
get_view
());
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
limit
=
$limit
;
$commentoptions
->
offset
=
$offset
;
$commentoptions
->
showcomment
=
$showcomment
;
$commentoptions
->
view
=
$instance
->
get_view
();
$feedback
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$smarty
=
smarty_core
();
$smarty
->
assign
(
'feedback'
,
$feedback
);
if
(
isset
(
$addfeedbackpopup
))
{
...
...
htdocs/artefact/comment/comments.json.php
View file @
9e5fce6d
...
...
@@ -30,11 +30,17 @@ if (!empty($extradata->artefact) && !artefact_in_view($extradata->artefact, $ext
$limit
=
param_integer
(
'limit'
,
10
);
$offset
=
param_integer
(
'offset'
);
$artefact
=
null
;
if
(
!
empty
(
$extradata
->
artefact
))
{
$artefact
=
artefact_instance_from_id
(
$extradata
->
artefact
);
}
$view
=
new
View
(
$extradata
->
view
);
$data
=
ArtefactTypeComment
::
get_comments
(
$limit
,
$offset
,
null
,
$view
,
$artefact
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
limit
=
$limit
;
$commentoptions
->
offset
=
$offset
;
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$artefact
;
$data
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
json_reply
(
false
,
array
(
'data'
=>
$data
));
htdocs/artefact/comment/lib.php
View file @
9e5fce6d
...
...
@@ -306,22 +306,47 @@ class ArtefactTypeComment extends ArtefactType {
}
/**
* Generates data object required for displaying comments on the page.
* Generates default data object required for displaying comments on the page.
* The is called before populating with specific data to send to get_comments() as
* an easy way to add variables to get passed to get_comments.
*
* @param int $limit The number of comments to display (set to
* 0 for disabling pagination and showing all comments)
* @param int $offset The offset of comments used for pagination
* @param int|string $showcomment Optionally show page with particular comment
* on it or the last page. $offset will be ignored.
* Specify either comment_id or 'last' respectively.
* Set to null to use $offset for pagination.
* @param object $view The view object
* @param object $artefact Optional artefact object
* @param bool $export Determines if comments are fetched for html export purposes
* @return object $result Comments data object
* int $limit The number of comments to display (set to
* 0 for disabling pagination and showing all comments)
* int $offset The offset of comments used for pagination
* int|string $showcomment Optionally show page with particular comment
* on it or the last page. $offset will be ignored.
* Specify either comment_id or 'last' respectively.
* Set to null to use $offset for pagination.
* object $view The view object
* object $artefact Optional artefact object
* bool $export Determines if comments are fetched for html export purposes
* bool $onview Optional - is viewing artefact comments on view page so don't show edit buttons
* @return object $options Default comments data object
*/
public
static
function
get_comments
(
$limit
=
10
,
$offset
=
0
,
$showcomment
,
&
$view
,
&
$artefact
=
null
,
$export
=
false
)
{
public
static
function
get_comment_options
()
{
$options
=
new
stdClass
();
$options
->
limit
=
10
;
$options
->
offset
=
0
;
$options
->
showcomment
=
null
;
$options
->
view
=
null
;
$options
->
artefact
=
null
;
$options
->
export
=
false
;
return
$options
;
}
/**
* Generates the data object required for displaying comments on the page.
*
* @param object $options Object of comment options
* - defaults can be retrieved from get_comment_options()
* @return object $result Comment data object
*/
public
static
function
get_comments
(
$options
)
{
global
$USER
;
// set the object's key/val pairs as variables
foreach
(
$options
as
$key
=>
$option
)
{
$$key
=
$option
;
}
$userid
=
$USER
->
get
(
'id'
);
$viewid
=
$view
->
get
(
'id'
);
if
(
!
empty
(
$artefact
))
{
...
...
@@ -1201,7 +1226,11 @@ function add_feedback_form_submit(Pieform $form, $values) {
db_commit
();
$newlist
=
ArtefactTypeComment
::
get_comments
(
10
,
0
,
'last'
,
$view
,
$artefact
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
showcomment
=
'last'
;
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$artefact
;
$newlist
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
// If you're anonymous and your message is moderated or private, then you won't
// be able to tell what happened to it. So we'll provide some more explanation in
...
...
htdocs/artefact/internal/blocktype/textbox/lib.php
View file @
9e5fce6d
...
...
@@ -63,7 +63,10 @@ class PluginBlocktypeTextbox extends PluginBlocktype {
if
(
$artefact
->
get
(
'allowcomments'
))
{
require_once
(
get_config
(
'docroot'
)
.
'lib/view.php'
);
$view
=
new
View
(
$viewid
);
$comments
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
,
$artefact
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
view
=
$view
;
$commentoptions
->
artefact
=
$artefact
;
$comments
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$commentcount
=
isset
(
$comments
->
count
)
?
$comments
->
count
:
0
;
$artefacturl
=
get_config
(
'wwwroot'
)
.
'artefact/artefact.php?view='
.
$viewid
.
'&artefact='
.
$configdata
[
'artefactid'
];
$smarty
->
assign
(
'artefacturl'
,
$artefacturl
);
...
...
htdocs/export/html/lib.php
View file @
9e5fce6d
...
...
@@ -385,9 +385,11 @@ class PluginExportHtml extends PluginExport {
// Include comments
if
(
$this
->
includefeedback
)
{
$feedback
=
null
;
$artefact
=
null
;
if
(
$feedback
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
,
$artefact
,
true
))
{
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
view
=
$view
;
$commentoptions
->
limit
=
0
;
$commentoptions
->
export
=
true
;
if
(
$feedback
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
))
{
$feedback
->
tablerows
=
$outputfilter
->
filter
(
$feedback
->
tablerows
);
}
$smarty
->
assign
(
'feedback'
,
$feedback
);
...
...
htdocs/group/report.php
View file @
9e5fce6d
...
...
@@ -31,6 +31,9 @@ if (!group_role_can_access_report($group, $role)) {
throw
new
AccessDeniedException
();
}
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
limit
=
0
;
$sharedviews
=
View
::
get_sharedviews_data
(
0
,
null
,
$group
->
id
);
$sharedviewscount
=
$sharedviews
->
count
;
$sharedviews
=
$sharedviews
->
data
;
...
...
@@ -41,7 +44,8 @@ foreach ($sharedviews as &$data) {
}
$view
=
new
View
(
$data
[
'id'
]);
$comments
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
);
$commentoptions
->
view
=
$view
;
$comments
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$extcommenters
=
0
;
$membercommenters
=
0
;
...
...
@@ -102,7 +106,8 @@ $groupviewscount = count($groupviews);
foreach
(
$groupviews
as
&
$data
)
{
$view
=
new
View
(
$data
[
'id'
]);
$comments
=
ArtefactTypeComment
::
get_comments
(
0
,
0
,
null
,
$view
);
$commentoptions
->
view
=
$view
;
$comments
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
$extcommenters
=
0
;
$membercommenters
=
0
;
...
...
htdocs/view/view.php
View file @
9e5fce6d
...
...
@@ -209,8 +209,12 @@ if ($USER->is_logged_in()) {
}
$viewbeingwatched
=
(
int
)
record_exists
(
'usr_watchlist_view'
,
'usr'
,
$USER
->
get
(
'id'
),
'view'
,
$viewid
);
$feedback
=
ArtefactTypeComment
::
get_comments
(
$limit
,
$offset
,
$showcomment
,
$view
);
$commentoptions
=
ArtefactTypeComment
::
get_comment_options
();
$commentoptions
->
limit
=
$limit
;
$commentoptions
->
offset
=
$offset
;
$commentoptions
->
showcomment
=
$showcomment
;
$commentoptions
->
view
=
$view
;
$feedback
=
ArtefactTypeComment
::
get_comments
(
$commentoptions
);
// Set up theme
$viewtheme
=
$view
->
get
(
'theme'
);
...
...
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