-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added credential fetching, some diagnostics, and did a settings tidy up
- Loading branch information
1 parent
7e9c559
commit 6e05f3c
Showing
9 changed files
with
192 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
// 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 <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* A Free Trial Jumper | ||
* | ||
* | ||
* @package filter_poodll | ||
* @copyright Justin Hunt ([email protected]) | ||
* @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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
<h2>{{#str}}freetrial, filter_poodll{{/str}}</h2> | ||
<div class="filter_poodll_freetrial_desc"> | ||
{{#str}}freetrial_desc, filter_poodll{{/str}} | ||
</div> | ||
{{^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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="filter_poodll_credsmanager"> | ||
<!-- If API user then show a link + js to poke creds in --> | ||
{{#apiuser}}<a href="#" class="cloudpoodll_poke_creds">{{#str}}fillcredentials, filter_poodll{{/str}}</a>{{/apiuser}} | ||
<!-- if no API user then the user sees a link to a page which will allow them to take a free trial --> | ||
{{^apiuser}}<a href="{{{apppath}}}/fetchcbpage.php" target="_blank">{{#str}}freetrial, filter_poodll{{/str}} [↗]</a>{{/apiuser}} | ||
</div> | ||
{{^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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters