]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15350: format code (mostly white spaces) + skeleton for documentation
authorjerome <jerome>
Tue, 16 Sep 2008 02:09:35 +0000 (02:09 +0000)
committerjerome <jerome>
Tue, 16 Sep 2008 02:09:35 +0000 (02:09 +0000)
repository/boxnet/repository.class.php

index 0948d0222b62026152409813e633d0a1152e3ff5..f229614f7128a16e0aad030f858137b2f76c90da 100755 (executable)
 
 require_once($CFG->libdir.'/boxlib.php');
 
-class repository_boxnet extends repository{
+/**
+ *
+ */
+class repository_boxnet extends repository {
     private $box;
 
-    public function __construct($repositoryid, $context = SITEID, $options = array()){
+    /**
+     *
+     * @global <type> $SESSION
+     * @param <type> $repositoryid
+     * @param <type> $context
+     * @param <type> $options
+     */
+    public function __construct($repositoryid, $context = SITEID, $options = array()) {
         global $SESSION;
+
         $options['username']   = optional_param('boxusername', '', PARAM_RAW);
         $options['password']   = optional_param('boxpassword', '', PARAM_RAW);
         $options['ticket']     = optional_param('ticket', '', PARAM_RAW);
@@ -26,21 +37,18 @@ class repository_boxnet extends repository{
         $sess_name = 'box_token'.$this->id;
         $this->sess_name = 'box_token'.$this->id;
         // do login
-        if(!empty($options['username'])
-                    && !empty($options['password'])
-                    && !empty($options['ticket']) )
-        {
+        if (!empty($options['username']) && !empty($options['password']) && !empty($options['ticket']) ) {
             $this->box = new boxclient($this->api_key);
-            try{
+            try {
                 $SESSION->$sess_name = $this->box->getAuthToken($options['ticket'], 
-                    $options['username'], $options['password']);
+                $options['username'], $options['password']);
             } catch (repository_exception $e) {
                 throw $e;
             }
         }
         // already logged
-        if(!empty($SESSION->$sess_name)) {
-            if(empty($this->box)) {
+        if (!empty($SESSION->$sess_name)) {
+            if (empty($this->box)) {
                 $this->box = new boxclient($this->api_key, $SESSION->$sess_name);
             }
             $this->auth_token = $SESSION->$sess_name;
@@ -49,18 +57,35 @@ class repository_boxnet extends repository{
         }
     }
 
-    public function check_login(){
+    /**
+     *
+     * @global <type> $SESSION
+     * @return <type>
+     */
+    public function check_login() {
         global $SESSION;
+
         return !empty($SESSION->{$this->sess_name});
     }
 
-    public function logout(){
+    /**
+     *
+     * @global <type> $SESSION
+     * @return <type>
+     */
+    public function logout() {
         global $SESSION;
+
         unset($SESSION->{$this->sess_name});
         return $this->print_login();
     }
 
-    public function set_option($options = array()){
+    /**
+     *
+     * @param <type> $options
+     * @return <type>
+     */
+    public function set_option($options = array()) {
         if (!empty($options['api_key'])) {
             set_config('api_key', trim($options['api_key']), 'boxnet');
         }
@@ -69,8 +94,13 @@ class repository_boxnet extends repository{
         return $ret;
     }
 
-    public function get_option($config = ''){
-        if($config==='api_key'){
+    /**
+     *
+     * @param <type> $config
+     * @return <type>
+     */
+    public function get_option($config = '') {
+        if ($config==='api_key') {
             return trim(get_config('boxnet', 'api_key'));
         } else {
             $options['api_key'] = trim(get_config('boxnet', 'api_key'));
@@ -79,7 +109,12 @@ class repository_boxnet extends repository{
         return $options;
     }
 
-    public function global_search(){
+    /**
+     *
+     * @global <type> $SESSION
+     * @return <type>
+     */
+    public function global_search() {
         global $SESSION;
         $sess_name = 'box_token'.$this->id;
         if (empty($SESSION->$sess_name)) {
@@ -89,8 +124,14 @@ class repository_boxnet extends repository{
         }
     }
 
-    public function get_login(){
+    /**
+     *
+     * @global <type> $DB
+     * @return <type>
+     */
+    public function get_login() {
         global $DB;
+
         if ($entry = $DB->get_record('repository_instances', array('id'=>$this->id))) {
             $ret->username = $entry->username;
             $ret->password = $entry->password;
@@ -100,8 +141,18 @@ class repository_boxnet extends repository{
         }
         return $ret;
     }
-    public function get_listing($path = '/', $search = ''){
+
+    /**
+     *
+     * @global <type> $CFG
+     * @global <type> $SESSION
+     * @param <type> $path
+     * @param <type> $search
+     * @return <type>
+     */
+    public function get_listing($path = '/', $search = '') {
         global $CFG, $SESSION;
+
         $list = array();
         $ret  = array();
         if (!empty($search)) {
@@ -112,8 +163,8 @@ class repository_boxnet extends repository{
                 $filesizes = $tree['file_size'];
                 $filedates = $tree['file_date'];
                 $fileicon  = $tree['thumbnail'];
-                foreach ($filenames as $n=>$v){
-                    if(strstr($v, $search) !== false) {
+                foreach ($filenames as $n=>$v) {
+                    if (strstr($v, $search) !== false) {
                         $list[] = array('title'=>$v, 
                                 'size'=>$filesizes[$n],
                                 'date'=>$filedates[$n],
@@ -127,7 +178,7 @@ class repository_boxnet extends repository{
             return $ret;
         }
         $tree = $this->box->getfiletree($path);
-        if(!empty($tree)) {
+        if (!empty($tree)) {
             $ret['list']   = $tree;
             $ret['manage'] = 'http://www.box.net/files';
             $ret['path'] = array(array('name'=>'Root', 'path'=>0));
@@ -140,7 +191,11 @@ class repository_boxnet extends repository{
         }
     }
 
-    public function print_login(){
+    /**
+     *
+     * @return <type>
+     */
+    public function print_login() {
         $t = $this->box->getTicket();
         $ret = $this->get_login();
         if ($this->options['ajax']) {
@@ -165,30 +220,58 @@ class repository_boxnet extends repository{
         }
     }
 
-    public function print_search(){
+    /**
+     *
+     * @return <type>
+     */
+    public function print_search() {
         return false;
     }
 
+    /**
+     *
+     * @return <type>
+     */
     public static function has_admin_config() {
         return true;
     }
 
+    /**
+     *
+     * @return <type>
+     */
     public static function has_instance_config() {
         return false;
     }
 
-    public static function has_multiple_instances(){
+    /**
+     *
+     * @return <type>
+     */
+    public static function has_multiple_instances() {
         return false;
     }
 
-    public static function get_admin_option_names(){
+    /**
+     *
+     * @return <type>
+     */
+    public static function get_admin_option_names() {
         return array('api_key');
     }
 
-    public static function get_instance_option_names(){
+    /**
+     *
+     * @return <type>
+     */
+    public static function get_instance_option_names() {
         return array('share_url');
     }
 
+    /**
+     *
+     * @param <type> $
+     */
     public function admin_config_form(&$mform) {
         $public_account = get_config('boxnet', 'public_account');
         $api_key = get_config('boxnet', 'api_key');
@@ -200,6 +283,10 @@ class repository_boxnet extends repository{
         $mform->addRule('api_key', $strrequired, 'required', null, 'client');
     }
 
+    /**
+     *
+     * @param <type> $ 
+     */
     public function instance_config_form(&$mform) {
         //$share_url = get_config('boxnet', 'share_url');
         $mform->addElement('text', 'share_url', get_string('shareurl', 'repository_boxnet'));