/** * Hook for making sure that all resume artefacts are associated with a * blockinstance at blockinstance commit time */ public static function ensure_resume_artefacts_in_blockinstance($event, $blockinstance) { if ($blockinstance->get('blocktype') == 'entireresume') { safe_require('artefact', 'resume'); $artefacttypes = implode(', ', array_map('db_quote', PluginArtefactResume::get_artefact_types())); // Get all artefacts that are resume related and belong to the correct owner $artefacts = get_records_sql_array(' SELECT id FROM {artefact} WHERE artefacttype IN(' . $artefacttypes . ') AND "owner" = ( SELECT "owner" FROM {view} WHERE id = ? )', array($blockinstance->get('view'))); if ($artefacts) { // Make sure they're registered as being in this view foreach ($artefacts as $artefact) { $record = (object) array('view' => $blockinstance->get('view'), 'artefact' => $artefact->id, 'block' => $blockinstance->get('id')); ensure_record_exists('view_artefact', $record, $record); } } } }
* attached to the resume goals or skills. */ $wwwroot = get_config('wwwroot'); $noimagesmessage = json_encode(get_string('noimageshavebeenattachedtothispost', 'artefact.blog')); $javascript = <<<EOF function editgoalsandskills_callback(form, data) { editgoalsandskills_filebrowser.callback(form, data); }; EOF; $smarty = smarty(array(), array(), array(), array('tinymceconfig' => ' plugins: "tooltoggle,textcolor,link,imagebrowser,table,emoticons,spellchecker,paste,code,fullscreen,directionality,searchreplace,nonbreaking,charmap", image_filebrowser: "editgoalsandskills_filebrowser", ', 'sideblocks' => array(array('name' => 'quota', 'weight' => -10, 'data' => array())))); $smarty->assign('INLINEJAVASCRIPT', $javascript); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items()); $smarty->assign('subsectionheading', get_string('goalsandskills', 'artefact.resume')); $smarty->assign_by_ref('artefactform', $form); $smarty->assign('artefacttype', $type); $smarty->display('artefact:resume:editgoalsandskills.tpl'); 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();
function compositeformedit_submit(Pieform $form, $values) { global $SESSION; $tabs = PluginArtefactResume::composite_tabs(); $goto = get_config('wwwroot') . 'artefact/resume/'; if (isset($tabs[$values['compositetype']])) { $goto .= $tabs[$values['compositetype']] . '.php'; } else { $goto .= 'index.php'; } try { call_static_method(generate_artefact_class_name($values['compositetype']), 'process_compositeform', $form, $values); } catch (Exception $e) { $SESSION->add_error_msg(get_string('compositesavefailed', 'artefact.resume')); redirect($goto); } $result = array('error' => false, 'message' => get_string('compositesaved', 'artefact.resume'), 'goto' => $goto); if ($form->submitted_by_js()) { // Redirect back to the resume composite page from within the iframe $SESSION->add_ok_msg($result['message']); $form->json_reply(PIEFORM_OK, $result, false); } $form->reply(PIEFORM_OK, $result); }
public static function artefactchooser_element($default = null) { safe_require('artefact', 'resume'); return array('name' => 'artefactid', 'type' => 'artefactchooser', 'title' => get_string('fieldtoshow', 'blocktype.resume/resumefield'), 'defaultvalue' => $default, 'blocktype' => 'resumefield', 'limit' => 655360, 'selectone' => true, 'search' => false, 'artefacttypes' => PluginArtefactResume::get_artefact_types(), 'template' => 'artefact:resume:artefactchooser-element.tpl'); }
function compositeformedit_submit(Pieform $form, $values) { global $SESSION; $tabs = PluginArtefactResume::composite_tabs(); $goto = get_config('wwwroot') . '/artefact/resume/'; if (isset($tabs[$values['compositetype']])) { $goto .= $tabs[$values['compositetype']] . '.php'; } try { call_static_method(generate_artefact_class_name($values['compositetype']), 'process_compositeform', $form, $values); } catch (Exception $e) { $SESSION->add_error_msg(get_string('compositesavefailed', 'artefact.resume')); redirect($goto); } $SESSION->add_ok_msg(get_string('compositesaved', 'artefact.resume')); redirect($goto); }
public static function getRecordDataById($type, $id) { global $USER; $sql = 'SELECT a.id, a.artefacttype, a.parent, a.owner, a.title, a.description, a.institution, a.group, a.author, p.artefacttype AS parent_artefacttype, p.title AS parent_title, p.description AS parent_description, a.license, afi.width, afi.height, a.note FROM {artefact} a LEFT OUTER JOIN {artefact} p ON p.id = a.parent LEFT OUTER JOIN {artefact_file_image} afi ON afi.artefact = a.id WHERE a.id = ?'; $record = get_record_sql($sql, array($id)); if (!$record) { return false; } $record->title = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->title)); $record->description = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->description)); // If user is owner if ($USER->get('id') == $record->owner) { switch ($record->artefacttype) { case 'image': case 'video': case 'audio': case 'file': $record->link = 'artefact/file'; if (isset($record->parent) && intval($record->parent) > 0) { $record->link .= '/index.php?folder=' . $record->parent; } break; case 'blogpost': if (isset($record->parent) && intval($record->parent) > 0) { $record->link = 'artefact/blog/view/index.php?id=' . $record->parent; } break; case 'blog': $record->link = 'artefact/blog/view/index.php'; if ($USER->get_account_preference('multipleblogs')) { $record->link .= '?id=' . $record->id; } break; case 'coverletter': case 'personalinformation': $record->link = 'artefact/resume/index.php'; break; case 'educationhistory': case 'employmenthistory': $record->link = 'artefact/resume/employment.php'; break; case 'book': case 'certification': case 'membership': $record->link = 'artefact/resume/achievements.php'; break; case 'academicgoal': case 'careergoal': case 'personalgoal': case 'personalinformation': case 'academicskill': case 'personalskill': case 'workskill': $record->link = 'artefact/resume/goalsandskills.php'; break; case 'interest': $record->link = 'artefact/resume/interests.php'; break; case 'plan': $record->link = 'artefact/plans/plan.php?id=' . $record->id; break; case 'task': if (isset($record->parent) && intval($record->parent) > 0) { $record->link = 'artefact/plans/plan.php?id=' . $record->parent; } break; case 'socialprofile': safe_require('artefact', 'internal'); $record->note = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->note)); $socialprofile = new ArtefactTypeSocialprofile($record->id); $icons = $socialprofile->get_profile_icons(array($record)); if (!empty($icons)) { $record->link = $icons[0]->link; $record->icon = $icons[0]->icon; } break; } } require_once get_config('docroot') . 'artefact/resume/lib.php'; if (PluginArtefactResume::is_active()) { // If the artefacttype is one of the résumé ones we need to fetch the related item info $resumetypes = PluginArtefactResume::composite_tabs(); if (array_key_exists($record->artefacttype, $resumetypes)) { try { $query = "SELECT * FROM {artefact_resume_" . $record->artefacttype . "} WHERE artefact = ?"; $results = get_records_sql_assoc($query, array($record->id)); } catch (SQLException $e) { // Table doesn't exist $results = array(); } $record->resumeitems = $results; } } // VIEWS get all the views the artefact is included into. // artefact parents are folder, blog, plan, cpd $sql = 'SELECT COALESCE(v.id, vp.id) AS id, COALESCE(v.title, vp.title) AS title FROM {artefact} a LEFT OUTER JOIN {view_artefact} va ON va.artefact = a.id LEFT OUTER JOIN {view} v ON v.id = va.view LEFT OUTER JOIN {artefact} parent ON parent.id = a.parent LEFT OUTER JOIN {view_artefact} vap ON vap.artefact = parent.id LEFT OUTER JOIN {view} vp ON vp.id = vap.view WHERE a.id = ?'; $views = get_records_sql_array($sql, array($id)); if ($views) { $record_views = array(); foreach ($views as $view) { if (isset($view->id)) { $record_views[$view->id] = $view->title; } } $record_views = self::views_by_artefact_acl_filter($record_views); $record->views = $record_views; } // Tags $tags = get_records_array('artefact_tag', 'artefact', $id); if ($tags != false) { foreach ($tags as $tag) { $record->tags[] = $tag->tag; } } else { $record->tags = null; } // Created by if (intval($record->author) > 0) { $record->createdby = get_record('usr', 'id', $record->author); $record->createdbyname = display_name($record->createdby); } // Thumb if ($record->artefacttype == 'image' || $record->artefacttype == 'profileicon') { if (isset($record->width) && isset($record->height) && intval($record->width) > 0 && intval($record->height) > 0) { if ($record->width > $record->height) { $size = '80x' . intval($record->height * 80 / $record->width); } else { $size = intval($record->width * 80 / $record->height) . 'x80'; } } $record->thumb = ArtefactTypeImage::get_icon(array('id' => $id, 'size' => $size)); } return $record; }