/**
 *
 * @package    mahara
 * @subpackage artefact-resume
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', true);
define('MENUITEM', 'content/resume');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'resume');
define('SECTION_PAGE', 'index');
define('RESUME_SUBPAGE', 'achievements');
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')));
}
$compositetypes = array('certification', 'book', 'membership');
$inlinejs = ArtefactTypeResumeComposite::get_js($compositetypes);
$compositeforms = ArtefactTypeResumeComposite::get_forms($compositetypes);
$smarty = smarty(array('tablerenderer', 'expandable'));
$smarty->assign('compositeforms', $compositeforms);
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('SUBPAGENAV', PluginArtefactResume::submenu_items());
$smarty->display('artefact:resume:achievements.tpl');
示例#2
0
 public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries)
 {
     $artefactmapping = array();
     switch ($strategy) {
         case self::STRATEGY_IMPORT_AS_ENTRY:
         case self::STRATEGY_IMPORT_AS_ABILITY:
             // Based on the mahara:type, we might be able to import it as
             // something useful - otherwise, there is nothing we can do. The
             // entry already claimed it was mahara:plugin="resume", so it's
             // perfectly fine for us to not import it if we don't recognise it
             if ($strategy == self::STRATEGY_IMPORT_AS_ENTRY) {
                 $types = array('careergoal', 'academicgoal', 'personalgoal', 'interest', 'coverletter');
             } else {
                 $types = array('workskill', 'academicskill', 'personalskill');
             }
             $typexpath = join('" or @mahara:type="', $types);
             $artefactpluginelement = $entry->xpath('mahara:artefactplugin[@mahara:type="' . $typexpath . '"]');
             if (count($artefactpluginelement) == 1) {
                 $artefactpluginelement = $artefactpluginelement[0];
                 $maharaattributes = PluginImportLeap::get_attributes($artefactpluginelement, PluginImportLeap::NS_MAHARA);
                 if (isset($maharaattributes['type']) && in_array($maharaattributes['type'], $types)) {
                     $artefactmapping[(string) $entry->id] = array(self::create_artefact($importer, $maharaattributes['type'], $entry->title, PluginImportLeap::get_entry_content($entry, $importer)));
                 }
             }
             break;
         case self::STRATEGY_IMPORT_AS_ACHIEVEMENT:
             $dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
             $enddate = isset($dates['end']) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
             $values = array('date' => $enddate, 'title' => $entry->title, 'description' => PluginImportLeap::get_entry_content($entry, $importer), 'displayorder' => self::get_display_order_for_entry($entry, $importer, 'certification'));
             ArtefactTypeResumeComposite::ensure_composite_value($values, 'certification', $importer->get('usr'));
             break;
         case self::STRATEGY_IMPORT_AS_EMPLOYMENT:
             $dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
             $startdate = isset($dates['start']) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
             $enddate = isset($dates['end']) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
             $employer = '';
             if (isset($otherentries['organization'])) {
                 $organization = $importer->get_entry_by_id($otherentries['organization']);
                 $employer = $organization->title;
             }
             $values = array('startdate' => $startdate, 'enddate' => $enddate, 'employer' => $employer, 'jobtitle' => $entry->title, 'positiondescription' => PluginImportLeap::get_entry_content($entry, $importer), 'displayorder' => self::get_display_order_for_entry($entry, $importer, 'employmenthistory'));
             ArtefactTypeResumeComposite::ensure_composite_value($values, 'employmenthistory', $importer->get('usr'));
             break;
         case self::STRATEGY_IMPORT_AS_BOOK:
             $dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
             $enddate = isset($dates['end']) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
             $contribution = $description = '';
             if (count($otherentries)) {
                 $role = $importer->get_entry_by_id($otherentries[0]);
                 $contribution = $role->title;
                 $description = PluginImportLeap::get_entry_content($role, $importer);
             }
             // check if the import is of the version leap2a 2010-07. If it is then override the contribution and description
             if ($importer->get_leap2a_namespace() == PluginImportLeap::NS_LEAP) {
                 $myrole = PluginImportLeap::get_leap_myrole($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
                 if ($myrole) {
                     $contribution = $myrole;
                 }
                 $description = PluginImportLeap::get_entry_content($entry, $importer);
             }
             $values = array('date' => $enddate, 'title' => $entry->title, 'contribution' => $contribution, 'description' => $description, 'displayorder' => self::get_display_order_for_entry($entry, $importer, 'book'));
             ArtefactTypeResumeComposite::ensure_composite_value($values, 'book', $importer->get('usr'));
             break;
         case self::STRATEGY_IMPORT_AS_EDUCATION:
             $dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
             $startdate = isset($dates['start']) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
             $enddate = isset($dates['end']) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
             $qualtype = $qualname = '';
             if (isset($otherentries['achievement'])) {
                 $qualification = $importer->get_entry_by_id($otherentries['achievement']);
                 $qualtype = $qualification->title;
                 $qualname = PluginImportLeap::get_entry_content($qualification, $importer);
             }
             $institution = '';
             if (isset($otherentries['organization'])) {
                 $organization = $importer->get_entry_by_id($otherentries['organization']);
                 $institution = $organization->title;
             }
             if (!$qualname) {
                 $qualname = $entry->title;
             }
             $values = array('startdate' => $startdate, 'enddate' => $enddate, 'qualtype' => $qualtype, 'qualname' => $qualname, 'institution' => $institution, 'qualdescription' => PluginImportLeap::get_entry_content($entry, $importer), 'displayorder' => self::get_display_order_for_entry($entry, $importer, 'educationhistory'));
             ArtefactTypeResumeComposite::ensure_composite_value($values, 'educationhistory', $importer->get('usr'));
             break;
         case self::STRATEGY_IMPORT_AS_MEMBERSHIP:
             $dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
             $startdate = isset($dates['start']) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
             $enddate = isset($dates['end']) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
             $values = array('startdate' => $startdate, 'enddate' => $enddate, 'title' => $entry->title, 'description' => PluginImportLeap::get_entry_content($entry, $importer), 'displayorder' => self::get_display_order_for_entry($entry, $importer, 'membership'));
             ArtefactTypeResumeComposite::ensure_composite_value($values, 'membership', $importer->get('usr'));
             break;
         case self::STRATEGY_IMPORT_AS_SELECTION:
             // This space intentionally left blank
             break;
         default:
             throw new ImportException($importer, 'TODO: get_string: unknown strategy chosen for importing entry');
     }
     return $artefactmapping;
 }
示例#3
0
文件: lib.php 项目: vohung96/mahara
 public static function render_import_entry_request($entry_content)
 {
     return parent::render_import_entry_request($entry_content, array_keys(self::get_addform_elements()));
 }
示例#4
0
 /**
  * Render import entry requests for Mahara user's resume fields
  * @param PluginImportLeap $importer
  * @return HTML code for displaying user's resume fields and choosing how to import them
  */
 public static function render_import_entry_requests(PluginImportLeap $importer)
 {
     safe_require('artefact', 'resume');
     $importid = $importer->get('importertransport')->get('importid');
     $resumefields = array('introduction' => array('legend' => get_string('introduction', 'artefact.resume'), 'fields' => array('coverletter', 'personalinformation')), 'employment' => array('legend' => get_string('educationandemployment', 'artefact.resume'), 'fields' => array('educationhistory', 'employmenthistory')), 'achievements' => array('legend' => get_string('achievements', 'artefact.resume'), 'fields' => array('certification', 'book', 'membership')), 'goals' => array('legend' => get_string('goals', 'artefact.resume'), 'fields' => array('personalgoal', 'academicgoal', 'careergoal')), 'skills' => array('legend' => get_string('skills', 'artefact.resume'), 'fields' => array('personalskill', 'academicskill', 'workskill')), 'interests' => array('legend' => get_string('interests', 'artefact.resume'), 'fields' => array('interests')));
     $resumecompositefields = array('book', 'certificattion', 'educationhistory', 'employmenthistory', 'membership');
     // Get import entry requests for Mahara resume fields
     $resumegroups = array();
     foreach ($resumefields as $gr_key => $group) {
         $resumegroup = array();
         $resumegroup['id'] = $gr_key;
         $resumegroup['legend'] = $group['legend'];
         foreach ($group['fields'] as $f) {
             if ($iers = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ?', array($importid, $f))) {
                 $resumefieldvalues = array();
                 $fieldname = $f == 'url' ? get_string('bookurl', 'artefact.resume') : get_string($f, 'artefact.resume');
                 foreach ($iers as $ier) {
                     $resumefieldvalue = unserialize($ier->entrycontent);
                     $classname = generate_artefact_class_name($f);
                     $resumefieldvalue['id'] = $ier->id;
                     $resumefieldvalue['decision'] = $ier->decision;
                     $resumefieldvalue['html'] = $classname::render_import_entry_request($resumefieldvalue);
                     if (is_string($ier->duplicateditemids)) {
                         $ier->duplicateditemids = unserialize($ier->duplicateditemids);
                     }
                     if (is_string($ier->existingitemids)) {
                         $ier->existingitemids = unserialize($ier->existingitemids);
                     }
                     $resumefieldvalue['disabled'][PluginImport::DECISION_IGNORE] = false;
                     if (!empty($ier->duplicateditemids)) {
                         $duplicated_rfield = artefact_instance_from_id($ier->duplicateditemids[0]);
                         $resumefieldvalue['duplicateditem']['id'] = $duplicated_rfield->get('id');
                         $res = $duplicated_rfield->render_self(array());
                         $resumefieldvalue['duplicateditem']['html'] = $res['html'];
                         $resumefieldvalue['disabled'][PluginImport::DECISION_ADDNEW] = true;
                         $resumefieldvalue['disabled'][PluginImport::DECISION_APPEND] = true;
                         $resumefieldvalue['disabled'][PluginImport::DECISION_REPLACE] = true;
                     } else {
                         if (!empty($ier->existingitemids)) {
                             if (in_array($f, $resumecompositefields)) {
                                 $existing_rfield = artefact_instance_from_id($ier->existingitemids[0]);
                                 $res = $existing_rfield->render_self(array());
                                 $resumefieldvalue['existingitems'][] = array('id' => $existing_rfield->get('id'), 'html' => $res['html']);
                             } else {
                                 foreach ($ier->existingitemids as $id) {
                                     $existing_rfield = artefact_instance_from_id($id);
                                     $res = $existing_rfield->render_self(array());
                                     $resumefieldvalue['existingitems'][] = array('id' => $existing_rfield->get('id'), 'html' => $res['html']);
                                 }
                             }
                             // Composite artefacts: There's just one "artefact" and then multiple entries
                             // in an associated artefact_resume_* table. So, you want to disable everything
                             // except for "Append"
                             if (in_array($ier->entrytype, ArtefactTypeResumeComposite::get_composite_artefact_types())) {
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_ADDNEW] = true;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_APPEND] = false;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_REPLACE] = true;
                             } else {
                                 $is_singular = call_static_method(generate_artefact_class_name($ier->entrytype), 'is_singular');
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_ADDNEW] = $is_singular;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_APPEND] = !$is_singular;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_REPLACE] = !$is_singular;
                             }
                         } else {
                             if (in_array($ier->entrytype, ArtefactTypeResumeComposite::get_composite_artefact_types())) {
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_ADDNEW] = true;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_APPEND] = false;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_REPLACE] = true;
                             } else {
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_ADDNEW] = false;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_APPEND] = true;
                                 $resumefieldvalue['disabled'][PluginImport::DECISION_REPLACE] = true;
                             }
                         }
                     }
                     $resumefieldvalues[] = $resumefieldvalue;
                 }
                 $resumegroup['fields'][$fieldname] = $resumefieldvalues;
             }
         }
         $resumegroups[] = $resumegroup;
     }
     $smarty = smarty_core();
     $smarty->assign_by_ref('displaydecisions', $importer->get('displaydecisions'));
     $smarty->assign_by_ref('resumegroups', $resumegroups);
     return $smarty->fetch('artefact:resume:import/resumefields.tpl');
 }
