Permalink
Browse files

MDL-29872 Dropbox repository: add message handler to filepicker heade…

…r and add message to logout from dropbox.

When user clicked on logout button from dropbox repository, it will also logging them out from dropbox site through a popup window
  • Loading branch information...
1 parent 71e12dc commit cd029574b699c74e55fa287f0b4db45d2dcf9fde @rwijaya rwijaya committed Aug 31, 2012
View
@@ -526,6 +526,7 @@ private function fp_js_template_generallayout() {
<div class="{!}fp-tb-logout"><img src="'.$this->pix_url('a/logout').'" /><a href="#"></a></div>
<div class="{!}fp-tb-manage"><a href="#"><img src="'.$this->pix_url('a/setting').'" /> '.get_string('manageurl', 'repository').'</a></div>
<div class="{!}fp-tb-help"><a href="#"><img src="'.$this->pix_url('a/help').'" /> '.get_string('help').'</a></div>
+ <div class="{!}fp-tb-message"></div>
</div>
<div class="{!}fp-viewbar">
<a class="{!}fp-vb-icons" href="#"></a>
@@ -33,3 +33,4 @@
$string['cachelimit'] = 'Cache limit';
$string['cachelimit_info'] = 'Enter the maximum size of files (in bytes) to be cached on server for Dropbox aliases/shortcuts. Cached files will be served when the source is no longer available. Empty value or zero mean caching of all files regardless of size.';
$string['dropbox:view'] = 'View a Dropbox folder';
+$string['logoutdesc'] = '(Logout when you finish using Dropbox)';
@@ -179,6 +179,8 @@ public function get_listing($path = '', $page = '1') {
$list['manage'] = 'https://www.dropbox.com/home';
$list['dynload'] = true;
$list['nosearch'] = true;
+ $list['logouturl'] = 'https://www.dropbox.com/logout';
+ $list['message'] = get_string('logoutdesc', 'repository_dropbox');
// process breadcrumb trail
$list['path'] = array(
array('name'=>get_string('dropbox', 'repository_dropbox'), 'path'=>'/')
View
@@ -1386,6 +1386,8 @@ M.core_filepicker.init = function(Y, options) {
this.active_repo.norefresh = (data.login || data.norefresh); // this is either login form or 'norefresh' attribute set
this.active_repo.nologin = (data.login || data.nologin); // this is either login form or 'nologin' attribute is set
this.active_repo.logouttext = data.logouttext?data.logouttext:null;
+ this.active_repo.logouturl = (data.logouturl || '');
+ this.active_repo.message = (data.message || '');
this.active_repo.help = data.help?data.help:null;
this.active_repo.manage = data.manage?data.manage:null;
this.print_header();
@@ -1698,6 +1700,9 @@ M.core_filepicker.init = function(Y, options) {
callback: this.display_response
}, true);
}
+ if (this.active_repo.logouturl) {
+ window.open(this.active_repo.logouturl, 'repo_auth', 'location=0,status=0,width=500,height=300,scrollbars=yes');
+ }
}, this);
toolbar.one('.fp-tb-refresh').one('a,button').on('click', function(e) {
e.preventDefault();
@@ -1720,7 +1725,7 @@ M.core_filepicker.init = function(Y, options) {
callback: this.display_response
}, true);
}
- }, this);
+ }, this);
// it does not matter what kind of element is .fp-tb-manage, we create a dummy <a>
// element and use it to open url on click event
@@ -1817,6 +1822,12 @@ M.core_filepicker.init = function(Y, options) {
// help url
enable_tb_control(toolbar.one('.fp-tb-help'), r.help);
Y.one('#fp-tb-help-'+client_id+'-link').set('href', r.help);
+
+ // message
+ if (toolbar.one('.fp-tb-message')) {
+ enable_tb_control(toolbar.one('.fp-tb-message'), r.message);
+ toolbar.one('.fp-tb-message').setContent(r.message);
+ }
},
print_path: function() {
if (!this.pathbar) {

0 comments on commit cd02957

Please sign in to comment.