From 04b0a7ef72feba6d4d32eb4128db90194f1b444c Mon Sep 17 00:00:00 2001 From: L_DA Date: Wed, 16 Sep 2020 06:59:58 +0000 Subject: [PATCH] formatting, icon, language strings and capapilities --- db/access.php | 33 +++++++++++++-- externallib.php | 9 ++-- lang/en/timetable.php | 17 +++++--- pix/icon.png | Bin 0 -> 745 bytes pix/icon.svg | 79 +++++++++++++++++++++++++++++++++++ styles.css | 18 ++++---- templates/timetable.mustache | 4 +- version.php | 2 +- 8 files changed, 137 insertions(+), 25 deletions(-) create mode 100644 pix/icon.png create mode 100644 pix/icon.svg diff --git a/db/access.php b/db/access.php index 94191d8..2bd3f2e 100644 --- a/db/access.php +++ b/db/access.php @@ -28,45 +28,70 @@ defined('MOODLE_INTERNAL') || die(); $capabilities = array( - 'mod/timetable:view_teacher' => array( + 'mod/timetable:addinstance' => array( 'riskbitmask' => RISK_XSS, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( + 'manager' => CAP_ALLOW + ), + ), + + 'mod/timetable:search' => array( + 'riskbitmask' => RISK_XSS, + + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'coursecreator' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + ), + + 'mod/timetable:viewteacher' => array( + 'riskbitmask' => RISK_XSS, + + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'coursecreator' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ), ), - 'mod/timetable:view_class' => array( + 'mod/timetable:viewclass' => array( 'riskbitmask' => RISK_XSS, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( + 'coursecreator' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ), ), - 'mod/timetable:view_room' => array( + 'mod/timetable:viewroom' => array( 'riskbitmask' => RISK_XSS, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( + 'coursecreator' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ), ), - 'mod/timetable:view_own_class' => array( + 'mod/timetable:viewownclass' => array( 'riskbitmask' => RISK_XSS, 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( + 'coursecreator' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, 'student' => CAP_ALLOW diff --git a/externallib.php b/externallib.php index 35782fb..c8b6125 100644 --- a/externallib.php +++ b/externallib.php @@ -53,8 +53,8 @@ class mod_timetable_external extends external_api { //Capability checking //OPTIONAL but in most web service it should present - if (!has_capability('moodle/user:viewdetails', $context)) { - throw new moodle_exception('cannotviewprofile'); + if (!has_capability('mod/timetable:search', $context)) { + throw new moodle_exception('cannotperformsearch'); } @@ -146,11 +146,10 @@ class mod_timetable_external extends external_api { //$contextmodule = context_module::instance($cm->id); $usercontext = context_user::instance($USER->id); - //Capability checking //OPTIONAL but in most web service it should present - if (!has_capability('mod/timetable:view_'.$params['type'], $usercontext)) { - if (!(($params['type'] == 'class') && has_capability('mod/timetable:view_own_class', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department)))) + if (!has_capability('mod/timetable:view'.$params['type'], $usercontext)) { + if (!(($params['type'] == 'class') && has_capability('mod/timetable:viewownclass', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department)))) throw new \moodle_exception('cannotviewtimetable'.$params['type']); } diff --git a/lang/en/timetable.php b/lang/en/timetable.php index 47579ea..18c105c 100644 --- a/lang/en/timetable.php +++ b/lang/en/timetable.php @@ -26,18 +26,23 @@ defined('MOODLE_INTERNAL') || die(); $string['pluginname'] = 'Timetable'; +$string['modulename'] = 'Timetable'; +$string['timetablename'] = 'Timetable'; +$string['timetablefieldset'] = 'Settings'; +$string['timetablesettings'] = 'Timetable settings'; $string['import_data'] = 'import_data'; $string['labelfnamelesson'] = 'lesson import file'; -$string['descfnamelesson'] = 'Absolute path and Filename of untis export file lesson.txt'; +$string['descfnamelesson'] = 'Absolute path and filename of untis export file lesson.txt'; $string['labelfnamesubst'] = 'substitution import file'; -$string['descfnamesubst'] = 'Absolute path and Filename of untis export file GPU014.TXT'; +$string['descfnamesubst'] = 'Absolute path and filename of untis export file GPU014.TXT'; $string['labelfnameteacher'] = 'teacher import file'; -$string['descfnameteacher'] = 'Absolute path and Filename of untis export file teacher.txt'; +$string['descfnameteacher'] = 'Absolute path and filename of untis export file teacher.txt'; $string['labelfnameroom'] = 'room import file'; -$string['descfnameroom'] = 'Absolute path and Filename of untis export file room.txt'; +$string['descfnameroom'] = 'Absolute path and filename of untis export file room.txt'; $string['labelfnameclass'] = 'class import file'; -$string['descfnameclass'] = 'Absolute path and Filename of untis export file class.txt'; +$string['descfnameclass'] = 'Absolute path and filename of untis export file class.txt'; $string['labelnumperiod'] = 'max period'; $string['descnumperiod'] = 'max period per day'; $string['labelsaturday'] = 'saturday'; -$string['descsaturday'] = 'enabled if saturday in timetable'; \ No newline at end of file +$string['descsaturday'] = 'enabled if saturday in timetable'; +$string['descfnamesroom'] = 'Absolute path and filename of untis export file room.txt'; diff --git a/pix/icon.png b/pix/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2d5e88d317d4616a5772d617c77b4a236a804694 GIT binary patch literal 745 zcmVe zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00L1-L_t(Y$L-WjXq;6P2H@vT zQzMCxwBVw~jn&OeDE7y0+pb)>CEWmCh$xvYkw^eWDwAJ-|={UdE9l*z9|fL(a9`oR}$9v3l?B%xS! zh#AArh() zdgHwuxqpZO{Ai6qX(Yv2>_EM`#&In2UB-L}CWeN>a^0#(J87Ne?M47^#y(8oS>4+* zMw4VU;TpThHI`;cZ{u&aEmCU1TNsRfKM@w1Tz1-U5@+x)rJ1;{-$6V6BwT2`Mm7YH zohFRn102Bq$m + + + + + + + + + image/svg+xml + + + + + + + S + P + + diff --git a/styles.css b/styles.css index fe2c476..12df7e3 100644 --- a/styles.css +++ b/styles.css @@ -1,7 +1,3 @@ -.timetableffffo th { - width: 4rem; -} - .timetable_description { display:block; float: left; @@ -31,6 +27,8 @@ div.timetable { text-align: center; padding-top:0rem; padding-bottom:0rem; + padding-left:2px; + padding-right:0px; margin: 0 auto; width: 100%; line-height: 1; @@ -55,11 +53,17 @@ div.timetable { } -.timetable th, -.timetable td { +.timetable th { padding: 2px; font-size: 0.8em; text-align: center; - width: 5rem; + width: 4rem; } +.timetable td { + padding: 2px; + padding-left: 2px; + font-size: 0.8em; + text-align: center; + width: 1rem; +} diff --git a/templates/timetable.mustache b/templates/timetable.mustache index 3cd0fdc..acae7b7 100644 --- a/templates/timetable.mustache +++ b/templates/timetable.mustache @@ -14,12 +14,12 @@ -MoDiMiDoFr{{#saturday}}Sa{{/saturday}} +MoDiMiDoFr{{#saturday}}Sa{{/saturday}} {{#periods}} -{{number}} +{{number}} {{#days}} {{#lessons}} diff --git a/version.php b/version.php index 7bd5d27..fb0f255 100644 --- a/version.php +++ b/version.php @@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_timetable'; $plugin->release = '0.1.0'; -$plugin->version = 2020083004; +$plugin->version = 2020091505; $plugin->requires = 2020061500; $plugin->maturity = MATURITY_ALPHA;