function make_annotation_feedback_public_submit(Pieform $form, $values) { global $USER; $annotationfeedback = new ArtefactTypeAnnotationFeedback((int) $values['annotationfeedbackid']); $annotationid = $annotationfeedback->get('onannotation'); $annotation = new ArtefactTypeAnnotation((int) $annotationid); $viewid = $values['viewid']; $view = new View($viewid); $relativeurl = $annotation->get_view_url($viewid, true, false); $url = get_config('wwwroot') . $relativeurl; $author = $annotationfeedback->get('author'); $owner = $annotationfeedback->get('owner'); $groupid = $annotationfeedback->get('group'); $group_admins = array(); if ($groupid) { $group_admins = group_get_admin_ids($groupid); } $requester = $USER->get('id'); if ($author == $owner && $requester == $owner || $requester == $owner && $annotationfeedback->get('requestpublic') == 'author' || array_search($requester, $group_admins) !== false && $annotationfeedback->get('requestpublic') == 'author' || $requester == $author && $annotationfeedback->get('requestpublic') == 'owner') { $annotationfeedback->set('private', 0); $annotationfeedback->set('requestpublic', null); $annotationfeedback->commit(); $form->reply(PIEFORM_OK, array('message' => get_string('annotationfeedbackmadepublic', 'artefact.annotation'), 'goto' => $url)); } $subject = 'makepublicrequestsubject'; if ($requester == $owner) { $annotationfeedback->set('requestpublic', 'owner'); $message = 'makepublicrequestbyownermessage'; $arg = display_name($owner, $author); $userid = $author; $sessionmessage = get_string('makepublicrequestsent', 'artefact.annotation', display_name($author)); } else { if ($requester == $author) { $annotationfeedback->set('requestpublic', 'author'); $message = 'makepublicrequestbyauthormessage'; $arg = display_name($author, $owner); $userid = $owner; $sessionmessage = get_string('makepublicrequestsent', 'artefact.annotation', display_name($owner)); } else { if (array_search($requester, $group_admins) !== false) { $annotationfeedback->set('requestpublic', 'owner'); $message = 'makepublicrequestbyownermessage'; $arg = display_name($requester, $author); $userid = $author; $sessionmessage = get_string('makepublicrequestsent', 'artefact.annotation', display_name($author)); } else { // Something is wrong. Go back to the view. redirect($url); } } } db_begin(); $annotationfeedback->commit(); $data = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => $subject, 'section' => 'artefact.annotation', 'args' => array()), 'message' => (object) array('key' => $message, 'section' => 'artefact.annotation', 'args' => array(hsc($arg))), 'urltext' => (object) array('key' => 'Annotation', 'section' => 'artefact.annotation')), 'users' => array($userid), 'url' => $relativeurl); activity_occurred('maharamessage', $data); db_commit(); $options = ArtefactTypeAnnotationfeedback::get_annotation_feedback_options(); $options->showcomment = $annotationfeedback->get('id'); $options->artefact = $values['artefactid']; $options->view = $viewid; $options->annotation = $annotationid; $options->block = $values['blockid']; $newlist = ArtefactTypeAnnotationfeedback::get_annotation_feedback($options); $form->reply(PIEFORM_OK, array('message' => $sessionmessage, 'goto' => $url, 'data' => $newlist)); }
* @package mahara * @subpackage artefact-annotation * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'myportfolio'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('editannotationfeedback', 'artefact.annotation')); safe_require('artefact', 'annotation'); $annotationfeedbackid = param_integer('id'); $viewid = param_integer('viewid'); $annotationfeedback = new ArtefactTypeAnnotationFeedback((int) $annotationfeedbackid); if ($USER->get('id') != $annotationfeedback->get('author')) { throw new AccessDeniedException(get_string('canteditnotauthor', 'artefact.annotation')); } $annotationid = $annotationfeedback->get('onannotation'); $annotation = new ArtefactTypeAnnotation($annotationid); $onview = $annotation->get('view'); if ($onview && $onview != $viewid) { throw new NotFoundException(get_string('annotationfeedbacknotinview', 'artefact.annotation', $annotationfeedbackid, $viewid)); } $maxage = (int) get_config_plugin('artefact', 'annotation', 'commenteditabletime'); $editableafter = time() - 60 * $maxage; $goto = $annotation->get_view_url($viewid, false); if ($annotationfeedback->get('ctime') < $editableafter) { $SESSION->add_error_msg(get_string('cantedittooold', 'artefact.annotation', $maxage)); redirect($goto); }