public function add_links() { $fields = ArtefactTypeContactinformation::get_profile_fields(); foreach ($fields as $f) { try { ${$f} = artefact_instance_from_type($f, $this->artefact->get('owner')); $this->add_artefact_link(${$f}, 'has_part'); } catch (MaharaException $e) { } // might not exist which is ok } }
public static function render_instance(BlockInstance $instance, $editing = false) { // Check if XSLT extension is loaded properly, because we will need it... // The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library. $xslext = extension_loaded('xsl'); if (!$xslext) { $missingextensions = array(); !$xslext && ($missingextensions[] = 'xsl'); $errormsg = '<p>' . get_string('europassextensionmissing', 'artefact.europass') . '</p>'; $errormsg .= '<ul>'; foreach ($missingextensions as $extension) { $errormsg .= '<li><a href="http://www.php.net/' . $extension . '">' . $extension . '</a></li>'; } $errormsg .= '</ul>'; return $errormsg; exit; } require_once get_config('docroot') . 'artefact/lib.php'; $smarty = smarty_core(); $configdata = $instance->get('configdata'); $configdata['viewid'] = $instance->get('view'); // Get data about the resume field in this blockinstance if (!empty($configdata['artefactid'])) { $europassfield = $instance->get_artefact_instance($configdata['artefactid']); if ($europassfield->get('artefacttype') != 'application') { $rendered = $europassfield->render_self($configdata); $result = $rendered['html']; if (!empty($rendered['javascript'])) { $result .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>'; } } else { require_once get_config('docroot') . 'artefact/europass/lib/locale.php'; $personalinformation = null; try { $personalinformation = artefact_instance_from_type('personalinformation'); } catch (Exception $e) { } if (!empty($personalinformation)) { $gender = $personalinformation->get_composite('gender'); } else { $gender = null; } $occupation = get_occupation($europassfield->get('description'), get_config('lang'), $gender); $result = $occupation['label']; } return $result; } return ''; }
function set_profile_field($userid, $field, $value) { safe_require('artefact', 'internal'); // this is a special case that replaces the primary email address with the // specified one if ($field == 'email') { try { $email = artefact_instance_from_type('email', $userid); } catch (ArtefactNotFoundException $e) { $email = new ArtefactTypeEmail(); $email->set('owner', $userid); } $email->set('title', $value); $email->commit(); } else { $classname = generate_artefact_class_name($field); $profile = new $classname(0, array('owner' => $userid)); $profile->set('title', $value); $profile->commit(); } }
function generate_europasslp_xml($userid, $showHTML = false, $locale = 'en_GB', $internaldateformat = 'dmy11', $externaldateformat = '/numeric/long', $convert = false) { // ================================ // Load values from Mahara database // ================================ // load user's existing contact information $element_list = array('firstname' => 'text', 'lastname' => 'text'); $contactinfo = array('firstname' => null, 'lastname' => null); $contactinfo_data = get_records_select_array('artefact', "owner=? AND artefacttype IN (" . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($element_list))) . ")", array($userid)); if ($contactinfo_data) { foreach ($contactinfo_data as $field) { $contactinfo[$field->artefacttype] = $field->title; } } // load user's existing demographics information $demographics = null; try { $demographics = artefact_instance_from_type('personalinformation', $userid); } catch (Exception $e) { } // load user's existing mother tongue(s) and foreign language(s) $artefact_id = get_field('artefact', 'id', 'artefacttype', 'mothertongue', 'owner', $userid); if ($artefact_id !== false) { $mothertongue_list = get_records_select_array('artefact_europass_mothertongue', "artefact=?", array($artefact_id)); } else { $mothertongue_list = array(); } $artefact_id = get_field('artefact', 'id', 'artefacttype', 'otherlanguage', 'owner', $userid); if ($artefact_id !== false) { $otherlanguage_list = get_records_select_array('artefact_europass_otherlanguage', "artefact=?", array($artefact_id)); } else { $otherlanguage_list = array(); } // ====================== // Dinamically create XML // ====================== $xmlDoc = new DOMDocument('1.0', 'UTF-8'); // We want a nice output //$xmlDoc->formatOutput = true; $styleSheet = $xmlDoc->createProcessingInstruction('xml-stylesheet', 'href="http://europass.cedefop.europa.eu/xml/lp_' . $locale . '_V2.0.xsl" type="text/xsl"'); $xmlDoc->appendChild($styleSheet); $rootElement = $xmlDoc->createElement('europass:learnerinfo'); $rootNode = $xmlDoc->appendChild($rootElement); $rootNode->setAttribute('locale', $locale); $rootNode->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $rootNode->setAttribute('xmlns:europass', 'http://europass.cedefop.europa.eu/Europass/V2.0'); $rootNode->setAttribute('xsi:schemaLocation', 'http://europass.cedefop.europa.eu/Europass/V2.0 http://europass.cedefop.europa.eu/xml/EuropassSchema_V2.0.xsd'); $children = array('docinfo', 'prefs', 'identification', 'languagelist'); foreach ($children as $child) { $childRoot = $xmlDoc->getElementsByTagName('europass:learnerinfo')->item(0); $childElement = $xmlDoc->createElement($child); $childRoot->appendChild($childElement); } // ======================= // Dinamically set docinfo // ======================= // Dinamically set issuedate $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0); $childElement = $xmlDoc->createElement('issuedate'); $childElement->nodeValue = date('Y-m-d\\TH:i:sP'); $childRoot->appendChild($childElement); // Dinamically set xsdversion $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0); $childElement = $xmlDoc->createElement('xsdversion'); $childElement->nodeValue = 'V2.0'; $childRoot->appendChild($childElement); // Dinamically set comment $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0); $childElement = $xmlDoc->createElement('comment'); $childElement->nodeValue = 'Automatically generated Europass Language Passport from Mahara e-portfolio data'; $childRoot->appendChild($childElement); // ======================================== // Dinamically set prefs and identification // ======================================== // Dinamically set first and last name $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0); $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'personal.lastName'); $childElement->setAttribute('before', 'personal.firstName'); $childRoot->appendChild($childElement); $childRoot = $xmlDoc->getElementsByTagName('identification')->item(0); $childElement = $xmlDoc->createElement('firstname'); $childElement->nodeValue = valid_xml_string($contactinfo['firstname']); $childRoot->appendChild($childElement); $childElement = $xmlDoc->createElement('lastname'); $childElement->nodeValue = valid_xml_string($contactinfo['lastname']); $childRoot->appendChild($childElement); // ---------------------------- // Dinamically set demographics // ---------------------------- $childRoot = $xmlDoc->getElementsByTagName('identification')->item(0); $childElement = $xmlDoc->createElement('demographics'); $childRoot->appendChild($childElement); // Dinamically set birthdate $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0); $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'personal.birthDate'); $childElement->setAttribute('keep', !empty($demographics) ? 'false' : 'true'); $childElement->setAttribute('format', $externaldateformat); $childRoot->appendChild($childElement); $childRoot = $xmlDoc->getElementsByTagName('demographics')->item(0); $childElement = $xmlDoc->createElement('birthdate'); $childElement->nodeValue = !empty($demographics) ? strftime('%Y-%m-%d', $demographics->get_composite('dateofbirth') + 3600) : null; $childRoot->appendChild($childElement); // ======================================= // Dinamically set prefs and language list // ======================================= // Dinamically add mother tongue(s) $childRoot = $xmlDoc->getElementsByTagName('languagelist')->item(0); $childElement = $xmlDoc->createElement('language'); $childElement->setAttribute('xsi:type', 'europass:mother'); $childRoot->appendChild($childElement); $language_label = null; if (!empty($mothertongue_list)) { foreach ($mothertongue_list as $mothertongue) { $language_label .= get_string_from_file('language.' . $mothertongue->language, get_config('docroot') . 'artefact/europass/lang/' . get_lang_from_locale($locale) . '/artefact.europass.php') . ', '; } $language_label = substr($language_label, 0, -2); // omitt last comma and whitespace from $language_label $childRoot = $xmlDoc->getElementsByTagName('language')->item(0); if (count($mothertongue_list) == 1) { $childElement = $xmlDoc->createElement('code'); $childElement->nodeValue = $mothertongue->language; $childRoot->appendChild($childElement); } $childElement = $xmlDoc->createElement('label'); $childElement->nodeValue = $language_label; $childRoot->appendChild($childElement); } //Dinamically add foreign language(s) $l = 0; if (!empty($otherlanguage_list)) { foreach ($otherlanguage_list as $otherlanguage) { // Get otherlanguage's diploma list if ($otherlanguage->id !== false) { $diploma_list = get_records_select_array('artefact_europass_languagediploma', "languageid=?", array($otherlanguage->id)); } else { $diploma_list = array(); } // Get otherlanguage's experience list if ($otherlanguage->id !== false) { $experience_list = get_records_select_array('artefact_europass_languageexperience', "languageid=?", array($otherlanguage->id)); } else { $experience_list = array(); } $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0); // Set foreign language $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].ass'); $childElement->setAttribute('keep', $otherlanguage->language == null ? 'false' : 'true'); $childRoot->appendChild($childElement); // Set foreign language diploma(s) if (!empty($diploma_list)) { for ($d = 0; $d < count($diploma_list); $d++) { $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].diplomaList[' . $d . ']'); $childElement->setAttribute('keep', 'true'); $childRoot->appendChild($childElement); } } // Set foreign language experience(s) if (!empty($experience_list)) { for ($e = 0; $e < count($experience_list); $e++) { $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].experienceList[' . $e . ']'); $childElement->setAttribute('keep', 'true'); $childRoot->appendChild($childElement); $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].experienceList[' . $e . '].period'); $childElement->setAttribute('format', $externaldateformat); $childRoot->appendChild($childElement); } } // Dinamically set data for each foreign language $childRoot = $xmlDoc->getElementsByTagName('languagelist')->item(0); $childElement = $xmlDoc->createElement('language'); $childElement->setAttribute('xsi:type', 'europass:foreign'); $childRoot->appendChild($childElement); $childRoot = $xmlDoc->getElementsByTagName('language')->item($l + 1); // Because mothertongue has index 0... $childElement = $xmlDoc->createElement('code'); $childElement->nodeValue = $otherlanguage->language; $childRoot->appendChild($childElement); $childElement = $xmlDoc->createElement('label'); $childElement->nodeValue = get_string_from_file('language.' . $otherlanguage->language, get_config('docroot') . 'artefact/europass/lang/' . get_lang_from_locale($locale) . '/artefact.europass.php'); $childRoot->appendChild($childElement); $childElement = $xmlDoc->createElement('level'); $childRoot->appendChild($childElement); // language levels $grandchildRoot = $childRoot->lastChild; $levels = array('listening' => $otherlanguage->listening, 'reading' => $otherlanguage->reading, 'spokeninteraction' => $otherlanguage->spokeninteraction, 'spokenproduction' => $otherlanguage->spokenproduction, 'writing' => $otherlanguage->writing); foreach ($levels as $field => $value) { $grandchildElement = $xmlDoc->createElement($field); $grandchildElement->nodeValue = strtolower($value); $grandchildRoot->appendChild($grandchildElement); } // language diploma list $childElement = $xmlDoc->createElement('diplomalist'); $childRoot->appendChild($childElement); //language experience list $childElement = $xmlDoc->createElement('experiencelist'); $childRoot->appendChild($childElement); // ----------------------------- // language diploma list entries // ----------------------------- $parentRoot = $xmlDoc->getElementsByTagName('diplomalist')->item($l); if (!empty($diploma_list)) { foreach ($diploma_list as $diploma) { $parentElement = $xmlDoc->createElement('diploma'); $parentRoot->appendChild($parentElement); $childRoot = $parentRoot->lastChild; // diploma title $childElement = $xmlDoc->createElement('title'); $childElement->nodeValue = valid_xml_string($diploma->certificate); $childRoot->appendChild($childElement); // diploma awarding body $childElement = $xmlDoc->createElement('awardingBody'); $childElement->nodeValue = $showHTML ? replacehtmlchars(nl2br($diploma->awardingbody)) : valid_xml_string($diploma->awardingbody); // Execute nl2br transformation for HTML display... $childRoot->appendChild($childElement); // diploma date $childElement = $xmlDoc->createElement('date'); $childRoot->appendChild($childElement); $grandchildRoot = $childRoot->firstChild->nextSibling->nextSibling; if ($diploma->certificatedate != null) { if (date('Y', strtotime($diploma->certificatedate)) != null) { $grandchildElement = $xmlDoc->createElement('year'); $grandchildElement->nodeValue = date('Y', strtotime($diploma->certificatedate)); $grandchildRoot->appendChild($grandchildElement); } if (date('m', strtotime($diploma->certificatedate)) != null) { $grandchildElement = $xmlDoc->createElement('month'); $grandchildElement->nodeValue = '--' . date('m', strtotime($diploma->certificatedate)); $grandchildRoot->appendChild($grandchildElement); } if (date('d', strtotime($diploma->certificatedate)) != null) { $grandchildElement = $xmlDoc->createElement('day'); $grandchildElement->nodeValue = '---' . date('d', strtotime($diploma->certificatedate)); $grandchildRoot->appendChild($grandchildElement); } } // diploma level $childElement = $xmlDoc->createElement('level'); $childElement->nodeValue = strtolower($diploma->europeanlevel); $childRoot->appendChild($childElement); } } // -------------------------------- // language experience list entries // -------------------------------- $parentRoot = $xmlDoc->getElementsByTagName('experiencelist')->item($l); if (!empty($experience_list)) { foreach ($experience_list as $experience) { $parentElement = $xmlDoc->createElement('experience'); $parentRoot->appendChild($parentElement); $childRoot = $parentRoot->lastChild; // experience period $childElement = $xmlDoc->createElement('period'); $childRoot->appendChild($childElement); // experience period - from $grandchildRoot = $childRoot->firstChild; $grandchildElement = $xmlDoc->createElement('from'); $grandchildRoot->appendChild($grandchildElement); $grandgrandchildRoot = $grandchildRoot->firstChild; if ($experience->startdate != null) { if (date('Y', strtotime($experience->startdate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('year'); $grandgrandchildElement->nodeValue = date('Y', strtotime($experience->startdate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } if (date('m', strtotime($experience->startdate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('month'); $grandgrandchildElement->nodeValue = '--' . date('m', strtotime($experience->startdate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } if (date('d', strtotime($experience->startdate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('day'); $grandgrandchildElement->nodeValue = '---' . date('d', strtotime($experience->startdate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } } // experience period - to $grandchildElement = $xmlDoc->createElement('to'); $grandchildRoot->appendChild($grandchildElement); $grandgrandchildRoot = $grandchildRoot->firstChild->nextSibling; if ($experience->enddate != null) { if (date('Y', strtotime($experience->enddate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('year'); $grandgrandchildElement->nodeValue = date('Y', strtotime($experience->enddate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } if (date('m', strtotime($experience->enddate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('month'); $grandgrandchildElement->nodeValue = '--' . date('m', strtotime($experience->enddate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } if (date('d', strtotime($experience->enddate)) != null) { $grandgrandchildElement = $xmlDoc->createElement('day'); $grandgrandchildElement->nodeValue = '---' . date('d', strtotime($experience->enddate)); $grandgrandchildRoot->appendChild($grandgrandchildElement); } } // experience description $childElement = $xmlDoc->createElement('description'); $childElement->nodeValue = $showHTML ? replacehtmlchars(nl2br($experience->description)) : valid_xml_string($experience->description); $childRoot->appendChild($childElement); } } $l++; } } // =================================== // Dinamically set prefs (grid option) // =================================== $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0); $childElement = $xmlDoc->createElement('field'); $childElement->setAttribute('name', 'grid'); $childElement->setAttribute('keep', 'true'); $childRoot->appendChild($childElement); // ================================ // Return dinamically generated XML // ================================ return $xmlDoc->saveXML(); }
} catch (Exception $e) { } try { $computerskill = artefact_instance_from_type('computerskill'); } catch (Exception $e) { } try { $artisticskill = artefact_instance_from_type('artisticskill'); } catch (Exception $e) { } try { $otherskill = artefact_instance_from_type('otherskill'); } catch (Exception $e) { } try { $drivinglicence = artefact_instance_from_type('drivinglicence'); $drivinglicence = unserialize($drivinglicence->get('description')); } catch (Exception $e) { } // Locations for various buttons and graphics $topbanner = get_config('wwwroot') . 'artefact/europass/images/topbanner.png'; $rightlogo = get_config('wwwroot') . 'artefact/europass/images/rightlogo.png'; $skillsform = pieform(array('name' => 'europassform', 'plugintype' => 'artefact', 'pluginname' => 'europass', 'template' => 'skillsform.php', 'elements' => array('AM' => array('type' => 'checkbox', 'title' => 'AM', 'defaultvalue' => !empty($drivinglicence['AM']) ? $drivinglicence['AM'] : null, 'disabled' => true), 'A1' => array('type' => 'checkbox', 'title' => 'A1', 'defaultvalue' => !empty($drivinglicence['A1']) ? $drivinglicence['A1'] : null), 'A' => array('type' => 'checkbox', 'title' => 'A', 'defaultvalue' => !empty($drivinglicence['A']) ? $drivinglicence['A'] : null), 'B' => array('type' => 'checkbox', 'title' => 'B', 'defaultvalue' => !empty($drivinglicence['B']) ? $drivinglicence['B'] : null), 'BE' => array('type' => 'checkbox', 'title' => 'BE', 'defaultvalue' => !empty($drivinglicence['BE']) ? $drivinglicence['BE'] : null), 'B1' => array('type' => 'checkbox', 'title' => 'B1', 'defaultvalue' => !empty($drivinglicence['B1']) ? $drivinglicence['B1'] : null), 'C' => array('type' => 'checkbox', 'title' => 'C', 'defaultvalue' => !empty($drivinglicence['C']) ? $drivinglicence['C'] : null), 'CE' => array('type' => 'checkbox', 'title' => 'CE', 'defaultvalue' => !empty($drivinglicence['CE']) ? $drivinglicence['CE'] : null), 'C1' => array('type' => 'checkbox', 'title' => 'C1', 'defaultvalue' => !empty($drivinglicence['C1']) ? $drivinglicence['C1'] : null), 'C1E' => array('type' => 'checkbox', 'title' => 'C1E', 'defaultvalue' => !empty($drivinglicence['C1E']) ? $drivinglicence['C1E'] : null), 'D' => array('type' => 'checkbox', 'title' => 'D', 'defaultvalue' => !empty($drivinglicence['D']) ? $drivinglicence['D'] : null), 'DE' => array('type' => 'checkbox', 'title' => 'DE', 'defaultvalue' => !empty($drivinglicence['DE']) ? $drivinglicence['DE'] : null), 'D1' => array('type' => 'checkbox', 'title' => 'D1', 'defaultvalue' => !empty($drivinglicence['D1']) ? $drivinglicence['D1'] : null), 'D1E' => array('type' => 'checkbox', 'title' => 'D1E', 'defaultvalue' => !empty($drivinglicence['D1E']) ? $drivinglicence['D1E'] : null), 'socialskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($socialskill) ? $socialskill->get('description') : null, 'title' => get_string('socialskill', 'artefact.europass'), 'help' => true), 'organisationalskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($organisationalskill) ? $organisationalskill->get('description') : null, 'title' => get_string('organisationalskill', 'artefact.europass'), 'help' => true), 'technicalskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($technicalskill) ? $technicalskill->get('description') : null, 'title' => get_string('technicalskill', 'artefact.europass'), 'help' => true), 'computerskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($computerskill) ? $computerskill->get('description') : null, 'title' => get_string('computerskill', 'artefact.europass'), 'help' => true), 'artisticskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($artisticskill) ? $artisticskill->get('description') : null, 'title' => get_string('artisticskill', 'artefact.europass'), 'help' => true), 'otherskill' => array('type' => 'textarea', 'rows' => 4, 'cols' => 60, 'defaultvalue' => !empty($otherskill) ? $otherskill->get('description') : null, 'title' => get_string('otherskill', 'artefact.europass')), 'submit' => array('type' => 'submit', 'value' => get_string('save', 'mahara')), 'drivingform' => array('type' => 'hidden', 'value' => true), 'redirect' => array('type' => 'hidden', 'value' => 'skills')))); $smarty = smarty(); // Check if Mahara release is older than 1.3.0 if (get_config('version') < 2010083102) { $SESSION->add_info_msg(get_string('newerversionforcompatibility', 'artefact.europass')); $smarty->assign('mahararelease', 1); } $smarty->assign('topbanner', $topbanner); $smarty->assign('rightlogo', $rightlogo);
/** * Save a profile field. * Exception is 'socialprofile' field. It is made up of 2 fields: * socialprofile_profileurl, * socialprofile_profiletype * @param int $userid * @param string $field * @param string (or array for socialprofile) $value * @param int $new - Whether the user is new (avoid unnecessary queries) */ function set_profile_field($userid, $field, $value, $new = FALSE) { safe_require('artefact', 'internal'); // this is a special case that replaces the primary email address with the // specified one if ($field == 'email') { if (!$new) { try { $email = artefact_instance_from_type('email', $userid); } catch (ArtefactNotFoundException $e) { // We'll create a new artefact then. } } if (!isset($email)) { $email = new ArtefactTypeEmail(0, null, TRUE); $email->set('owner', $userid); } $email->set('title', $value); $email->commit(); } else { if ($field == 'socialprofile') { if (in_array($value['socialprofile_profiletype'], ArtefactTypeSocialprofile::$socialnetworks)) { $desc = get_string($value['socialprofile_profiletype'], 'artefact.internal'); $type = $value['socialprofile_profiletype']; } else { $desc = $value['socialprofile_profiletype']; $type = 'website'; } $classname = generate_artefact_class_name($field); $profile = new $classname(0, array('owner' => $userid), $new); $profile->set('title', $value['socialprofile_profileurl']); $profile->set('description', $desc); $profile->set('note', $type); $profile->commit(); } else { $classname = generate_artefact_class_name($field); $profile = new $classname(0, array('owner' => $userid), $new); $profile->set('title', $value); $profile->commit(); } } }
define('MENUITEM', 'profile/myresume'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'resume'); define('SECTION_PAGE', 'index'); define('RESUME_SUBPAGE', 'skills'); require_once dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; define('TITLE', get_string('myresume', 'artefact.resume')); require_once get_config('docroot') . 'artefact/lib.php'; $personal = null; $academic = null; $work = null; try { $personal = artefact_instance_from_type('personalskill'); } catch (Exception $e) { } try { $academic = artefact_instance_from_type('academicskill'); } catch (Exception $e) { } try { $work = artefact_instance_from_type('workskill'); } catch (Exception $e) { } $sform = array('name' => 'skillform', 'jsform' => true, 'plugintype' => 'artefact', 'pluginname' => 'resume', 'successcallback' => 'goalandskillform_submit', 'elements' => array('myskills' => array('type' => 'fieldset', 'legend' => get_string('myskills', 'artefact.resume'), 'help' => true, 'elements' => array('personalskill' => array('type' => 'wysiwyg', 'rows' => 20, 'cols' => 80, 'defaultvalue' => !empty($personal) ? $personal->get('description') : null, 'title' => get_string('personalskill', 'artefact.resume')), 'academicskill' => array('type' => 'wysiwyg', 'rows' => 20, 'cols' => 80, 'defaultvalue' => !empty($academic) ? $academic->get('description') : null, 'title' => get_string('academicskill', 'artefact.resume')), 'workskill' => array('type' => 'wysiwyg', 'rows' => 20, 'cols' => 80, 'defaultvalue' => !empty($work) ? $work->get('description') : null, 'title' => get_string('workskill', 'artefact.resume')), 'submit' => array('type' => 'submit', 'value' => get_string('save')))))); $skillform = pieform($sform); $smarty = smarty(); $smarty->assign('skillform', $skillform); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items()); $smarty->display('artefact:resume:skills.tpl');
/** * Creates an artefact in the manner required to overwrite existing profile * artefacts * * @param PluginImportLeap $importer The importer * @param string $artefacttype The type of artefact to create * @param string $title The title for the artefact (with profile * fields, this is the main data) * @return int The ID of the artefact created */ private static function create_artefact(PluginImportLeap $importer, $artefacttype, $title) { $classname = generate_artefact_class_name($artefacttype); $artefact = null; if ($artefacttype == 'email') { // this type is a bit special. just check if we have one with this value already if ($a = get_record('artefact', 'artefacttype', 'email', 'owner', $importer->get('usr'), 'title', $title)) { $artefact = new $classname($a->id, $a); } } if (empty($artefact)) { try { $artefact = artefact_instance_from_type($artefacttype, $importer->get('usr')); } catch (Exception $e) { $artefact = new $classname(0, array('owner' => $importer->get('usr'))); } } $artefact->set('title', $title); $artefact->commit(); return $artefact->get('id'); }
/** * Imports data for the "Personal Information" section of the resume. * TODO: Currently the user has to make one decision about all of it -- it would be nice if * they could make a separate decision about each field. * @param PluginImport $importer * @param array $entry_request * @return int The ID of the artefact created or updated, or 0 if none was touched */ private static function create_personalinformation_artefact_from_request(PluginImport $importer, $entry_request) { global $USER; $aid = 0; $values = unserialize($entry_request->entrycontent); switch ($entry_request->decision) { case PluginImport::DECISION_IGNORE: $duplicatedids = unserialize($entry_request->duplicateditemids); if (!empty($duplicatedids)) { $aid = $duplicatedids[0]; } break; case PluginImport::DECISION_REPLACE: $existingids = unserialize($entry_request->existingitemids); if (!empty($existingids)) { try { $a = artefact_instance_from_id($existingids[0]); if ($USER->get('id') != $a->get('owner')) { return 0; } } catch (Exception $e) { return 0; } } break; case PluginImport::DECISION_APPEND: // We will literally append the content of each text field to each existing text field // We ignore numeric and date fields $existingids = unserialize($entry_request->existingitemids); if (!empty($existingids)) { try { $a = artefact_instance_from_id($existingids[0]); if ($USER->get('id') != $a->get('owner')) { return 0; } foreach (array_keys(ArtefactTypePersonalinformation::get_composite_fields()) as $fieldname) { if (!empty($values[$fieldname]) && !is_numeric($values[$fieldname]) && $fieldname !== 'dateofbirth') { $values[$fieldname] = $a->get_composite($fieldname) . ' ' . $values[$fieldname]; } } } catch (ArtefactNotFoundException $e) { $a = new ArtefactTypePersonalinformation(0, array('owner' => $importer->get('usr'), 'title' => get_string($entry_request->entrytype, 'artefact.resume'))); $a->commit(); } catch (Exception $e) { return 0; } break; } break; case PluginImport::DECISION_ADDNEW: try { $a = artefact_instance_from_type('personalinformation', $USER->get('id')); $a->set('mtime', time()); } catch (ArtefactNotFoundException $e) { $a = new ArtefactTypePersonalinformation(0, array('owner' => $importer->get('usr'), 'title' => get_string($entry_request->entrytype, 'artefact.resume'))); } catch (Exception $e) { return 0; } break; default: break; } if (isset($a)) { foreach (array_keys(ArtefactTypePersonalinformation::get_composite_fields()) as $field) { if (!empty($values[$field])) { $a->set_composite($field, $values[$field]); } } $a->commit(); $aid = $a->get('id'); } if ($aid) { $importer->add_artefactmapping($entry_request->entryid, $aid); } return $aid; }
/** * Creates an artefact in the manner required to overwrite existing profile * artefacts * * @param PluginImportLeap $importer The importer * @param string $artefacttype The type of artefact to create * @param string $title The title for the artefact (with profile * fields, this is the main data) * @param array $extradata An array containing extra data (used for socialprofile artefacts) * @return int The ID of the artefact created */ private static function create_artefact(PluginImportLeap $importer, $artefacttype, $title, $extradata = null) { $classname = generate_artefact_class_name($artefacttype); if ($artefacttype == 'email' && ($a = get_record('artefact', 'artefacttype', 'email', 'owner', $importer->get('usr'), 'title', $title))) { // email is a bit special. just check if we have one with this value already // User may have several email addresses but they must be UNIQUE return $a->id; } try { $artefact = artefact_instance_from_type($artefacttype, $importer->get('usr')); } catch (Exception $e) { $artefact = new $classname(0, array('owner' => $importer->get('usr'))); } $artefact->set('title', $title); if (!empty($extradata)) { foreach ($extradata as $field => $value) { $artefact->set($field, $value); } } $artefact->commit(); return $artefact->get('id'); }
if (!$xslext) { $smarty = smarty(); $missingextensions = array(); !$xslext && ($missingextensions[] = 'xsl'); $smarty->assign('missingextensions', $missingextensions); $smarty->display('artefact:europass:index.tpl'); exit; } $additionalinfo = null; $annexes = null; try { $additionalinfo = artefact_instance_from_type('additionalinfo'); } catch (Exception $e) { } try { $annexes = artefact_instance_from_type('annexes'); } catch (Exception $e) { } // Locations for various buttons and graphics $topbanner = get_config('wwwroot') . 'artefact/europass/images/topbanner.png'; $rightlogo = get_config('wwwroot') . 'artefact/europass/images/rightlogo.png'; $annexesform = pieform(array('name' => 'europassform', 'plugintype' => 'artefact', 'pluginname' => 'europass', 'elements' => array('additionalinfo' => array('type' => 'textarea', 'rows' => 6, 'cols' => 60, 'defaultvalue' => !empty($additionalinfo) ? $additionalinfo->get('description') : null, 'labelhtml' => get_string('additionalinfo', 'artefact.europass'), 'help' => true), 'annexes' => array('type' => 'textarea', 'rows' => 6, 'cols' => 60, 'defaultvalue' => !empty($annexes) ? $annexes->get('description') : null, 'labelhtml' => get_string('annexes', 'artefact.europass'), 'help' => false), 'submit' => array('type' => 'submit', 'value' => get_string('save', 'mahara')), 'redirect' => array('type' => 'hidden', 'value' => 'annexes')))); $smarty = smarty(array('tablerenderer')); // Check if Mahara release is older than 1.3.0 if (get_config('version') < 2010083102) { $SESSION->add_info_msg(get_string('newerversionforcompatibility', 'artefact.europass')); $smarty->assign('mahararelease', 1); } $smarty->assign('topbanner', $topbanner); $smarty->assign('rightlogo', $rightlogo); $smarty->assign('annexesform', $annexesform);
/** * Ensures that the given value for the given composite is present * TODO: expand on these docs. */ public static function ensure_composite_value($values, $compositetype, $owner) { if (!in_array($compositetype, self::get_composite_artefact_types())) { throw new SystemException("ensure_composite_value called with invalid composite type"); } try { $a = artefact_instance_from_type($compositetype, $owner); $a->set('mtime', time()); } catch (Exception $e) { $classname = generate_artefact_class_name($compositetype); $a = new $classname(0, array('owner' => $owner, 'title' => get_string($compositetype, 'artefact.resume'))); } $a->commit(); $values['artefact'] = $a->get('id'); $table = 'artefact_resume_' . $compositetype; if (!empty($values['id'])) { update_record($table, (object) $values, 'id'); } else { if (isset($values['displayorder'])) { $values['displayorder'] = intval($values['displayorder']); } else { $max = get_field($table, 'MAX(displayorder)', 'artefact', $values['artefact']); $values['displayorder'] = is_numeric($max) ? $max + 1 : 0; } insert_record($table, (object) $values); } }
define('SECTION_PLUGINNAME', 'resume'); define('SECTION_PAGE', 'index'); define('RESUME_SUBPAGE', 'index'); require_once dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('resume', 'artefact.resume')); require_once 'pieforms/pieform.php'; safe_require('artefact', 'resume'); if (!PluginArtefactResume::is_active()) { throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('resume', 'artefact.resume'))); } $defaults = array('coverletter' => array('default' => '', 'fshelp' => true)); $coverletterform = pieform(simple_resumefield_form($defaults, 'artefact/resume/index.php', array('editortitle' => get_string('coverletter', 'artefact.resume')))); // load up all the artefacts this user already has.... $personalinformation = null; try { $personalinformation = artefact_instance_from_type('personalinformation'); } catch (Exception $e) { } $personalinformationform = pieform(array('name' => 'personalinformation', 'plugintype' => 'artefact', 'pluginname' => 'resume', 'jsform' => true, 'method' => 'post', 'elements' => array('personalinfomation' => array('type' => 'fieldset', 'legend' => get_string('personalinformation', 'artefact.resume'), 'elements' => array('dateofbirth' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false, 'ifFormat' => '%Y/%m/%d', 'dateFormat' => 'yy/mm/dd'), 'defaultvalue' => !empty($personalinformation) && null !== $personalinformation->get_composite('dateofbirth') ? $personalinformation->get_composite('dateofbirth') + 3600 : null, 'title' => get_string('dateofbirth', 'artefact.resume'), 'description' => get_string('dateofbirthformatguide')), 'placeofbirth' => array('type' => 'text', 'defaultvalue' => !empty($personalinformation) ? $personalinformation->get_composite('placeofbirth') : null, 'title' => get_string('placeofbirth', 'artefact.resume'), 'size' => 30), 'citizenship' => array('type' => 'text', 'defaultvalue' => !empty($personalinformation) ? $personalinformation->get_composite('citizenship') : null, 'title' => get_string('citizenship', 'artefact.resume'), 'size' => 30), 'visastatus' => array('type' => 'text', 'defaultvalue' => !empty($personalinformation) ? $personalinformation->get_composite('visastatus') : null, 'title' => get_string('visastatus', 'artefact.resume'), 'help' => true, 'size' => 30), 'gender' => array('type' => 'radio', 'defaultvalue' => !empty($personalinformation) ? $personalinformation->get_composite('gender') : null, 'options' => array('' => get_string('gendernotspecified', 'artefact.resume'), 'female' => get_string('female', 'artefact.resume'), 'male' => get_string('male', 'artefact.resume')), 'title' => get_string('gender', 'artefact.resume')), 'maritalstatus' => array('type' => 'text', 'defaultvalue' => !empty($personalinformation) ? $personalinformation->get_composite('maritalstatus') : null, 'title' => get_string('maritalstatus', 'artefact.resume'), 'size' => 30), 'save' => array('type' => 'submit', 'value' => get_string('save'))))))); $smarty = smarty(array('artefact/resume/js/simpleresumefield.js')); $smarty->assign('coverletterform', $coverletterform); $smarty->assign('personalinformationform', $personalinformationform); $smarty->assign('INLINEJAVASCRIPT', '$j(simple_resumefield_init);'); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items()); $smarty->display('artefact:resume:index.tpl'); function personalinformation_validate(Pieform $form, $values) { if (!empty($values['dateofbirth'])) { if ($values['dateofbirth'] > time()) { $form->json_reply(PIEFORM_ERR, get_string('dateofbirthinvalid1', 'artefact.resume'));
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', true); define('MENUITEM', 'profile/myresume'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'resume'); define('SECTION_PAGE', 'index'); define('RESUME_SUBPAGE', 'interests'); require_once dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('myresume', 'artefact.resume')); require_once 'pieforms/pieform.php'; safe_require('artefact', 'resume'); $interest = null; try { $interest = artefact_instance_from_type('interest'); } catch (Exception $e) { } $interestsform = pieform(array('name' => 'interests', 'jsform' => true, 'plugintype' => 'artefact', 'pluginname' => 'resume', 'jsform' => true, 'method' => 'post', 'elements' => array('interestsfs' => array('type' => 'fieldset', 'legend' => get_string('interest', 'artefact.resume'), 'elements' => array('interest' => array('type' => 'wysiwyg', 'defaultvalue' => !empty($interest) ? $interest->get('description') : null, 'cols' => 100, 'rows' => 30), 'save' => array('type' => 'submit', 'value' => get_string('save'))), 'help' => true)))); $smarty = smarty(); $smarty->assign('interestsform', $interestsform); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items()); $smarty->display('artefact:resume:interests.tpl'); function interests_submit(Pieform $form, $values) { global $coverletter, $personalinformation, $interest, $USER; $userid = $USER->get('id'); $errors = array(); try { if (empty($interest) && !empty($values['interest'])) {
/** * This function processes the form for the composite * @throws Exception */ public static function process_compositeform(Pieform $form, $values) { try { $a = artefact_instance_from_type($values['compositetype']); $a->set('mtime', time()); } catch (Exception $e) { global $USER; $classname = generate_artefact_class_name($values['compositetype']); $a = new $classname(0, array('owner' => $USER->get('id'), 'title' => get_string($values['compositetype'], 'artefact.resume'))); } $a->commit(); $values['artefact'] = $a->get('id'); $table = 'artefact_resume_' . $values['compositetype']; if (!empty($values['id'])) { update_record($table, (object) $values, 'id'); } else { $max = get_field($table, 'MAX(displayorder)', 'artefact', $values['artefact']); $values['displayorder'] = is_numeric($max) ? $max + 1 : 0; insert_record($table, (object) $values); } }
* */ define('INTERNAL', true); define('MENUITEM', 'profile/mygoals'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'resume'); define('SECTION_PAGE', 'goals'); require_once dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; require_once get_config('docroot') . 'artefact/lib.php'; $personal = null; $academic = null; $career = null; try { $personal = artefact_instance_from_type('personalgoal'); } catch (Exception $e) { } try { $academic = artefact_instance_from_type('academicgoal'); } catch (Exception $e) { } try { $career = artefact_instance_from_type('careergoal'); } catch (Exception $e) { } $gform = array('name' => 'goalform', 'jsform' => true, 'plugintype' => 'artefact', 'pluginname' => 'resume', 'successcallback' => 'goalandskillform_submit', 'elements' => array('personalgoal' => array('type' => 'wysiwyg', 'rows' => 10, 'cols' => 65, 'defaultvalue' => !empty($personal) ? $personal->get('description') : null, 'title' => get_string('personalgoal', 'artefact.resume')), 'academicgoal' => array('type' => 'wysiwyg', 'rows' => 10, 'cols' => 65, 'defaultvalue' => !empty($academic) ? $academic->get('description') : null, 'title' => get_string('academicgoal', 'artefact.resume')), 'careergoal' => array('type' => 'wysiwyg', 'rows' => 10, 'cols' => 65, 'defaultvalue' => !empty($career) ? $career->get('description') : null, 'title' => get_string('careergoal', 'artefact.resume')), 'submit' => array('type' => 'submit', 'value' => get_string('save')))); $goalform = pieform($gform); $smarty = smarty(); $smarty->assign('goalform', $goalform); $smarty->assign('heading', get_string('mygoals', 'artefact.resume')); $smarty->display('artefact:resume:goals.tpl');
safe_require('artefact', 'resume'); safe_require('artefact', 'file'); if (!PluginArtefactResume::is_active()) { throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('resume', 'artefact.resume'))); } define('TITLE', get_string('resume', 'artefact.resume')); $id = param_integer('id', 0); $type = param_variable('type', ''); if ($id > 0) { $artefact = artefact_instance_from_id($id); $type = $artefact->get('artefacttype'); } else { if ($id == 0 && !empty($type)) { $classname = generate_artefact_class_name($type); try { $artefact = artefact_instance_from_type($type); } catch (Exception $e) { $artefact = new $classname(0, array('owner' => $USER->get('id'))); $artefact->commit(); } } else { throw new ArtefactNotFoundException(get_string('cannotfindcreateartefact', 'artefact.resume')); } } if ($artefact->get('owner') != $USER->get('id')) { throw new AccessDeniedException(get_string('notartefactowner', 'error')); } $folder = param_integer('folder', 0); $browse = (int) param_variable('browse', 0); $highlight = null; if ($file = param_integer('file', 0)) {
/** * Ensures that the given value for the given composite is present * TODO: expand on these docs. * @param unknown_type $values * @param unknown_type $compositetype * @param unknown_type $owner * @return int If successful, the ID of the composite artefact * @throws SystemException */ public static function ensure_composite_value($values, $compositetype, $owner) { global $USER; if (!in_array($compositetype, self::get_composite_artefact_types())) { throw new SystemException("ensure_composite_value called with invalid composite type"); } try { $a = artefact_instance_from_type($compositetype, $owner); $a->set('mtime', time()); } catch (Exception $e) { $classname = generate_artefact_class_name($compositetype); $a = new $classname(0, array('owner' => $owner, 'title' => get_string($compositetype, 'artefact.resume'))); } $a->commit(); $values['artefact'] = $a->get('id'); $table = 'artefact_resume_' . $compositetype; if (!empty($values['id'])) { $itemid = $values['id']; update_record($table, (object) $values, 'id'); } else { if (isset($values['displayorder'])) { $values['displayorder'] = intval($values['displayorder']); } else { $max = get_field($table, 'MAX(displayorder)', 'artefact', $values['artefact']); $values['displayorder'] = is_numeric($max) ? $max + 1 : 0; } $itemid = insert_record($table, (object) $values, 'id', true); } // If there are any attachments, attach them to your Resume... if ($compositetype == 'educationhistory' || $compositetype == 'employmenthistory') { $goto = get_config('wwwroot') . 'artefact/resume/employment.php'; } else { $goto = get_config('wwwroot') . 'artefact/resume/achievements.php'; } // Attachments via 'files' pieform element // This happens when adding new resume composite... if (array_key_exists('attachments', $values)) { require_once get_config('libroot') . 'uploadmanager.php'; safe_require('artefact', 'file'); $folderid = null; $attachment = (object) array('owner' => $owner, 'group' => null, 'institution' => null, 'author' => $owner, 'allowcomments' => 0, 'parent' => $folderid, 'description' => null); foreach ($values['attachments'] as $filesindex) { $originalname = $_FILES[$filesindex]['name']; $attachment->title = ArtefactTypeFileBase::get_new_file_title($originalname, $folderid, $owner, null, null); try { $fileid = ArtefactTypeFile::save_uploaded_file($filesindex, $attachment); } catch (QuotaExceededException $e) { return array('message' => $e->getMessage(), 'goto' => $goto); } catch (UploadException $e) { return array('message' => $e->getMessage(), 'goto' => $goto); } $a->attach($fileid, $itemid); } } // Attachments via 'filebrowser' pieform element // This happens when editing resume composite... if (array_key_exists('filebrowser', $values)) { $old = $a->attachment_id_list_with_item($itemid); $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 { $a->detach($o, $itemid); } catch (ArtefactNotFoundException $e) { } } } $is_error = false; foreach ($new as $n) { if (!in_array($n, $old)) { // check the new item is not already attached to the // artefact under a different $itemid if (record_exists('artefact_attachment', 'artefact', $a->get('id'), 'attachment', $n)) { $artefactfile = artefact_instance_from_id($n); $is_error[] = $artefactfile->get('title'); } else { try { $a->attach($n, $itemid); } catch (ArtefactNotFoundException $e) { } } } } if (!empty($is_error)) { if (sizeof($is_error) > 1) { $error = get_string('duplicateattachments', 'artefact.resume', implode('\', \'', $is_error)); } else { $error = get_string('duplicateattachment', 'artefact.resume', implode(', ', $is_error)); } return array('message' => $error); } } } return $a->id; }