getName())), strtolower(convert_diacrit($b->getName())));
}
class webdav extends connecteur_out {
public function get_config_form() {
//Rien
return '';
}
public function update_config_from_form() {
return;
}
public function instantiate_source_class($source_id) {
return new webdav_source($this, $source_id, $this->msg);
}
public function process($source_id, $pmb_user_id) {
global $class_path;
global $webdav_current_user_id,$webdav_current_user_name;
global $pmb_url_base;
$source_object = $this->instantiate_source_class($source_id);
$webdav_current_user_id=0;
$webdav_current_user_name = "Anonymous";
switch ($source_object->config['group_tree']) {
case 'scan_request' :
$rootDir = new Sabre\PMB\ScanRequest\Tree($source_object->config);
break;
case 'music' :
$rootDir = new Sabre\PMB\Music\Tree($source_object->config);
break;
case 'standard' :
default :
$rootDir = new Sabre\PMB\Tree($source_object->config);
break;
}
$server = new Sabre\DAV\Server($rootDir);
if($source_object->config['allow_web']){
$web = new Sabre\PMB\BrowserPlugin();
$server->addPlugin($web);
}
if($source_object->config['authentication'] != "anonymous"){
$auth = new Sabre\PMB\Auth($source_object->config['authentication']);
$authPlugin = new Sabre\DAV\Auth\Plugin($auth,md5($pmb_url_base));
// Adding the plugin to the server
$server->addPlugin($authPlugin);
}
// We're required to set the base uri, it is recommended to put your webdav server on a root of a domain
$server->setBaseUri($source_object->config['base_uri']);
// And off we go!
$server->exec();
}
}
class webdav_source extends connecteur_out_source {
public $onglets = array();
public $groups_collections = array();
public function __construct($connector, $id, $msg) {
parent::__construct($connector, $id, $msg);
$this->included_sets = isset($this->config["included_sets"]) ? $this->config["included_sets"] : array();
}
protected function get_msg_to_display($message) {
global $msg;
if (substr($message, 0, 4) == "msg:") {
if(isset($this->msg[substr($message, 4)])){
return $this->msg[substr($message, 4)];
}
}
return $message;
}
protected function parse_file_collections() {
global $base_path;
//Liste des collections possibles
if (file_exists("$base_path/admin/connecteurs/out/webdav/collections_subst.xml"))
$filename = "$base_path/admin/connecteurs/out/webdav/collections_subst.xml";
else
$filename = "$base_path/admin/connecteurs/out/webdav/collections.xml";
$xml=file_get_contents($filename);
$param=_parser_text_no_function_($xml,"COLLECTIONS");
foreach ($param['GROUPS'][0]['GROUP'] as $group) {
$group_collections = array();
if($group['COLLECTION']){
foreach ($group['COLLECTION'] as $collection) {
$group_collections[$collection['CODE']] = $this->get_msg_to_display($collection['value']);
}
}
$this->groups_collections[$group['NAME']] = array(
'label' => $this->get_msg_to_display($group['VALUE']),
'collections' => $group_collections,
'class' => $group['CLASS']
);
}
}
public function get_groups_collections() {
if(!count($this->groups_collections)){
$this->parse_file_collections();
}
return $this->groups_collections;
}
public function get_group_collections($name) {
if(!count($this->groups_collections)){
$this->parse_file_collections();
}
return $this->groups_collections[$name]['collections'];
}
public function get_config_form() {
global $charset, $msg, $dbh;
global $base_path, $class_path;
if(!$this->config['base_uri']){
$this->config['base_uri'] = "/";
}
if(!$this->config['group_tree']){
$this->config['group_tree'] = 'standard';
}
if(!$this->config['restricted_empr_write_permission']){
$this->config['restricted_empr_write_permission'] = array();
}
if(!$this->config['restricted_user_write_permission']){
$this->config['restricted_user_write_permission'] = array();
}
if(!$this->config['metasMapper_class']){
$this->config['metasMapper_class'] = "";
}
if(!$this->config['upload_rep']){
global $PMBuserid;
$query = "select deflt_upload_repertoire from users where userid = ".$PMBuserid;
$result = pmb_mysql_query($query);
if(pmb_mysql_num_rows($result)){
$this->config['upload_rep'] = pmb_mysql_result($result,0,0);
}else{
$this->config['upload_rep'] = 0;
}
}
$result = parent::get_config_form();
//Included sets
$result.= "