Example #1
0
/**
 * Returns a (hopefully) human-readable version of the date & time format. To be used in help strings.
 * @return string
 */
function pieform_element_calendar_human_readable_datetimeformat()
{
    return pieform_element_calendar_human_readable_dateformat() . ' ' . pieform_element_calendar_human_readable_timeformat();
}
Example #2
0
define('TITLE', get_string('resume', 'artefact.resume'));
require_once 'pieforms/pieform.php';
require_once 'pieforms/pieform/elements/calendar.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' => ''));
$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', 'class' => 'form-group-nested', 'elements' => array('personalinfomation' => array('type' => 'fieldset', 'legend' => get_string('personalinformation', 'artefact.resume'), 'elements' => array('dateofbirth' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false), 'defaultvalue' => !empty($personalinformation) && null !== $personalinformation->get_composite('dateofbirth') ? $personalinformation->get_composite('dateofbirth') + 3600 : null, 'title' => get_string('dateofbirth', 'artefact.resume'), 'description' => get_string('dateofbirthformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat())), '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'), 'class' => 'btn-primary'))))));
$smarty = smarty(array('artefact/resume/js/simpleresumefield.js'));
$smarty->assign('coverletterform', $coverletterform);
$smarty->assign('personalinformationform', $personalinformationform);
$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'));
        }
    }
}
function personalinformation_submit(Pieform $form, $values)
Example #3
0
function editaccess_validate(Pieform $form, $values)
{
    global $SESSION, $institution, $group;
    $retainview = isset($values['retainview']) ? $values['retainview'] : false;
    if ($retainview && !$values['template']) {
        $form->set_error('retainview', get_string('viewswithretainviewrightsmustbecopyable', 'view'));
    }
    if ($values['startdate'] && $values['stopdate'] && $values['startdate'] > $values['stopdate']) {
        $form->set_error('startdate', get_string('newstartdatemustbebeforestopdate', 'view', 'Overriding'));
    }
    $accesstypestrings = array('public' => get_string('public', 'view'), 'loggedin' => get_string('registeredusers', 'view'), 'friends' => get_string('friends', 'view'), 'user' => get_string('user', 'group'), 'group' => get_string('group', 'group'), 'institution' => get_string('institution'));
    $loggedinaccess = false;
    if ($values['accesslist']) {
        $dateformat = get_string('strftimedatetimeshort');
        foreach ($values['accesslist'] as &$item) {
            if (isset($item['startdate']) && $item['startdate'] === false) {
                $SESSION->add_error_msg(get_string('datetimeformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat()));
                $form->set_error('accesslist', '');
                break;
            }
            if (isset($item['stopdate']) && $item['stopdate'] === false) {
                $SESSION->add_error_msg(get_string('datetimeformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat()));
                $form->set_error('accesslist', '');
                break;
            }
            if ($item['type'] == 'loggedin' && !$item['startdate'] && !$item['stopdate']) {
                $loggedinaccess = true;
            }
            $now = time();
            if ($item['stopdate'] && $now > $item['stopdate']) {
                $SESSION->add_error_msg(get_string('newstopdatecannotbeinpast', 'view', $accesstypestrings[$item['type']]));
                $form->set_error('accesslist', '');
                break;
            }
            if ($item['startdate'] && $item['stopdate'] && $item['startdate'] > $item['stopdate']) {
                $SESSION->add_error_msg(get_string('newstartdatemustbebeforestopdate', 'view', $accesstypestrings[$item['type']]));
                $form->set_error('accesslist', '');
                break;
            }
        }
    }
}
Example #4
0
 /**
  * Gets the new/edit fields for the tasks pieform
  *
  */
 public static function get_taskform_elements($parent, $task = null)
 {
     require_once 'pieforms/pieform/elements/calendar.php';
     $elements = array('title' => array('type' => 'text', 'defaultvalue' => null, 'title' => get_string('title', 'artefact.plans'), 'description' => get_string('titledesc', 'artefact.plans'), 'size' => 30, 'rules' => array('required' => true)), 'completiondate' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false), 'defaultvalue' => null, 'title' => get_string('completiondate', 'artefact.plans'), 'description' => get_string('dateformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat()), 'rules' => array('required' => true)), 'description' => array('type' => 'textarea', 'rows' => 10, 'cols' => 50, 'resizable' => false, 'defaultvalue' => null, 'title' => get_string('description', 'artefact.plans')), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile')), 'completed' => array('type' => 'switchbox', 'defaultvalue' => null, 'title' => get_string('completed', 'artefact.plans'), 'description' => get_string('completeddesc', 'artefact.plans')));
     if (!empty($task)) {
         foreach ($elements as $k => $element) {
             $elements[$k]['defaultvalue'] = $task->get($k);
         }
         $elements['task'] = array('type' => 'hidden', 'value' => $task->id);
     }
     if (get_config('licensemetadata')) {
         $elements['license'] = license_form_el_basic($task);
         $elements['license_advanced'] = license_form_el_advanced($task);
     }
     $elements['parent'] = array('type' => 'hidden', 'value' => $parent);
     return $elements;
 }