diff --git a/CHANGELOG.md b/CHANGELOG.md index 22863c33..8fb02705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Wallet Enrollment for Moodle # ========== + +## V 5.4.0 ## +- increase precisions of data fields holding amounts. +- Improve the UI of the referrals page (thanks to Davor Budimir) +- Fix bug in referral page that always redirect users. + ## V 5.3.2 ## - Adding main page for wallet (when the user click my wallet). - Add bundles for quick top up with conditional discounts diff --git a/amd/build/overlyprice.min.js b/amd/build/overlyprice.min.js index 26d4f645..a9df27c4 100644 --- a/amd/build/overlyprice.min.js +++ b/amd/build/overlyprice.min.js @@ -6,6 +6,6 @@ define("enrol_wallet/overlyprice",["exports"],(function(_exports){Object.defineP * @copyright 2024 Mohammad Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -const config={attributes:!0,childList:!0,subtree:!0};let observer,regionMain;const callback=mutationList=>{for(const mutation of mutationList)if("childList"===mutation.type&&mutation.addedNodes.length>0)for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:document;stopObserver();let icons=node.querySelectorAll("[data-selector=enrol_wallet_icon]");for(let i=0;i0){var discountLabel=document.createElement("div");discountLabel.classList.add("enrol_wallet_offer"),discountLabel.innerHTML='
'+discount+"%
";let found=!1;for(;!found;){if(parent.getAttribute("data-courseid")||parent.getAttribute("data-course-id")){parent.style.position="relative",parent.appendChild(discountLabel),found=!0;break}if(parent=parent.parentNode,"BODY"==parent.tagName)break}}icons[i].replaceWith(container)}startObserver()}function startObserver(){regionMain=document.getElementById("region-main"),observer.observe(regionMain,config)}function stopObserver(){observer.disconnect()}_exports.init=()=>{observer=new MutationObserver(callback),setTimeout((function(){searchAndInject()}),1e3)}})); +const config={attributes:!0,childList:!0,subtree:!0};let observer,regionMain;const callback=mutationList=>{for(const mutation of mutationList)if("childList"===mutation.type&&mutation.addedNodes.length>0)for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:document;stopObserver();let icons=node.querySelectorAll("[data-selector=enrol_wallet_icon]");for(let i=0;i0){var discountLabel=document.createElement("div");discountLabel.classList.add("enrol_wallet_offer"),discountLabel.innerHTML='
'+discount+"%
";let found=!1;for(;!found;){if(parent.getAttribute("data-courseid")||parent.getAttribute("data-course-id")){parent.style.position="relative",parent.appendChild(discountLabel),found=!0;break}if(parent=parent.parentNode,"BODY"==parent.tagName)break}}icons[i].replaceWith(container)}startObserver()}function startObserver(){regionMain=document.getElementById("region-main"),regionMain&&observer.observe(regionMain,config)}function stopObserver(){observer.disconnect()}_exports.init=()=>{observer=new MutationObserver(callback),setTimeout((function(){searchAndInject()}),1e3)}})); //# sourceMappingURL=overlyprice.min.js.map \ No newline at end of file diff --git a/amd/build/overlyprice.min.js.map b/amd/build/overlyprice.min.js.map index 4663e870..30e97638 100644 --- a/amd/build/overlyprice.min.js.map +++ b/amd/build/overlyprice.min.js.map @@ -1 +1 @@ -{"version":3,"file":"overlyprice.min.js","sources":["../src/overlyprice.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * module overlyprice\n *\n * @module enrol_wallet/overlyprice\n * @copyright 2024 Mohammad Farouk \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst config = {attributes: true, childList: true, subtree: true};\n// Create an observer instance linked to the callback function\nlet observer;\nlet regionMain;\n\nconst callback = (mutationList) => {\n for (const mutation of mutationList) {\n if (mutation.type === \"childList\" && mutation.addedNodes.length > 0) {\n for (let i = 0; i < mutation.addedNodes.length; i++) {\n let node = mutation.addedNodes[i];\n if (node instanceof HTMLElement) {\n searchAndInject(node);\n }\n }\n }\n }\n};\n\n/**\n * Search for enrol wallet icons and inject price and offers.\n * @param {HTMLElement} node\n */\nfunction searchAndInject(node = document) {\n stopObserver();\n let icons = node.querySelectorAll('[data-selector=enrol_wallet_icon]');\n\n for (let i = 0; i < icons.length; i++) {\n let instanceId = icons[i].getAttribute('data-instance-id');\n let parent = icons[i].parentNode;\n let id = 'enrol-wallet-cost-overlay-' + instanceId;\n let exist = parent.querySelector('[data-identifier=' + id + ']');\n if (exist) {\n continue;\n }\n\n let cost = icons[i].getAttribute('data-cost');\n let discount = icons[i].getAttribute('data-discount');\n var titleElement = document.createElement('div');\n titleElement.textContent = cost;\n titleElement.dataIdentifier = id;\n titleElement.title = icons[i].title;\n titleElement.classList.add('enrol_wallet_walletcost');\n\n let container = document.createElement('div');\n container.className = 'wallet-icon';\n container.style.position = 'relative';\n container.style.display = 'flex';\n icons[i].className = 'icon';\n parent.style.display = 'flex';\n parent.style.justifyContent = 'center';\n parent.style.alignItems = 'center';\n\n container.appendChild(icons[i].cloneNode(true));\n container.appendChild(titleElement);\n\n if (discount > 0) {\n var discountLabel = document.createElement('div');\n discountLabel.classList.add('enrol_wallet_offer');\n discountLabel.innerHTML = '
' + discount + '%' + '
';\n let found = false;\n while (!found) {\n if (parent.getAttribute('data-courseid') || parent.getAttribute('data-course-id')) {\n parent.style.position = 'relative';\n parent.appendChild(discountLabel);\n found = true;\n break;\n }\n parent = parent.parentNode;\n if (parent.tagName == 'BODY') {\n break;\n }\n }\n }\n icons[i].replaceWith(container);\n }\n startObserver();\n}\n\n/**\n * Start document mutation observation.\n */\nfunction startObserver() {\n regionMain = document.getElementById(\"region-main\");\n observer.observe(regionMain, config);\n}\n\n/**\n * Stop mutation observer.\n */\nfunction stopObserver() {\n observer.disconnect();\n}\n\n/**\n * Init\n */\nexport const init = () => {\n observer = new MutationObserver(callback);\n setTimeout(function() {\n searchAndInject();\n }, 1000);\n};"],"names":["config","attributes","childList","subtree","observer","regionMain","callback","mutationList","mutation","type","addedNodes","length","i","node","HTMLElement","searchAndInject","document","stopObserver","icons","querySelectorAll","instanceId","getAttribute","parent","parentNode","id","querySelector","cost","discount","titleElement","createElement","textContent","dataIdentifier","title","classList","add","container","className","style","position","display","justifyContent","alignItems","appendChild","cloneNode","discountLabel","innerHTML","found","tagName","replaceWith","startObserver","getElementById","observe","disconnect","MutationObserver","setTimeout"],"mappings":";;;;;;;;MAuBMA,OAAS,CAACC,YAAY,EAAMC,WAAW,EAAMC,SAAS,OAExDC,SACAC,iBAEEC,SAAYC,mBACT,MAAMC,YAAYD,gBACG,cAAlBC,SAASC,MAAwBD,SAASE,WAAWC,OAAS,MACzD,IAAIC,EAAI,EAAGA,EAAIJ,SAASE,WAAWC,OAAQC,IAAK,KAC7CC,KAAOL,SAASE,WAAWE,GAC3BC,gBAAgBC,aACfC,gBAAgBF,iBAW5BE,sBAAgBF,4DAAOG,SAC5BC,mBACIC,MAAQL,KAAKM,iBAAiB,yCAE7B,IAAIP,EAAI,EAAGA,EAAIM,MAAMP,OAAQC,IAAK,KAC/BQ,WAAaF,MAAMN,GAAGS,aAAa,oBACnCC,OAASJ,MAAMN,GAAGW,WAClBC,GAAK,6BAA+BJ,cAC5BE,OAAOG,cAAc,oBAAsBD,GAAK,kBAKxDE,KAAOR,MAAMN,GAAGS,aAAa,aAC7BM,SAAWT,MAAMN,GAAGS,aAAa,qBACjCO,aAAeZ,SAASa,cAAc,OAC1CD,aAAaE,YAAcJ,KAC3BE,aAAaG,eAAiBP,GAC9BI,aAAaI,MAAQd,MAAMN,GAAGoB,MAC9BJ,aAAaK,UAAUC,IAAI,+BAEvBC,UAAYnB,SAASa,cAAc,UACvCM,UAAUC,UAAY,cACtBD,UAAUE,MAAMC,SAAW,WAC3BH,UAAUE,MAAME,QAAU,OAC1BrB,MAAMN,GAAGwB,UAAY,OACrBd,OAAOe,MAAME,QAAU,OACvBjB,OAAOe,MAAMG,eAAiB,SAC9BlB,OAAOe,MAAMI,WAAa,SAE1BN,UAAUO,YAAYxB,MAAMN,GAAG+B,WAAU,IACzCR,UAAUO,YAAYd,cAElBD,SAAW,EAAG,KACViB,cAAgB5B,SAASa,cAAc,OAC3Ce,cAAcX,UAAUC,IAAI,sBAC5BU,cAAcC,UAAY,yCAA2ClB,SAA3C,cACtBmB,OAAQ,QACJA,OAAO,IACPxB,OAAOD,aAAa,kBAAoBC,OAAOD,aAAa,kBAAmB,CAC/EC,OAAOe,MAAMC,SAAW,WACxBhB,OAAOoB,YAAYE,eACnBE,OAAQ,WAGZxB,OAASA,OAAOC,WACM,QAAlBD,OAAOyB,eAKnB7B,MAAMN,GAAGoC,YAAYb,WAEzBc,yBAMKA,gBACL5C,WAAaW,SAASkC,eAAe,eACrC9C,SAAS+C,QAAQ9C,WAAYL,iBAMxBiB,eACLb,SAASgD,2BAMO,KAChBhD,SAAW,IAAIiD,iBAAiB/C,UAChCgD,YAAW,WACPvC,oBACD"} \ No newline at end of file +{"version":3,"file":"overlyprice.min.js","sources":["../src/overlyprice.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * module overlyprice\n *\n * @module enrol_wallet/overlyprice\n * @copyright 2024 Mohammad Farouk \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst config = {attributes: true, childList: true, subtree: true};\n// Create an observer instance linked to the callback function\nlet observer;\nlet regionMain;\n\nconst callback = (mutationList) => {\n for (const mutation of mutationList) {\n if (mutation.type === \"childList\" && mutation.addedNodes.length > 0) {\n for (let i = 0; i < mutation.addedNodes.length; i++) {\n let node = mutation.addedNodes[i];\n if (node instanceof HTMLElement) {\n searchAndInject(node);\n }\n }\n }\n }\n};\n\n/**\n * Search for enrol wallet icons and inject price and offers.\n * @param {HTMLElement} node\n */\nfunction searchAndInject(node = document) {\n stopObserver();\n let icons = node.querySelectorAll('[data-selector=enrol_wallet_icon]');\n\n for (let i = 0; i < icons.length; i++) {\n let instanceId = icons[i].getAttribute('data-instance-id');\n let parent = icons[i].parentNode;\n let id = 'enrol-wallet-cost-overlay-' + instanceId;\n let exist = parent.querySelector('[data-identifier=' + id + ']');\n if (exist) {\n continue;\n }\n\n let cost = icons[i].getAttribute('data-cost');\n let discount = icons[i].getAttribute('data-discount');\n var titleElement = document.createElement('div');\n titleElement.textContent = cost;\n titleElement.dataIdentifier = id;\n titleElement.title = icons[i].title;\n titleElement.classList.add('enrol_wallet_walletcost');\n\n let container = document.createElement('div');\n container.className = 'wallet-icon';\n container.style.position = 'relative';\n container.style.display = 'flex';\n icons[i].className = 'icon';\n parent.style.display = 'flex';\n parent.style.justifyContent = 'center';\n parent.style.alignItems = 'center';\n\n container.appendChild(icons[i].cloneNode(true));\n container.appendChild(titleElement);\n\n if (discount > 0) {\n var discountLabel = document.createElement('div');\n discountLabel.classList.add('enrol_wallet_offer');\n discountLabel.innerHTML = '
' + discount + '%' + '
';\n let found = false;\n while (!found) {\n if (parent.getAttribute('data-courseid') || parent.getAttribute('data-course-id')) {\n parent.style.position = 'relative';\n parent.appendChild(discountLabel);\n found = true;\n break;\n }\n parent = parent.parentNode;\n if (parent.tagName == 'BODY') {\n break;\n }\n }\n }\n icons[i].replaceWith(container);\n }\n startObserver();\n}\n\n/**\n * Start document mutation observation.\n */\nfunction startObserver() {\n regionMain = document.getElementById(\"region-main\");\n if (regionMain) {\n observer.observe(regionMain, config);\n }\n}\n\n/**\n * Stop mutation observer.\n */\nfunction stopObserver() {\n observer.disconnect();\n}\n\n/**\n * Init\n */\nexport const init = () => {\n observer = new MutationObserver(callback);\n setTimeout(function() {\n searchAndInject();\n }, 1000);\n};"],"names":["config","attributes","childList","subtree","observer","regionMain","callback","mutationList","mutation","type","addedNodes","length","i","node","HTMLElement","searchAndInject","document","stopObserver","icons","querySelectorAll","instanceId","getAttribute","parent","parentNode","id","querySelector","cost","discount","titleElement","createElement","textContent","dataIdentifier","title","classList","add","container","className","style","position","display","justifyContent","alignItems","appendChild","cloneNode","discountLabel","innerHTML","found","tagName","replaceWith","startObserver","getElementById","observe","disconnect","MutationObserver","setTimeout"],"mappings":";;;;;;;;MAuBMA,OAAS,CAACC,YAAY,EAAMC,WAAW,EAAMC,SAAS,OAExDC,SACAC,iBAEEC,SAAYC,mBACT,MAAMC,YAAYD,gBACG,cAAlBC,SAASC,MAAwBD,SAASE,WAAWC,OAAS,MACzD,IAAIC,EAAI,EAAGA,EAAIJ,SAASE,WAAWC,OAAQC,IAAK,KAC7CC,KAAOL,SAASE,WAAWE,GAC3BC,gBAAgBC,aACfC,gBAAgBF,iBAW5BE,sBAAgBF,4DAAOG,SAC5BC,mBACIC,MAAQL,KAAKM,iBAAiB,yCAE7B,IAAIP,EAAI,EAAGA,EAAIM,MAAMP,OAAQC,IAAK,KAC/BQ,WAAaF,MAAMN,GAAGS,aAAa,oBACnCC,OAASJ,MAAMN,GAAGW,WAClBC,GAAK,6BAA+BJ,cAC5BE,OAAOG,cAAc,oBAAsBD,GAAK,kBAKxDE,KAAOR,MAAMN,GAAGS,aAAa,aAC7BM,SAAWT,MAAMN,GAAGS,aAAa,qBACjCO,aAAeZ,SAASa,cAAc,OAC1CD,aAAaE,YAAcJ,KAC3BE,aAAaG,eAAiBP,GAC9BI,aAAaI,MAAQd,MAAMN,GAAGoB,MAC9BJ,aAAaK,UAAUC,IAAI,+BAEvBC,UAAYnB,SAASa,cAAc,UACvCM,UAAUC,UAAY,cACtBD,UAAUE,MAAMC,SAAW,WAC3BH,UAAUE,MAAME,QAAU,OAC1BrB,MAAMN,GAAGwB,UAAY,OACrBd,OAAOe,MAAME,QAAU,OACvBjB,OAAOe,MAAMG,eAAiB,SAC9BlB,OAAOe,MAAMI,WAAa,SAE1BN,UAAUO,YAAYxB,MAAMN,GAAG+B,WAAU,IACzCR,UAAUO,YAAYd,cAElBD,SAAW,EAAG,KACViB,cAAgB5B,SAASa,cAAc,OAC3Ce,cAAcX,UAAUC,IAAI,sBAC5BU,cAAcC,UAAY,yCAA2ClB,SAA3C,cACtBmB,OAAQ,QACJA,OAAO,IACPxB,OAAOD,aAAa,kBAAoBC,OAAOD,aAAa,kBAAmB,CAC/EC,OAAOe,MAAMC,SAAW,WACxBhB,OAAOoB,YAAYE,eACnBE,OAAQ,WAGZxB,OAASA,OAAOC,WACM,QAAlBD,OAAOyB,eAKnB7B,MAAMN,GAAGoC,YAAYb,WAEzBc,yBAMKA,gBACL5C,WAAaW,SAASkC,eAAe,eACjC7C,YACAD,SAAS+C,QAAQ9C,WAAYL,iBAO5BiB,eACLb,SAASgD,2BAMO,KAChBhD,SAAW,IAAIiD,iBAAiB/C,UAChCgD,YAAW,WACPvC,oBACD"} \ No newline at end of file diff --git a/amd/src/overlyprice.js b/amd/src/overlyprice.js index 9b836b3e..c91bcf47 100644 --- a/amd/src/overlyprice.js +++ b/amd/src/overlyprice.js @@ -104,7 +104,9 @@ function searchAndInject(node = document) { */ function startObserver() { regionMain = document.getElementById("region-main"); - observer.observe(regionMain, config); + if (regionMain) { + observer.observe(regionMain, config); + } } /** diff --git a/amd/src/referral.js b/amd/src/referral.js index f9f640e5..05cae0ae 100644 --- a/amd/src/referral.js +++ b/amd/src/referral.js @@ -22,6 +22,7 @@ */ import $ from 'jquery'; +// eslint-disable-next-line camelcase import {get_strings} from 'core/str'; import Prefetch from 'core/prefetch'; diff --git a/classes/form/transactions_filter.php b/classes/form/transactions_filter.php index 3ff5d7e1..1f45be2a 100644 --- a/classes/form/transactions_filter.php +++ b/classes/form/transactions_filter.php @@ -81,7 +81,9 @@ public function definition() { $mform->addElement('text', 'value', get_string('value', 'enrol_wallet')); $mform->setType('value', PARAM_FLOAT); - $options = \enrol_wallet\category\options::get_all_categories_options(); + $catoptions = \enrol_wallet\category\options::get_all_categories_options(); + $mform->addElement('select', 'category', get_string('category'), $catoptions); + // Transaction per page. $limits = []; for ($i = 25; $i <= 1000; $i = $i + 25) { diff --git a/classes/pages.php b/classes/pages.php index cc4e4dc5..add640b8 100644 --- a/classes/pages.php +++ b/classes/pages.php @@ -99,7 +99,7 @@ public static function process_referral_page($userid = 0) { 'url' => $signup->out(), 'code' => $exist->code, 'mail_subject' => rawurlencode(get_string('referral_share_subject', 'enrol_wallet')), - 'mail_body' => rawurlencode(get_string('referral_share_body', 'enrol_wallet')) + 'mail_body' => rawurlencode(get_string('referral_share_body', 'enrol_wallet')), ]; $output .= $OUTPUT->render_from_template('enrol_wallet/referral', $templatedata); if (!empty($holdgift)) { diff --git a/classes/payment/service_provider.php b/classes/payment/service_provider.php index a2a9103f..19a4fd4b 100644 --- a/classes/payment/service_provider.php +++ b/classes/payment/service_provider.php @@ -94,6 +94,7 @@ public static function get_success_url(string $paymentarea, int $itemid): \moodl */ public static function deliver_order(string $paymentarea, int $itemid, int $paymentid, int $userid): bool { global $DB, $CFG; + require_once($CFG->dirroot.'/enrol/wallet/lib.php'); // Get the fake item in case of topping up the wallet. $item = $DB->get_record('enrol_wallet_items', ['id' => $itemid], '*', MUST_EXIST); diff --git a/classes/restriction/info.php b/classes/restriction/info.php index 1028a00b..4f897271 100644 --- a/classes/restriction/info.php +++ b/classes/restriction/info.php @@ -164,7 +164,7 @@ public function get_course_module() { * @return bool True if this item is available to the user, false otherwise */ public function is_available(&$information, $grabthelot = false, $userid = 0, - \course_modinfo|null $modinfo = null) { + $modinfo = null) { global $USER, $OUTPUT, $DB; // Default to no information. diff --git a/classes/table/transactions.php b/classes/table/transactions.php index c1d171a9..05f17696 100644 --- a/classes/table/transactions.php +++ b/classes/table/transactions.php @@ -162,6 +162,11 @@ public function set_sql($fields = '*', $from = '{enrol_wallet_transactions}', $w $params['timeto'] = $data->dateto; $where .= "AND timecreated <= :timeto "; } + + if (!empty($data->category)) { + $params['category'] = $data->category; + $where .= "AND category = :category"; + } $this->sql->where = $where; $this->sql->params = $params; } diff --git a/confirm.php b/confirm.php index aaa87a63..accb1f3d 100644 --- a/confirm.php +++ b/confirm.php @@ -38,11 +38,20 @@ $courseid = required_param('id', PARAM_INT); $confirm = optional_param('confirm', false, PARAM_BOOL); +$params = [ + 'instance' => $instanceid, + 'confirm' => $confirm, +]; + +$pageurl = new moodle_url('/enrol/wallet/confirm.php', $params); +$courseurl = new moodle_url('/course/view.php', ['id' => $courseid]); + $context = context_course::instance($courseid); $PAGE->set_context($context); +$PAGE->set_url($pageurl); if (is_enrolled($context, null, '', true)) { - redirect(new moodle_url('/course/view.php', ['id' => $courseid])); + redirect($courseurl); } $helper = new instance($instanceid); @@ -50,14 +59,6 @@ $instance = $helper->get_instance(); $course = get_course($courseid); -$params = [ - 'instance' => $instance->id, - 'id' => $course->id, - 'confirm' => $confirm, -]; - -$PAGE->set_url($CFG->wwwroot.'/enrol/wallet/confirm.php', $params); - $canselfenrol = ($wallet->can_self_enrol($instance, false) === true); // Some security as in the enrol page. @@ -69,7 +70,7 @@ || !$canselfenrol ) { $msg = get_string('confirm_enrol_error', 'enrol_wallet'); - redirect(new moodle_url('/'), $msg, null, 'error'); + redirect($courseurl, $msg, null, 'error'); } if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) { @@ -92,7 +93,7 @@ $wallet->enrol_self($instance); - redirect(new moodle_url('/course/view.php', ['id' => $courseid])); + redirect($courseurl); } $PAGE->set_title($course->shortname); @@ -113,8 +114,9 @@ $cancelbutton = new single_button($cancelurl, get_string('cancel')); $params['confirm'] = true; -$confirmurl = new moodle_url('/enrol/wallet/confirm.php', $params); -$confirmbutton = new single_button($confirmurl, get_string('confirm')); +$pageurl->param('confirm', true); +$confirmbutton = new single_button($pageurl, get_string('confirm')); + $balance = balance::create_from_instance($instance); $a = [ 'balance' => $balance->get_valid_balance(), diff --git a/extra/transaction.php b/extra/transaction.php index 5ad4fa98..b76d5c56 100644 --- a/extra/transaction.php +++ b/extra/transaction.php @@ -48,7 +48,7 @@ 'tsort' => $sort, 'pagesize' => $pagesize, 'page' => $limitfrom, - 'userid' => $userid, + 'userid' => $userid, 'ttype' => $ttype, 'value' => $value, ]; diff --git a/lang/ar/enrol_wallet.php b/lang/ar/enrol_wallet.php index 5d2deef7..edb32e5c 100644 --- a/lang/ar/enrol_wallet.php +++ b/lang/ar/enrol_wallet.php @@ -22,6 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + $string['MWC'] = 'عملات المحفظة'; diff --git a/lang/en/enrol_wallet.php b/lang/en/enrol_wallet.php index 9a575f2f..7f8d659c 100644 --- a/lang/en/enrol_wallet.php +++ b/lang/en/enrol_wallet.php @@ -22,6 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + $string['MWC'] = 'Wallet Coins'; @@ -562,6 +563,8 @@ $string['referral_holdgift'] = 'You have a holding gift ({$a->amount}) due to use of referral code from {$a->name}, buy a course to get your gift.'; $string['referral_max'] = 'Maximum Referrals'; $string['referral_max_desc'] = 'The maximum times a user can receive referral gifts (0 means unlimited).'; +$string['referral_not_enabled'] = 'Referrals not enabled'; +$string['referral_noparents'] = 'Parents not allow to access referral program'; $string['referral_notexist'] = 'The code: \'{$a}\' not exist in the database.'; $string['referral_past'] = 'Past Referrals'; $string['referral_plugins'] = 'Enrol plugins'; @@ -758,3 +761,13 @@ $string['youhavebalance'] = 'You have balance:'; + + +$string['referral_header'] = 'Share link and earn credits in Wallet!'; +$string['referral_subheader'] = 'Simple share link and when someone registers and purchases a course, you\'ll receive {$a} in your Wallet.'; +$string['share_referral'] = 'Share with friends'; +$string['referral_notyet'] = 'Not yet received!'; +$string['referral_copy_to_clipboard'] = 'Copy to clipboard'; +$string['referral_copied'] = 'Copied!'; +$string['referral_share_subject'] = 'Email subject text - change in language strings!'; +$string['referral_share_body'] = 'Email body text - change in language strings!'; diff --git a/lib.php b/lib.php index f495832d..b3da7d90 100644 --- a/lib.php +++ b/lib.php @@ -1896,7 +1896,7 @@ public function get_possible_currencies($account = null) { * @param array|null $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array|null $fields = null) { + public function add_instance($course, $fields = null) { offers::parse_data($fields); diff --git a/styles.css b/styles.css index e0938a5a..0d9b7ef9 100644 --- a/styles.css +++ b/styles.css @@ -316,7 +316,7 @@ background-color: #075e54; } #page-enrol-wallet-extra-referral .shareSocial .socialList li:nth-child(3) a { - background-color: #26617c + background-color: #26617c; } #page-enrol-wallet-extra-referral .shareSocial .socialList li:nth-child(4) a { background-color: #111; diff --git a/templates/referral.mustache b/templates/referral.mustache new file mode 100644 index 00000000..6ef4b642 --- /dev/null +++ b/templates/referral.mustache @@ -0,0 +1,72 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template enrol_wallet/referral + + TODO describe template referral + + Example context (json): + { + } +}} + +
+
+
+
+

{{#str}} referral_header, enrol_wallet{{/str}}

+

{{#str}} referral_subheader, enrol_wallet, {{amount}} {{/str}}

+ + +
+
+

{{#str}} share_referral, enrol_wallet{{/str}}

+
    +
  • +
  • +
  • +
  • +
+
+
+
+
+ +
+
+
+
+ +{{#js}} + require(['enrol_wallet/referral'], function(ref) { + ref.init('{{url}}', '{{uniqid}}'); + }); +{{/js}} \ No newline at end of file diff --git a/tests/coupons_test.php b/tests/coupons_test.php index 21d1d819..74e6664d 100644 --- a/tests/coupons_test.php +++ b/tests/coupons_test.php @@ -30,7 +30,6 @@ * @category test * @copyright 2024 2024, Mohammad Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\coupons */ final class coupons_test extends \advanced_testcase { diff --git a/tests/enrol_wallet_test.php b/tests/enrol_wallet_test.php index 14641dbe..9e03e867 100644 --- a/tests/enrol_wallet_test.php +++ b/tests/enrol_wallet_test.php @@ -38,7 +38,6 @@ * @package enrol_wallet * @copyright 2023 Mo Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet_plugin */ final class enrol_wallet_test extends \advanced_testcase { /** diff --git a/tests/externallib_test.php b/tests/externallib_test.php index 91d8b0a4..d8ec771a 100644 --- a/tests/externallib_test.php +++ b/tests/externallib_test.php @@ -31,7 +31,6 @@ * @copyright 2023 Mohammad Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @runTestsInSeparateProcesses - * @coversDefaultClass \enrol_wallet_external */ final class externallib_test extends externallib_advanced_testcase { diff --git a/tests/notifications_test.php b/tests/notifications_test.php index 461aacf8..ed1e9e1c 100644 --- a/tests/notifications_test.php +++ b/tests/notifications_test.php @@ -31,7 +31,6 @@ * @package enrol_wallet * @copyright 2023 Mo Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\notifications */ final class notifications_test extends \advanced_testcase { /** diff --git a/tests/observer_test.php b/tests/observer_test.php index edba8326..23e4c483 100644 --- a/tests/observer_test.php +++ b/tests/observer_test.php @@ -37,7 +37,6 @@ * @package enrol_wallet * @copyright 2023 Mo Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\observer */ final class observer_test extends \advanced_testcase { /** diff --git a/tests/payment/service_provider_test.php b/tests/payment/service_provider_test.php index 55f6a258..33380902 100644 --- a/tests/payment/service_provider_test.php +++ b/tests/payment/service_provider_test.php @@ -28,7 +28,7 @@ use enrol_wallet\util\instance; /** * Unit tests for the enrol_wallet's payment subsystem callback implementation. - * @coversDefaultClass \enrol_wallet\payment\service_provider + * */ final class service_provider_test extends \advanced_testcase { diff --git a/tests/transactions_test.php b/tests/transactions_test.php index 164cbb8f..764205a0 100644 --- a/tests/transactions_test.php +++ b/tests/transactions_test.php @@ -33,7 +33,6 @@ * @package enrol_wallet * @copyright 2023 Mo Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\transactions */ final class transactions_test extends \advanced_testcase { @@ -47,6 +46,7 @@ final class transactions_test extends \advanced_testcase { * Setup. */ public function setUp(): void { + parent::setUp(); $this->resetAfterTest(true); $this->transactions = new \enrol_wallet\transactions(); diff --git a/tests/turn_non_refundable_test.php b/tests/turn_non_refundable_test.php index 2bf5dbfc..9721ad3d 100644 --- a/tests/turn_non_refundable_test.php +++ b/tests/turn_non_refundable_test.php @@ -33,7 +33,6 @@ * @package enrol_wallet * @copyright 2023 Mo Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\task\turn_non_refundable */ final class turn_non_refundable_test extends \advanced_testcase { /** diff --git a/tests/util/balance_op_test.php b/tests/util/balance_op_test.php index d7ca3987..c2a9c288 100644 --- a/tests/util/balance_op_test.php +++ b/tests/util/balance_op_test.php @@ -35,7 +35,6 @@ * @category test * @copyright 2024 Mohammad Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\util\balance_op */ final class balance_op_test extends \advanced_testcase { /** diff --git a/tests/util/instance_test.php b/tests/util/instance_test.php index 93bb3d4f..52929983 100644 --- a/tests/util/instance_test.php +++ b/tests/util/instance_test.php @@ -30,7 +30,6 @@ * @category test * @copyright 2024 2024, Mohammad Farouk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @coversDefaultClass \enrol_wallet\util\instance */ final class instance_test extends \advanced_testcase { /**