]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-16597, disable add button once reach max files limit"
authordongsheng <dongsheng>
Wed, 29 Jul 2009 03:28:36 +0000 (03:28 +0000)
committerdongsheng <dongsheng>
Wed, 29 Jul 2009 03:28:36 +0000 (03:28 +0000)
lang/en_utf8/repository.php
lib/form/filemanager.js
lib/form/filemanager.php
repository/repository.src.js

index 46f1f4e01c29bcf4c7e07b50e0018ae60fbcbac9..ed39d8fb363b6cffcbf80404a35c128eb6a59e14 100644 (file)
@@ -73,6 +73,7 @@ $string['manageuserrepository'] = 'Manage individual repository';
 $string['noenter'] = 'Nothing entered';
 $string['nofilesattached'] = 'No files attached';
 $string['nopermissiontoaccess'] = 'No permission to access this repository';
+$string['nomorefiles'] = 'No more attachments allowed';
 $string['notyourinstances'] = 'You can not view/edit repository instances of another user';
 $string['noresult'] = 'No search result';
 $string['operation'] = 'Operation';
index 5e5e552bf230ab1a3278f726f6f76996a43332c2..0fcd96309c54604de989d5c5c5c7c059763f8eae 100644 (file)
@@ -22,6 +22,11 @@ function fp_callback(obj) {
     var html = '<li><a href="'+obj['url']+'"><img src="'+obj['icon']+'" class="icon" /> '+obj['file']+'</a> ';
     html += '<a href="###" onclick=\'rm_file('+obj['id']+', "'+obj['file']+'", this)\'><img src="'+filemanager.deleteicon+'" class="iconsmall" /></a>';
     html += '</li>';
+    if(obj.maxfileslimit){
+        var btn = document.getElementById('btnadd-'+obj.client_id);
+        btn.onclick = function(){return false;};
+        btn.innerHTML = mstr.repository.nomorefiles;
+    }
     list.innerHTML += html;
 }
 function callpicker(el_id, client_id, itemid) {
@@ -39,4 +44,4 @@ function callpicker(el_id, client_id, itemid) {
     params.callback = fp_callback;
     var fp = open_filepicker(client_id, params);
     return false;
-}
\ No newline at end of file
+}
index 88036cba6d59d23bcc4aa07740a2590ac22c181b..f12dc563a0ce5676818085f96da208ce140da3ef 100644 (file)
@@ -176,6 +176,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
 <a href="###" id="btnadd-{$client_id}" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
 EOD;
         $PAGE->requires->yui_lib('dom');
+        $PAGE->requires->string_for_js('nomorefiles', 'repository');
         $PAGE->requires->js_function_call('YAHOO.util.Dom.setStyle', Array("btnadd-{$client_id}", 'display', 'inline'));
         if (empty($CFG->filemanagerjsloaded)) {
             $jsvars = Array('clientid'   => $client_id,
index 49066c9aa2850788f19d29cd174b93879a0e3472..abfbb91dbd3d9ac3c3cd7ddc32d323cf93b9f761 100644 (file)
@@ -1028,6 +1028,9 @@ repository_client.download_cb = {
 }
 repository_client.end = function(client_id, obj) {
     var fp = repository_client.fp[client_id];
+    if (repository_client.files[client_id] == undefined) {
+        repository_client.files[client_id] = 0;
+    }
     if(fp.env=='filepicker') {
         fp.target.value = obj['id'];
     }else if(fp.env=='editor'){
@@ -1038,6 +1041,7 @@ repository_client.end = function(client_id, obj) {
         }
         fp.target.onchange();
     }
+    obj.maxfileslimit = (repository_client.files[client_id]>=fp.maxfiles);
     fp.formcallback(obj);
     fp.hide();
     repository_client.viewfiles(client_id);