MDL-15350, search files in box.net repository.
This commit is contained in:
+7
-2
@@ -91,6 +91,7 @@ function openpicker(){
|
||||
// 10px top/bottom padding applied to Panel body element. The top/bottom border width is 0
|
||||
var panel = new YAHOO.widget.Panel('file-picker', {
|
||||
draggable: true,
|
||||
close: false,
|
||||
underlay: 'none',
|
||||
width: '510px',
|
||||
xy: [100, 100]
|
||||
@@ -190,8 +191,12 @@ function openpicker(){
|
||||
})
|
||||
var search = new YAHOO.util.Element('search');
|
||||
search.on('click', function(e){
|
||||
if(repositoryid==0){
|
||||
alert('Select a repository first.');
|
||||
return;
|
||||
}
|
||||
var data=window.prompt("What are you searching for?");
|
||||
if(data != null || data != '') {
|
||||
if(data != null && data != '') {
|
||||
dosearch(data);
|
||||
}
|
||||
})
|
||||
@@ -285,7 +290,7 @@ success: function(o) {
|
||||
try {
|
||||
var ret = YAHOO.lang.JSON.parse(o.responseText);
|
||||
} catch(e) {
|
||||
alert(e);
|
||||
alert('Invalid JSON String\n'+o.responseText);
|
||||
}
|
||||
datasource = ret;
|
||||
if(datasource.l){
|
||||
|
||||
+192
-192
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Box REST Client Library for PHP5 Developers
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author James Levy <[email protected]>
|
||||
* @link http://enabled.box.net
|
||||
* @access public
|
||||
* @version 1.0
|
||||
* copyright Box.net 2007
|
||||
* copyright Box.net 2007
|
||||
* Available for use and distribution under GPL-license
|
||||
* Go to http://www.gnu.org/licenses/gpl-3.0.txt for full text
|
||||
*/
|
||||
@@ -32,7 +32,7 @@ class boxclient {
|
||||
$this->auth_token = $str;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function __construct($api_key, $auth_token) {
|
||||
$this->api_key = $api_key;
|
||||
$this->auth_token = $auth_token;
|
||||
@@ -48,8 +48,8 @@ class boxclient {
|
||||
$query_str = implode('/', $args);
|
||||
}
|
||||
$request = $this->_box_api_upload_url .'/'. $query_str;
|
||||
if ($this->_debug){
|
||||
echo "Upload Request: ".$request;
|
||||
if ($this->_debug){
|
||||
echo "Upload Request: ".$request;
|
||||
}
|
||||
}else{
|
||||
$args = array();
|
||||
@@ -91,20 +91,20 @@ class boxclient {
|
||||
$xml .= fgets($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
|
||||
|
||||
|
||||
$xml_start = strpos($xml, '<?xml');
|
||||
$xml = substr($xml, $xml_start, strlen($xml));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>XML Response</h2>';
|
||||
echo '<pre class="xml">';
|
||||
echo htmlspecialchars($xml);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
|
||||
$xml_parser = xml_parser_create();
|
||||
xml_parse_into_struct($xml_parser, $xml, $data);
|
||||
xml_parser_free($xml_parser);
|
||||
@@ -131,7 +131,7 @@ class boxclient {
|
||||
echo '<h2>Ticket Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
// Get Auth Token
|
||||
@@ -144,17 +144,17 @@ class boxclient {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag'])
|
||||
switch ($a['tag'])
|
||||
{
|
||||
case 'STATUS':
|
||||
case 'STATUS':
|
||||
$ret_array['status'] = $a['value'];
|
||||
break;
|
||||
break;
|
||||
case 'AUTH_TOKEN':
|
||||
$ret_array['auth_token'] = $a['value'];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($ret_array['status'] == 'get_auth_token_ok'){
|
||||
$this->auth_token = $ret_array['auth_token'];
|
||||
$auth_token = $ret_array['auth_token'];
|
||||
@@ -162,10 +162,10 @@ class boxclient {
|
||||
}else{
|
||||
echo '<a href="http://www.box.net/api/1.0/auth/'.$ticket.'">Login</a>';
|
||||
return false;
|
||||
//header ('location: http://www.box.net/api/1.0/auth/'.$ticket) ;
|
||||
}
|
||||
//header ('location: http://www.box.net/api/1.0/auth/'.$ticket) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Retrieve Account Tree (http://enabled.box.net/docs/rest#get_account_tree)
|
||||
function getAccountTree($params = array()) {
|
||||
$params['api_key'] = $this->api_key;
|
||||
@@ -183,7 +183,7 @@ class boxclient {
|
||||
$entry_count = 0;
|
||||
for ($i=0, $tree_count=count($data); $i<$tree_count; $i++) {
|
||||
$a = $data[$i];
|
||||
switch ($a['tag'])
|
||||
switch ($a['tag'])
|
||||
{
|
||||
case 'FOLDER':
|
||||
if (@is_array($a['attributes'])) {
|
||||
@@ -192,7 +192,7 @@ class boxclient {
|
||||
$ret_array['shared'][$i] = $a['attributes']['SHARED'];
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'FILE':
|
||||
if (@is_array($a['attributes'])) {
|
||||
$ret_array['file_id'][$i] = $a['attributes']['ID'];
|
||||
@@ -210,139 +210,139 @@ class boxclient {
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
// Create New Folder
|
||||
function CreateFolder($new_folder_name, $params = array()) {
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['parent_id'] = 0; //Set to '0' by default. Change to create within sub-folder.
|
||||
$params['name'] = $new_folder_name;
|
||||
$params['share'] = 1; //Set to '1' by default. Set to '0' to make folder private.
|
||||
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=create_folder', $params);
|
||||
|
||||
// Create New Folder
|
||||
function CreateFolder($new_folder_name, $params = array()) {
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['parent_id'] = 0; //Set to '0' by default. Change to create within sub-folder.
|
||||
$params['name'] = $new_folder_name;
|
||||
$params['share'] = 1; //Set to '1' by default. Set to '0' to make folder private.
|
||||
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=create_folder', $params);
|
||||
|
||||
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
case 'FOLDER_ID':
|
||||
$ret_array['folder_id'] = $a['value'];
|
||||
break;
|
||||
|
||||
$ret_array['folder_id'] = $a['value'];
|
||||
break;
|
||||
|
||||
case 'FOLDER_NAME':
|
||||
$ret_array['folder_type'] = $a['value'];
|
||||
break;
|
||||
|
||||
$ret_array['folder_type'] = $a['value'];
|
||||
break;
|
||||
|
||||
case 'SHARED':
|
||||
$ret_array['shared'] = $a['value'];
|
||||
break;
|
||||
$ret_array['shared'] = $a['value'];
|
||||
break;
|
||||
case 'PASSWORD':
|
||||
$ret_array['password'] = $a['value'];
|
||||
$ret_array['password'] = $a['value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Account Tree Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
// Upload File
|
||||
function UploadFile ($params = array()) {
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['new_file1'] = $_FILES['new_file1'];
|
||||
$params['folder id'] = 0; //Set to '0' by default. Change to create within sub-folder.
|
||||
$params['share'] = 1; //Set to '1' by default. Set to '0' to make folder private.
|
||||
$ret_array = array();
|
||||
$data = $this->makeUploadRequst($params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
for ($i=0, $tree_count=count($data); $i<$tree_count; $i++) {
|
||||
$a = $data[$i];
|
||||
switch ($a['tag']) {
|
||||
echo '<h2>Account Tree Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
// Upload File
|
||||
function UploadFile ($params = array()) {
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['new_file1'] = $_FILES['new_file1'];
|
||||
$params['folder id'] = 0; //Set to '0' by default. Change to create within sub-folder.
|
||||
$params['share'] = 1; //Set to '1' by default. Set to '0' to make folder private.
|
||||
$ret_array = array();
|
||||
$data = $this->makeUploadRequst($params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
for ($i=0, $tree_count=count($data); $i<$tree_count; $i++) {
|
||||
$a = $data[$i];
|
||||
switch ($a['tag']) {
|
||||
case 'STATUS':
|
||||
$ret_array['status'] = $a['value'];
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'FILE':
|
||||
if (is_array($a['attributes'])) {
|
||||
$ret_array['file_name'][$i] = $a['attributes']['FILE_NAME'];
|
||||
$ret_array['id'][$i] = $a['attributes']['ID'];
|
||||
$ret_array['folder_name'][$i] = $a['attributes']['FOLDER_NAME'];
|
||||
if (is_array($a['attributes'])) {
|
||||
$ret_array['file_name'][$i] = $a['attributes']['FILE_NAME'];
|
||||
$ret_array['id'][$i] = $a['attributes']['ID'];
|
||||
$ret_array['folder_name'][$i] = $a['attributes']['FOLDER_NAME'];
|
||||
$ret_array['error'][$i] = $a['attributes']['ERROR'];
|
||||
$ret_array['public_name'][$i] = $a['attributes']['PUBLIC_NAME'];
|
||||
$entry_count++;
|
||||
}
|
||||
break;
|
||||
$entry_count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Account Tree Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
// Set Description of File or Folder
|
||||
|
||||
|
||||
|
||||
|
||||
// Register New User
|
||||
|
||||
function RegisterUser($params = array()) {
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['login'] = $_REQUEST['login'];
|
||||
$params['password'] = $_REQUEST['password'];
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=register_new_user', $params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
echo '<h2>Account Tree Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
// Set Description of File or Folder
|
||||
|
||||
|
||||
|
||||
|
||||
// Register New User
|
||||
|
||||
function RegisterUser($params = array()) {
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['login'] = $_REQUEST['login'];
|
||||
$params['password'] = $_REQUEST['password'];
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=register_new_user', $params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
case 'STATUS':
|
||||
$ret_array['status'] = $a['value'];
|
||||
break;
|
||||
|
||||
|
||||
case 'AUTH_TOKEN':
|
||||
$ret_array['auth_token'] = $a['value'];
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'LOGIN':
|
||||
$ret_array['login'] = $a['value'];
|
||||
break;
|
||||
break;
|
||||
case 'SPACE_AMOUNT':
|
||||
$ret_array['space_amount'] = $a['value'];
|
||||
break;
|
||||
case 'SPACE_USED':
|
||||
break;
|
||||
case 'SPACE_USED':
|
||||
$ret_array['space_used'] = $a['value'];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Registration Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
// Add Tags (http://enabled.box.net/docs/rest#add_to_tag)
|
||||
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Registration Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
// Add Tags (http://enabled.box.net/docs/rest#add_to_tag)
|
||||
|
||||
function AddTag($tag, $id, $target_type, $params = array()) {
|
||||
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['target'] = $target_type; // File or folder
|
||||
@@ -357,24 +357,24 @@ class boxclient {
|
||||
switch ($a['tag']) {
|
||||
case 'STATUS':
|
||||
$ret_array['status'] = $a['value'];
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Tag Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $ret_array;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Public Share (http://enabled.box.net/docs/rest#public_share)
|
||||
|
||||
|
||||
function PublicShare($message, $emails, $id, $target_type, $password, $params = array()) {
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
@@ -398,20 +398,20 @@ class boxclient {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Public Share Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get Friends (http://enabled.box.net/docs/rest#get_friends)
|
||||
|
||||
|
||||
function GetFriends ($params = array()) {
|
||||
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$params['params[]'] = 'nozip';
|
||||
@@ -449,75 +449,75 @@ class boxclient {
|
||||
echo '<h2>Get Friend Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Logout User
|
||||
|
||||
function Logout($params = array()) {
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=logout', $params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
|
||||
function Logout($params = array()) {
|
||||
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['auth_token'] = $this->auth_token;
|
||||
$ret_array = array();
|
||||
$data = $this->makeRequest('action=logout', $params);
|
||||
if ($this->_checkForError($data)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($data as $a) {
|
||||
switch ($a['tag']) {
|
||||
case 'ACTION':
|
||||
$ret_array['logout'] = $a['value'];
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($this->_debug) {
|
||||
echo '<h2>Logout Return</h2>';
|
||||
$this->_a($ret_array);
|
||||
var_dump ($a);
|
||||
}
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
}
|
||||
function _checkForError($data) {
|
||||
if (@$data[0]['attributes']['STAT'] == 'fail') {
|
||||
$this->_error_code = $data[1]['attributes']['CODE'];
|
||||
$this->_error_msg = $data[1]['attributes']['MSG'];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _checkForError($data) {
|
||||
if (@$data[0]['attributes']['STAT'] == 'fail') {
|
||||
$this->_error_code = $data[1]['attributes']['CODE'];
|
||||
$this->_error_msg = $data[1]['attributes']['MSG'];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isError() {
|
||||
if ($this->_error_msg != '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getErrorMsg() {
|
||||
return '<p>Error: (' . $this->_error_code . ') ' . $this->_error_msg . '</p>';
|
||||
}
|
||||
public function isError() {
|
||||
if ($this->_error_msg != '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getErrorCode() {
|
||||
return $this->_error_code;
|
||||
}
|
||||
|
||||
|
||||
function _clearErrors() {
|
||||
$this->_error_code = '';
|
||||
$this->_error_msg = '';
|
||||
}
|
||||
|
||||
public function setDebug($debug) {
|
||||
$this->_debug = $debug;
|
||||
}
|
||||
|
||||
private function _a($array) {
|
||||
var_dump($array);
|
||||
}
|
||||
|
||||
function getErrorMsg() {
|
||||
return '<p>Error: (' . $this->_error_code . ') ' . $this->_error_msg . '</p>';
|
||||
}
|
||||
|
||||
function getErrorCode() {
|
||||
return $this->_error_code;
|
||||
}
|
||||
|
||||
|
||||
function _clearErrors() {
|
||||
$this->_error_code = '';
|
||||
$this->_error_msg = '';
|
||||
}
|
||||
|
||||
public function setDebug($debug) {
|
||||
$this->_debug = $debug;
|
||||
}
|
||||
|
||||
private function _a($array) {
|
||||
var_dump($array);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -27,10 +27,10 @@ class repository_boxnet extends repository{
|
||||
if(!empty($reset)) {
|
||||
unset($SESSION->box_token);
|
||||
}
|
||||
// do login
|
||||
// do login
|
||||
if(!empty($options['username'])
|
||||
&& !empty($options['password'])
|
||||
&& !empty($options['ticket']) )
|
||||
&& !empty($options['password'])
|
||||
&& !empty($options['ticket']) )
|
||||
{
|
||||
$c = new curl;
|
||||
$str = '';
|
||||
@@ -71,9 +71,23 @@ class repository_boxnet extends repository{
|
||||
$filenames = $tree['file_name'];
|
||||
$fileids = $tree['file_id'];
|
||||
foreach ($filenames as $n=>$v){
|
||||
$list[] = array('title'=>$v, 'size'=>0, 'date'=>'',
|
||||
'source'=>'http://box.net/api/1.0/download/'.$this->options['auth_token'].'/'.$fileids[$n],
|
||||
'thumbnail'=>$CFG->pixpath.'/i/files.gif');
|
||||
if(!empty($search)) {
|
||||
if(strstr($v, $search) !== false) {
|
||||
$list[] = array('title'=>$v,
|
||||
'size'=>0,
|
||||
'date'=>'',
|
||||
'source'=>'http://box.net/api/1.0/download/'
|
||||
.$this->options['auth_token'].'/'.$fileids[$n],
|
||||
'thumbnail'=>$CFG->pixpath.'/f/text.gif');
|
||||
}
|
||||
} else {
|
||||
$list[] = array('title'=>$v,
|
||||
'size'=>0,
|
||||
'date'=>'',
|
||||
'source'=>'http://box.net/api/1.0/download/'
|
||||
.$this->options['auth_token'].'/'.$fileids[$n],
|
||||
'thumbnail'=>$CFG->pixpath.'/f/text.gif');
|
||||
}
|
||||
}
|
||||
$this->listing = $list;
|
||||
$ret['list'] = $list;
|
||||
|
||||
+17
-17
@@ -51,19 +51,19 @@ class curl {
|
||||
public function resetopt(){
|
||||
$this->options = array();
|
||||
$this->options['CURLOPT_USERAGENT'] = 'MoodleBot/1.0';
|
||||
// True to include the header in the output
|
||||
// True to include the header in the output
|
||||
$this->options['CURLOPT_HEADER'] = 0;
|
||||
// True to Exclude the body from the output
|
||||
// True to Exclude the body from the output
|
||||
$this->options['CURLOPT_NOBODY'] = 0;
|
||||
// TRUE to follow any "Location: " header that the server
|
||||
// sends as part of the HTTP header (note this is recursive,
|
||||
// PHP will follow as many "Location: " headers that it is sent,
|
||||
// unless CURLOPT_MAXREDIRS is set).
|
||||
// TRUE to follow any "Location: " header that the server
|
||||
// sends as part of the HTTP header (note this is recursive,
|
||||
// PHP will follow as many "Location: " headers that it is sent,
|
||||
// unless CURLOPT_MAXREDIRS is set).
|
||||
$this->options['CURLOPT_FOLLOWLOCATION'] = 1;
|
||||
$this->options['CURLOPT_MAXREDIRS'] = 10;
|
||||
$this->options['CURLOPT_ENCODING'] = '';
|
||||
// TRUE to return the transfer as a string of the return
|
||||
// value of curl_exec() instead of outputting it out directly.
|
||||
// TRUE to return the transfer as a string of the return
|
||||
// value of curl_exec() instead of outputting it out directly.
|
||||
$this->options['CURLOPT_RETURNTRANSFER'] = 1;
|
||||
$this->options['CURLOPT_BINARYTRANSFER'] = 0;
|
||||
$this->options['CURLOPT_SSL_VERIFYPEER'] = 0;
|
||||
@@ -73,7 +73,7 @@ class curl {
|
||||
|
||||
/**
|
||||
* Reset Cookie
|
||||
*
|
||||
*
|
||||
* @param array $options If array is null, this function will
|
||||
* reset the options to default value.
|
||||
*
|
||||
@@ -92,7 +92,7 @@ class curl {
|
||||
|
||||
/**
|
||||
* Set curl options
|
||||
*
|
||||
*
|
||||
* @param array $options If array is null, this function will
|
||||
* reset the options to default value.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ class curl {
|
||||
$name = strtoupper('CURLOPT_'.$name);
|
||||
}
|
||||
$this->options[$name] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ class curl {
|
||||
|
||||
/**
|
||||
* Set HTTP Request Header
|
||||
*
|
||||
* @param array $headers
|
||||
*
|
||||
* @param array $headers
|
||||
*
|
||||
*/
|
||||
public function setHeader($header) {
|
||||
@@ -138,7 +138,7 @@ class curl {
|
||||
}
|
||||
/**
|
||||
* Set HTTP Response Header
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function getResponse(){
|
||||
return $this->response;
|
||||
@@ -146,9 +146,9 @@ class curl {
|
||||
/**
|
||||
* private callback function
|
||||
* Formatting HTTP Response Header
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function formatHeader($ch, $header)
|
||||
private function formatHeader($ch, $header)
|
||||
{
|
||||
$this->count++;
|
||||
if (strlen($header) > 2) {
|
||||
@@ -173,7 +173,7 @@ class curl {
|
||||
|
||||
/**
|
||||
* Formatting HTTP Response Header
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected function request($url, $options = array()){
|
||||
// Clean up
|
||||
|
||||
+1038
-1038
File diff suppressed because it is too large
Load Diff
+9
-9
@@ -26,7 +26,7 @@
|
||||
/**
|
||||
* This is the base class of the repository class
|
||||
*
|
||||
* To use repository plugin, you need to create a new folder under repository/, named as the remote
|
||||
* To use repository plugin, you need to create a new folder under repository/, named as the remote
|
||||
* repository, the subclass must be defined in the name
|
||||
|
||||
*
|
||||
@@ -35,8 +35,8 @@
|
||||
* See an example of use of this library in repository/box/repository.class.php
|
||||
*
|
||||
* A few notes :
|
||||
* // options are stored as serialized format in database
|
||||
* $options = array('api_key'=>'dmls97d8j3i9tn7av8y71m9eb55vrtj4',
|
||||
* // options are stored as serialized format in database
|
||||
* $options = array('api_key'=>'dmls97d8j3i9tn7av8y71m9eb55vrtj4',
|
||||
* 'auth_token'=>'', 'path_root'=>'/');
|
||||
* $repo = new repository_xxx($options);
|
||||
* // print login page or a link to redirect to another page
|
||||
@@ -154,7 +154,7 @@ abstract class repository {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the login screen, if required
|
||||
* This is an abstract function, it must be overriden.
|
||||
@@ -166,7 +166,7 @@ abstract class repository {
|
||||
* 3. Redirect to authentication page, in this case, the repository
|
||||
* will callback moodle with following common parameters:
|
||||
* (1) boolean callback To tell moodle this is a callback
|
||||
* (2) int id Specify repository ID
|
||||
* (2) int id Specify repository ID
|
||||
* The callback page need to use these parameters to init
|
||||
* the repository plug-ins correctly. Also, auth_token or ticket may
|
||||
* attach in the callback url, these must be taken into account too.
|
||||
@@ -309,13 +309,13 @@ function repository_get_plugins(){
|
||||
$ret = array();
|
||||
if($dir = opendir($repo)){
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if(is_dir($file) && $file != '.' && $file != '..'
|
||||
if(is_dir($file) && $file != '.' && $file != '..'
|
||||
&& file_exists($repo.$file.'/repository.class.php')){
|
||||
require_once($repo.$file.'/version.php');
|
||||
$ret[] = array('name'=>$plugin->name,
|
||||
'version'=>$plugin->version,
|
||||
$ret[] = array('name'=>$plugin->name,
|
||||
'version'=>$plugin->version,
|
||||
'path'=>$repo.$file,
|
||||
'settings'=>file_exists($repo.$file.'/settings.php'));
|
||||
'settings'=>file_exists($repo.$file.'/settings.php'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user