示例#5
0
 public static function bulk_delete($artefactids)
 {
     ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'membership');
 }
 public static function getRecordById($type, $id, $artefacttypesmap_array)
 {
     $record = parent::getRecordById($type, $id);
     if (!$record) {
         return false;
     }
     // Tags
     $tags = get_records_array('artefact_tag', 'artefact', $id);
     if ($tags != false) {
         foreach ($tags as $tag) {
             $record->tags[] = $tag->tag;
         }
     } else {
         $record->tags = null;
     }
     // Access: get all the views where the artefact is included
     $access = self::view_access_records($id);
     $accessObj = self::access_process($access);
     if (!$access) {
         // File access: get viewable group media not attached to a view
         $groupaccess = self::group_artefact_access_records($id);
         if ($groupaccess) {
             foreach ($groupaccess as $access) {
                 $accessObj['groups'][$access->role][] = $access->can_view;
             }
         }
     }
     $record->access = $accessObj;
     // set 'mainfacetterm' & 'artefactgroup'
     $terms = explode("|", $artefacttypesmap_array[$record->artefacttype]);
     $record->mainfacetterm = $terms[2];
     $record->secfacetterm = $terms[1];
     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 get the description
         // from this artefact's related résumé table. There is a one -> many relationship between
         // the artefact and the items but seen as all resume items are added
         // to a page when choosing One résumé field, rather than selecting them individually,
         // we can just blob together all the info for this résumé artefact into $record->description.
         $resumetypes = ArtefactTypeResumeComposite::get_composite_artefact_types();
         if (in_array($terms[0], $resumetypes)) {
             try {
                 $query = "SELECT * FROM {artefact_resume_" . $terms[0] . "} WHERE artefact = ?";
                 $results = get_records_sql_assoc($query, array($record->id));
             } catch (SQLException $e) {
                 // Table doesn't exist
                 $results = array();
             }
             foreach ($results as $result) {
                 $items = get_object_vars($result);
                 foreach ($items as $key => $item) {
                     if (!in_array($key, array('id', 'artefact', 'displayorder'))) {
                         $record->description .= $item . ' ';
                     }
                 }
             }
         }
     }
     // AS the field "sort" is not analyzed, we need to clean it (remove html tags & lowercase)
     $record->sort = strtolower(strip_tags($record->title));
     return $record;
 }
