diff --git a/CHANGES.txt b/CHANGES.txt index 28283168..026a1dc0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,10 @@ Change List ========= +Version 3.1.51 (Build 2021122200) +- added some more modern diagnostics +- moved recorder order and some player settings from general to legacy +- added credential fetching + Version 3.1.50 (Build 2021120900) - Fixed issues causing errors in php 8 on poodlltools diff --git a/classes/constants.php b/classes/constants.php index df2b2c99..bf14f8d5 100644 --- a/classes/constants.php +++ b/classes/constants.php @@ -11,6 +11,8 @@ class constants { const MOD_FRANKY = 'filter_poodll'; const M_COMP = 'filter_poodll'; + const M_COMPONENT = 'filter_poodll'; + const M_URL = 'filter/poodll'; const CLOUDPOODLL = 'https://cloud.poodll.com'; // const CLOUDPOODLL = 'https://cloudpoodll.poodll.com'; // const CLOUDPOODLL = 'http://localhost/moodle'; diff --git a/classes/diagnosticstools.php b/classes/diagnosticstools.php index f28ce1d4..2eba9415 100644 --- a/classes/diagnosticstools.php +++ b/classes/diagnosticstools.php @@ -73,8 +73,15 @@ public function compile_properties() { $ds['data_field_version'] = get_config('datafield_poodll', 'version'); $ds['repository_poodll'] = get_config('repository_poodll', 'version'); $ds['atto_cloudpoodll_version'] = get_config('atto_cloudpoodll', 'version'); + $ds['tinymce_cloudpoodll_version'] = get_config('tinymce_cloudpoodll', 'version'); $ds['assignsubmission_cloudpoodll_version'] = get_config('assignsubmission_cloudpoodll', 'version'); + $ds['assignfeedback_cloudpoodll_version'] = get_config('assignfeedback_cloudpoodll', 'version'); + $ds['qtype_cloudpoodll_version'] = get_config('qtype_cloudpoodll', 'version'); $ds['mod_readaloud_version'] = get_config('mod_readaloud', 'version'); + $ds['mod_solo_version'] = get_config('mod_solo', 'version'); + $ds['mod_minilesson_version'] = get_config('mod_minilesson', 'version'); + $ds['mod_wordcards_version'] = get_config('mod_wordcards', 'version'); + $ds['mod_pchat_version'] = get_config('mod_pchat', 'version'); //Registration Key info $lm = new \filter_poodll\licensemanager(); diff --git a/classes/settingstools.php b/classes/settingstools.php index 9b1d539c..65814236 100644 --- a/classes/settingstools.php +++ b/classes/settingstools.php @@ -43,7 +43,7 @@ public static function fetch_jumpcat_items($poodllcat) { } public static function fetch_general_items() { - global $CFG; + global $CFG, $OUTPUT; $items = array(); $items[] = new \admin_setting_heading('filter_poodll_registration_settings', @@ -54,17 +54,50 @@ public static function fetch_general_items() { $items[] = new \admin_setting_configtext('filter_poodll/cpapiuser', get_string('cpapiuser', 'filter_poodll'), get_string('cpapiuser_details', 'filter_poodll'), ''); - //we show a summary of the users apps if we can get the info - $apiuser = get_config('filter_poodll', 'cpapiuser'); - $apisecret = get_config('filter_poodll', 'cpapisecret'); - if ($apiuser && $apisecret) { + $cloudpoodll_apiuser = get_config('filter_poodll', 'cpapiuser'); + $cloudpoodll_apisecret = get_config('filter_poodll', 'cpapisecret'); + $show_below_apisecret=''; + + //if we have an API user and secret we fetch token + if(!empty($cloudpoodll_apiuser) && !empty($cloudpoodll_apisecret)) { $lm = new \filter_poodll\licensemanager(); - $tokeninfo = $lm->fetch_token_for_display($apiuser, $apisecret); - } else { - $tokeninfo = get_string('cpapisecret_details', 'filter_poodll'); + $tokeninfo = $lm->fetch_token_for_display($cloudpoodll_apiuser, $cloudpoodll_apisecret); + $show_below_apisecret=$tokeninfo; + //if we have no API user and secret we show a "fetch from elsewhere on site" or "take a free trial" link + }else{ + $amddata=['apppath'=>$CFG->wwwroot . '/' .constants::M_URL]; + $cp_components=['qtype_cloudpoodll','mod_readaloud','mod_wordcards','mod_solo','mod_minilesson','mod_englishcentral','mod_pchat', + 'atto_cloudpoodll','tinymce_cloudpoodll', 'assignsubmission_cloudpoodll','assignfeedback_cloudpoodll']; + foreach($cp_components as $cp_component){ + switch($cp_component){ + case 'filter_poodll': + $apiusersetting='cpapiuser'; + $apisecretsetting='cpapisecret'; + break; + case 'mod_englishcentral': + $apiusersetting='poodllapiuser'; + $apisecretsetting='poodllapisecret'; + break; + default: + $apiusersetting='apiuser'; + $apisecretsetting='apisecret'; + } + $cloudpoodll_apiuser=get_config($cp_component,$apiusersetting); + if(!empty($cloudpoodll_apiuser)){ + $cloudpoodll_apisecret=get_config($cp_component,$apisecretsetting); + if(!empty($cloudpoodll_apisecret)){ + $amddata['apiuser']=$cloudpoodll_apiuser; + $amddata['apisecret']=$cloudpoodll_apisecret; + break; + } + } + } + $show_below_apisecret=$OUTPUT->render_from_template( constants::M_COMPONENT . '/managecreds',$amddata); } + + $items[] = new \admin_setting_configtext('filter_poodll/cpapisecret', get_string('cpapisecret', 'filter_poodll'), - $tokeninfo, ''); + $show_below_apisecret, ''); //Adding Amazon AWS regions $options = self::fetch_awsregion_options(); @@ -78,38 +111,6 @@ public static function fetch_general_items() { $items[] = new \admin_setting_configcheckbox('filter_poodll_cloudnotifications', get_string('usecloudnotifications', 'filter_poodll'), get_string('usecloudnotifications_desc', 'filter_poodll'), 1); - - $items[] = new \admin_setting_heading('filter_poodll_recorderorder_heading', get_string('recorderorder', 'filter_poodll'), - get_string('recorderorder_desc', 'filter_poodll')); - - //PoodLL player type settings. - $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_audio', - get_string('recorderorder_audio', 'filter_poodll'), - get_string('recorderorder_audio_desc', 'filter_poodll'), 'media,mobile,flashaudio,red5,upload', PARAM_TEXT); - - //PoodLL player type settings. - $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_video', - get_string('recorderorder_video', 'filter_poodll'), - get_string('recorderorder_video_desc', 'filter_poodll'), 'media,mobile,red5,upload', PARAM_TEXT); - - //PoodLL player type settings. - $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_whiteboard', - get_string('recorderorder_whiteboard', 'filter_poodll'), - get_string('recorderorder_whiteboard_desc', 'filter_poodll'), 'upload', PARAM_TEXT); - - //PoodLL player type settings. - $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_snapshot', - get_string('recorderorder_snapshot', 'filter_poodll'), - get_string('recorderorder_snapshot_desc', 'filter_poodll'), 'snapshot,upload', PARAM_TEXT); - - //Allow Adobe Flash on Android - $items[] = - new \admin_setting_configcheckbox('filter_poodll_flash_on_android', get_string('flashonandroid', 'filter_poodll'), - get_string('flashonandroid_desc', 'filter_poodll'), 0); - - $items[] = new \admin_setting_configcheckbox('filter_poodll_download_media_ok', - get_string('showdownloadicon', 'filter_poodll'), get_string('showdownloadicon_desc', 'filter_poodll'), 0); - //html5 recorder settings. $items[] = new \admin_setting_heading('filter_poodll_html5recorder_settings', get_string('filter_poodll_html5recorder_heading', 'filter_poodll'), ''); @@ -125,8 +126,10 @@ public static function fetch_general_items() { get_string('skinstyleaudio_details', 'filter_poodll'), ''); $items[] = new \admin_setting_configtext('filter_poodll/skinstylevideo', get_string('skinstylevideo', 'filter_poodll'), get_string('skinstylevideo_details', 'filter_poodll'), ''); - $items[] = new \admin_setting_configcheckbox('filter_poodll_html5ondsafari', get_string('html5ondsafari', 'filter_poodll'), - get_string('html5ondsafaridetails', 'filter_poodll'), 0); + + $items[] = new \admin_setting_configcheckbox('filter_poodll_download_media_ok', + get_string('showdownloadicon', 'filter_poodll'), get_string('showdownloadicon_desc', 'filter_poodll'), 0); + //PoodLL Whiteboard $items[] = new \admin_setting_heading('filter_poodll_whiteboard_setting', @@ -233,6 +236,37 @@ public static function fetch_legacy_items() { global $CFG; $items = array(); + $items[] = new \admin_setting_heading('filter_poodll_recorderorder_heading', get_string('recorderorder', 'filter_poodll'), + get_string('recorderorder_desc', 'filter_poodll')); + + //PoodLL player type settings. + $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_audio', + get_string('recorderorder_audio', 'filter_poodll'), + get_string('recorderorder_audio_desc', 'filter_poodll'), 'media,mobile,flashaudio,red5,upload', PARAM_TEXT); + + //PoodLL player type settings. + $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_video', + get_string('recorderorder_video', 'filter_poodll'), + get_string('recorderorder_video_desc', 'filter_poodll'), 'media,mobile,red5,upload', PARAM_TEXT); + + //PoodLL player type settings. + $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_whiteboard', + get_string('recorderorder_whiteboard', 'filter_poodll'), + get_string('recorderorder_whiteboard_desc', 'filter_poodll'), 'upload', PARAM_TEXT); + + //PoodLL player type settings. + $items[] = new \admin_setting_configtext('filter_poodll_recorderorder_snapshot', + get_string('recorderorder_snapshot', 'filter_poodll'), + get_string('recorderorder_snapshot_desc', 'filter_poodll'), 'snapshot,upload', PARAM_TEXT); + + //Allow Adobe Flash on Android + $items[] = + new \admin_setting_configcheckbox('filter_poodll_flash_on_android', get_string('flashonandroid', 'filter_poodll'), + get_string('flashonandroid_desc', 'filter_poodll'), 0); + + $items[] = new \admin_setting_configcheckbox('filter_poodll_html5ondsafari', get_string('html5ondsafari', 'filter_poodll'), + get_string('html5ondsafaridetails', 'filter_poodll'), 0); + //PoodLL Network Settings. $items[] = new \admin_setting_heading('filter_poodll_network_settings', get_string('filter_poodll_network_heading', 'filter_poodll'), ''); diff --git a/fetchcbpage.php b/fetchcbpage.php new file mode 100644 index 00000000..6b92b38e --- /dev/null +++ b/fetchcbpage.php @@ -0,0 +1,46 @@ +. + +/** + * A Free Trial Jumper + * + * + * @package filter_poodll + * @copyright Justin Hunt (justin@poodll.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); + +use \filter_poodll\constants; + +require_login(0, false); +$systemcontext = context_system::instance(); +$PAGE->set_context($systemcontext); +$PAGE->set_url('/' . CONSTANTS::M_URL . '/fetchcbpage.php'); + +if(has_capability('moodle/site:config',$systemcontext)){ + + $amddata=['poodllcbsite'=>'poodllcom','wwwroot'=>$CFG->wwwroot, + 'first_name'=>$USER->firstname,'last_name'=>$USER->lastname,'email'=>$USER->email,'country'=>$USER->country]; + echo $OUTPUT->header(); + echo $OUTPUT->render_from_template( constants::M_COMPONENT . '/fetchcbpage',$amddata); + echo $OUTPUT->footer(); +}else{ + echo "no permission to do that action"; +} diff --git a/lang/en/filter_poodll.php b/lang/en/filter_poodll.php index 9a15756a..b9b8bf42 100644 --- a/lang/en/filter_poodll.php +++ b/lang/en/filter_poodll.php @@ -472,4 +472,8 @@ $string['no_subscriptions'] = 'No subscriptions.'; $string['failedfetchsubreport'] = 'Failed to fetch subscription report'; - +$string['freetrial'] = "Get Cloud Poodll API Credentials and a Free Trial"; +$string['freetrial_desc'] = "A dialog should appear that allows you to register for a free trial with Poodll. After registering you should login to the members dashboard to get your API user and secret. And to register your site URL."; +$string['memberdashboard'] = "Member Dashboard"; +$string['memberdashboard_desc'] = ""; +$string['fillcredentials']="Set API user and secret with existing credentials"; diff --git a/templates/fetchcbpage.mustache b/templates/fetchcbpage.mustache new file mode 100644 index 00000000..e27d510c --- /dev/null +++ b/templates/fetchcbpage.mustache @@ -0,0 +1,28 @@ + +

{{#str}}freetrial, filter_poodll{{/str}}

+
+ {{#str}}freetrial_desc, filter_poodll{{/str}} +
+{{^element.frozen}} + {{#js}} + require(['jquery'],function($) { + //set up checkout links + $.getScript('https://js.chargebee.com/v2/chargebee.js', function(){ + var chargebee = Chargebee.init({'site': '{{poodllcbsite}}', isItemsModel: true}); + var cart = chargebee.getCart() + var planPriceId = 'Poodll-Free-Trial-USD-Daily'; + var planPriceQuantity = 1 + var product = chargebee.initializeProduct(planPriceId, planPriceQuantity) + cart.replaceProduct(product); + var customer = {email: "{{email}}", billing_address: {first_name: "{{first_name}}",last_name: "{{last_name}}", country: "{{country}}"}}; + cart.setCustomer(customer); + // Passing values for custom fields + product.setCustomData({cf_startsiteurl: "{{{wwwroot}}}"}); + + // Opening the checkout + cart.proceedToCheckout(); + }); + + }); + {{/js}} +{{/element.frozen}} \ No newline at end of file diff --git a/templates/managecreds.mustache b/templates/managecreds.mustache new file mode 100644 index 00000000..33f46379 --- /dev/null +++ b/templates/managecreds.mustache @@ -0,0 +1,20 @@ +
+ + {{#apiuser}}{{#str}}fillcredentials, filter_poodll{{/str}}{{/apiuser}} + + {{^apiuser}}{{#str}}freetrial, filter_poodll{{/str}} [↗]{{/apiuser}} +
+{{^element.frozen}} + {{#js}} + require(['jquery'],function($) { + //set up fetch from elsewhere + $(".filter_poodll_credsmanager .cloudpoodll_poke_creds").on("click", function() { + event.preventDefault(); + var apiuser = document.getElementById('id_s_filter_poodll_cpapiuser'); + var apisecret = document.getElementById('id_s_filter_poodll_cpapisecret'); + apiuser.value='{{{apiuser}}}'; + apisecret.value='{{{apisecret}}}'; + }); + }); + {{/js}} +{{/element.frozen}} \ No newline at end of file diff --git a/version.php b/version.php index 82103b91..f9741213 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021120900; +$plugin->version = 2021122200; $plugin->requires = 2016052300;//moodle 3.1.0 $plugin->component = 'filter_poodll'; $plugin->maturity = MATURITY_STABLE; -$plugin->release = '3.1.50 (Build 2021120900)'; +$plugin->release = '3.1.51 (Build 2021122200)';