"MDL-16384, upgrade alfresco php library, fixed bugs in offical php sdk"

This commit is contained in:
dongsheng 2009-06-05 06:55:07 +00:00
parent eacb462e38
commit fb8103e6a0
11 changed files with 894 additions and 880 deletions

View File

@ -1,14 +1,14 @@
@VERSION $Id$
== CHANGELOG ==
Alfresco PHP Libarary was modified by Moodle, because of class name conflict.
See, Service/Repository.php & Service/WebService/AlfrescoWebService.php
All the changes are marked as "Moodle"
1. Rename class name , see Service/Repository.php & Service/WebService/AlfrescoWebService.php
2. Change library path name
3. In Alfresco_Repository class construct function, set _port to 80 if it is not specified
== Alfresco PHP Libarary ==
Installation and developer documentation for the Alfresco PHP Library can be found on the Alfresco Wiki.
Get the source from http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/modules/php-sdk
== Documentation Links ==

View File

@ -1,290 +1,292 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once("Functions.php");
class ContentData extends BaseObject
{
private $_isPopulated = false;
private $_isDirty = false;
private $_node;
private $_property;
private $_mimetype;
private $_size;
private $_encoding;
private $_url;
private $_newContent;
private $_newFileContent;
public function __construct($node, $property, $mimetype=null, $encoding=null, $size=-1)
{
$this->_node = $node;
$this->_property = $property;
$this->_mimetype = $mimetype;
$this->_encoding = $encoding;
if ($size != -1)
{
$this->size = $size;
}
$this->_isPopulated = false;
}
public function setPropertyDetails($node, $property)
{
$this->_node = $node;
$this->_property = $property;
}
public function __toString()
{
$this->populateContentData();
}
public function getNode()
{
return $this->_node;
}
public function getProperty()
{
return $this->_property;
}
public function getIsDirty()
{
return $this->_isDirty;
}
public function getMimetype()
{
$this->populateContentData();
return $this->_mimetype;
}
public function setMimetype($mimetype)
{
$this->populateContentData();
$this->_mimetype = $mimetype;
}
public function getSize()
{
$this->populateContentData();
return $this->_size;
}
public function getEncoding()
{
$this->populateContentData();
return $this->_encoding;
}
public function setEncoding($encoding)
{
$this->populateContentData();
$this->_encoding = $encoding;
}
public function getUrl()
{
// TODO what should be returned if the content has been updated??
$this->populateContentData();
$result = null;
if ($this->_url != null)
{
$result = $this->_url."?ticket=".$this->_node->session->ticket;
}
return $result;
}
public function getGuestUrl()
{
// TODO what should be returned if the content has been updated??
$this->populateContentData();
$result = null;
if ($this->_url != null)
{
$result = $this->_url."?guest=true";
}
return $result;
}
public function getContent()
{
$this->populateContentData();
$result = null;
if ($this->_isDirty == true)
{
if ($this->_newFileContent != null)
{
$handle = fopen($this->_newFileContent, "rb");
$result = stream_get_contents($handle);
fclose($handle);
}
else if ($this->_newContent != null)
{
$result = $this->_newContent;
}
}
else
{
if ($this->getUrl() != null)
{
$handle = fopen($this->getUrl(), "rb");
$result = stream_get_contents($handle);
fclose($handle);
}
}
return $result;
}
public function setContent($content)
{
$this->populateContentData();
$this->_isDirty = true;
$this->_newContent = $content;
}
public function writeContentFromFile($fileName)
{
$this->populateContentData();
$this->_isDirty = true;
$this->_newFileContent = $fileName;
}
public function readContentToFile($fileName)
{
$handle = fopen($fileName, "wb");
fwrite($handle, $this->getContent());
fclose($handle);
}
public function onBeforeSave(&$statements, $where)
{
if ($this->_isDirty == true)
{
// Check mimetype has been set
if ($this->_mimetype == null)
{
throw new Exception("A mime type for the content property ".$this->_property." on node ".$this->_node->__toString()." must be set");
}
// If a file has been specified then read content from there
//$content = null;
if ($this->_newFileContent != null)
{
// Upload the content to the repository
$contentData = upload_file($this->node->session, $this->_newFileContent, $this->_mimetype, $this->_encoding);
// Set the content property value
$this->addStatement(
$statements,
"update",
array("property" => array(
"name" => $this->property,
"isMultiValue" => false,
"value" => $contentData)) + $where);
}
else
{
// Add the writeContent statement
$this->addStatement(
$statements,
"writeContent",
array(
"property" => $this->_property,
"content" => $this->_newContent,
"format" => array(
"mimetype" => $this->_mimetype,
"encoding" => $this->_encoding)) +
$where);
}
}
}
public function onAfterSave()
{
$this->_isDirty = false;
$this->_isPopulated = false;
$this->_mimetype = null;
$this->__size = null;
$this->__encoding = null;
$this->__url = null;
$this->__newContent = null;
}
private function populateContentData()
{
//echo "isPopulated:".$this->_isPopulated."; node:".$this->_node."; property:".$this->_property."<br>";
if ($this->_isPopulated == false && $this->_node != null && $this->_property != null && $this->_node->isNewNode == false)
{
$result = $this->_node->session->contentService->read( array(
"items" => array(
"nodes" => array(
"store" => $this->_node->store->__toArray(),
"uuid" => $this->_node->id)),
"property" => $this->_property) );
if (isset($result->content) == true)
{
if (isset($result->content->length) == true)
{
$this->_size = $result->content->length;
}
if (isset($result->content->format->mimetype) == true)
{
$this->_mimetype = $result->content->format->mimetype;
}
if (isset($result->content->format->encoding) == true)
{
$this->_encoding = $result->content->format->encoding;
}
if (isset($result->content->url) == true)
{
$this->_url = $result->content->url;
}
}
$this->_isPopulated = true;
}
}
private function addStatement(&$statements, $statement, $body)
{
$result = array();
if (array_key_exists($statement, $statements) == true)
{
$result = $statements[$statement];
}
$result[] = $body;
$statements[$statement] = $result;
}
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
// change by moodle
require_once($CFG->libdir."/alfresco/Service/Functions.php");
class ContentData extends BaseObject
{
private $_isPopulated = false;
private $_isDirty = false;
private $_node;
private $_property;
private $_mimetype;
private $_size;
private $_encoding;
private $_url;
private $_newContent;
private $_newFileContent;
public function __construct($node, $property, $mimetype=null, $encoding=null, $size=-1)
{
$this->_node = $node;
$this->_property = $property;
$this->_mimetype = $mimetype;
$this->_encoding = $encoding;
if ($size != -1)
{
$this->size = $size;
}
$this->_isPopulated = false;
}
public function setPropertyDetails($node, $property)
{
$this->_node = $node;
$this->_property = $property;
}
public function __toString()
{
$this->populateContentData();
return "mimetype=".$this->mimetype."|encoding=".$this->encoding."|size=".$this->size;
}
public function getNode()
{
return $this->_node;
}
public function getProperty()
{
return $this->_property;
}
public function getIsDirty()
{
return $this->_isDirty;
}
public function getMimetype()
{
$this->populateContentData();
return $this->_mimetype;
}
public function setMimetype($mimetype)
{
$this->populateContentData();
$this->_mimetype = $mimetype;
}
public function getSize()
{
$this->populateContentData();
return $this->_size;
}
public function getEncoding()
{
$this->populateContentData();
return $this->_encoding;
}
public function setEncoding($encoding)
{
$this->populateContentData();
$this->_encoding = $encoding;
}
public function getUrl()
{
// TODO what should be returned if the content has been updated??
$this->populateContentData();
$result = null;
if ($this->_url != null)
{
$result = $this->_url."?ticket=".$this->_node->session->ticket;
}
return $result;
}
public function getGuestUrl()
{
// TODO what should be returned if the content has been updated??
$this->populateContentData();
$result = null;
if ($this->_url != null)
{
$result = $this->_url."?guest=true";
}
return $result;
}
public function getContent()
{
$this->populateContentData();
$result = null;
if ($this->_isDirty == true)
{
if ($this->_newFileContent != null)
{
$handle = fopen($this->_newFileContent, "rb");
$result = stream_get_contents($handle);
fclose($handle);
}
else if ($this->_newContent != null)
{
$result = $this->_newContent;
}
}
else
{
if ($this->getUrl() != null)
{
$handle = fopen($this->getUrl(), "rb");
$result = stream_get_contents($handle);
fclose($handle);
}
}
return $result;
}
public function setContent($content)
{
$this->populateContentData();
$this->_isDirty = true;
$this->_newContent = $content;
}
public function writeContentFromFile($fileName)
{
$this->populateContentData();
$this->_isDirty = true;
$this->_newFileContent = $fileName;
}
public function readContentToFile($fileName)
{
$handle = fopen($fileName, "wb");
fwrite($handle, $this->getContent());
fclose($handle);
}
public function onBeforeSave(&$statements, $where)
{
if ($this->_isDirty == true)
{
// Check mimetype has been set
if ($this->_mimetype == null)
{
throw new Exception("A mime type for the content property ".$this->_property." on node ".$this->_node->__toString()." must be set");
}
// If a file has been specified then read content from there
//$content = null;
if ($this->_newFileContent != null)
{
// Upload the content to the repository
$contentData = upload_file($this->node->session, $this->_newFileContent, $this->_mimetype, $this->_encoding);
// Set the content property value
$this->addStatement(
$statements,
"update",
array("property" => array(
"name" => $this->property,
"isMultiValue" => false,
"value" => $contentData)) + $where);
}
else
{
// Add the writeContent statement
$this->addStatement(
$statements,
"writeContent",
array(
"property" => $this->_property,
"content" => $this->_newContent,
"format" => array(
"mimetype" => $this->_mimetype,
"encoding" => $this->_encoding)) +
$where);
}
}
}
public function onAfterSave()
{
$this->_isDirty = false;
$this->_isPopulated = false;
$this->_mimetype = null;
$this->__size = null;
$this->__encoding = null;
$this->__url = null;
$this->__newContent = null;
}
private function populateContentData()
{
//echo "isPopulated:".$this->_isPopulated."; node:".$this->_node."; property:".$this->_property."<br>";
if ($this->_isPopulated == false && $this->_node != null && $this->_property != null && $this->_node->isNewNode == false)
{
$result = $this->_node->session->contentService->read( array(
"items" => array(
"nodes" => array(
"store" => $this->_node->store->__toArray(),
"uuid" => $this->_node->id)),
"property" => $this->_property) );
if (isset($result->content) == true)
{
if (isset($result->content->length) == true)
{
$this->_size = $result->content->length;
}
if (isset($result->content->format->mimetype) == true)
{
$this->_mimetype = $result->content->format->mimetype;
}
if (isset($result->content->format->encoding) == true)
{
$this->_encoding = $result->content->format->encoding;
}
if (isset($result->content->url) == true)
{
$this->_url = $result->content->url;
}
}
$this->_isPopulated = true;
}
}
private function addStatement(&$statements, $statement, $body)
{
$result = array();
if (array_key_exists($statement, $statements) == true)
{
$result = $statements[$statement];
}
$result[] = $body;
$statements[$statement] = $result;
}
}
?>

View File

@ -1,114 +1,115 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once("Repository.php");
require_once("Session.php");
/**
* Uploads a file into content store and returns the content data string which
* can be used to populate a content property.
*
* @param $session the session
* @param $filePath the file location
* @return String the content data that can be used to update the content property
*/
function upload_file($session, $filePath, $mimetype=null, $encoding=null)
{
$result = null;
// Check for the existance of the file
if (file_exists($filePath) == false)
{
throw new Exception("The file ".$filePath."does no exist.");
}
// Get the file name and size
$fileName = basename($filePath);
$fileSize = filesize($filePath);
// Get the address and the
$host = $session->repository->host;
$port = $session->repository->port;
// Get the IP address for the target host
$address = gethostbyname($host);
// Create a TCP/IP socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false)
{
throw new Exception ("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
}
// Connect the socket to the repository
$result = socket_connect($socket, $address, $port);
if ($result === false)
{
throw new Exception("socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)));
}
// Write the request header onto the socket
$url = "/alfresco/upload/".urlencode($fileName)."?ticket=".$session->ticket;
if ($mimetype != null)
{
// Add mimetype if specified
$url .= "&mimetype=".$mimetype;
}
if ($encoding != null)
{
// Add encoding if specified
$url .= "&encoding=".$encoding;
}
$in = "PUT ".$url." HTTP/1.1\r\n".
"Content-Length: ".$fileSize."\r\n".
"Host: ".$address.":".$port."\r\n".
"Connection: Keep-Alive\r\n".
"\r\n";
socket_write($socket, $in, strlen($in));
// Write the content found in the file onto the socket
$handle = fopen($filePath, "r");
while (feof($handle) == false)
{
$content = fread($handle, 1024);
socket_write($socket, $content, strlen($content));
}
fclose($handle);
// Read the response
$recv = socket_read ($socket, 2048, PHP_BINARY_READ);
$index = strpos($recv, "contentUrl");
if ($index !== false)
{
$result = substr($recv, $index);
}
// Close the socket
socket_close($socket);
return $result;
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
// change by moodle
require_once($CFG->libdir."/alfresco/Service/Repository.php");
require_once($CFG->libdir."/alfresco/Service/Session.php");
/**
* Uploads a file into content store and returns the content data string which
* can be used to populate a content property.
*
* @param $session the session
* @param $filePath the file location
* @return String the content data that can be used to update the content property
*/
function upload_file($session, $filePath, $mimetype=null, $encoding=null)
{
$result = null;
// Check for the existance of the file
if (file_exists($filePath) == false)
{
throw new Exception("The file ".$filePath."does no exist.");
}
// Get the file name and size
$fileName = basename($filePath);
$fileSize = filesize($filePath);
// Get the address and the
$host = $session->repository->host;
$port = $session->repository->port;
// Get the IP address for the target host
$address = gethostbyname($host);
// Create a TCP/IP socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false)
{
throw new Exception ("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
}
// Connect the socket to the repository
$result = socket_connect($socket, $address, $port);
if ($result === false)
{
throw new Exception("socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)));
}
// Write the request header onto the socket
$url = "/alfresco/upload/".urlencode($fileName)."?ticket=".$session->ticket;
if ($mimetype != null)
{
// Add mimetype if specified
$url .= "&mimetype=".$mimetype;
}
if ($encoding != null)
{
// Add encoding if specified
$url .= "&encoding=".$encoding;
}
$in = "PUT ".$url." HTTP/1.1\r\n".
"Content-Length: ".$fileSize."\r\n".
"Host: ".$address.":".$port."\r\n".
"Connection: Keep-Alive\r\n".
"\r\n";
socket_write($socket, $in, strlen($in));
// Write the content found in the file onto the socket
$handle = fopen($filePath, "r");
while (feof($handle) == false)
{
$content = fread($handle, 1024);
socket_write($socket, $content, strlen($content));
}
fclose($handle);
// Read the response
$recv = socket_read ($socket, 2048, PHP_BINARY_READ);
$index = strpos($recv, "contentUrl");
if ($index !== false)
{
$result = substr($recv, $index);
}
// Close the socket
socket_close($socket);
return $result;
}
?>

View File

@ -1,90 +1,90 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once "LoggerConfig.php";
class Logger
{
private $componentName;
public function __construct($componentName = null)
{
$this->componentName = $componentName;
}
public function isDebugEnabled()
{
return $this->isEnabled(DEBUG);
}
public function debug($message)
{
$this->write(DEBUG, $message);
}
public function isWarningEnabled()
{
return $this->isEnabled(WARNING);
}
public function warning($message)
{
$this->write(WARNING, $message);
}
public function isInformationEnabled()
{
return $this->isEnabled(INFORMATION);
}
public function information($message)
{
$this->write(INFORMATION, $message);
}
private function isEnabled($logLevel)
{
global $componentLogLevels, $defaultLogLevel;
$logLevels = $defaultLogLevel;
if ($this->componentName != null && isset($componentLogLevels[$this->componentName]) == true)
{
$logLevels = $componentLogLevels[$this->componentName];
}
return in_array($logLevel, $logLevels);
}
private function write($logLevel, $message)
{
global $logFile;
$handle = fopen($logFile, "a");
fwrite($handle, $logLevel." ".date("G:i:s d/m/Y")." - ".$message."\r\n");
fclose($handle);
}
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once "LoggerConfig.php";
class Logger
{
private $componentName;
public function __construct($componentName = null)
{
$this->componentName = $componentName;
}
public function isDebugEnabled()
{
return $this->isEnabled(DEBUG);
}
public function debug($message)
{
$this->write(DEBUG, $message);
}
public function isWarningEnabled()
{
return $this->isEnabled(WARNING);
}
public function warning($message)
{
$this->write(WARNING, $message);
}
public function isInformationEnabled()
{
return $this->isEnabled(INFORMATION);
}
public function information($message)
{
$this->write(INFORMATION, $message);
}
private function isEnabled($logLevel)
{
global $componentLogLevels, $defaultLogLevel;
$logLevels = $defaultLogLevel;
if ($this->componentName != null && isset($componentLogLevels[$this->componentName]) == true)
{
$logLevels = $componentLogLevels[$this->componentName];
}
return in_array($logLevel, $logLevels);
}
private function write($logLevel, $message)
{
global $logFile;
$handle = fopen($logFile, "a");
fwrite($handle, $logLevel." ".date("G:i:s d/m/Y")." - ".$message."\r\n");
fclose($handle);
}
}
?>

View File

@ -1,44 +1,44 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
define("DEBUG", "Debug");
define("WARNING", "Warning");
define("INFO", "Information");
$debugLevel = array(DEBUG, WARNING, INFO);
$warningLevel = array(WARNING, INFO);
$infoLevel = array(INFO);
$noneLevel = array();
$defaultLogLevel = $infoLevel;
$logFile = "c:/work/AlfrescoPHPLog.txt";
$componentLogLevels = array(
"integration.mediawiki.ExternalStoreAlfresco" => $debugLevel
);
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
define("DEBUG", "Debug");
define("WARNING", "Warning");
define("INFO", "Information");
$debugLevel = array(DEBUG, WARNING, INFO);
$warningLevel = array(WARNING, INFO);
$infoLevel = array(INFO);
$noneLevel = array();
$defaultLogLevel = $infoLevel;
$logFile = "c:/work/AlfrescoPHPLog.txt";
$componentLogLevels = array(
"integration.mediawiki.ExternalStoreAlfresco" => $debugLevel
);
?>

View File

@ -92,12 +92,12 @@ class Node extends BaseObject
// Set the property values
foreach ($properties as $name=>$value)
{
$name = $this->expandToFullName($name);
$name = $this->_session->namespaceMap->getFullName($name);
$this->_properties[$name] = $value;
}
}
public function setContent($property, $mimetype=null, $encoding=null, $content=null)
public function updateContent($property, $mimetype, $encoding="UTF-8", $content=null)
{
list($property) = $this->_session->namespaceMap->getFullNames(array($property));
$contentData = new ContentData($this, $property, $mimetype, $encoding);

View File

@ -1,133 +1,139 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once 'WebService/WebServiceFactory.php';
require_once 'BaseObject.php';
if (isset($_SESSION) == false)
{
// Start the session
session_start();
}
class Al_Repository extends BaseObject // Moodle
{
private $_connectionUrl;
private $_host;
private $_port;
public function __construct($connectionUrl="http://localhost:8080/alfresco/api")
{
$this->_connectionUrl = $connectionUrl;
$parts = parse_url($connectionUrl);
$this->_host = $parts["host"];
$this->_port = $parts["port"];
}
public function getConnectionUrl()
{
return $this->_connectionUrl;
}
public function getHost()
{
return $this->_host;
}
public function getPort()
{
return $this->_port;
}
public function authenticate($userName, $password)
{
// TODO need to handle exceptions!
$authenticationService = WebServiceFactory::getAuthenticationService($this->_connectionUrl);
$result = $authenticationService->startSession(array (
"username" => $userName,
"password" => $password
));
// Get the ticket and sessionId
$ticket = $result->startSessionReturn->ticket;
$sessionId = $result->startSessionReturn->sessionid;
// Store the session id for later use
if ($sessionId != null)
{
$sessionIds = null;
if (isset($_SESSION["sessionIds"]) == false)
{
$sessionIds = array();
}
else
{
$sessionIds = $_SESSION["sessionIds"];
}
$sessionIds[$ticket] = $sessionId;
$_SESSION["sessionIds"] = $sessionIds;
}
return $ticket;
}
public function createSession($ticket=null)
{
$session = null;
if ($ticket == null)
{
// TODO get ticket from some well known location ie: the $_SESSION
}
else
{
// TODO would be nice to be able to check that the ticket is still valid!
// Create new session
$session = new Session($this, $ticket);
}
return $session;
}
/**
* For a given ticket, returns the realated session id, null if one can not be found.
*/
public static function getSessionId($ticket)
{
$result = null;
if (isset($_SESSION["sessionIds"]) == true)
{
$result = $_SESSION["sessionIds"][$ticket];
}
return $result;
}
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
// change by moodle
require_once $CFG->libdir.'/alfresco/Service/WebService/WebServiceFactory.php';
require_once $CFG->libdir.'/alfresco/Service/BaseObject.php';
if (isset($_SESSION) == false)
{
// Start the session
session_start();
}
// change by moodle
class Alfresco_Repository extends BaseObject
{
private $_connectionUrl;
private $_host;
private $_port;
public function __construct($connectionUrl="http://localhost:8080/alfresco/api")
{
$this->_connectionUrl = $connectionUrl;
$parts = parse_url($connectionUrl);
$this->_host = $parts["host"];
if (empty($parts["port"])) {
$this->_port = 80;
} else {
$this->_port = $parts["port"];
}
}
public function getConnectionUrl()
{
return $this->_connectionUrl;
}
public function getHost()
{
return $this->_host;
}
public function getPort()
{
return $this->_port;
}
public function authenticate($userName, $password)
{
// TODO need to handle exceptions!
$authenticationService = WebServiceFactory::getAuthenticationService($this->_connectionUrl);
$result = $authenticationService->startSession(array (
"username" => $userName,
"password" => $password
));
// Get the ticket and sessionId
$ticket = $result->startSessionReturn->ticket;
$sessionId = $result->startSessionReturn->sessionid;
// Store the session id for later use
if ($sessionId != null)
{
$sessionIds = null;
if (isset($_SESSION["sessionIds"]) == false)
{
$sessionIds = array();
}
else
{
$sessionIds = $_SESSION["sessionIds"];
}
$sessionIds[$ticket] = $sessionId;
$_SESSION["sessionIds"] = $sessionIds;
}
return $ticket;
}
public function createSession($ticket=null)
{
$session = null;
if ($ticket == null)
{
// TODO get ticket from some well known location ie: the $_SESSION
}
else
{
// TODO would be nice to be able to check that the ticket is still valid!
// Create new session
$session = new Session($this, $ticket);
}
return $session;
}
/**
* For a given ticket, returns the realated session id, null if one can not be found.
*/
public static function getSessionId($ticket)
{
$result = null;
if (isset($_SESSION["sessionIds"]) == true)
{
$result = $_SESSION["sessionIds"][$ticket];
}
return $result;
}
}
?>

View File

@ -122,7 +122,7 @@ class Session extends BaseObject
public function getNodeFromString($value)
{
// TODO
throw Exception("getNode($value) no yet implemented");
throw new Exception("getNode($value) not yet implemented");
}
/**
@ -274,4 +274,4 @@ class Session extends BaseObject
return $sessionId;
}
}
?>
?>

View File

@ -1,117 +1,118 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
class AlfrescoWebService extends SoapClient
{
private $securityExtNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
private $wsUtilityNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
private $passwordType = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
private $ticket;
public function __construct($wsdl, $options = array('trace' => true, 'exceptions' => true), $ticket = null)
{
// Store the current ticket
$this->ticket = $ticket;
// Call the base class
parent::__construct($wsdl, $options);
}
public function __call($function_name, $arguments=array())
{
return $this->__soapCall($function_name, $arguments);
}
public function __soapCall($function_name, $arguments=array(), $options=array(), $input_headers=array(), $output_headers=array())
{
if (isset($this->ticket))
{
// Automatically add a security header
$input_headers[] = new SoapHeader($this->securityExtNS, "Security", null, 1);
// Set the JSESSION cookie value
$sessionId = Al_Repository::getSessionId($this->ticket); // Moodle
if ($sessionId != null)
{
$this->__setCookie("JSESSIONID", $sessionId);
}
}
return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
}
public function __doRequest($request, $location, $action, $version)
{
// If this request requires authentication we have to manually construct the
// security headers.
if (isset($this->ticket))
{
$dom = new DOMDocument("1.0");
$dom->loadXML($request);
$securityHeader = $dom->getElementsByTagName("Security");
if ($securityHeader->length != 1)
{
throw new Exception("Expected length: 1, Received: " . $securityHeader->length . ". No Security Header, or more than one element called Security!");
}
$securityHeader = $securityHeader->item(0);
// Construct Timestamp Header
$timeStamp = $dom->createElementNS($this->wsUtilityNS, "Timestamp");
$createdDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y")));
$expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y")));
$created = new DOMElement("Created", $createdDate, $this->wsUtilityNS);
$expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS);
$timeStamp->appendChild($created);
$timeStamp->appendChild($expires);
// Construct UsernameToken Header
$userNameToken = $dom->createElementNS($this->securityExtNS, "UsernameToken");
$userName = new DOMElement("Username", "username", $this->securityExtNS);
$passWord = $dom->createElementNS($this->securityExtNS, "Password");
$typeAttr = new DOMAttr("Type", $this->passwordType);
$passWord->appendChild($typeAttr);
$passWord->appendChild($dom->createTextNode($this->ticket));
$userNameToken->appendChild($userName);
$userNameToken->appendChild($passWord);
// Construct Security Header
$securityHeader->appendChild($timeStamp);
$securityHeader->appendChild($userNameToken);
// Save the XML Request
$request = $dom->saveXML();
}
return parent::__doRequest($request, $location, $action, $version);
}
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
class AlfrescoWebService extends SoapClient
{
private $securityExtNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
private $wsUtilityNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
private $passwordType = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
private $ticket;
public function __construct($wsdl, $options = array('trace' => true, 'exceptions' => true), $ticket = null)
{
// Store the current ticket
$this->ticket = $ticket;
// Call the base class
parent::__construct($wsdl, $options);
}
public function __call($function_name, $arguments=array())
{
return $this->__soapCall($function_name, $arguments);
}
public function __soapCall($function_name, $arguments=array(), $options=array(), $input_headers=array(), $output_headers=array())
{
if (isset($this->ticket))
{
// Automatically add a security header
$input_headers[] = new SoapHeader($this->securityExtNS, "Security", null, 1);
// Set the JSESSION cookie value
// change by moodle
$sessionId = Alfresco_Repository::getSessionId($this->ticket);
if ($sessionId != null)
{
$this->__setCookie("JSESSIONID", $sessionId);
}
}
return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
}
public function __doRequest($request, $location, $action, $version)
{
// If this request requires authentication we have to manually construct the
// security headers.
if (isset($this->ticket))
{
$dom = new DOMDocument("1.0");
$dom->loadXML($request);
$securityHeader = $dom->getElementsByTagName("Security");
if ($securityHeader->length != 1)
{
throw new Exception("Expected length: 1, Received: " . $securityHeader->length . ". No Security Header, or more than one element called Security!");
}
$securityHeader = $securityHeader->item(0);
// Construct Timestamp Header
$timeStamp = $dom->createElementNS($this->wsUtilityNS, "Timestamp");
$createdDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y")));
$expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y")));
$created = new DOMElement("Created", $createdDate, $this->wsUtilityNS);
$expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS);
$timeStamp->appendChild($created);
$timeStamp->appendChild($expires);
// Construct UsernameToken Header
$userNameToken = $dom->createElementNS($this->securityExtNS, "UsernameToken");
$userName = new DOMElement("Username", "username", $this->securityExtNS);
$passWord = $dom->createElementNS($this->securityExtNS, "Password");
$typeAttr = new DOMAttr("Type", $this->passwordType);
$passWord->appendChild($typeAttr);
$passWord->appendChild($dom->createTextNode($this->ticket));
$userNameToken->appendChild($userName);
$userNameToken->appendChild($passWord);
// Construct Security Header
$securityHeader->appendChild($timeStamp);
$securityHeader->appendChild($userNameToken);
// Save the XML Request
$request = $dom->saveXML();
}
return parent::__doRequest($request, $location, $action, $version);
}
}
?>

View File

@ -1,63 +1,64 @@
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
require_once 'AlfrescoWebService.php';
class WebServiceFactory
{
public static function getAuthenticationService($path)
{
$path .= '/AuthenticationService?wsdl';
return new AlfrescoWebService($path, array());
}
public static function getRepositoryService($path, $ticket)
{
$path .= '/RepositoryService?wsdl';
return new AlfrescoWebService($path, array(), $ticket);
}
public static function getContentService($path, $ticket)
{
$path .= '/ContentService?wsdl';
return new AlfrescoWebService($path, array(), $ticket);
}
public static function getAdministrationService($path, $ticket)
{
$path .= '/AdministrationService?wsdl';
return new AlfrescoWebService($path, array(), $ticket);
}
public static function getAuthoringService($path, $ticket)
{
$path .= '/AuthoringService?wsdl';
return new AlfrescoWebService($path, array(), $ticket);
}
}
?>
<?php
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
// changed by moodle
require_once ($CFG->libdir.'/alfresco/Service/WebService/AlfrescoWebService.php');
class WebServiceFactory
{
public static function getAuthenticationService($path)
{
$path .= '/AuthenticationService?wsdl';
return new AlfrescoWebService($path, array('location'=>$path));
}
public static function getRepositoryService($path, $ticket)
{
$path .= '/RepositoryService?wsdl';
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
}
public static function getContentService($path, $ticket)
{
$path .= '/ContentService?wsdl';
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
}
public static function getAdministrationService($path, $ticket)
{
$path .= '/AdministrationService?wsdl';
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
}
public static function getAuthoringService($path, $ticket)
{
$path .= '/AuthoringService?wsdl';
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
}
}
?>

View File

@ -5,35 +5,38 @@
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
require_once($CFG->libdir . '/soaplib.php');
class repository_alfresco extends repository {
private $repo = null;
private $instance = null;
private $ticket = null;
private $sess = null;
private $user_session = null;
private $store = null;
public function __construct($repositoryid, $context = SITEID, $options = array()) {
global $SESSION, $CFG;
parent::__construct ($repositoryid, $context, $options);
parent::__construct($repositoryid, $context, $options);
$this->sessname = 'alfresco_ticket_'.$this->id;
if (class_exists('SoapClient')) {
require_once($CFG->libdir . '/alfresco/Service/Repository.php');
require_once($CFG->libdir . '/alfresco/Service/Session.php');
require_once($CFG->libdir . '/alfresco/Service/SpacesStore.php');
require_once($CFG->libdir . '/alfresco/Service/Node.php');
$this->repo = new Al_Repository($this->alfresco_url);
$this->sess_name = 'alfresco_ticket_'.$this->id;
// setup alfresco instance
$this->instance = new Alfresco_Repository($this->options['alfresco_url']);
$this->username = optional_param('al_username', '', PARAM_RAW);
$this->password = optional_param('al_password', '', PARAM_RAW);
try{
if ( empty($SESSION->{$this->sess_name}) && !empty($this->username) && !empty($this->password)) {
$this->ticket = $this->repo->authenticate($this->username, $this->password);
$SESSION->{$this->sess_name} = $this->ticket;
// deal with user logging in
if (empty($SESSION->{$this->sessname}) && !empty($this->username) && !empty($this->password)) {
$this->ticket = $this->instance->authenticate($this->username, $this->password);
$SESSION->{$this->sessname} = $this->ticket;
} else {
$this->ticket = $SESSION->{$this->sess_name};
if (!empty($SESSION->{$this->sessname})) {
$this->ticket = $SESSION->{$this->sessname};
}
}
$this->sess = $this->repo->createSession($this->ticket);
$this->store = new SpacesStore($this->sess);
$this->user_session = $this->instance->createSession($this->ticket);
$this->store = new SpacesStore($this->user_session);
} catch (Exception $e) {
$this->logout();
}
@ -62,13 +65,13 @@ class repository_alfresco extends repository {
public function logout() {
global $SESSION;
unset($SESSION->{$this->sess_name});
unset($SESSION->{$this->sessname});
return $this->print_login();
}
public function check_login() {
global $SESSION;
return !empty($SESSION->{$this->sess_name});
return !empty($SESSION->{$this->sessname});
}
private function get_url($node) {
@ -93,7 +96,7 @@ class repository_alfresco extends repository {
$ret = array();
$ret['dynload'] = true;
$ret['list'] = array();
$url = $this->alfresco_url;
$url = $this->options['alfresco_url'];
$pattern = '#^(.*)api#';
preg_match($pattern, $url, $matches);
$ret['manage'] = $matches[1].'faces/jsp/dashboards/container.jsp';
@ -103,7 +106,7 @@ class repository_alfresco extends repository {
if (empty($uuid)) {
$this->current_node = $this->store->companyHome;
} else {
$this->current_node = $this->sess->getNode($this->store, $uuid);
$this->current_node = $this->user_session->getNode($this->store, $uuid);
}
$folder_filter = "{http://www.alfresco.org/model/content/1.0}folder";
$file_filter = "{http://www.alfresco.org/model/content/1.0}content";
@ -113,7 +116,7 @@ class repository_alfresco extends repository {
{
$ret['list'][] = array('title'=>$child->child->cm_name,
'path'=>$child->child->id,
'thumbnail'=>$CFG->httpswwwroot.'/pix/f/folder.gif',
'thumbnail'=>$CFG->httpswwwroot.'/pix/f/folder-32.png',
'children'=>array());
} elseif ($child->child->type == $file_filter) {
$ret['list'][] = array('title'=>$child->child->cm_name,
@ -126,7 +129,7 @@ class repository_alfresco extends repository {
public function get_file($uuid, $file = '') {
global $CFG;
$node = $this->sess->getNode($this->store, $uuid);
$node = $this->user_session->getNode($this->store, $uuid);
$url = $this->get_url($node);
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
@ -138,7 +141,7 @@ class repository_alfresco extends repository {
public function print_search($client_id) {
$str = parent::print_search($client_id);
$str .= '<label>Space: </label><br /><select name="space">';
foreach ($this->sess->stores as $v) {
foreach ($this->user_session->stores as $v) {
$str .= '<option ';
if ($v->__toString() === 'workspace://SpacesStore') {
$str .= 'selected ';
@ -155,8 +158,8 @@ class repository_alfresco extends repository {
public function search($search_text) {
global $CFG;
$space = optional_param('space', 'workspace://SpacesStore', PARAM_RAW);
$currentStore = $this->sess->getStoreFromString($space);
$nodes = $this->sess->query($currentStore, $search_text);
$currentStore = $this->user_session->getStoreFromString($space);
$nodes = $this->user_session->query($currentStore, $search_text);
$ret = array();
$ret['list'] = array();
foreach($nodes as $v) {