public function commit() { if (empty($this->dirty)) { return; } $new = empty($this->id); db_begin(); parent::commit(); $data = (object) array('artefact' => $this->get('id'), 'onview' => $this->get('onview'), 'onartefact' => $this->get('onartefact'), 'private' => $this->get('private'), 'deletedby' => $this->get('deletedby'), 'requestpublic' => $this->get('requestpublic'), 'rating' => $this->get('rating')); if ($this->get('lastcontentupdate')) { $data->lastcontentupdate = db_format_timestamp($this->get('lastcontentupdate')); } if ($new) { insert_record('artefact_comment_comment', $data); } else { update_record('artefact_comment_comment', $data, 'artefact'); } db_commit(); $this->dirty = false; }
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; }
/** * Overrides the default commit to make sure that any 'entireresume' blocks * in views the user have know about this artefact - but only if necessary. * Goals and skills are not in the entireresume block * * @param boolean $updateresumeblocks Whether to update any resume blockinstances */ public function commit() { parent::commit(); if ($blockinstances = get_records_sql_array(' SELECT id, "view", configdata FROM {block_instance} WHERE blocktype = \'entireresume\' AND "view" IN ( SELECT id FROM {view} WHERE "owner" = ?)', array($this->owner))) { foreach ($blockinstances as $blockinstance) { $whereobject = (object) array('view' => $blockinstance->view, 'artefact' => $this->get('id'), 'block' => $blockinstance->id); ensure_record_exists('view_artefact', $whereobject, $whereobject); } } }
/** * This method extends ArtefactType::commit() by adding additional data * into the artefact_plans_task table. * */ public function commit() { if (empty($this->dirty)) { return; } // Return whether or not the commit worked $success = FALSE; db_begin(); parent::commit(); db_commit(); $this->dirty = $success ? FALSE : TRUE; return $success; }
/** * This function updates or inserts the artefact. This involves putting * some data in the artefact table (handled by parent::commit()), and then * some data in the artefact_file_files table. */ public function commit() { // Just forget the whole thing when we're clean. if (empty($this->dirty)) { return; } // We need to keep track of newness before and after. $new = empty($this->id); // Commit to the artefact table. parent::commit(); // Reset dirtyness for the time being. $this->dirty = true; $data = (object) array('artefact' => $this->get('id'), 'size' => $this->get('size'), 'oldextension' => $this->get('oldextension'), 'fileid' => $this->get('fileid'), 'filetype' => $this->get('filetype')); if ($new) { if ($this->get('artefacttype') != 'folder' && empty($data->fileid)) { $data->fileid = $data->artefact; } insert_record('artefact_file_files', $data); } else { update_record('artefact_file_files', $data, 'artefact'); } $this->dirty = false; }
/** * This method extends ArtefactType::commit() by adding additional data * into the artefact_cpds_activity table. * */ public function commit() { if (empty($this->dirty)) { return; } // Return whether or not the commit worked $success = false; db_begin(); $new = empty($this->id); parent::commit(); $this->dirty = true; $startdate = $this->get('startdate'); if (!empty($startdate)) { $date = db_format_timestamp($startdate); } $data = (object) array('artefact' => $this->get('id'), 'hours' => $this->get('hours'), 'location' => $this->get('location'), 'startdate' => $date, 'enddate' => db_format_timestamp($this->get('enddate'))); if ($new) { $success = insert_record('artefact_cpds_activity', $data); } else { $success = update_record('artefact_cpds_activity', $data, 'artefact'); } db_commit(); $this->dirty = !$success; return $success; }
public function commit() { if (empty($this->dirty)) { return; } $new = empty($this->id); db_begin(); parent::commit(); $data = (object) array('artefact' => $this->get('id'), 'onview' => $this->get('onview'), 'onartefact' => $this->get('onartefact'), 'private' => $this->get('private'), 'deletedby' => $this->get('deletedby'), 'requestpublic' => $this->get('requestpublic'), 'rating' => $this->get('rating')); if ($this->get('lastcontentupdate')) { $data->lastcontentupdate = db_format_timestamp($this->get('lastcontentupdate')); } if ($new) { insert_record('artefact_comment_comment', $data); } else { update_record('artefact_comment_comment', $data, 'artefact'); } if (!$this->get('private')) { if ($this->get('onview')) { set_field('view', 'mtime', db_format_timestamp(time()), 'id', $this->get('onview')); } else { if ($this->get('onartefact')) { execute_sql("UPDATE {view} SET mtime = ? WHERE id IN (SELECT va.view FROM {view_artefact} va WHERE va.artefact = ?)", array(db_format_timestamp(time()), $this->get('onartefact'))); } } } db_commit(); $this->dirty = false; }
/** * This method extends ArtefactType::commit() by adding additional data * into the artefact_plans_task table. * */ public function commit() { if (empty($this->dirty)) { return; } // Return whether or not the commit worked $success = false; db_begin(); $new = empty($this->id); parent::commit(); $this->dirty = true; $completiondate = $this->get('completiondate'); if (!empty($completiondate)) { $date = db_format_timestamp($completiondate); } $data = (object) array('artefact' => $this->get('id'), 'completed' => $this->get('completed'), 'completiondate' => $date); if ($new) { $success = insert_record('artefact_plans_task', $data); } else { $success = update_record('artefact_plans_task', $data, 'artefact'); } db_commit(); $this->dirty = $success ? false : true; return $success; }
/** * This function updates or inserts the artefact. This involves putting * some data in the artefact table (handled by parent::commit()), and then * some data in the artefact_blog_blog table. */ public function commit() { // Just forget the whole thing when we're clean. if (empty($this->dirty)) { return; } // We need to keep track of newness before and after. $new = empty($this->id); // Commit to the artefact table. parent::commit(); $this->dirty = false; }
/** * This method extends ArtefactType::commit() by adding additional data * into the artefact_blog_blogpost table. * * This method also works out what blockinstances this blogpost is in, and * informs them that they should re-check what artefacts they have in them. * The post content may now link to different artefacts. See {@link * PluginBlocktypeBlogPost::get_artefacts for more information} */ public function commit() { if (empty($this->dirty)) { return; } db_begin(); $new = empty($this->id); parent::commit(); $this->dirty = true; $data = (object) array('blogpost' => $this->get('id'), 'published' => $this->get('published') ? 1 : 0); if ($new) { insert_record('artefact_blog_blogpost', $data); } else { update_record('artefact_blog_blogpost', $data, 'blogpost'); } // We want to get all blockinstances that contain this blog post. That is currently: // 1) All blogpost blocktypes with this post in it // 2) All blog blocktypes with this posts's blog in it // // With these, we tell them to rebuild what artefacts they have in them, // since the post content could have changed and now have links to // different artefacts in it $blockinstanceids = (array) get_column_sql('SELECT block FROM {view_artefact} WHERE artefact = ? OR artefact = ?', array($this->get('id'), $this->get('parent'))); if ($blockinstanceids) { require_once get_config('docroot') . 'blocktype/lib.php'; foreach ($blockinstanceids as $id) { $instance = new BlockInstance($id); $instance->rebuild_artefact_list(); } } db_commit(); $this->dirty = false; }
/** * This method extends ArtefactType::commit() by adding additional data * into the artefact_ilps_unit table. * */ public function commit() { if (empty($this->dirty)) { return; } // Return whether or not the commit worked $success = false; db_begin(); $new = empty($this->id); parent::commit(); $this->dirty = true; $targetcompletion = $this->get('targetcompletion'); if (!empty($targetcompletion)) { $date = db_format_timestamp($targetcompletion); } $data = (object) array('artefact' => $this->get('id'), 'points' => $this->get('points'), 'status' => $this->get('status'), 'targetcompletion' => $date, 'datecompleted' => db_format_timestamp($this->get('datecompleted'))); if ($new) { $success = insert_record('artefact_ilps_unit', $data); } else { $success = update_record('artefact_ilps_unit', $data, 'artefact'); } db_commit(); $this->dirty = $success ? false : true; return $success; }