]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15402: minor changes for flickr admin settings
authorjerome <jerome>
Mon, 15 Sep 2008 08:42:56 +0000 (08:42 +0000)
committerjerome <jerome>
Mon, 15 Sep 2008 08:42:56 +0000 (08:42 +0000)
lang/en_utf8/repository_flickr.php
repository/flickr/repository.class.php
repository/lib.php

index 643640e10db7f5d8da890dc3167fe3c8e63a404d..5420e6921b57d9018929b9bf8c63fdd4c6fcfd5f 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 $string['apikey'] = 'API Key';
 $string['callbackurl'] = 'Callback URL';
+$string['callbackwarning'] = 'You will need to copy the callback URL into Flickr. This callback URL will be generated once you save this information. Please click on Save button, then on Settings in order to check the generated callback URL';
 $string['configplugin'] = 'Flickr configuration';
 $string['emailaddress'] = 'Email address';
 $string['invalidemail'] = 'Invalid email address for flickr';
index 615b8ee42f468b430dfc4d0f3b67fc20697c51d3..5a61f07de6a4505e2d81a8c9ef1efc1edc5940cb 100755 (executable)
@@ -209,7 +209,7 @@ class repository_flickr extends repository{
     }
 
     public static function has_instance_config() {
-        return true;
+        return false;
     }
 
     public function instance_config_form(&$mform) {
@@ -224,17 +224,24 @@ class repository_flickr extends repository{
     public function admin_config_form(&$mform) {
         global $CFG;
         $api_key = get_config('flickr', 'api_key');
-        $secret  = get_config('flickr', 'secret');
-        $callbackurl = get_config('flickr', 'callbackurl');
+        $secret = get_config('flickr', 'secret');
+
+        //retrieve the flickr instances
+        $instances = repository_get_instances(array(),null,false,"flickr");
+        if (empty($instances)){
+            $callbackurl = get_string("callbackwarning","repository_flickr");
+        }
+        else {
+             $callbackurl = $CFG->wwwroot.'/repository/ws.php?callback=yes&repo_id='.$instances[0]->id;
+        }
+
         if (empty($api_key)) {
             $api_key = '';
         }
         if (empty($secret)) {
             $secret = '';
         }
-        if (empty($callbackurl)) {
-            $callbackurl = $CFG->wwwroot.'/repository/ws.php?callback=yes&repo_id=';
-        }
+
         $strrequired = get_string('required');
         $mform->addElement('text', 'api_key', get_string('apikey', 'repository_flickr'), array('value'=>$api_key,'size' => '40'));
         $mform->addElement('text', 'secret', get_string('secret', 'repository_flickr'), array('value'=>$secret,'size' => '40'));
index aa5621faeec2acbac82480bf59118ca57601fb90..6d6db042e7b91d58e39a4efddf4f8090df71a65d 100644 (file)
@@ -872,6 +872,20 @@ abstract class repository {
         return true;
     }
 
+    /**
+     * function which is run when a type is created
+     * This should be a function from a type, but as I plugin wrtie, only write
+     * a class extended from repository class, the init() for type has been placed
+     * into the repository.
+     */
+    public static function type_init(){
+
+    }
+
+    public static function add_unremovable_instances(){
+
+    }
+
     /**
      * Return true if the plugin type has at least one general option field
      * By default: false
@@ -1005,8 +1019,8 @@ function repository_get_instances($contexts=array(), $userid = null, $onlyvisibl
         $params[] = $context->id;
     }
 
-    if ($firstcontext) {
-        $sql .=')';
+    if (!empty($firstcontext)) {
+       $sql .=')';
     }
 
     if ($onlyvisible == true) {
@@ -1274,7 +1288,7 @@ function repository_get_client($context) {
         .fp-grid .label{height:48px}
         .fp-grid span{background: #EEF9EB;color:gray}
         </style>
-            EOD;
+EOD;
 
         $js = <<<EOD
             <script type="text/javascript" src="$CFG->httpswwwroot/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
@@ -1288,7 +1302,7 @@ function repository_get_client($context) {
             <script type="text/javascript" src="$CFG->httpswwwroot/lib/yui/json/json-min.js"></script>
             <script type="text/javascript" src="$CFG->httpswwwroot/lib/yui/button/button-min.js"></script>
             <script type="text/javascript" src="$CFG->httpswwwroot/lib/yui/selector/selector-beta-min.js"></script>
-            EOD;
+EOD;
         $CFG->repo_yui_loaded = true;
     } else {
         $js = '';
@@ -2314,8 +2328,7 @@ function repository_display_instances_list($context, $typename = null) {
             $addable = 1;
             $instancehtml .= "<form action='".$baseurl."&amp;new=".$typename."' method='post'>
                 <p style='text-align:center'><input type='submit' value='".get_string('createinstance', 'repository')."'/></p>
-                </form>";
-        }
+                </form>";     
     }
 
     if ($addable) {