Browse Source

Merge pull request #4672 from owncloud/ocs_cleanup

Ocs cleanup
tags/v6.0.0alpha2
blizzz 11 years ago
parent
commit
431cf06e99
2 changed files with 0 additions and 52 deletions
  1. 0
    3
      config/config.sample.php
  2. 0
    49
      lib/ocsclient.php

+ 0
- 3
config/config.sample.php View File

/* Enable the help menu item in the settings */ /* Enable the help menu item in the settings */
"knowledgebaseenabled" => true, "knowledgebaseenabled" => true,


/* URL to use for the help page, server should understand OCS */
"knowledgebaseurl" => "http://api.apps.owncloud.com/v1",

/* Enable installing apps from the appstore */ /* Enable installing apps from the appstore */
"appstoreenabled" => true, "appstoreenabled" => true,



+ 0
- 49
lib/ocsclient.php View File

return($url); return($url);
} }


/**
* @brief Get the url of the OCS KB server.
* @returns string of the KB server
* This function returns the url of the OCS knowledge base server. It´s
* possible to set it in the config file or it will fallback to the default
*/
private static function getKBURL() {
$url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1');
return($url);
}


/** /**
* @brief Get the content of an OCS url call. * @brief Get the content of an OCS url call.
} }




/**
* @brief Get all the knowledgebase entries from the OCS server
* @returns array with q and a data
*
* This function returns a list of all the knowledgebase entries from the OCS server
*/
public static function getKnownledgebaseEntries($page, $pagesize, $search='') {
$kbe = array('totalitems' => 0);
if(OC_Config::getValue('knowledgebaseenabled', true)) {
$p = (int) $page;
$s = (int) $pagesize;
$searchcmd = '';
if ($search) {
$searchcmd = '&search='.urlencode($search);
}
$url = OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='. $p .'&pagesize='. $s . $searchcmd;
$xml = OC_OCSClient::getOCSresponse($url);
$data = @simplexml_load_string($xml);
if($data===false) {
OC_Log::write('core', 'Unable to parse knowledgebase content', OC_Log::FATAL);
return null;
}
$tmp = $data->data->content;
for($i = 0; $i < count($tmp); $i++) {
$kbe[] = array(
'id' => $tmp[$i]->id,
'name' => $tmp[$i]->name,
'description' => $tmp[$i]->description,
'answer' => $tmp[$i]->answer,
'preview1' => $tmp[$i]->smallpreviewpic1,
'detailpage' => $tmp[$i]->detailpage
);
}
$kbe['totalitems'] = $data->meta->totalitems;
}
return $kbe;
}




} }

Loading…
Cancel
Save