Permalink
Browse files

Merge branch 'MDL-59285-master' of git://github.com/lameze/moodle

  • Loading branch information...
dmonllao committed Jun 28, 2017
2 parents 1bff0a1 + 83f50ac commit 7f382c05b027112f9711461f9e498732a4805e79
Showing with 83 additions and 0 deletions.
  1. +4 −0 admin/tool/mobile/lang/en/tool_mobile.php
  2. +76 −0 admin/tool/mobile/lib.php
  3. +3 −0 admin/tool/mobile/settings.php
@@ -62,12 +62,16 @@
$string['loginintheembeddedbrowser'] = 'Via an embedded browser (for SSO plugins)';
$string['mainmenu'] = 'Main menu';
$string['mobileapp'] = 'Mobile app';
$string['mobileappconnected'] = 'Mobile app connected';
$string['mobileappenabled'] = 'This site has mobile app access enabled. You can use mobile app to access the content of your courses and much more. Click <a href="{$a}">here</a> for more information';
$string['mobileappearance'] = 'Mobile appearance';
$string['mobileauthentication'] = 'Mobile authentication';
$string['mobilecssurl'] = 'CSS';
$string['mobilefeatures'] = 'Mobile features';
$string['mobilesettings'] = 'Mobile settings';
$string['pluginname'] = 'Moodle Mobile tools';
$string['setuplink'] = 'Mobile setup link';
$string['setuplink_desc'] = 'Link to documentation page to help users setup their mobile app.';
$string['smartappbanners'] = 'App Banners';
$string['pluginnotenabledorconfigured'] = 'Plugin not enabled or configured.';
$string['remoteaddons'] = 'Remote add-ons';
@@ -50,3 +50,79 @@ function tool_mobile_before_standard_html_head() {
}
return $output;
}
/**
* Generate the app download url to promote moodle mobile.
*
* @return moodle_url|void App download moodle_url object or return if setuplink is not set.
*/
function tool_mobile_create_app_download_url() {
global $CFG;
$mobilesettings = get_config('tool_mobile');
if (empty($mobilesettings->setuplink)) {
return;
}
$downloadurl = new moodle_url($mobilesettings->setuplink);
$downloadurl->param('version', $CFG->version);
$downloadurl->param('lang', current_language());
if (!empty($mobilesettings->iosappid)) {
$downloadurl->param('iosappid', $mobilesettings->iosappid);
}
if (!empty($mobilesettings->androidappid)) {
$downloadurl->param('androidappid', $mobilesettings->androidappid);
}
return $downloadurl;
}
/**
* User profile page callback.
*
* Used add a section about the moodle mobile app.
*
* @param \core_user\output\myprofile\tree $tree My profile tree where the setting will be added.
* @param stdClass $user The user object.
* @param bool $iscurrentuser Is this the current user viewing
* @return void Return if the mobile web services setting is disabled or if not the current user.
*/
function tool_mobile_myprofile_navigation(\core_user\output\myprofile\tree $tree, $user, $iscurrentuser) {
global $CFG, $DB;
if (empty($CFG->enablemobilewebservice)) {
return;
}
if (!$iscurrentuser) {
return;
}
if (!$url = tool_mobile_create_app_download_url()) {
return;
}
$sql = "SELECT 1
FROM {external_tokens} t, {external_services} s
WHERE t.externalserviceid = s.id
AND s.enabled = 1
AND s.shortname IN ('moodle_mobile_app', 'local_mobile')
AND t.userid = ?";
$userhastoken = $DB->record_exists_sql($sql, [$user->id]);
$mobilecategory = new core_user\output\myprofile\category('mobile', get_string('mobileapp', 'tool_mobile'),
'loginactivity');
$tree->add_category($mobilecategory);
if ($userhastoken) {
$mobilestr = get_string('mobileappconnected', 'tool_mobile');
} else {
$mobilestr = get_string('mobileappenabled', 'tool_mobile', $url->out());
}
$node = new core_user\output\myprofile\node('mobile', 'mobileappnode', $mobilestr, null);
$tree->add_node($node);
}
@@ -83,6 +83,9 @@
$temp->add(new admin_setting_configtext('tool_mobile/androidappid', new lang_string('androidappid', 'tool_mobile'),
new lang_string('androidappid_desc', 'tool_mobile'), 'com.moodle.moodlemobile', PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('tool_mobile/setuplink', new lang_string('setuplink', 'tool_mobile'),
new lang_string('setuplink_desc', 'tool_mobile'), 'https://download.moodle.org/mobile', PARAM_URL));
$ADMIN->add('mobileapp', $temp);
// Features related settings.

0 comments on commit 7f382c0

Please sign in to comment.