function deletepost_submit(Pieform $form, $values) { global $SESSION, $USER; $postid = $values['post']; $objectionable = get_record_sql("SELECT fp.id\n FROM {interaction_forum_post} fp\n JOIN {objectionable} o\n ON (o.objecttype = 'forum' AND o.objectid = fp.id)\n WHERE fp.id = ?\n AND o.resolvedby IS NULL\n AND o.resolvedtime IS NULL", array($postid)); if ($objectionable !== false) { // Trigger activity. $data = new StdClass(); $data->postid = $postid; $data->message = ''; $data->reporter = $USER->get('id'); $data->ctime = time(); $data->event = DELETE_OBJECTIONABLE_POST; activity_occurred('reportpost', $data, 'interaction', 'forum'); } update_record('interaction_forum_post', array('deleted' => 1), array('id' => $postid)); // Delete embedded images in the forum post description require_once 'embeddedimage.php'; EmbeddedImage::delete_embedded_images('post', $postid); $SESSION->add_ok_msg(get_string('deletepostsuccess', 'interaction.forum')); // Figure out which parent record to redirect us to. If the parent record is deleted, // keep moving up the chain until you find one that's not deleted. $postrec = new stdClass(); $postrec->parent = $values['parent']; do { $postrec = get_record('interaction_forum_post', 'id', $postrec->parent, null, null, null, null, 'id, deleted, parent'); } while ($postrec && $postrec->deleted && $postrec->parent); $redirecturl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic']; if ($postrec && $postrec->parent) { $redirecturl .= '&post=' . $postrec->id; } redirect($redirecturl); }
function deletegroup_submit(Pieform $form, $values) { require_once 'embeddedimage.php'; global $SESSION, $USER, $groupid; group_delete($groupid); EmbeddedImage::delete_embedded_images('group', $groupid); $SESSION->add_ok_msg(get_string('deletegroup', 'group')); redirect('/group/mygroups.php'); }
function delete_blog_submit(Pieform $form, $values) { global $SESSION; require_once 'embeddedimage.php'; $blog = new ArtefactTypeBlog($values['delete']); $blog->check_permission(); if ($blog->get('locked')) { $SESSION->add_error_msg(get_string('submittedforassessment', 'view')); } else { $blog->delete(); EmbeddedImage::delete_embedded_images('blog', $blog->get('id')); $SESSION->add_ok_msg(get_string('blogdeleted', 'artefact.blog')); } redirect('/artefact/blog/index.php'); }
function editgoalsandskills_submit(Pieform $form, array $values) { global $SESSION, $artefact, $USER; require_once 'embeddedimage.php'; $newdescription = EmbeddedImage::prepare_embedded_images($values['description'], $values['artefacttype'], $USER->get('id')); db_begin(); $artefact->set('title', get_string($values['artefacttype'], 'artefact.resume')); $artefact->set('description', $newdescription); $artefact->commit(); // Attachments $old = $artefact->attachment_id_list(); $new = is_array($values['filebrowser']) ? $values['filebrowser'] : array(); // only allow the attaching of files that exist and are editable by user foreach ($new as $key => $fileid) { $file = artefact_instance_from_id($fileid); if (!$file instanceof ArtefactTypeFile || !$USER->can_publish_artefact($file)) { unset($new[$key]); } } if (!empty($new) || !empty($old)) { foreach ($old as $o) { if (!in_array($o, $new)) { try { $artefact->detach($o); } catch (ArtefactNotFoundException $e) { } } } foreach ($new as $n) { if (!in_array($n, $old)) { try { $artefact->attach($n); } catch (ArtefactNotFoundException $e) { } } } } db_commit(); $result = array('error' => false, 'message' => get_string('goalandskillsaved', 'artefact.resume'), 'goto' => get_config('wwwroot') . 'artefact/resume/goalsandskills.php'); if ($form->submitted_by_js()) { // Redirect back to the resume goals and skills page from within the iframe $SESSION->add_ok_msg($result['message']); $form->json_reply(PIEFORM_OK, $result, false); } $form->reply(PIEFORM_OK, $result); }
function edit_comment_submit(Pieform $form, $values) { global $viewid, $comment, $SESSION, $goto, $USER; require_once 'embeddedimage.php'; db_begin(); $comment->set('rating', valid_rating($values['rating'])); require_once get_config('libroot') . 'view.php'; $view = new View($viewid); $owner = $view->get('owner'); $group = $comment->get('group'); $newdescription = EmbeddedImage::prepare_embedded_images($values['message'], 'comment', $comment->get('id'), $group); $comment->set('description', $newdescription); $approvecomments = $view->get('approvecomments'); if (!empty($group) && ($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !$USER->can_edit_view($view)) { $comment->set('requestpublic', 'author'); } else { if (($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && (!empty($owner) && $owner != $comment->get('author'))) { $comment->set('requestpublic', 'author'); } else { $comment->set('private', 1 - (int) $values['ispublic']); $comment->set('requestpublic', null); } } $comment->commit(); require_once 'activity.php'; $data = (object) array('commentid' => $comment->get('id'), 'viewid' => $viewid); activity_occurred('feedback', $data, 'artefact', 'comment'); if ($comment->get('requestpublic') == 'author') { if (!empty($owner)) { edit_comment_notify($view, $comment->get('author'), $owner); } else { if (!empty($group)) { $group_admins = group_get_admin_ids($group); // TODO: need to notify the group admins bug #1197197 } } } db_commit(); $SESSION->add_ok_msg(get_string('commentupdated', 'artefact.comment')); redirect($goto); }
function deletetopic_submit(Pieform $form, $values) { global $SESSION, $USER, $topicid; $objectionable = get_record_sql("SELECT fp.id\n FROM {interaction_forum_post} fp\n JOIN {objectionable} o\n ON (o.objecttype = 'forum' AND o.objectid = fp.id)\n WHERE fp.topic = ?\n AND fp.parent IS NULL\n AND o.resolvedby IS NULL\n AND o.resolvedtime IS NULL", array($topicid)); if ($objectionable !== false) { // Trigger activity. $data = new StdClass(); $data->postid = $objectionable->id; $data->message = ''; $data->reporter = $USER->get('id'); $data->ctime = time(); $data->event = DELETE_OBJECTIONABLE_TOPIC; activity_occurred('reportpost', $data, 'interaction', 'forum'); } // mark topic as deleted update_record('interaction_forum_topic', array('deleted' => 1), array('id' => $topicid)); EmbeddedImage::delete_embedded_images('topic', $topicid); // mark relevant posts as deleted update_record('interaction_forum_post', array('deleted' => 1), array('topic' => $topicid)); $SESSION->add_ok_msg(get_string('deletetopicsuccess', 'interaction.forum')); redirect('/interaction/forum/view.php?id=' . $values['forum']); }
/** * Rewrite extra config data for a Text blockinstance * * See more PluginBlocktype::import_rewrite_blockinstance_extra_config_leap() */ public static function import_rewrite_blockinstance_extra_config_leap(array $artefactids, array $configdata) { // Rewrite embedded image urls in the configdata['text'] require_once 'embeddedimage.php'; $configdata['text'] = EmbeddedImage::rewrite_embedded_image_urls_from_import($configdata['text'], $artefactids); return $configdata; }
function editview_submit(Pieform $form, $values) { global $new, $view, $SESSION, $urlallowed; $view->set('title', $values['title']); if (trim($values['description']) !== '') { // Add or update embedded images in the view description require_once 'embeddedimage.php'; $view->set('description', EmbeddedImage::prepare_embedded_images($values['description'], 'description', $view->get('id'))); } else { // deleting description $view->set('description', ''); } $view->set('tags', $values['tags']); if (isset($values['locked'])) { $view->set('locked', (int) $values['locked']); } if (isset($values['ownerformat']) && $view->get('owner')) { $view->set('ownerformat', $values['ownerformat']); } if (isset($values['anonymise'])) { $view->set('anonymise', (int) $values['anonymise']); } if (isset($values['urlid'])) { $view->set('urlid', strlen($values['urlid']) == 0 ? null : $values['urlid']); } else { if ($new && $urlallowed) { // Generate one automatically based on the title $desired = generate_urlid($values['title'], get_config('cleanurlviewdefault'), 3, 100); $ownerinfo = (object) array('owner' => $view->get('owner'), 'group' => $view->get('group')); $view->set('urlid', View::new_urlid($desired, $ownerinfo)); } } $SESSION->add_ok_msg(get_string('viewsavedsuccessfully', 'view')); $view->commit(); redirect('/view/blocks.php?id=' . $view->get('id')); }
public static function instance_config_save($values, $instance) { require_once 'embeddedimage.php'; safe_require('artefact', 'annotation'); $data = array(); $view = $instance->get_view(); $configdata = $instance->get('configdata'); foreach (array('owner', 'group', 'institution') as $f) { $data[$f] = $view->get($f); } // The title will always be Annotation. $title = get_string('Annotation', 'artefact.annotation'); $data['title'] = $title; $values['title'] = $title; if (empty($configdata['artefactid'])) { // This is a new annotation. $artefact = new ArtefactTypeAnnotation(0, $data); } else { // The user is editing the annotation. $artefact = new ArtefactTypeAnnotation($configdata['artefactid']); } $artefact->set('title', $title); $artefact->set('description', $values['text']); $artefact->set('allowcomments', !empty($values['allowfeedback']) ? $values['allowfeedback'] : 0); $artefact->set('tags', $values['tags']); $artefact->set('view', $view->get('id')); $artefact->commit(); // Now fix up the text in case there were any embedded images. // Do this after saving because we may not have an artefactid yet. $newdescription = EmbeddedImage::prepare_embedded_images($values['text'], 'annotation', $artefact->get('id'), $view->get('group')); if ($newdescription !== false && $newdescription !== $values['text']) { $updatedartefact = new stdClass(); $updatedartefact->id = $artefact->get('id'); $updatedartefact->description = $newdescription; update_record('artefact', $updatedartefact, 'id'); } $values['artefactid'] = $artefact->get('id'); $instance->save_artefact_instance($artefact); unset($values['text']); unset($values['allowfeedback']); unset($values['annotationreadonlymsg']); // Pass back a list of any other blocks that need to be rendered // due to this change. $values['_redrawblocks'] = array_unique(get_column('view_artefact', 'block', 'artefact', $values['artefactid'], 'view', $instance->get('view'))); return $values; }
function editpost_submit(Pieform $form, $values) { global $USER, $SESSION, $blogpost, $blog; require_once 'embeddedimage.php'; db_begin(); $postobj = new ArtefactTypeBlogPost($blogpost, null); $postobj->set('title', $values['title']); $postobj->set('description', $values['description']); $postobj->set('tags', $values['tags']); if (get_config('licensemetadata')) { $postobj->set('license', $values['license']); $postobj->set('licensor', $values['licensor']); $postobj->set('licensorurl', $values['licensorurl']); } $postobj->set('published', !$values['draft']); $postobj->set('allowcomments', (int) $values['allowcomments']); if (!$blogpost) { $postobj->set('parent', $blog); $blogobj = new ArtefactTypeBlog($blog); if ($blogobj->get('institution')) { $postobj->set('institution', $blogobj->get('institution')); } else { if ($blogobj->get('group')) { $postobj->set('group', $blogobj->get('group')); } else { $postobj->set('owner', $USER->id); } } } $postobj->commit(); $blogpost = $postobj->get('id'); // Need to wait until post is saved in case we are a new blogpost before we can sort out embedded images as we need an id $postobj->set('description', EmbeddedImage::prepare_embedded_images($values['description'], 'blogpost', $postobj->get('id'))); // Attachments $old = $postobj->attachment_id_list(); // $new = is_array($values['filebrowser']['selected']) ? $values['filebrowser']['selected'] : array(); $new = is_array($values['filebrowser']) ? $values['filebrowser'] : array(); // only allow the attaching of files that exist and are editable by user foreach ($new as $key => $fileid) { $file = artefact_instance_from_id($fileid); if (!$file instanceof ArtefactTypeFile || !$USER->can_publish_artefact($file)) { unset($new[$key]); } } if (!empty($new) || !empty($old)) { foreach ($old as $o) { if (!in_array($o, $new)) { try { $postobj->detach($o); } catch (ArtefactNotFoundException $e) { } } } foreach ($new as $n) { if (!in_array($n, $old)) { try { $postobj->attach($n); } catch (ArtefactNotFoundException $e) { } } } } db_commit(); $result = array('error' => false, 'message' => get_string('blogpostsaved', 'artefact.blog'), 'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog); if ($form->submitted_by_js()) { // Redirect back to the blog page from within the iframe $SESSION->add_ok_msg($result['message']); $form->json_reply(PIEFORM_OK, $result, false); } $form->reply(PIEFORM_OK, $result); }
public function commit() { if (empty($this->dirty)) { return; } $new = empty($this->id); db_begin(); parent::commit(); // Now fix up the text in case there were any embedded images. // Do this after saving because we may not have an artefactid yet. // This will add a record to the artefact_file_embedded table // for each file that is embedded in the feedback text. require_once 'embeddedimage.php'; $newtext = EmbeddedImage::prepare_embedded_images($this->get('description'), 'annotationfeedback', $this->id); if ($newtext !== false && $newtext !== $this->get('description')) { $updatedartefact = new stdClass(); $updatedartefact->id = $this->get('id'); $updatedartefact->description = $newtext; update_record('artefact', $updatedartefact, 'id'); } $data = (object) array('artefact' => $this->get('id'), 'onannotation' => $this->get('onannotation'), 'private' => $this->get('private'), 'deletedby' => $this->get('deletedby'), 'requestpublic' => $this->get('requestpublic')); if ($this->get('lastcontentupdate')) { $data->lastcontentupdate = db_format_timestamp($this->get('lastcontentupdate')); } if ($new) { insert_record('artefact_annotation_feedback', $data); } else { update_record('artefact_annotation_feedback', $data, 'artefact'); } // Get the block instance that contains this artefact // so we can add to the view any artefacts containted in the feedback text // as well as the feedback itself. $sql = "SELECT bi.*\n FROM {block_instance} bi\n INNER JOIN {view_artefact} va ON va.view = bi.view\n WHERE bi.blocktype = 'annotation'\n AND va.artefact = ?"; if ($blocks = get_records_sql_array($sql, array($this->get('onannotation')))) { require_once get_config('docroot') . 'blocktype/lib.php'; foreach ($blocks as $bi) { $block = new BlockInstance($bi->id); $blockconfig = $block->get('configdata'); if (isset($blockconfig['artefactid']) && $blockconfig['artefactid'] == $this->get('onannotation')) { // Currently, all annotations can only exist on views. // But, put the check anyway. if ($block->get('view')) { // We found the annotation we're inputting feedback for. // Rebuild the block's list and break out of the loop. $block->rebuild_artefact_list(); // Otherwise, we can do this but any images that were deleted while editing will still exist. // if (count_records_select('view_artefact', "view = {$block->get('view')} AND block = {$block->get('id')} AND artefact = {$this->get('id')}") == 0) { // // Insert the feedback record in the view_artefact table. // $va = new StdClass; // $va->view = $block->get('view'); // $va->block = $block->get('id'); // // this is the feedback id that was just inserted/updated. // $va->artefact = $this->get('id'); // insert_record('view_artefact', $va); // } // // // Get any artefacts (i.e. images) that may have been embedded // // in the feedback text. // $feedbackartefacts = artefact_get_references_in_html($this->get('description')); // if (count($feedbackartefacts) > 0) { // // // Get list of allowed artefacts. // // Please note that images owned by other users that are place on feedback // // will not be part of the view_artefact because the owner of the // // annotation does not own the image being placed on the feedback. // // Therefore, when exported as Leap2A, these images will not come through. // require_once('view.php'); // $searchdata = array( // 'extraselect' => array(array('fieldname' => 'id', 'type' => 'int', 'values' => $feedbackartefacts)), // 'userartefactsallowed' => true, // If this is a group view, the user can add personally owned artefacts // ); // $view = $block->get_view(); // list($allowedfeedbackartefacts, $count) = View::get_artefactchooser_artefacts( // $searchdata, // $view->get('owner'), // $view->get('group'), // $view->get('institution'), // true // ); // foreach ($feedbackartefacts as $id) { // $va = new StdClass; // $va->view = $block->get('view'); // $va->block = $block->get('id'); // if (isset($allowedfeedbackartefacts[$id]) || isset($old[$id])) { // // only insert artefacts that the view can actually own // // and which are not already in the view_artefact table. // $va->artefact = $id; // if (count_records_select('view_artefact', "view = {$block->get('view')} AND block = {$block->get('id')} AND artefact = {$id}") == 0) { // insert_record('view_artefact', $va); // } // } // } // } } break; } } } db_commit(); $this->dirty = false; }
function editgroup_submit(Pieform $form, $values) { global $USER, $SESSION, $group_data, $publicallowed; $values['public'] = isset($values['public']) ? $values['public'] : 0; $values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0; $newvalues = array('name' => $group_data->name == $values['name'] ? $values['name'] : trim($values['name']), 'description' => $values['description'], 'grouptype' => $values['grouptype'], 'category' => empty($values['category']) ? null : intval($values['category']), 'open' => intval($values['open']), 'controlled' => intval($values['controlled']), 'request' => intval($values['request']), 'usersautoadded' => intval($values['usersautoadded']), 'public' => $publicallowed ? intval($values['public']) : 0, 'viewnotify' => intval($values['viewnotify']), 'submittableto' => intval($values['submittableto']), 'allowarchives' => intval(!empty($values['allowarchives']) ? $values['allowarchives'] : 0), 'editroles' => $values['editroles'], 'hidden' => intval($values['hidden']), 'hidemembers' => intval(!empty($values['hidemembersfrommembers']) || !empty($values['hidemembers'])), 'hidemembersfrommembers' => intval($values['hidemembersfrommembers']), 'groupparticipationreports' => intval($values['groupparticipationreports']), 'invitefriends' => intval($values['invitefriends']), 'suggestfriends' => intval($values['suggestfriends']), 'editwindowstart' => db_format_timestamp($values['editwindowstart']), 'editwindowend' => db_format_timestamp($values['editwindowend']), 'sendnow' => intval($values['sendnow']), 'feedbacknotify' => intval($values['feedbacknotify'])); if (get_config('cleanurls') && isset($values['urlid']) && '' !== (string) $values['urlid']) { $newvalues['urlid'] = $values['urlid']; } db_begin(); if (!$group_data->id) { $newvalues['members'] = array($USER->get('id') => 'admin'); $group_data->id = group_create($newvalues); $USER->reset_grouproles(); } // Now update the description with any embedded image info $newvalues['description'] = EmbeddedImage::prepare_embedded_images($newvalues['description'], 'group', $group_data->id, $group_data->id); $newvalues['id'] = $group_data->id; unset($newvalues['members']); group_update((object) $newvalues); $SESSION->add_ok_msg(get_string('groupsaved', 'group')); db_commit(); // Reload $group_data->urlid or else the redirect will fail if (get_config('cleanurls') && (!isset($values['urlid']) || $group_data->urlid != $values['urlid'])) { $group_data->urlid = get_field('group', 'urlid', 'id', $group_data->id); } redirect(group_homepage_url($group_data)); }
function simple_resumefield_submit(Pieform $form, $values) { global $simple_resume_types, $simple_resume_artefacts, $USER; require_once 'embeddedimage.php'; $owner = $USER->get('id'); if (isset($values['coverletter'])) { $newcoverletter = EmbeddedImage::prepare_embedded_images($values['coverletter'], 'resumecoverletter', $USER->get('id')); $values['coverletter'] = $newcoverletter; } else { if (isset($values['interest'])) { $newinterest = EmbeddedImage::prepare_embedded_images($values['interest'], 'resumeinterest', $USER->get('id')); $values['interest'] = $newinterest; } } foreach ($simple_resume_types as $t) { if (isset($values[$t . 'submit']) && isset($values[$t])) { if (!isset($simple_resume_artefacts[$t])) { $classname = generate_artefact_class_name($t); $simple_resume_artefacts[$t] = new $classname(0, array('owner' => $USER->get('id'), 'title' => get_string($t))); } $simple_resume_artefacts[$t]->set('description', $values[$t]); $simple_resume_artefacts[$t]->commit(); $data = array('message' => get_string('goalandskillsaved', 'artefact.resume'), 'update' => $t, 'content' => clean_html($values[$t]), 'goto' => get_config('wwwroot') . $values['goto']); $form->reply(PIEFORM_OK, $data); } } $form->reply(PIEFORM_OK, array('goto' => get_config('wwwroot') . $values['goto'])); }
public function commit() { if (empty($this->dirty)) { return; } db_begin(); parent::commit(); // Update embedded images in the forum description require_once 'embeddedimage.php'; $newdescription = EmbeddedImage::prepare_embedded_images($this->description, 'forum', $this->id, $this->group); set_field('interaction_instance', 'description', $newdescription, 'id', $this->id); db_commit(); }
function editnote_submit(Pieform $form, array $values) { global $SESSION, $artefact, $goto; require_once 'embeddedimage.php'; db_begin(); $artefact->set('title', $values['title']); $newdescription = EmbeddedImage::prepare_embedded_images($values['description'], 'textbox', $artefact->get('id'), $artefact->get('group')); $artefact->set('description', $newdescription); $artefact->set('tags', $values['tags']); $artefact->set('allowcomments', (int) $values['allowcomments']); if (isset($values['perms'])) { $artefact->set('rolepermissions', $values['perms']); $artefact->set('dirty', true); } if (get_config('licensemetadata')) { $artefact->set('license', $values['license']); $artefact->set('licensor', $values['licensor']); $artefact->set('licensorurl', $values['licensorurl']); } $artefact->commit(); // Attachments $old = $artefact->attachment_id_list(); $new = is_array($values['filebrowser']) ? $values['filebrowser'] : array(); if (!empty($new) || !empty($old)) { foreach ($old as $o) { if (!in_array($o, $new)) { try { $artefact->detach($o); } catch (ArtefactNotFoundException $e) { } } } foreach ($new as $n) { if (!in_array($n, $old)) { try { $artefact->attach($n); } catch (ArtefactNotFoundException $e) { } } } } // need to update the block_instances where this artefact is used - so they have // the correct configuration artefactids if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefact->get('id'))) { require_once get_config('docroot') . 'blocktype/lib.php'; foreach ($blocks as $block) { $bi = new BlockInstance($block); $configdata = $bi->get('configdata'); $configdata['artefactids'] = $new; $bi->set('configdata', $configdata); $bi->commit(); } } db_commit(); $result = array('error' => false, 'message' => get_string('noteupdated', 'artefact.internal'), 'goto' => $goto); if ($form->submitted_by_js()) { // Redirect back to the note page from within the iframe $SESSION->add_ok_msg($result['message']); $form->json_reply(PIEFORM_OK, $result, false); } $form->reply(PIEFORM_OK, $result); }
function addpost_submit(Pieform $form, $values) { global $USER, $SESSION; require_once 'embeddedimage.php'; $parentid = param_integer('parent'); $post = (object) array('topic' => $values['topic'], 'poster' => $USER->get('id'), 'parent' => $parentid, 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time())); $sendnow = isset($values['sendnow']) && $values['sendnow'] ? 1 : 0; // See if the same content has been submitted in the last 5 seconds. If so, don't add this post. $oldpost = get_record_select('interaction_forum_post', 'topic = ? AND poster = ? AND parent = ? AND subject = ? AND body = ? AND ctime > ?', array($post->topic, $post->poster, $post->parent, $post->subject, $post->body, db_format_timestamp(time() - 5)), 'id'); if ($oldpost) { redirect(get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'] . '&post=' . $oldpost->id); } $postrec = new stdClass(); $postid = $postrec->id = insert_record('interaction_forum_post', $post, 'id', true); $postrec->path = get_field('interaction_forum_post', 'path', 'id', $parentid) . '/' . sprintf('%010d', $postrec->id); update_record('interaction_forum_post', $postrec); // Rewrite the post id into links in the body $groupid = get_groupid_from_postid($postid); $newbody = EmbeddedImage::prepare_embedded_images($post->body, 'post', $postid, $groupid); $newbody = PluginInteractionForum::prepare_post_body($newbody, $postid); if (!empty($newbody) && $newbody != $post->body) { set_field('interaction_forum_post', 'body', $newbody, 'id', $postid); } if ($sendnow == 0) { $delay = get_config_plugin('interaction', 'forum', 'postdelay'); } else { $delay = 0; } if (!is_null($delay) && $delay == 0) { PluginInteractionForum::interaction_forum_new_post(array($postid)); } $SESSION->add_ok_msg(get_string('addpostsuccess', 'interaction.forum')); if (is_using_probation() && $post->parent) { $parentposter = get_field('interaction_forum_post', 'poster', 'id', $post->parent); vouch_for_probationary_user($parentposter); } redirect(get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'] . '&post=' . $postid); }
function deletenote_submit(Pieform $form, array $values) { global $SESSION, $data, $baseurl; require_once 'embeddedimage.php'; $id = $data[$values['delete']]->id; $note = new ArtefactTypeHtml($id); $note->delete(); EmbeddedImage::delete_embedded_images('editnote', $id); $SESSION->add_ok_msg(get_string('notedeleted', 'artefact.internal')); redirect($baseurl); }
function edit_interaction_submit(Pieform $form, $values) { require_once 'embeddedimage.php'; safe_require('interaction', $values['plugin']); $classname = generate_interaction_instance_class_name($values['plugin']); $instance = new $classname($values['id']); $instance->set('creator', $values['creator']); $instance->set('title', $values['title']); $newdescription = EmbeddedImage::prepare_embedded_images($values['description'], 'forum', $instance->get('id'), $instance->get('group')); $instance->set('description', $newdescription); if (empty($values['id'])) { $instance->set('group', $values['group']); } $instance->commit(); call_static_method(generate_class_name('interaction', $values['plugin']), 'instance_config_save', $instance, $values); global $SESSION; $SESSION->add_ok_msg(get_string('interactionsaved', 'group', get_string('name', 'interaction.' . $values['plugin']))); $returnto = param_alpha('returnto', 'view'); if ($returnto == 'index') { redirect('/interaction/' . $values['plugin'] . '/index.php?group=' . $instance->get('group')); } else { redirect('/interaction/' . $values['plugin'] . '/view.php?id=' . $instance->get('id')); } }
function edittopic_submit(Pieform $form, $values) { global $SESSION, $USER, $topic; $topicid = param_integer('id'); $returnto = param_alpha('returnto', 'topic'); $groupid = get_field_sql("SELECT DISTINCT i.group FROM {interaction_instance} i\n INNER JOIN {interaction_forum_topic} t ON i.id = t.forum\n WHERE t.id =?", array($topicid)); db_begin(); // check the post content actually changed // otherwise topic could have been set as sticky/closed $postchanged = $values['subject'] != $topic->subject || $values['body'] != $topic->body; if ($postchanged) { $newbody = EmbeddedImage::prepare_embedded_images($values['body'], 'topic', $topicid, $groupid); update_record('interaction_forum_post', array('subject' => $values['subject'], 'body' => PluginInteractionForum::prepare_post_body($newbody, $values['post'])), array('id' => $values['post'])); } if ($values['editrecord'] && $postchanged) { insert_record('interaction_forum_edit', (object) array('user' => $USER->get('id'), 'post' => $values['post'], 'ctime' => db_format_timestamp(time()))); } if (isset($values['sticky'])) { update_record('interaction_forum_topic', array('sticky' => isset($values['sticky']) && $values['sticky'] == 1 ? 1 : 0, 'closed' => isset($values['closed']) && $values['closed'] == 1 ? 1 : 0), array('id' => $topicid)); } db_commit(); $SESSION->add_ok_msg(get_string('edittopicsuccess', 'interaction.forum')); if ($returnto == 'view') { redirect('/interaction/forum/view.php?id=' . $topic->forum); } else { redirect('/interaction/forum/topic.php?id=' . $topicid); } }
/** * Check if the image is embedded in an artefact of type: * comment, annotation, annotationfeedback, blog, textbox, editnote, text. * Please check first that the fileid is of type ArtefactTypeImage and that the download * is called with the embedded flag set. * * @param int $fileid the id of the file to check. * @param array $includeresourcetypes an array of extra artefact types to include in the check. * @param array $excluderesourcetypes an array of artefact types to exclude from the check. * @return boolean TRUE the image is visible; FALSE the image is not visible. */ function check_is_embedded_image_visible($fileid, $includeresourcetypes = null, $excluderesourcetypes = null) { $isvisible = false; // Check for resource types a file may be embeded in. $resourcetypes = array('comment', 'annotation', 'annotationfeedback', 'blog', 'textbox', 'editnote', 'text'); if (!empty($includeresourcetypes)) { if (!is_array($includeresourcetypes)) { $includeresourcetypes = array($includeresourcetypes); } $resourcetypes = array_merge($defaultresourcetypes, $includeresourcetypes); } if (!empty($excluderesourcetypes)) { if (!is_array($excluderesourcetypes)) { $excluderesourcetypes = array($excluderesourcetypes); } $resourcetypes = array_diff($resourcetypes, $excluderesourcetypes); } foreach ($resourcetypes as $resourcetype) { $resourceid = param_integer($resourcetype, null); if ($resourceid) { $isvisible = EmbeddedImage::can_see_embedded_image($fileid, $resourcetype, $resourceid); } if ($isvisible) { break; } } return $isvisible; }
function profileform_submit(Pieform $form, $values) { global $SESSION; global $USER; global $element_list; global $profilefields; require_once 'embeddedimage.php'; db_begin(); $now = db_format_timestamp(time()); $email_errors = array(); $lockedfields = locked_profile_fields(); foreach ($element_list as $element => $type) { if (isset($lockedfields[$element]) && !$USER->get('admin')) { continue; } if ($element == 'email') { if (!isset($values['email']['unsent'])) { $values['email']['unsent'] = array(); } // find new addresses foreach ($values['email']['unsent'] as $email) { if (in_array($email, $profilefields['email']['validated']) || in_array($email, $profilefields['email']['unvalidated'])) { continue; } $key = get_random_key(); $key_url = get_config('wwwroot') . 'artefact/internal/validate.php?email=' . rawurlencode($email) . '&key=' . $key; $key_url_decline = $key_url . '&decline=1'; try { $sitename = get_config('sitename'); email_user((object) array('id' => $USER->get('id'), 'username' => $USER->get('username'), 'firstname' => $USER->get('firstname'), 'lastname' => $USER->get('lastname'), 'preferredname' => $USER->get('preferredname'), 'admin' => $USER->get('admin'), 'staff' => $USER->get('staff'), 'email' => $email), null, get_string('emailvalidation_subject', 'artefact.internal'), get_string('emailvalidation_body1', 'artefact.internal', $USER->get('firstname'), $email, $sitename, $key_url, $sitename, $key_url_decline)); } catch (EmailException $e) { $email_errors[] = $email; } insert_record('artefact_internal_profile_email', (object) array('owner' => $USER->get('id'), 'email' => $email, 'verified' => 0, 'key' => $key, 'expiry' => db_format_timestamp(time() + 86400))); } // remove old addresses foreach ($profilefields['email']['validated'] as $email) { if (in_array($email, $values['email']['validated'])) { continue; } if (!empty($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) { continue; } $artefact_id = get_field('artefact_internal_profile_email', 'artefact', 'email', $email, 'owner', $USER->get('id')); delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id')); if ($artefact_id) { $artefact = new ArtefactTypeEmail($artefact_id); $artefact->delete(); // this is unset here to force the destructor to run now, // rather than script exit time where it doesn't like // throwing exceptions properly unset($artefact); } } foreach ($profilefields['email']['unvalidated'] as $email) { if (in_array($email, $values['email']['validated']) || isset($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) { continue; } delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id')); } if ($profilefields['email']['default'] != $values['email']['default']) { update_record('artefact_internal_profile_email', (object) array('principal' => 0), (object) array('owner' => $USER->get('id'), 'email' => $profilefields['email']['default'])); update_record('artefact_internal_profile_email', (object) array('principal' => 1), (object) array('owner' => $USER->get('id'), 'email' => $values['email']['default'])); update_record('usr', (object) array('email' => $values['email']['default']), (object) array('id' => $USER->get('id'))); $USER->email = $values['email']['default']; $USER->commit(); } } else { if ($element == 'maildisabled') { continue; } else { if ($element == 'socialprofile') { continue; } else { if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]) { if ($element == 'introduction') { $newintroduction = EmbeddedImage::prepare_embedded_images($values[$element], 'profileintrotext', $USER->get('id')); $values[$element] = $newintroduction; } $classname = generate_artefact_class_name($element); $profile = new $classname(0, array('owner' => $USER->get('id'))); $profile->set('title', $values[$element]); $profile->commit(); } } } } } try { db_commit(); } catch (Exception $e) { profileform_reply($form, PIEFORM_ERR, get_string('profilefailedsaved', 'artefact.internal')); } handle_event('updateuser', $USER->get('id')); if (count($email_errors)) { profileform_reply($form, PIEFORM_ERR, array('message' => get_string('emailingfailed', 'artefact.internal', join(', ', $email_errors)))); } profileform_reply($form, PIEFORM_OK, get_string('profilesaved', 'artefact.internal')); }
public function update_artefact_references(&$view, &$template, &$artefactcopies, $oldid) { parent::update_artefact_references($view, $template, $artefactcopies, $oldid); // 1. Attach copies of the files that were attached to the old post. if (isset($artefactcopies[$oldid]->oldattachments)) { foreach ($artefactcopies[$oldid]->oldattachments as $a) { if (isset($artefactcopies[$a])) { $this->attach($artefactcopies[$a]->newid); } } } // 2. Update embedded images in the post body field $regexp = array(); $replacetext = array(); if (isset($artefactcopies[$oldid]->oldembeds)) { foreach ($artefactcopies[$oldid]->oldembeds as $a) { if (isset($artefactcopies[$a])) { // Change the old image id to the new one $regexp[] = '#<img([^>]+)src="' . get_config('wwwroot') . 'artefact/file/download.php\\?file=' . $a . '(&|&)embedded=1(.*?"[^>]+)#'; $replacetext[] = '<img$1src="' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactcopies[$a]->newid . '$2embedded=1$3'; } } require_once 'embeddedimage.php'; $newdescription = EmbeddedImage::prepare_embedded_images(preg_replace($regexp, $replacetext, $this->get('description')), 'blogpost', $this->get('id'), $view->get('group')); $this->set('description', $newdescription); } }
public static function instance_config_save($values, $instance) { global $USER; require_once 'embeddedimage.php'; $data = array(); $view = $instance->get_view(); foreach (array('owner', 'group', 'institution') as $f) { $data[$f] = $view->get($f); } if (empty($values['artefactid']) || $values['makecopy']) { // The artefact title will be the same as the block title when the // artefact is first created, or, if there's no block title, generate // 'Note (1)', 'Note (2)', etc. After that, the artefact title can't // be edited inside the block, but can be changed in the Notes area. if (empty($values['title'])) { $title = artefact_new_title(get_string('Note', 'artefact.internal'), 'html', $data['owner'], $data['group'], $data['institution']); } else { $title = $values['title']; } $artefact = new ArtefactTypeHtml(0, $data); $artefact->set('title', $title); $artefact->set('description', $values['text']); if (get_config('licensemetadata')) { $artefact->set('license', $values['license']); $artefact->set('licensor', $values['licensor']); $artefact->set('licensorurl', $values['licensorurl']); } $artefact->set('allowcomments', !empty($values['allowcomments']) ? $values['allowcomments'] : 0); $artefact->set('tags', $values['tags']); } else { $artefact = new ArtefactTypeHtml((int) $values['artefactid']); if (!$USER->can_publish_artefact($artefact)) { throw new AccessDeniedException(get_string('nopublishpermissiononartefact', 'mahara', hsc($artefact->get('title')))); } // Stop users from editing textbox artefacts whose owner is not the same as the // view owner, even if they would normally be allowed to edit the artefact. // It's too confusing. Textbox artefacts with other owners *can* be included in // the view read-only, provided the artefact has the correct republish // permission. if ($artefact->get('owner') === $data['owner'] && $artefact->get('group') === $data['group'] && $artefact->get('institution') === $data['institution'] && !$artefact->get('locked') && $USER->can_edit_artefact($artefact)) { $newdescription = EmbeddedImage::prepare_embedded_images($values['text'], 'textbox', (int) $values['artefactid'], $view->get('group')); $artefact->set('description', $newdescription); if (get_config('licensemetadata')) { $artefact->set('license', $values['license']); $artefact->set('licensor', $values['licensor']); $artefact->set('licensorurl', $values['licensorurl']); } $artefact->set('tags', $values['tags']); $artefact->set('allowcomments', !empty($values['allowcomments']) ? 1 : 0); } } $artefact->commit(); $newdescription = EmbeddedImage::prepare_embedded_images($values['text'], 'textbox', $artefact->get('id'), $view->get('group')); if ($newdescription !== $values['text']) { $updatedartefact = new stdClass(); $updatedartefact->id = $artefact->get('id'); $updatedartefact->description = $newdescription; update_record('artefact', $updatedartefact, 'id'); } // Add attachments, if there are any... $old = $artefact->attachment_id_list(); $new = is_array($values['artefactids']) ? $values['artefactids'] : array(); // only allow the attaching of files that exist and are editable by user foreach ($new as $key => $fileid) { $file = artefact_instance_from_id($fileid); if (!$file instanceof ArtefactTypeFile || !$USER->can_publish_artefact($file)) { unset($new[$key]); } } if (!empty($new) || !empty($old)) { foreach ($old as $o) { if (!in_array($o, $new)) { try { $artefact->detach($o); } catch (ArtefactNotFoundException $e) { } } } foreach ($new as $n) { if (!in_array($n, $old)) { try { $artefact->attach($n); } catch (ArtefactNotFoundException $e) { } } } } $values['artefactid'] = $artefact->get('id'); $instance->save_artefact_instance($artefact); unset($values['text']); unset($values['otherblocksmsg']); unset($values['readonlymsg']); unset($values['textreadonly']); unset($values['makecopy']); unset($values['chooseartefact']); unset($values['managenotes']); unset($values['allowcomments']); // Pass back a list of any other blocks that need to be rendered // due to this change. $values['_redrawblocks'] = array_unique(get_column('view_artefact', 'block', 'artefact', $values['artefactid'], 'view', $instance->get('view'))); return $values; }
/** * Deletes a group. * * All group deleting should be done through this function, even though it is * simple. What is required to perform group deletion may change over time. * * @param int $groupid The group to delete * @param string $shortname shortname of the group * @param string $institution institution of the group * * {{@internal Maybe later we can have a group_can_be_deleted function if * necessary}} */ function group_delete($groupid, $shortname = null, $institution = null, $notifymembers = true) { if (empty($groupid) && !empty($institution) && !is_null($shortname) && strlen($shortname)) { // External call to delete a group, check permission of $USER. global $USER; if (!$USER->can_edit_institution($institution)) { throw new AccessDeniedException("group_delete: cannot delete a group in this institution"); } $group = get_record('group', 'shortname', $shortname, 'institution', $institution); } else { $groupid = group_param_groupid($groupid); $group = get_record('group', 'id', $groupid); } db_begin(); // Leave the group_member table alone, it's needed for the deleted // group notification that's about to happen on cron. delete_records('group_member_invite', 'group', $group->id); delete_records('group_member_request', 'group', $group->id); delete_records('view_access', 'group', $group->id); // Delete embedded images in the group description require_once 'embeddedimage.php'; EmbeddedImage::delete_embedded_images('group', $group->id); // Delete views owned by the group require_once get_config('libroot') . 'view.php'; foreach (get_column('view', 'id', 'group', $group->id) as $viewid) { $view = new View($viewid); $view->delete(); } // Release views submitted to the group foreach (get_column('view', 'id', 'submittedgroup', $group->id) as $viewid) { $view = new View($viewid); $view->release(); } // Delete artefacts require_once get_config('docroot') . 'artefact/lib.php'; ArtefactType::delete_by_artefacttype(get_column('artefact', 'id', 'group', $group->id)); // Delete forums require_once get_config('docroot') . 'interaction/lib.php'; foreach (get_column('interaction_instance', 'id', 'group', $group->id) as $forumid) { $forum = interaction_instance_from_id($forumid); $forum->delete(); } if ($notifymembers) { require_once 'activity.php'; activity_occurred('groupmessage', array('group' => $group->id, 'deletedgroup' => true, 'strings' => (object) array('subject' => (object) array('key' => 'deletegroupnotificationsubject', 'section' => 'group', 'args' => array(hsc($group->name))), 'message' => (object) array('key' => 'deletegroupnotificationmessage', 'section' => 'group', 'args' => array(hsc($group->name), get_config('sitename')))))); } // make sure the group name + deleted suffix will fit within 128 chars $delete_name = $group->name; if (strlen($delete_name) > 100) { $delete_name = substr($delete_name, 0, 100) . '(...)'; } update_record('group', array('deleted' => 1, 'name' => $delete_name . '.deleted.' . time(), 'shortname' => null, 'institution' => null, 'category' => null, 'urlid' => null), array('id' => $group->id)); db_commit(); }
public function delete() { safe_require('artefact', 'comment'); db_begin(); ArtefactTypeComment::delete_view_comments($this->id); delete_records('view_access', 'view', $this->id); delete_records('view_autocreate_grouptype', 'view', $this->id); delete_records('view_tag', 'view', $this->id); delete_records('view_visit', 'view', $this->id); delete_records('collection_view', 'view', $this->id); delete_records('usr_watchlist_view', 'view', $this->id); if ($blockinstanceids = get_column('block_instance', 'id', 'view', $this->id)) { require_once get_config('docroot') . 'blocktype/lib.php'; foreach ($blockinstanceids as $id) { $bi = new BlockInstance($id); $bi->delete(); } } handle_event('deleteview', $this->id); delete_records('view_rows_columns', 'view', $this->id); delete_records('view', 'id', $this->id); if (!empty($this->owner) && $this->is_submitted()) { // There should be no way to delete a submitted view, // but unlock its artefacts just in case. ArtefactType::update_locked($this->owner); } require_once 'embeddedimage.php'; EmbeddedImage::delete_embedded_images('description', $this->id); $this->deleted = true; db_commit(); }
/** * Import an Mahara view from request * @throws ImportException */ public function import_view_from_request($entry_request) { $viewdata = unserialize($entry_request->entrycontent); $view = View::import_from_config($this->rewrite_blockinstance_config($viewdata), $this->get('usr'), 'leap'); // Rewrite embedded image urls in the view description // These links have been generated by export_leap_rewrite_links() require_once 'embeddedimage.php'; $newdescription = EmbeddedImage::rewrite_embedded_image_urls_from_import($view->get('description'), $this->artefactids, 'description', $view->get('id')); $view->set('description', $newdescription); if (isset($viewdata->ctime)) { $view->set('ctime', $viewdata->ctime); } if (isset($viewdata->mtime)) { $view->set('mtime', $viewdata->mtime); } $view->set('owner', $this->get('usr')); $view->commit(); $this->viewids[$entry_request->entryid] = $view->get('id'); }
/** * This function extends ArtefactType::delete() by deleting embedded images */ public function delete() { if (empty($this->id)) { return; } db_begin(); // Delete embedded images in the note require_once 'embeddedimage.php'; EmbeddedImage::delete_embedded_images('textbox', $this->id); // Delete the artefact and all children. parent::delete(); db_commit(); }
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'); } else { $data->onview = $view->get('id'); $data->owner = $view->get('owner'); $data->group = $view->get('group'); $data->institution = $view->get('institution'); } $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']) { $data->parent = $values['replyto']; } $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); $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')); // We want to add the user placing the comment to the watchlist so they // can get notified about future comments to the page. // @TODO Add a site/institution preference to override this. $updatelink = false; if (!get_field('usr_watchlist_view', 'ctime', 'usr', $author, 'view', $view->get('id')) && $author != $owner) { insert_record('usr_watchlist_view', (object) array('usr' => $author, 'view' => $view->get('id'), 'ctime' => db_format_timestamp(time()))); $updatelink = $artefact ? get_string('removefromwatchlistartefact', 'view', $view->get('title')) : get_string('removefromwatchlist', 'view'); } activity_occurred('feedback', $data, 'artefact', 'comment'); if (isset($moderatemsg)) { activity_occurred('maharamessage', $moderatemsg); } db_commit(); $commentoptions = ArtefactTypeComment::get_comment_options(); $commentoptions->showcomment = $comment->get('id'); $commentoptions->view = $view; $commentoptions->artefact = $artefact; $newlist = ArtefactTypeComment::get_comments($commentoptions); $newlist->updatelink = $updatelink; // 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)); }
/** * This function extends ArtefactType::delete() by also deleting anything * that's in blogpost. */ public function delete() { if (empty($this->id)) { return; } require_once 'embeddedimage.php'; db_begin(); $this->detach(); // Detach all file attachments delete_records('artefact_blog_blogpost', 'blogpost', $this->id); EmbeddedImage::delete_embedded_images('blogpost', $this->id); parent::delete(); db_commit(); }
public static function delete_instance($instance) { require_once 'embeddedimage.php'; EmbeddedImage::delete_embedded_images('introtext', $instance->get('id')); }