Beispiel #1
0
 * @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('RESUME_SUBPAGE', 'goalsandskills');
require_once dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'pieforms/pieform.php';
require_once 'pieforms/pieform/elements/calendar.php';
require_once get_config('docroot') . 'artefact/lib.php';
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')));
 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;
 }