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;
 }
Ejemplo n.º 2
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');
 }
Ejemplo n.º 3
0
        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) {