Commit 19bd48d3 authored by Lisa Seeto's avatar Lisa Seeto
Browse files

Bug 1875492: Add 'start' and 'end' date options to the default group page settings



- added in start and end windows for default settings pieform
- alter date format to consider time as well as date
- alter calendar to accept an existing time as well as existing date
- added lang string for admin view

Change-Id: I4e2f781bf535fdd7f9f132cc0a6f273d7db13d00
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent ce0a2652
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ $default_group_data = (object) array(
   'hidemembers'    => GROUP_HIDE_NONE,
   'hidemembersfrommembers'  => GROUP_HIDE_NONE,
   'groupparticipationreports' => 0,
   'editwindowstart'  => null,
   'editwindowend'    => null,
   'category'       => 0,
   'usersautoadded' => 0,
   'viewnotify'     => GROUP_ROLES_ALL,
@@ -44,6 +46,9 @@ foreach ($default_group_data as $k => $v) {
    $opt = get_config_institution('mahara', 'group_' . $k);
    if ($opt !== null) {
        $v = $opt;
        if ($k == 'editwindowstart' || $k == 'editwindowend') {
            $v = strtotime($v);
        }
    }
    $group_data->$k = $v;
}
@@ -52,6 +57,7 @@ $groupcategories = get_records_menu('group_category', '', '', 'displayorder', 'i
$groupcategories = $groupcategories ? $groupcategories : array();
$notifyroles = group_get_editroles_options(true);
$notifyroles = $notifyroles ? $notifyroles : array();
$currentdate = getdate();

$optionform = pieform(array(
    'name'       => 'groupsettings',
@@ -164,6 +170,36 @@ $optionform = pieform(array(
            'description'  => get_string('groupparticipationreportsdesc1', 'group'),
            'defaultvalue' => $group_data->groupparticipationreports,
        ),
        'editability' => array(
            'type'        => 'html',
            'value'       => '<h4>' . get_string('editability', 'group') . '</h4>',
        ),
        'editwindowstart' => array(
            'type'        => 'calendar',
            'class'        => '',
            'title'        => get_string('windowstart', 'group'),
            'defaultvalue' => $group_data->editwindowstart,
            'description'  => get_string('windowstartdescription', 'group') . ' ' . get_string('windowdatedescriptionadmin', 'group'),
            'minyear'      => $currentdate['year'],
            'maxyear'      => $currentdate['year'] + 20,
            'time'         => true,
            'caloptions'   => array(
                'showsTime'      => true,
            )
        ),
        'editwindowend' => array(
            'type'        => 'calendar',
            'class'        => '',
            'title'        => get_string('windowend', 'group'),
            'defaultvalue' => $group_data->editwindowend,
            'description'  =>  get_string('windowenddescription', 'group') . ' ' . get_string('windowdatedescriptionadmin', 'group'),
            'minyear'      => $currentdate['year'],
            'maxyear'      => $currentdate['year'] + 20,
            'time'         => true,
            'caloptions'   => array(
                'showsTime'      => true,
            )
        ),
        'general' => array(
            'type'         => 'html',
            'value'        => '<h4>' . get_string('general') . '</h4>',
@@ -344,6 +380,9 @@ function groupsettings_submit(Pieform $form, $values) {
                    execute_sql("DELETE FROM {institution_config} WHERE institution = ? AND field = ?", array('mahara', 'group_' . $k));
                }
                else {
                    if ($k == 'editwindowstart' || $k == 'editwindowend') {
                        $v = db_format_timestamp($v);
                    }
                    set_config_institution('mahara', 'group_' . $k, $v);
                }
            }
+11 −2
Original line number Diff line number Diff line
@@ -88,10 +88,13 @@ else {
                                                 WHERE institution = ? AND field LIKE ? || '%'", array('mahara', $group_prefix))) {
        foreach ($group_defaults as $k => $v) {
            $item = preg_replace('/^' . $group_prefix . '/', '', $v->field);
            if (isset($group_data->$item)) {
            if (array_key_exists($item, $group_data)) {
                if ($item == 'controlled' && !$cancreatecontrolled) {
                    $v->value = 0;
                }
                if ($item == 'editwindowstart' || $item == 'editwindowend') {
                    $v->value = strtotime($v->value);
                }
                $group_data->$item = $v->value;
            }
        }
@@ -366,6 +369,9 @@ $elements['editwindowstart'] = array (
    'minyear'      => $currentdate['year'],
    'maxyear'      => $currentdate['year'] + 20,
    'time'         => true,
    'caloptions'   => array(
        'showsTime'      => true,
    )
);

$elements['editwindowend'] = array (
@@ -376,7 +382,10 @@ $elements['editwindowend'] = array (
    'description'  => get_string('windowenddescription', 'group'),
    'minyear'      => $currentdate['year'],
    'maxyear'      => $currentdate['year'] + 20,
    'time'         => true
    'time'         => true,
    'caloptions'   => array(
        'showsTime'      => true,
    )
);

$elements['general'] = array(
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ $string['editable'] = 'Editable';
$string['editability'] = 'Editability';
$string['windowstart'] = 'Start date';
$string['windowstartdescription'] = 'The group cannot be edited by normal group members before this date. This date will also be used as default start date for any imported plans.';
$string['windowdatedescriptionadmin'] = 'Only set this date if required and you are adding groups in bulk. Remember to clear this field once you are done.';
$string['windowend'] = 'End date';
$string['windowenddescription'] = 'The group cannot be edited by normal group members after this date. This date will also be used as default completion date for any imported plans.';
$string['editwindowbetween'] = 'Between %s and %s';
+8 −2
Original line number Diff line number Diff line
@@ -80,9 +80,15 @@ function pieform_element_calendar(Pieform $form, $element) {
    }
    $tooltips = json_encode(pieform_element_calendar_tooltip_lang_strings());
    if ($value) {
        if (!empty($options['showsTime'])) {
            $result .= '
                date: moment("' . $value . '", "' . $options['dateFormat'] . ' ' . $options['timeFormat'] . '"),';
        }
        else {
            $result .= '
                date: moment("' . $value . '", "' . $options['dateFormat'] . '"),';
        }
    }
    $result .= '
        locale: "' . strstr(current_language(), '.', true) . '",
        useCurrent: false,