本文整理汇总了PHP中ArtefactTypeComment::get_view_url方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::get_view_url方法的具体用法?PHP ArtefactTypeComment::get_view_url怎么用?PHP ArtefactTypeComment::get_view_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::get_view_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('TITLE', get_string('editcomment', 'artefact.comment'));
safe_require('artefact', 'comment');
$id = param_integer('id');
$viewid = param_integer('view');
$comment = new ArtefactTypeComment($id);
if ($USER->get('id') != $comment->get('author')) {
throw new AccessDeniedException(get_string('canteditnotauthor', 'artefact.comment'));
}
$onview = $comment->get('onview');
if ($onview && $onview != $viewid) {
throw new NotFoundException(get_string('commentnotinview', 'artefact.comment', $id, $viewid));
}
$maxage = (int) get_config_plugin('artefact', 'comment', 'commenteditabletime');
$editableafter = time() - 60 * $maxage;
$goto = $comment->get_view_url($viewid, false);
if ($comment->get('ctime') < $editableafter) {
$SESSION->add_error_msg(get_string('cantedittooold', 'artefact.comment', $maxage));
redirect($goto);
}
$lastcomment = ArtefactTypeComment::last_public_comment($viewid, $comment->get('onartefact'));
if (!$comment->get('private') && $id != $lastcomment->id) {
$SESSION->add_error_msg(get_string('cantedithasreplies', 'artefact.comment'));
redirect($goto);
}
$elements = array();
$elements['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'rows' => 5, 'cols' => 80, 'defaultvalue' => $comment->get('description'), 'rules' => array('maxlength' => 8192));
if (get_config_plugin('artefact', 'comment', 'commentratings')) {
$elements['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star', 'defaultvalue' => $comment->get('rating'));
} else {
$elements['rating'] = array('type' => 'hidden', 'value' => $comment->get('rating'));
示例2: add_feedback_form_submit
function add_feedback_form_submit(Pieform $form, $values)
{
global $view, $artefact, $USER;
$data = (object) array('title' => get_string('Comment', 'artefact.comment'), 'description' => $values['message']);
if ($artefact) {
$data->onartefact = $artefact->get('id');
$data->owner = $artefact->get('owner');
$data->group = $artefact->get('group');
$data->institution = $artefact->get('institution');
} else {
$data->onview = $view->get('id');
$data->owner = $view->get('owner');
$data->group = $view->get('group');
$data->institution = $view->get('institution');
}
if ($author = $USER->get('id')) {
$anonymous = false;
$data->author = $author;
} else {
$anonymous = true;
$data->authorname = $values['authorname'];
}
if (isset($values['moderate']) && $values['ispublic'] && !$USER->can_edit_view($view)) {
$data->private = 1;
$data->requestpublic = 'author';
$moderated = true;
} else {
$data->private = (int) (!$values['ispublic']);
$moderated = false;
}
$private = $data->private;
if (get_config('licensemetadata')) {
$data->license = $values['license'];
$data->licensor = $values['licensor'];
$data->licensorurl = $values['licensorurl'];
}
if (isset($values['rating'])) {
$data->rating = valid_rating($values['rating']);
}
$comment = new ArtefactTypeComment(0, $data);
db_begin();
$comment->commit();
$url = $comment->get_view_url($view->get('id'), true, false);
$goto = get_config('wwwroot') . $url;
if (isset($data->requestpublic) && $data->requestpublic === 'author' && $data->owner) {
$arg = $author ? display_name($USER, null, true) : $data->authorname;
$moderatemsg = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'makepublicrequestsubject', 'section' => 'artefact.comment', 'args' => array()), 'message' => (object) array('key' => 'makepublicrequestbyauthormessage', 'section' => 'artefact.comment', 'args' => array(hsc($arg))), 'urltext' => (object) array('key' => 'Comment', 'section' => 'artefact.comment')), 'users' => array($data->owner), 'url' => $url);
}
if (!empty($values['attachments']) && is_array($values['attachments']) && !empty($data->author)) {
require_once get_config('libroot') . 'uploadmanager.php';
safe_require('artefact', 'file');
$ownerlang = empty($data->owner) ? get_config('lang') : get_user_language($data->owner);
$folderid = ArtefactTypeFolder::get_folder_id(get_string_from_language($ownerlang, 'feedbackattachdirname', 'artefact.comment'), get_string_from_language($ownerlang, 'feedbackattachdirdesc', 'artefact.comment'), null, true, $data->owner, $data->group, $data->institution);
$attachment = (object) array('owner' => $data->owner, 'group' => $data->group, 'institution' => $data->institution, 'author' => $data->author, 'allowcomments' => 0, 'parent' => $folderid, 'description' => get_string_from_language($ownerlang, 'feedbackonviewbyuser', 'artefact.comment', $view->get('title'), display_name($USER)));
foreach ($values['attachments'] as $filesindex) {
$originalname = $_FILES[$filesindex]['name'];
$attachment->title = ArtefactTypeFileBase::get_new_file_title($originalname, $folderid, $data->owner, $data->group, $data->institution);
try {
$fileid = ArtefactTypeFile::save_uploaded_file($filesindex, $attachment);
} catch (QuotaExceededException $e) {
if ($data->owner == $USER->get('id')) {
$form->reply(PIEFORM_ERR, array('message' => $e->getMessage()));
}
redirect($goto);
} catch (UploadException $e) {
$form->reply(PIEFORM_ERR, array('message' => $e->getMessage()));
redirect($goto);
}
$comment->attach($fileid);
}
}
require_once 'activity.php';
$data = (object) array('commentid' => $comment->get('id'), 'viewid' => $view->get('id'));
activity_occurred('feedback', $data, 'artefact', 'comment');
if (isset($moderatemsg)) {
activity_occurred('maharamessage', $moderatemsg);
}
db_commit();
$newlist = ArtefactTypeComment::get_comments(10, 0, 'last', $view, $artefact);
// 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
// the feedback message.
if ($anonymous && $moderated) {
$message = get_string('feedbacksubmittedmoderatedanon', 'artefact.comment');
} else {
if ($anonymous && $private) {
$message = get_string('feedbacksubmittedprivateanon', 'artefact.comment');
} else {
$message = get_string('feedbacksubmitted', 'artefact.comment');
}
}
$form->reply(PIEFORM_OK, array('message' => $message, 'goto' => $goto, 'data' => $newlist));
}
示例3: add_feedback_form_submit
function add_feedback_form_submit(Pieform $form, $values)
{
global $view, $artefact, $USER;
require_once 'embeddedimage.php';
$data = (object) array('title' => get_string('Comment', 'artefact.comment'), 'description' => $values['message']);
if ($artefact) {
$data->onartefact = $artefact->get('id');
$data->owner = $artefact->get('owner');
$data->group = $artefact->get('group');
$data->institution = $artefact->get('institution');
$onvieworartefactstr = "onartefact = {$data->onartefact}";
} else {
$data->onview = $view->get('id');
$data->owner = $view->get('owner');
$data->group = $view->get('group');
$data->institution = $view->get('institution');
$onvieworartefactstr = "onview = {$data->onview}";
}
$owner = $data->owner;
$author = null;
if ($author = $USER->get('id')) {
$anonymous = false;
$data->author = $author;
} else {
$anonymous = true;
$data->authorname = $values['authorname'];
}
if (isset($values['moderate']) && $values['ispublic'] && !$USER->can_edit_view($view)) {
$data->private = 1;
$data->requestpublic = 'author';
$moderated = true;
} else {
$data->private = (int) (!$values['ispublic']);
$moderated = false;
}
$private = $data->private;
if (get_config('licensemetadata')) {
$data->license = $values['license'];
$data->licensor = $values['licensor'];
$data->licensorurl = $values['licensorurl'];
}
if (isset($values['rating'])) {
$data->rating = valid_rating($values['rating']);
}
if ($values['replyto'] && ($pcomment = artefact_instance_from_id($values['replyto']))) {
$data->parent = $pcomment->get('id');
$grandparentid = $pcomment->get('parent');
// Find the position for the new comment
// Find the last offspring of the parent
$parentid = $data->parent;
$data->threadedposition = $pcomment->get('threadedposition');
while ($lastchild = get_records_sql_array('
SELECT c.artefact, c.threadedposition
FROM {artefact_comment_comment} c
INNER JOIN {artefact} a ON a.id = c.artefact
WHERE
' . $onvieworartefactstr . '
AND a.parent = ?
ORDER BY c.threadedposition DESC
LIMIT 1', array($parentid))) {
$parentid = $lastchild[0]->artefact;
$data->threadedposition = $lastchild[0]->threadedposition;
}
$data->threadedposition++;
// Increase the threaded position of following comments by 1
execute_sql('
UPDATE {artefact_comment_comment}
SET threadedposition = threadedposition + 1
WHERE
' . $onvieworartefactstr . '
AND threadedposition >= ?', array($data->threadedposition));
}
if (!isset($data->threadedposition)) {
$lastcomment = get_record_sql('
SELECT max(threadedposition) AS lastposition
FROM {artefact_comment_comment} c
WHERE
' . $onvieworartefactstr);
$data->threadedposition = $lastcomment->lastposition ? $lastcomment->lastposition + 1 : 1;
}
$comment = new ArtefactTypeComment(0, $data);
db_begin();
$comment->commit();
$newdescription = EmbeddedImage::prepare_embedded_images($values['message'], 'comment', $comment->get('id'), $data->group);
if ($newdescription !== $values['message']) {
$updatedcomment = new stdClass();
$updatedcomment->id = $comment->get('id');
$updatedcomment->description = $newdescription;
update_record('artefact', $updatedcomment, 'id');
}
$url = $comment->get_view_url($view->get('id'), true, false);
$goto = get_config('wwwroot') . $url;
if (isset($data->requestpublic) && $data->requestpublic === 'author' && $data->owner) {
$arg = $author ? display_name($USER, null, true) : $data->authorname;
$moderatemsg = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'makepublicrequestsubject', 'section' => 'artefact.comment', 'args' => array()), 'message' => (object) array('key' => 'makepublicrequestbyauthormessage', 'section' => 'artefact.comment', 'args' => array(hsc($arg))), 'urltext' => (object) array('key' => 'Comment', 'section' => 'artefact.comment')), 'users' => array($data->owner), 'url' => $url);
}
if (!empty($values['attachments']) && is_array($values['attachments']) && !empty($data->author)) {
require_once get_config('libroot') . 'uploadmanager.php';
safe_require('artefact', 'file');
$ownerlang = empty($data->owner) ? get_config('lang') : get_user_language($data->owner);
//.........这里部分代码省略.........