From 2f09dddde7e88d41854c8acba75561bc81bd42c5 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Tue, 29 Sep 2020 23:37:26 -0400 Subject: [PATCH] Revert "New {UserFirstaccess} FilterCode (#115)" This reverts commit e552c467adc84e8e3ff48a27f2e342aeee1ce1ed. --- .filter.php.swp | Bin 16384 -> 0 bytes README.md | 14 -------- filter.php | 83 ++++++++---------------------------------------- 3 files changed, 14 insertions(+), 83 deletions(-) delete mode 100644 .filter.php.swp diff --git a/.filter.php.swp b/.filter.php.swp deleted file mode 100644 index d84e11883586e0374ca5f0ebe0de314fa9247063..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHNYmD4h6*hr}h7uYmsv04olXR+`4LdWtn@v+~nr$}w%1Zm{KJs9@op|j#Gj2S# zv9EW!q-lSEKuG;lA<>_x?QaB9U*QK5NC=4^AeF}tR8X|-CFxI(37*=RuhGh9;y>b~qXyc?^^r8xsR1Mh`_ zP}WNK?bQws4@IGV_rU{n$0yd_i-x>x&OpvU&OpvU&OpvU&OpvU&Opw<`N>5SZ)D`}D*2*%{(MIMFC~9iJ>R7oNZNTPqyKzH{!b-8qw2qu zkzZ5tQ%b&9btuvQwvsO>`C3N)mXgmZ`EwchKa_k@$**MOe^>HpB_I4?e3P{QHzhx* z>b`o}cwGVmf007Jmly_)u2;5)#hz!6{s7zAzuZUx@>DD(qg z0FD7ifqQ|E1N(rhw`tm&z_)?Rzze{6U<23>yz&uE`w{Ro@E|Y(ytYTvUIxAi3@67!( z$wvJ;Poj>i=K4Z68dNOEh82{?bl+$Qx$TKyy^!8-l*WA57M2;19#A2^@287eha##} zXxjBD(&pAkHUx1&t`fM0rAuK_%aV;qlBymcv}ar(E3Od+!lworaUDUOTFPl#mq^%w z$TZ%zwaacgPL@;EeP7=$7A$js{5T1KZ<(6`>fY}8c;p9hfv$F-a~`-v}t(3U~@zu21TEn9ZL z3T(Gt7pCPD`{}XA$O`JA2qb%AvCA?vJX<5j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tSOqF;i}PGfyJR@gF1O-*Hy{2l%&Bp{X|(%yZ-_H%AWWCk7Eyh4dDHM^8WK# z?DxM6=)eQOr-6OIZr~Q+H`x3C8u%LUd0-0I2kZvEg+2dMz-NKGf&IW;z%Jk&)z;hG zUVh~a2>Bo`kJx3?|_@xyTbi5bh1BYJKM&fEGcc{j1I|?E&bWfOk>?0f_Ju8Jq z>;NZRY_4&*AMHtTc*JkIcoP`g#b;BhdUR|QpH&2Sj4fj#*!0l>by&)Fw%Oocy{taW zR$tn|<{MQS=1LcLsFdyK&Ff{-JB{t)3#6UGUb=&T_&`mIr1;a_|L$L0rhua<2XCKn zzRIs_y5BTJ1(bgja9S5T5 html tag containing the user's profile picture. X indicates the size and can be **sm** (small), **md** (medium) or **lg** (large). If the user does not have profile picture or is logged out, the default faceless profile photo will be used instead. * {usercount} : Count total number of registered users on the site. Does not included deleted users, primary admin or guest. -* {userfirstaccess} : Date that the user first accessd the site * {usersactive} : Count total number of registered users on the site. Does not included deleted users, disabled users, primary admin or guest. * {usersonline} : Total number of users who were online in the last 5 minutes. * {siteyear} : 4-digit current year. @@ -228,19 +227,6 @@ The {langx fr-CA}{/langx} filter will convert this into the following HTML Contenu -Date strftime Arguments - -The 4 datetime codes can optionally take a strftime string to define the format. This string must be enclosed with double quotes. - -* {userfirstaccess} -* {coursestartdate} -* {courseenddate} -* {coursecompletiondate} - -Example: - - {userfirstaccess "%m/%d/%Y, %H:%M:%S"} - ## FilterCodes in a custom menu Here are a couple of examples of how to create really useful custom menus using FilterCodes. Just copy and paste the code into the **Custom menu items** field (Site administration > Appearance > Theme settings) diff --git a/filter.php b/filter.php index 20d3ee4..f5ef948 100644 --- a/filter.php +++ b/filter.php @@ -598,28 +598,6 @@ function ($matches) { } } - // Tag: {userfirstaccess} or {userfirstaccess "strftime"} - if (stripos($text, '{userfirstaccess') !== false) { - if (isloggedin() && !isguestuser()) { - $user = $DB->get_record('user', array('id' => $USER->id), 'firstaccess', MUST_EXIST); - $newtext = preg_replace_callback('/{userfirstaccess(\s+"(.*)")?}/i', - function($matches) use ($user) { - if(sizeof($matches) == 1 && $matches[0] == "{userfirstaccess}"){ - return userdate($user->firstaccess, get_string('strftimedatefullshort')); - }else if(sizeof($matches) == 3){ - return userdate($user->firstaccess, $matches[2]); - } - }, $text); - if ($newtext !== false) { - $text = $newtext; - $changed = true; - } - unset($user); - } else { - $replace['/\{userfirstaccess(\s+"(.*)")?\}/i'] = get_string('none'); - } - } - // Tag: {usercount}. if (stripos($text, '{usercount}') !== false) { // Count total number of current users on the site. @@ -787,78 +765,45 @@ function($matches) use ($user) { $replace['/\{courseimage\}/i'] = ''; } - // Tag: {coursestartdate} or {coursestartdate "strftime"}. The course start date. - if (stripos($text, '{coursestartdate') !== false) { + // Tag: {coursestartdate}. The course start date. + if (stripos($text, '{coursestartdate}') !== false) { if (empty($PAGE->course->startdate)) { $PAGE->course->startdate = $DB->get_field_select('course', 'startdate', 'id = :id', ['id' => $course->id]); } if ($PAGE->course->startdate > 0) { - $newtext = preg_replace_callback('/{coursestartdate(\s+"(.*)")?}/i', - function($matches) use ($PAGE) { - if(sizeof($matches) == 1 && $matches[0] == "{coursestartdate}"){ - return userdate($PAGE->course->startdate, get_string('strftimedatefullshort')); - }else if(sizeof($matches) == 3){ - return userdate($PAGE->course->startdate, $matches[2]); - } - }, $text); - if ($newtext !== false) { - $text = $newtext; - $changed = true; - } + $replace['/\{coursestartdate\}/i'] = userdate($PAGE->course->startdate, get_string('strftimedatefullshort')); } else { - $replace['/\{coursestartdate(\s+"(.*)")?\}/i'] = get_string('none'); + $replace['/\{coursestartdate\}/i'] = get_string('none'); } } - // Tag: {courseenddate} or {coursesenddate "strftime"}. The course end date. - if (stripos($text, '{courseenddate') !== false) { + // Tag: {courseenddate}. The course end date. + if (stripos($text, '{courseenddate}') !== false) { if (empty($PAGE->course->enddate)) { $PAGE->course->enddate = $DB->get_field_select('course', 'enddate', 'id = :id', ['id' => $course->id]); } if ($PAGE->course->enddate > 0) { - $newtext = preg_replace_callback('/{courseenddate(\s+"(.*)")?}/i', - function($matches) use ($PAGE) { - if(sizeof($matches) == 1 && $matches[0] == "{courseenddate}"){ - return userdate($PAGE->course->enddate, get_string('strftimedatefullshort')); - }else if(sizeof($matches) == 3){ - return userdate($PAGE->course->enddate, $matches[2]); - } - }, $text); - if ($newtext !== false) { - $text = $newtext; - $changed = true; - } + $replace['/\{courseenddate\}/i'] = userdate($PAGE->course->enddate, get_string('strftimedatefullshort')); } else { - $replace['/\{courseenddate(\s+"(.*)")?\}/i'] = get_string('none'); + $replace['/\{courseenddate\}/i'] = get_string('none'); } } - - // Tag: {coursecompletiondate} or {coursecompletiondate "strftime"}. The course completion date. - if (stripos($text, '{coursecompletiondate') !== false) { + // Tag: {coursecompletiondate}. The course completion date. + if (stripos($text, '{coursecompletiondate}') !== false) { if ($PAGE->course && isset($CFG->enablecompletion) && $CFG->enablecompletion == COMPLETION_ENABLED && $PAGE->course->enablecompletion) { $ccompletion = new completion_completion(['userid' => $USER->id, 'course' => $PAGE->course->id]); if ($ccompletion->timecompleted) { - $newtext = preg_replace_callback('/{coursecompletiondate(\s+"(.*)")?}/i', - function($matches) use ($ccompletion) { - if(sizeof($matches) == 1 && $matches[0] == "{coursecompletiondate}"){ - return userdate($ccompletion->timecompleted, get_string('strftimedatefullshort')); - }else if(sizeof($matches) == 3){ - return userdate($ccompletion->timecompleted, $matches[2]); - } - }, $text); - if ($newtext !== false) { - $text = $newtext; - $changed = true; - } + $replace['/\{coursecompletiondate\}/i'] = userdate($ccompletion->timecompleted, + get_string('strftimedatefullshort')); } else { - $replace['/\{coursecompletiondate(\s+"(.*)")?\}/i'] = get_string('notcompleted', 'completion'); + $replace['/\{coursecompletiondate\}/i'] = get_string('notcompleted', 'completion'); } } else { - $replace['/\{coursecompletiondate(\s+"(.*)")?\}/i'] = get_string('completionnotenabled', 'completion'); + $replace['/\{coursecompletiondate\}/i'] = get_string('completionnotenabled', 'completion'); } }