]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-17316, non-js file manager, support externel authentication"
authordongsheng <dongsheng>
Thu, 11 Jun 2009 02:54:33 +0000 (02:54 +0000)
committerdongsheng <dongsheng>
Thu, 11 Jun 2009 02:54:33 +0000 (02:54 +0000)
repository/filepicker.php
repository/flickr/repository.class.php
repository/ws.php

index 19d23454c1f37ccdc6d63d187a1509fc6e08d90f..f0b79fd6ff0887bcac9e64ae7cf206ed65508358 100755 (executable)
@@ -122,13 +122,15 @@ case 'sign':
             echo '<input type="submit" value="Upload" />';
             echo '</form>';
         } else {
-            foreach ($list['path'] as $p) {
-                echo '<form method="post" style="display:inline">';
-                echo '<input type="hidden" name="p" value="'.$p['path'].'"';
-                echo '<input type="hidden" name="action" value="list"';
-                echo '<input type="submit" value="'.$p['name'].'" />';
-                echo '</form>';
-                echo ' <strong>/</strong> ';
+            if (!empty($list['path'])) {
+                foreach ($list['path'] as $p) {
+                    echo '<form method="post" style="display:inline">';
+                    echo '<input type="hidden" name="p" value="'.$p['path'].'"';
+                    echo '<input type="hidden" name="action" value="list"';
+                    echo '<input type="submit" value="'.$p['name'].'" />';
+                    echo '</form>';
+                    echo ' <strong>/</strong> ';
+                }
             }
             echo '<table>';
             foreach ($list['list'] as $item) {
index ff81b1674046c2f0fc0075ca03029ee9a7013f95..24eecb957e3d5b7d72269116c76eb6fe0fee71be 100755 (executable)
@@ -124,14 +124,16 @@ class repository_flickr extends repository {
      * @param <type> $ajax
      * @return <type>
      */
-    public function print_login($ajax = true) {
-        if ($ajax) {
+    public function print_login() {
+        if ($this->options['ajax']) {
             $ret = array();
             $popup_btn = new stdclass;
             $popup_btn->type = 'popup';
             $popup_btn->url = $this->flickr->auth();
             $ret['login'] = array($popup_btn);
             return $ret;
+        } else {
+            echo '<a target="_blank" href="'.$this->flickr->auth().'">Login</a>';
         }
     }
 
index fc41538b2e56eab0afdaefe0a86b9602e1ba0026..cc5992b2e4692aff8a249e6e3fb4cbf92d685cf5 100644 (file)
                 $contextid = $context->id;
                 $fs = get_file_storage();
                 if ($file = $fs->get_file($contextid, 'user_draft', $itemid, '/', $title)) {
-                    $file->delete();
-                    echo 200;
+                    if($result = $file->delete()) {
+                        echo 200;
+                    } else {
+                        echo '';
+                    }
                 } else {
                     echo '';
                 }
         // parent window, in this case, we need to alert user to refresh the repository
         // manually.
         $js  =<<<EOD
-<html><head><script type="text/javascript">
+<html><head>
+<script type="text/javascript">
 if(window.opener){
     window.opener.repository_callback($repo_id);
     window.close();
 } else {
     alert("If parent window is on HTTPS, then we are not allowed to access window.opener object, so we cannot refresh the repository for you automatically, but we already got your session, just go back to file picker and select the repository again, it should work now.");
 }
-</script><body></body></html>
+</script>
+<body>
+<noscript>
+Close this window and refresh file picker.
+</noscript>
+</body>
+</html>
 EOD;
         echo $js;
         die;
@@ -195,6 +205,7 @@ EOD;
                     $itemid = (int)substr(hexdec(uniqid()), 0, 9)+rand(1,100);
                 }
                 if (preg_match('#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#', $filepath)) {
+                    // youtube plugin return a url instead a file path
                     $url = $filepath;
                     echo json_encode(array(
                                 /* File picker need to know this is a link
@@ -208,6 +219,7 @@ EOD;
                                 )
                             );
                 } else if (is_array($filepath)) {
+                    // file api don't have real file path, so we need more file api specific info for "local" plugin
                     $fileinfo = $filepath;
                     $info = array();
                     $info['client_id'] = $client_id;