示例#7
0
文件: lib.php 项目: Br3nda/mahara
 public static function get_tablerenderer_js()
 {
     return "\n                'startdate',\n                'enddate',\n                " . ArtefactTypeResumeComposite::get_tablerenderer_title_js(self::get_tablerenderer_title_js_string(), self::get_tablerenderer_body_js_string()) . "\n        ";
 }
示例#8
0
文件: index.php 项目: Br3nda/mahara
        function() {
            // @todo error
        }
    );
    return false;
}

function editprofilebutton() {
    document.location='{$wwwroot}artefact/internal/index.php?fs=contact';
    return false;
}

EOF;
$inlinejs .= ArtefactTypeResumeComposite::get_showhide_composite_js();
$compositeforms = array();
foreach (ArtefactTypeResumeComposite::get_composite_artefact_types() as $compositetype) {
    $inlinejs .= <<<EOF
tableRenderers.{$compositetype} = new TableRenderer(
    '{$compositetype}list',
    'composite.json.php',
    [
EOF;
    $inlinejs .= call_static_method(generate_artefact_class_name($compositetype), 'get_tablerenderer_js');
    $inlinejs .= <<<EOF

        function (r) {
            return TD(null, A({'href': 'editcomposite.php?id=' + r.id + '&artefact=' + r.artefact}, '{$editstr}'));
        },
        function (r, d) {
           var link = A({'href': ''}, '{$delstr}');
            connect(link, 'onclick', function (e) {