Merge branch 'MDL-49533-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
@@ -13,7 +13,6 @@ lib/editor/tinymce/plugins/pdw/tinymce/
|
||||
lib/editor/tinymce/plugins/spellchecker/rpc.php
|
||||
lib/editor/tinymce/tiny_mce/
|
||||
lib/adodb/
|
||||
lib/alfresco/
|
||||
lib/bennu/
|
||||
lib/evalmath/
|
||||
lib/lessphp/
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
== CHANGELOG ==
|
||||
|
||||
1. Rename class name 'Repository' to 'Alfresco_Repository' in
|
||||
- Service/Repository.php
|
||||
- Service/Webservice/AlfrescoWebService.php
|
||||
|
||||
2. Update path for require_once() in
|
||||
- Service/Logger/Logger.php
|
||||
- Service/WebService/WebServiceFactory.php
|
||||
- Service/ContentData.php
|
||||
- Service/Functions.php
|
||||
- Service/Node.php
|
||||
- Service/Repository.php
|
||||
- Service/Session.php
|
||||
- Service/SpacesStore.php
|
||||
- Service/Store.php
|
||||
|
||||
3. In Alfresco_Repository::__construct(), set _port to 80 when not specified
|
||||
|
||||
@@ -46,7 +46,11 @@ class Alfresco_Repository extends BaseObject
|
||||
$this->_connectionUrl = $connectionUrl;
|
||||
$parts = parse_url($connectionUrl);
|
||||
$this->_host = $parts["host"];
|
||||
- $this->_port = $parts["port"];
|
||||
+ if (empty($parts["port"])) {
|
||||
+ $this->_port = 80;
|
||||
+ } else {
|
||||
+ $this->_port = $parts["port"];
|
||||
+ }
|
||||
|
||||
4. Reapply changes from MDL-20876 Fix depreacted split() calls (bed733c)
|
||||
|
||||
5. Fix strict standards in Service/WebService/AlfrescoWebService.php
|
||||
- AlfrescoWebService::__soapCall() arguments do not match SoapClient::__soapCall()
|
||||
- AlfrescoWebService::__doRequest() arguments do not match SoapClient::__soapCall()
|
||||
|
||||
6. Apply the changes from MDL-41975 in regard with the timestamp
|
||||
|
||||
== Alfresco PHP Library ==
|
||||
|
||||
Installation and developer documentation for the Alfresco PHP Library can be found on the Alfresco Wiki.
|
||||
Get the source from http://code.google.com/p/alfresco-php-sdk/
|
||||
|
||||
== Documentation Links ==
|
||||
|
||||
Installation Instructions - http://code.google.com/p/alfresco-php-sdk/wiki/AlfrescoPHPLibraryInstallationInstructions
|
||||
MediaWiki Integration Installation Instructions - http://code.google.com/p/alfresco-php-sdk/wiki/AlfrescoMediaWikiInstallationInstructions
|
||||
PHP API Documentation - http://code.google.com/p/alfresco-php-sdk/wiki/AlfrescoPHPAPI
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Association extends BaseObject
|
||||
{
|
||||
private $_from;
|
||||
private $_to;
|
||||
private $_type;
|
||||
|
||||
public function __construct($from, $to, $type)
|
||||
{
|
||||
$this->_from = $from;
|
||||
$this->_to = $to;
|
||||
$this->_type = $type;
|
||||
}
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->_from;
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->_to;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,141 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class BaseObject
|
||||
{
|
||||
public function __get($name)
|
||||
{
|
||||
$methodName = $name;
|
||||
$methodName[0] = strtoupper($methodName[0]);
|
||||
$methodName = 'get' . $methodName;
|
||||
|
||||
if (method_exists($this, $methodName) == true)
|
||||
{
|
||||
return $this->$methodName();
|
||||
}
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$methodName = $name;
|
||||
$methodName[0] = strtoupper($methodName[0]);
|
||||
$methodName = 'set' . $methodName;
|
||||
|
||||
if (method_exists($this, $methodName) == true)
|
||||
{
|
||||
return $this->$methodName($value);
|
||||
}
|
||||
}
|
||||
|
||||
protected function resultSetToNodes($session, $store, $resultSet)
|
||||
{
|
||||
$return = array();
|
||||
if (isset($resultSet->rows) == true)
|
||||
{
|
||||
if (is_array($resultSet->rows) == true)
|
||||
{
|
||||
foreach($resultSet->rows as $row)
|
||||
{
|
||||
$id = $row->node->id;
|
||||
$return[] = $session->getNode($store, $id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $resultSet->rows->node->id;
|
||||
$return[] = $session->getNode($store, $id);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function resultSetToMap($resultSet)
|
||||
{
|
||||
$return = array();
|
||||
if (isset($resultSet->rows) == true)
|
||||
{
|
||||
if (is_array($resultSet->rows) == true)
|
||||
{
|
||||
foreach($resultSet->rows as $row)
|
||||
{
|
||||
$return[] = $this->columnsToMap($row->columns);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[] = $this->columnsToMap($resultSet->rows->columns);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function columnsToMap($columns)
|
||||
{
|
||||
$return = array();
|
||||
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$return[$column->name] = $column->value;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function remove_array_value($value, &$array)
|
||||
{
|
||||
if ($array != null)
|
||||
{
|
||||
if (in_array($value, $array) == true)
|
||||
{
|
||||
foreach ($array as $index=>$value2)
|
||||
{
|
||||
if ($value == $value2)
|
||||
{
|
||||
unset($array[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function isContentData($value)
|
||||
{
|
||||
$index = strpos($value, "contentUrl=");
|
||||
if ($index === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class ChildAssociation extends BaseObject
|
||||
{
|
||||
private $_parent;
|
||||
private $_child;
|
||||
private $_type;
|
||||
private $_name;
|
||||
private $_isPrimary;
|
||||
private $_nthSibling;
|
||||
|
||||
public function __construct($parent, $child, $type, $name, $isPrimary=false, $nthSibling=0)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
$this->_child = $child;
|
||||
$this->_type = $type;
|
||||
$this->_name = $name;
|
||||
$this->_isPrimary = $isPrimary;
|
||||
$this->_nthSibling = $nthSibling;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
public function getChild()
|
||||
{
|
||||
return $this->_child;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
public function getIsPrimary()
|
||||
{
|
||||
return $this->_isPrimary;
|
||||
}
|
||||
|
||||
public function getNthSibling()
|
||||
{
|
||||
return $this->_nthSibling;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,285 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
?>
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir."/alfresco/Service/Logger/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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class NamespaceMap
|
||||
{
|
||||
const DELIMITER = "_";
|
||||
|
||||
private $namespaceMap = array(
|
||||
"d" => "http://www.alfresco.org/model/dictionary/1.0",
|
||||
"sys" => "http://www.alfresco.org/model/system/1.0",
|
||||
"cm" => "http://www.alfresco.org/model/content/1.0",
|
||||
"app" => "http://www.alfresco.org/model/application/1.0",
|
||||
"bpm" => "http://www.alfresco.org/model/bpm/1.0",
|
||||
"wf" => "http://www.alfresco.org/model/workflow/1.0",
|
||||
"fm" => "http://www.alfresco.org/model/forum/1.0",
|
||||
"view" => "http://www.alfresco.org/view/repository/1.0",
|
||||
"security" => "http://www.alfresco.org/model/security/1.0",
|
||||
"wcm" => "http://www.alfresco.org/model/wcmmodel/1.0",
|
||||
"wca" => "http://www.alfresco.org/model/wcmappmodel/1.0");
|
||||
|
||||
public function isShortName($shortName)
|
||||
{
|
||||
return ($shortName != $this->getFullName($shortName));
|
||||
}
|
||||
|
||||
public function getFullName($shortName)
|
||||
{
|
||||
$result = $shortName;
|
||||
|
||||
$index = strpos($shortName, NamespaceMap::DELIMITER);
|
||||
if ($index !== false)
|
||||
{
|
||||
$prefix = substr($shortName, 0, $index);
|
||||
|
||||
if (isset($this->namespaceMap[$prefix]) == true)
|
||||
{
|
||||
$url = $this->namespaceMap[$prefix];
|
||||
$name = substr($shortName, $index+1);
|
||||
$name = str_replace("_", "-", $name);
|
||||
if ($name != null && strlen($name) != 0)
|
||||
{
|
||||
$result = "{".$url."}".$name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getFullNames($fullNames)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($fullNames as $fullName)
|
||||
{
|
||||
$result[] = $this->getFullName($fullName);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getShortName($fullName)
|
||||
{
|
||||
$result = $fullName;
|
||||
|
||||
$index = strpos($fullName, "}");
|
||||
if ($index !== false)
|
||||
{
|
||||
$url = substr($fullName, 1, $index-1);
|
||||
$prefix = $this->lookupPrefix($url);
|
||||
if ($prefix != null)
|
||||
{
|
||||
$name = substr($fullName, $index+1);
|
||||
if ($name != null && strlen($name) != 0)
|
||||
{
|
||||
$name = str_replace("-", "_", $name);
|
||||
$result = $prefix.NamespaceMap::DELIMITER.$name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function lookupPrefix($value)
|
||||
{
|
||||
$result = null;
|
||||
foreach($this->namespaceMap as $prefix => $url)
|
||||
{
|
||||
if ($url == $value)
|
||||
{
|
||||
$result = $prefix;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,809 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir.'/alfresco/Service/Store.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/ChildAssociation.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/Association.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/NamespaceMap.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/ContentData.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/VersionHistory.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/Version.php';
|
||||
|
||||
class Node extends BaseObject
|
||||
{
|
||||
private $_session;
|
||||
private $_store;
|
||||
private $_id;
|
||||
private $_type;
|
||||
private $_aspects;
|
||||
private $_properties;
|
||||
private $_children;
|
||||
private $_parents;
|
||||
private $_primaryParent;
|
||||
private $_isNewNode;
|
||||
private $_associations;
|
||||
private $_versionHistory;
|
||||
private $origionalProperties;
|
||||
private $addedAspects;
|
||||
private $removedAspects;
|
||||
private $addedChildren;
|
||||
private $addedParents;
|
||||
private $addedAssociations;
|
||||
private $removedAssociations;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($session, $store, $id)
|
||||
{
|
||||
$this->_session = $session;
|
||||
$this->_store = $store;
|
||||
$this->_id = $id;
|
||||
$this->_isNewNode = false;
|
||||
$this->addedChildren = array();
|
||||
$this->addedParents = array();
|
||||
$this->addedAssociations = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Util method to create a node from a web service node structure.
|
||||
*/
|
||||
public static function createFromWebServiceData($session, $webServiceNode)
|
||||
{
|
||||
$scheme = $webServiceNode->reference->store->scheme;
|
||||
$address = $webServiceNode->reference->store->address;
|
||||
$id = $webServiceNode->reference->uuid;
|
||||
|
||||
$store = $session->getStore($address, $scheme);
|
||||
$node = $session->getNode($store, $id);
|
||||
$node->populateFromWebServiceNode($webServiceNode);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
public function setPropertyValues($properties)
|
||||
{
|
||||
// Check that the properties of the node have been populated
|
||||
$this->populateProperties();
|
||||
|
||||
// Set the property values
|
||||
foreach ($properties as $name=>$value)
|
||||
{
|
||||
$name = $this->_session->namespaceMap->getFullName($name);
|
||||
$this->_properties[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if ($content != null)
|
||||
{
|
||||
$contentData->content = $content;
|
||||
}
|
||||
$this->_properties[$property] = $contentData;
|
||||
|
||||
return $contentData;
|
||||
}
|
||||
|
||||
public function hasAspect($aspect)
|
||||
{
|
||||
list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));
|
||||
$this->populateProperties();
|
||||
return in_array($aspect, $this->_aspects);
|
||||
}
|
||||
|
||||
public function addAspect($aspect, $properties = null)
|
||||
{
|
||||
list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));
|
||||
$this->populateProperties();
|
||||
|
||||
if (in_array($aspect, $this->_aspects) == false)
|
||||
{
|
||||
$this->_aspects[] = $aspect;
|
||||
if ($properties != null)
|
||||
{
|
||||
foreach ($properties as $name=>$value)
|
||||
{
|
||||
$name = $this->_session->namespaceMap->getFullName($name);
|
||||
$this->_properties[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->remove_array_value($aspect, $this->removedAspects);
|
||||
$this->addedAspects[] = $aspect;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAspect($aspect)
|
||||
{
|
||||
list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));
|
||||
$this->populateProperties();
|
||||
|
||||
if (in_array($aspect, $this->_aspects) == true)
|
||||
{
|
||||
$this->remove_array_value($aspect, $this->_aspects);
|
||||
$this->remove_array_value($aspect, $this->addedAspects);
|
||||
$this->removedAspects[] = $aspect;
|
||||
}
|
||||
}
|
||||
|
||||
public function createChild($type, $associationType, $associationName)
|
||||
{
|
||||
list($type, $associationType, $associationName) = $this->_session->namespaceMap->getFullNames(array($type, $associationType, $associationName));
|
||||
|
||||
$id = $this->_session->nextSessionId();
|
||||
$newNode = new Node($this->_session, $this->_store, $id);
|
||||
$childAssociation = new ChildAssociation($this, $newNode, $associationType, $associationName, true);
|
||||
|
||||
$newNode->_isNewNode = true;
|
||||
|
||||
$newNode->_properties = array();
|
||||
$newNode->_aspects = array();
|
||||
$newNode->_properties = array();
|
||||
$newNode->_children = array();
|
||||
$newNode->origionalProperties = array();
|
||||
$newNode->addedAspects = array();
|
||||
$newNode->removedAspects = array();
|
||||
|
||||
$newNode->_type = $type;
|
||||
$newNode->_parents = array();
|
||||
$newNode->addedParents = array($this->__toString() => $childAssociation);
|
||||
$newNode->_primaryParent = $this;
|
||||
|
||||
$this->addedChildren[$newNode->__toString()] = $childAssociation;
|
||||
|
||||
$this->_session->addNode($newNode);
|
||||
|
||||
return $newNode;
|
||||
}
|
||||
|
||||
public function addChild($node, $associationType, $associationName)
|
||||
{
|
||||
list($associationType, $associationName) = $this->_session->namespaceMap->getFullNames(array($associationType, $associationName));
|
||||
|
||||
$childAssociation = new ChildAssociation($this, $node, $associationType, $associationName, false);
|
||||
$this->addedChildren[$node->__toString()] = $childAssociation;
|
||||
$node->addedParents[$this->__toString()] = $childAssociation;
|
||||
}
|
||||
|
||||
public function removeChild($childAssociation)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function addAssociation($to, $associationType)
|
||||
{
|
||||
list($associationType) = $this->_session->namespaceMap->getFullNames(array($associationType));
|
||||
|
||||
$association = new Association($this, $to, $associationType);
|
||||
$this->addedAssociations[$to->__toString()] = $association;
|
||||
}
|
||||
|
||||
public function removeAssociation($association)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function createVersion($description=null, $major=false)
|
||||
{
|
||||
// We can only create a version if there are no outstanding changes for this node
|
||||
if ($this->isDirty() == true)
|
||||
{
|
||||
throw new Exception("You must save any outstanding modifications before a new version can be created.");
|
||||
}
|
||||
|
||||
// TODO implement major flag ...
|
||||
|
||||
$client = WebServiceFactory::getAuthoringService($this->_session->repository->connectionUrl, $this->_session->ticket);
|
||||
$result = $client->createVersion(
|
||||
array("items" => array("nodes" => $this->__toArray()),
|
||||
"comments" => array("name" => "description", "value" => $description),
|
||||
"versionChildren" => false));
|
||||
|
||||
// Clear the properties and aspects
|
||||
$this->_properties = null;
|
||||
$this->_aspects = null;
|
||||
|
||||
// Get the version details
|
||||
// TODO get some of the other details too ...
|
||||
$versionId = $result->createVersionReturn->versions->id->uuid;
|
||||
$versionStoreScheme = $result->createVersionReturn->versions->id->store->scheme;
|
||||
$versionStoreAddress = $result->createVersionReturn->versions->id->store->address;
|
||||
|
||||
// Create the version object to return
|
||||
return new Version($this->_session, new Store($this->_session, $versionStoreAddress, $versionStoreScheme), $versionId);
|
||||
}
|
||||
|
||||
private function isDirty()
|
||||
{
|
||||
$result = true;
|
||||
if ($this->_isNewNode == false &&
|
||||
count($this->getModifiedProperties()) == 0 &&
|
||||
($this->addedAspects == null || count($this->addedAspects) == 0) &&
|
||||
($this->removedAssociations == null || count($this->removedAssociations) == 0) &&
|
||||
($this->addedChildren == null || count($this->addedChildren) == 0) &&
|
||||
($this->addedAssociations == null || count($this->addedAssociations) == 0))
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
$fullName = $this->_session->namespaceMap->getFullName($name);
|
||||
if ($fullName != $name)
|
||||
{
|
||||
$this->populateProperties();
|
||||
if (array_key_exists($fullName, $this->_properties) == true)
|
||||
{
|
||||
return $this->_properties[$fullName];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::__get($name);
|
||||
}
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$fullName = $this->_session->namespaceMap->getFullName($name);
|
||||
if ($fullName != $name)
|
||||
{
|
||||
$this->populateProperties();
|
||||
$this->_properties[$fullName] = $value;
|
||||
|
||||
// Ensure that the node and property details are stored on the contentData object
|
||||
if ($value instanceof ContentData)
|
||||
{
|
||||
$value->setPropertyDetails($this, $fullName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parent::__set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toString method. Returns node as a node reference style string.
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return Node::__toNodeRef($this->_store, $this->id);
|
||||
}
|
||||
|
||||
public static function __toNodeRef($store, $id)
|
||||
{
|
||||
return $store->scheme . "://" . $store->address . "/" . $id;
|
||||
}
|
||||
|
||||
public function __toArray()
|
||||
{
|
||||
return array("store" => $this->_store->__toArray(),
|
||||
"uuid" => $this->_id);
|
||||
}
|
||||
|
||||
public function getSession()
|
||||
{
|
||||
return $this->_session;
|
||||
}
|
||||
|
||||
public function getStore()
|
||||
{
|
||||
return $this->_store;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function getIsNewNode()
|
||||
{
|
||||
return $this->_isNewNode;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
$this->populateProperties();
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function getAspects()
|
||||
{
|
||||
$this->populateProperties();
|
||||
return $this->_aspects;
|
||||
}
|
||||
|
||||
public function getProperties()
|
||||
{
|
||||
$this->populateProperties();
|
||||
return $this->_properties;
|
||||
}
|
||||
|
||||
public function setProperties($properties)
|
||||
{
|
||||
$this->populateProperties();
|
||||
$this->_properties = $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for the versionHistory property.
|
||||
*
|
||||
* @return VersionHistory the versionHistory for the node, null is none
|
||||
*/
|
||||
public function getVersionHistory()
|
||||
{
|
||||
if ($this->_versionHistory == null)
|
||||
{
|
||||
$this->_versionHistory = new VersionHistory($this);
|
||||
}
|
||||
return $this->_versionHistory;
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
if ($this->_children == null)
|
||||
{
|
||||
$this->populateChildren();
|
||||
}
|
||||
return $this->_children + $this->addedChildren;
|
||||
}
|
||||
|
||||
public function getParents()
|
||||
{
|
||||
if ($this->_parents == null)
|
||||
{
|
||||
$this->populateParents();
|
||||
}
|
||||
return $this->_parents + $this->addedParents;
|
||||
}
|
||||
|
||||
public function getPrimaryParent()
|
||||
{
|
||||
if ($this->_primaryParent == null)
|
||||
{
|
||||
$this->populateParents();
|
||||
}
|
||||
return $this->_primaryParent;
|
||||
}
|
||||
|
||||
public function getAssociations()
|
||||
{
|
||||
if ($this->_associations == null)
|
||||
{
|
||||
$this->populateAssociations();
|
||||
}
|
||||
return $this->_associations + $this->addedAssociations;
|
||||
}
|
||||
|
||||
/** Methods used to populate node details from repository */
|
||||
|
||||
private function populateProperties()
|
||||
{
|
||||
if ($this->_isNewNode == false && $this->_properties == null)
|
||||
{
|
||||
$result = $this->_session->repositoryService->get(array (
|
||||
"where" => array (
|
||||
"nodes" => array(
|
||||
"store" => $this->_store->__toArray(),
|
||||
"uuid" => $this->_id))));
|
||||
|
||||
$this->populateFromWebServiceNode($result->getReturn);
|
||||
}
|
||||
}
|
||||
|
||||
private function populateFromWebServiceNode($webServiceNode)
|
||||
{
|
||||
$this->_type = $webServiceNode->type;
|
||||
|
||||
// Get the aspects
|
||||
$this->_aspects = array();
|
||||
$aspects = $webServiceNode->aspects;
|
||||
if (is_array($aspects) == true)
|
||||
{
|
||||
foreach ($aspects as $aspect)
|
||||
{
|
||||
$this->_aspects[] = $aspect;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_aspects[] = $aspects;
|
||||
}
|
||||
|
||||
// Set the property values
|
||||
// NOTE: do we need to be concerned with identifying whether this is an array or not when there is
|
||||
// only one property on a node
|
||||
$this->_properties = array();
|
||||
foreach ($webServiceNode->properties as $propertyDetails)
|
||||
{
|
||||
$name = $propertyDetails->name;
|
||||
$isMultiValue = $propertyDetails->isMultiValue;
|
||||
$value = null;
|
||||
if ($isMultiValue == false)
|
||||
{
|
||||
$value = $propertyDetails->value;
|
||||
if ($this->isContentData($value) == true)
|
||||
{
|
||||
$value = new ContentData($this, $name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $propertyDetails->value;
|
||||
}
|
||||
$this->_properties[$name] = $value;
|
||||
|
||||
}
|
||||
|
||||
$this->origionalProperties = $this->_properties;
|
||||
$this->addedAspects = array();
|
||||
$this->removedAspects = array();
|
||||
|
||||
}
|
||||
|
||||
private function populateChildren()
|
||||
{
|
||||
// TODO should do some sort of limited pull here
|
||||
$result = $this->_session->repositoryService->queryChildren(array("node" => $this->__toArray()));
|
||||
$resultSet = $result->queryReturn->resultSet;
|
||||
|
||||
$children = array();
|
||||
$map = $this->resultSetToMap($resultSet);
|
||||
foreach($map as $value)
|
||||
{
|
||||
$id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
|
||||
$store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
|
||||
$store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
|
||||
$assoc_type = $value["associationType"];
|
||||
$assoc_name = $value["associationName"];
|
||||
$isPrimary = $value["isPrimary"];
|
||||
$nthSibling = $value["nthSibling"];
|
||||
|
||||
$child = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
|
||||
$children[$child->__toString()] = new ChildAssociation($this, $child, $assoc_type, $assoc_name, $isPrimary, $nthSibling);
|
||||
}
|
||||
|
||||
$this->_children = $children;
|
||||
}
|
||||
|
||||
private function populateAssociations()
|
||||
{
|
||||
// TODO should do some sort of limited pull here
|
||||
$result = $this->_session->repositoryService->queryAssociated(array("node" => $this->__toArray(),
|
||||
"association" => array("associationType" => null,
|
||||
"direction" => null)));
|
||||
$resultSet = $result->queryReturn->resultSet;
|
||||
|
||||
$associations = array();
|
||||
$map = $this->resultSetToMap($resultSet);
|
||||
foreach($map as $value)
|
||||
{
|
||||
$id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
|
||||
$store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
|
||||
$store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
|
||||
$assoc_type = $value["associationType"];
|
||||
|
||||
$to = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
|
||||
$associations[$to->__toString()] = new Association($this, $to, $assoc_type);
|
||||
}
|
||||
|
||||
$this->_associations = $associations;
|
||||
}
|
||||
|
||||
private function populateParents()
|
||||
{
|
||||
// TODO should do some sort of limited pull here
|
||||
$result = $this->_session->repositoryService->queryParents(array("node" => $this->__toArray()));
|
||||
$resultSet = $result->queryReturn->resultSet;
|
||||
|
||||
$parents = array();
|
||||
$map = $this->resultSetToMap($resultSet);
|
||||
foreach($map as $value)
|
||||
{
|
||||
$id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
|
||||
$store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
|
||||
$store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
|
||||
$assoc_type = $value["associationType"];
|
||||
$assoc_name = $value["associationName"];
|
||||
$isPrimary = $value["isPrimary"];
|
||||
$nthSibling = $value["nthSibling"];
|
||||
|
||||
$parent = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
|
||||
if ($isPrimary == "true" or $isPrimary == true)
|
||||
{
|
||||
$this->_primaryParent = $parent;
|
||||
}
|
||||
$parents[$parent->__toString()] = new ChildAssociation($parent, $this, $assoc_type, $assoc_name, $isPrimary, $nthSibling);
|
||||
}
|
||||
|
||||
$this->_parents = $parents;
|
||||
}
|
||||
|
||||
public function onBeforeSave(&$statements)
|
||||
{
|
||||
if ($this->_isNewNode == true)
|
||||
{
|
||||
$childAssociation = $this->addedParents[$this->_primaryParent->__toString()];
|
||||
|
||||
$parentArray = array();
|
||||
$parent = $this->_primaryParent;
|
||||
if ($parent->_isNewNode == true)
|
||||
{
|
||||
$parentArray["parent_id"] = $parent->id;
|
||||
$parentArray["associationType"] = $childAssociation->type;
|
||||
$parentArray["childName"] = $childAssociation->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$parentArray["parent"] = array(
|
||||
"store" => $this->_store->__toArray(),
|
||||
"uuid" => $this->_primaryParent->_id,
|
||||
"associationType" => $childAssociation->type,
|
||||
"childName" => $childAssociation->name);
|
||||
}
|
||||
|
||||
$this->addStatement($statements, "create",
|
||||
array("id" => $this->_id) +
|
||||
$parentArray +
|
||||
array(
|
||||
"type" => $this->_type,
|
||||
"property" => $this->getPropertyArray($this->_properties)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the update statement for the modified properties
|
||||
$modifiedProperties = $this->getModifiedProperties();
|
||||
if (count($modifiedProperties) != 0)
|
||||
{
|
||||
$this->addStatement($statements, "update", array("property" => $this->getPropertyArray($modifiedProperties)) + $this->getWhereArray());
|
||||
}
|
||||
|
||||
// TODO deal with any deleted properties
|
||||
}
|
||||
|
||||
// Update any modified content properties
|
||||
if ($this->_properties != null)
|
||||
{
|
||||
foreach($this->_properties as $name=>$value)
|
||||
{
|
||||
if (($value instanceof ContentData) && $value->isDirty == true)
|
||||
{
|
||||
$value->onBeforeSave($statements, $this->getWhereArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the addAspect statements
|
||||
if ($this->addedAspects != null)
|
||||
{
|
||||
foreach($this->addedAspects as $aspect)
|
||||
{
|
||||
$this->addStatement($statements, "addAspect", array("aspect" => $aspect) + $this->getWhereArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Add the removeAspect
|
||||
if ($this->removedAspects != null)
|
||||
{
|
||||
foreach($this->removedAspects as $aspect)
|
||||
{
|
||||
$this->addStatement($statements, "removeAspect", array("aspect" => $aspect) + $this->getWhereArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Add non primary children
|
||||
foreach($this->addedChildren as $childAssociation)
|
||||
{
|
||||
if ($childAssociation->isPrimary == false)
|
||||
{
|
||||
|
||||
$assocDetails = array("associationType" => $childAssociation->type, "childName" => $childAssociation->name);
|
||||
|
||||
$temp = array();
|
||||
if ($childAssociation->child->_isNewNode == true)
|
||||
{
|
||||
$temp["to_id"] = $childAssociation->child->_id;
|
||||
$temp = $temp + $assocDetails;
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp["to"] = array(
|
||||
"store" => $this->_store->__toArray(),
|
||||
"uuid" => $childAssociation->child->_id) +
|
||||
$assocDetails;
|
||||
}
|
||||
$temp = $temp + $this->getWhereArray();
|
||||
$this->addStatement($statements, "addChild", $temp);
|
||||
}
|
||||
}
|
||||
|
||||
// Add associations
|
||||
foreach($this->addedAssociations as $association)
|
||||
{
|
||||
$temp = array("association" => $association->type);
|
||||
$temp = $temp + $this->getPredicateArray("from", $this) + $this->getPredicateArray("to", $association->to);
|
||||
$this->addStatement($statements, "createAssociation", $temp);
|
||||
}
|
||||
}
|
||||
|
||||
private function addStatement(&$statements, $statement, $body)
|
||||
{
|
||||
$result = array();
|
||||
if (array_key_exists($statement, $statements) == true)
|
||||
{
|
||||
$result = $statements[$statement];
|
||||
}
|
||||
$result[] = $body;
|
||||
$statements[$statement] = $result;
|
||||
}
|
||||
|
||||
private function getWhereArray()
|
||||
{
|
||||
return $this->getPredicateArray("where", $this);
|
||||
}
|
||||
|
||||
private function getPredicateArray($label, $node)
|
||||
{
|
||||
if ($node->_isNewNode == true)
|
||||
{
|
||||
return array($label."_id" => $node->_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
$label => array(
|
||||
"nodes" => $node->__toArray()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function getPropertyArray($properties)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($properties as $name=>$value)
|
||||
{
|
||||
// Ignore content properties
|
||||
if (($value instanceof ContentData) == false)
|
||||
{
|
||||
// TODO need to support multi values
|
||||
$result[] = array(
|
||||
"name" => $name,
|
||||
"isMultiValue" => false,
|
||||
"value" => $value);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getModifiedProperties()
|
||||
{
|
||||
$modified = $this->_properties;
|
||||
$origional = $this->origionalProperties;
|
||||
$result = array();
|
||||
if ($modified != null)
|
||||
{
|
||||
foreach ($modified as $key=>$value)
|
||||
{
|
||||
// Ignore content properties
|
||||
if (($value instanceof ContentData) == false)
|
||||
{
|
||||
if (array_key_exists($key, $origional) == true)
|
||||
{
|
||||
// Check to see if the value have been modified
|
||||
if ($value != $origional[$key])
|
||||
{
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function onAfterSave($idMap)
|
||||
{
|
||||
if (array_key_exists($this->_id, $idMap ) == true)
|
||||
{
|
||||
$uuid = $idMap[$this->_id];
|
||||
if ($uuid != null)
|
||||
{
|
||||
$this->_id = $uuid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_isNewNode == true)
|
||||
{
|
||||
$this->_isNewNode = false;
|
||||
|
||||
// Clear the properties and aspect
|
||||
$this->_properties = null;
|
||||
$this->_aspects = null;
|
||||
}
|
||||
|
||||
// Update any modified content properties
|
||||
if ($this->_properties != null)
|
||||
{
|
||||
foreach($this->_properties as $name=>$value)
|
||||
{
|
||||
if (($value instanceof ContentData) && $value->isDirty == true)
|
||||
{
|
||||
$value->onAfterSave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->origionalProperties = $this->_properties;
|
||||
|
||||
if ($this->_aspects != null)
|
||||
{
|
||||
// Calculate the updated aspect list
|
||||
if ($this->addedAspects != null)
|
||||
{
|
||||
$this->_aspects = $this->_aspects + $this->addedAspects;
|
||||
}
|
||||
if ($this->removedAspects != null)
|
||||
{
|
||||
foreach ($this->_aspects as $aspect)
|
||||
{
|
||||
if (in_array($aspect, $this->removedAspects) == true)
|
||||
{
|
||||
$this->remove_array_value($aspect, $this->_aspects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->addedAspects = array();
|
||||
$this->removedAspects = array();
|
||||
|
||||
if ($this->_parents != null)
|
||||
{
|
||||
$this->_parents = $this->_parents + $this->addedParents;
|
||||
}
|
||||
$this->addedParents = array();
|
||||
|
||||
if ($this->_children != null)
|
||||
{
|
||||
$this->_children = $this->_children + $this->addedChildren;
|
||||
}
|
||||
$this->addedChildren = array();
|
||||
|
||||
if ($this->_associations != null)
|
||||
{
|
||||
$this->_associations = $this->_associations + $this->addedAssociations;
|
||||
}
|
||||
$this->addedAssociations = array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,271 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir.'/alfresco/Service/Store.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/Node.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/WebService/WebServiceFactory.php';
|
||||
|
||||
class Session extends BaseObject
|
||||
{
|
||||
public $authenticationService;
|
||||
public $repositoryService;
|
||||
public $contentService;
|
||||
|
||||
private $_repository;
|
||||
private $_ticket;
|
||||
private $_stores;
|
||||
private $_namespaceMap;
|
||||
|
||||
private $nodeCache;
|
||||
private $idCount = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param userName the user name
|
||||
* @param ticket the currenlty authenticated users ticket
|
||||
*/
|
||||
public function __construct($repository, $ticket)
|
||||
{
|
||||
$this->nodeCache = array();
|
||||
|
||||
$this->_repository = $repository;
|
||||
$this->_ticket = $ticket;
|
||||
|
||||
$this->repositoryService = WebServiceFactory::getRepositoryService($this->_repository->connectionUrl, $this->_ticket);
|
||||
$this->contentService = WebServiceFactory::getContentService($this->_repository->connectionUrl, $this->_ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new store in the current respository
|
||||
*
|
||||
* @param $address the address of the new store
|
||||
* @param $scheme the scheme of the new store, default value of 'workspace'
|
||||
* @return Store the new store
|
||||
*/
|
||||
public function createStore($address, $scheme="workspace")
|
||||
{
|
||||
// Create the store
|
||||
$result = $this->repositoryService->createStore(array(
|
||||
"scheme" => $scheme,
|
||||
"address" => $address));
|
||||
$store = new Store($this, $result->createStoreReturn->address, $result->createStoreReturn->scheme);
|
||||
|
||||
// Add to the cached list if its been populated
|
||||
if (isset($this->_stores) == true)
|
||||
{
|
||||
$this->_stores[] = $store;
|
||||
}
|
||||
|
||||
// Return the newly created store
|
||||
return $store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store
|
||||
*
|
||||
* @param $address the address of the store
|
||||
* @param $scheme the scheme of the store. The default it 'workspace'
|
||||
* @return Store the store
|
||||
*/
|
||||
public function getStore($address, $scheme="workspace")
|
||||
{
|
||||
return new Store($this, $address, $scheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store from it string representation (eg: workspace://SpacesStore)
|
||||
*
|
||||
* @param $value the stores string representation
|
||||
* @return Store the store
|
||||
*/
|
||||
public function getStoreFromString($value)
|
||||
{
|
||||
list($scheme, $address) = explode("://", $value);
|
||||
return new Store($this, $address, $scheme);
|
||||
}
|
||||
|
||||
public function getNode($store, $id)
|
||||
{
|
||||
$node = $this->getNodeImpl($store, $id);
|
||||
if ($node == null)
|
||||
{
|
||||
$node = new Node($this, $store, $id);
|
||||
$this->addNode($node);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
public function getNodeFromString($value)
|
||||
{
|
||||
// TODO
|
||||
throw new Exception("getNode($value) not yet implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new node to the session.
|
||||
*/
|
||||
public function addNode($node)
|
||||
{
|
||||
$this->nodeCache[$node->__toString()] = $node;
|
||||
}
|
||||
|
||||
private function getNodeImpl($store, $id)
|
||||
{
|
||||
$result = null;
|
||||
$nodeRef = $store->scheme . "://" . $store->address . "/" . $id;
|
||||
if (array_key_exists($nodeRef, $this->nodeCache) == true)
|
||||
{
|
||||
$result = $this->nodeCache[$nodeRef];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits all unsaved changes to the repository
|
||||
*/
|
||||
public function save($debug=false)
|
||||
{
|
||||
// Build the update statements from the node cache
|
||||
$statements = array();
|
||||
foreach ($this->nodeCache as $node)
|
||||
{
|
||||
$node->onBeforeSave($statements);
|
||||
}
|
||||
|
||||
if ($debug == true)
|
||||
{
|
||||
var_dump($statements);
|
||||
echo ("<br><br>");
|
||||
}
|
||||
|
||||
if (count($statements) > 0)
|
||||
{
|
||||
// Make the web service call
|
||||
$result = $this->repositoryService->update(array("statements" => $statements));
|
||||
//var_dump($result);
|
||||
|
||||
// Update the state of the updated nodes
|
||||
foreach ($this->nodeCache as $node)
|
||||
{
|
||||
$node->onAfterSave($this->getIdMap($result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current session by emptying the node cache.
|
||||
*
|
||||
* WARNING: all unsaved changes will be lost when clearing the session.
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
// Clear the node cache
|
||||
$this->nodeCache = array();
|
||||
}
|
||||
|
||||
private function getIdMap($result)
|
||||
{
|
||||
$return = array();
|
||||
$statements = $result->updateReturn;
|
||||
if (is_array($statements) == true)
|
||||
{
|
||||
foreach ($statements as $statement)
|
||||
{
|
||||
if ($statement->statement == "create")
|
||||
{
|
||||
$id = $statement->sourceId;
|
||||
$uuid = $statement->destination->uuid;
|
||||
$return[$id] = $uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($statements->statement == "create")
|
||||
{
|
||||
$id = $statements->sourceId;
|
||||
$uuid = $statements->destination->uuid;
|
||||
$return[$id] = $uuid;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function query($store, $query, $language='lucene')
|
||||
{
|
||||
// TODO need to support paged queries
|
||||
$result = $this->repositoryService->query(array(
|
||||
"store" => $store->__toArray(),
|
||||
"query" => array(
|
||||
"language" => $language,
|
||||
"statement" => $query),
|
||||
"includeMetaData" => false));
|
||||
|
||||
// TODO for now do nothing with the score and the returned data
|
||||
$resultSet = $result->queryReturn->resultSet;
|
||||
return $this->resultSetToNodes($this, $store, $resultSet);
|
||||
}
|
||||
|
||||
public function getTicket()
|
||||
{
|
||||
return $this->_ticket;
|
||||
}
|
||||
|
||||
public function getRepository()
|
||||
{
|
||||
return $this->_repository;
|
||||
}
|
||||
|
||||
public function getNamespaceMap()
|
||||
{
|
||||
if ($this->_namespaceMap == null)
|
||||
{
|
||||
$this->_namespaceMap = new NamespaceMap();
|
||||
}
|
||||
return $this->_namespaceMap;
|
||||
}
|
||||
|
||||
public function getStores()
|
||||
{
|
||||
if (isset ($this->_stores) == false)
|
||||
{
|
||||
$this->_stores = array ();
|
||||
$results = $this->repositoryService->getStores();
|
||||
|
||||
foreach ($results->getStoresReturn as $result)
|
||||
{
|
||||
$this->_stores[] = new Store($this, $result->address, $result->scheme);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_stores;
|
||||
}
|
||||
|
||||
/** Want these methods to be package scope some how! **/
|
||||
|
||||
public function nextSessionId()
|
||||
{
|
||||
$sessionId = "session".$this->_ticket.$this->idCount;
|
||||
$this->idCount ++;
|
||||
return $sessionId;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir.'/alfresco/Service/Store.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/Node.php';
|
||||
|
||||
class SpacesStore extends Store
|
||||
{
|
||||
private $_companyHome;
|
||||
|
||||
public function __construct($session)
|
||||
{
|
||||
parent::__construct($session, "SpacesStore");
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->scheme . "://" . $this->address;
|
||||
}
|
||||
|
||||
public function getCompanyHome()
|
||||
{
|
||||
if ($this->_companyHome == null)
|
||||
{
|
||||
$nodes = $this->_session->query($this, 'PATH:"app:company_home"');
|
||||
$this->_companyHome = $nodes[0];
|
||||
}
|
||||
return $this->_companyHome;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir.'/alfresco/Service/BaseObject.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/Node.php';
|
||||
|
||||
class Store extends BaseObject
|
||||
{
|
||||
protected $_session;
|
||||
protected $_address;
|
||||
protected $_scheme;
|
||||
protected $_rootNode;
|
||||
|
||||
public function __construct($session, $address, $scheme = "workspace")
|
||||
{
|
||||
$this->_session = $session;
|
||||
$this->_address = $address;
|
||||
$this->_scheme = $scheme;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->scheme . "://" . $this->address;
|
||||
}
|
||||
|
||||
public function __toArray()
|
||||
{
|
||||
return array(
|
||||
"scheme" => $this->_scheme,
|
||||
"address" => $this->_address);
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->_address;
|
||||
}
|
||||
|
||||
public function getScheme()
|
||||
{
|
||||
return $this->_scheme;
|
||||
}
|
||||
|
||||
public function getRootNode()
|
||||
{
|
||||
if (isset ($this->_rootNode) == false)
|
||||
{
|
||||
$result = $this->_session->repositoryService->get(
|
||||
array(
|
||||
"where" => array(
|
||||
"store" => $this->__toArray())));
|
||||
|
||||
$this->_rootNode = Node::createFromWebServiceData($this->_session, $result->getReturn);
|
||||
}
|
||||
|
||||
return $this->_rootNode;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,194 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Version class
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
class Version extends BaseObject
|
||||
{
|
||||
private $_session;
|
||||
private $_store;
|
||||
private $_id;
|
||||
private $_description;
|
||||
private $_major;
|
||||
private $_properties;
|
||||
private $_type;
|
||||
private $_aspects;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $session the session that the version is tied to
|
||||
* @param @store the store that the forzen node is stored in
|
||||
* @prarm @id the id of the frozen node
|
||||
* @param @description the description of the version
|
||||
* @param @major indicates whether this is a major or minor revision
|
||||
*/
|
||||
public function __construct($session, $store, $id, $description=null, $major=false)
|
||||
{
|
||||
$this->_session = $session;
|
||||
$this->_store = $store;
|
||||
$this->_id = $id;
|
||||
$this->_description = $description;
|
||||
$this->_major = $major;
|
||||
$this->_properties = null;
|
||||
$this->_aspects = null;
|
||||
$this->_type = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* __get override.
|
||||
*
|
||||
* If called with a valid property short name, the frozen value of that property is returned.
|
||||
*
|
||||
* @return String the appropriate property value, null if none found
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$fullName = $this->_session->namespaceMap->getFullName($name);
|
||||
if ($fullName != $name)
|
||||
{
|
||||
$this->populateProperties();
|
||||
if (array_key_exists($fullName, $this->_properties) == true)
|
||||
{
|
||||
return $this->_properties[$fullName];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::__get($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets session
|
||||
*
|
||||
* @return Session the session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->_session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the frozen nodes store
|
||||
*
|
||||
* @return Store the store
|
||||
*/
|
||||
public function getStore()
|
||||
{
|
||||
return $this->_store;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
public function getMajor()
|
||||
{
|
||||
return $this->_major;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->_properties;
|
||||
}
|
||||
|
||||
public function getAspects()
|
||||
{
|
||||
return $this->_aspects;
|
||||
}
|
||||
|
||||
private function populateProperties()
|
||||
{
|
||||
if ($this->_properties == null)
|
||||
{
|
||||
$result = $this->_session->repositoryService->get(array (
|
||||
"where" => array (
|
||||
"nodes" => array(
|
||||
"store" => $this->_store->__toArray(),
|
||||
"uuid" => $this->_id))));
|
||||
|
||||
$this->populateFromWebServiceNode($result->getReturn);
|
||||
}
|
||||
}
|
||||
|
||||
private function populateFromWebServiceNode($webServiceNode)
|
||||
{
|
||||
$this->_type = $webServiceNode->type;
|
||||
|
||||
// Get the aspects
|
||||
$this->_aspects = array();
|
||||
$aspects = $webServiceNode->aspects;
|
||||
if (is_array($aspects) == true)
|
||||
{
|
||||
foreach ($aspects as $aspect)
|
||||
{
|
||||
$this->_aspects[] = $aspect;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_aspects[] = $aspects;
|
||||
}
|
||||
|
||||
// Set the property values
|
||||
$this->_properties = array();
|
||||
foreach ($webServiceNode->properties as $propertyDetails)
|
||||
{
|
||||
$name = $propertyDetails->name;
|
||||
$isMultiValue = $propertyDetails->isMultiValue;
|
||||
$value = null;
|
||||
if ($isMultiValue == false)
|
||||
{
|
||||
$value = $propertyDetails->value;
|
||||
if ($this->isContentData($value) == true)
|
||||
{
|
||||
$value = new ContentData($this, $name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $propertyDetails->values;
|
||||
}
|
||||
|
||||
$this->_properties[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Version history class.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
class VersionHistory extends BaseObject
|
||||
{
|
||||
/** Node to which this version history relates */
|
||||
private $_node;
|
||||
|
||||
/** Array of versions */
|
||||
private $_versions;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $node the node that this version history apples to
|
||||
*/
|
||||
public function __construct($node)
|
||||
{
|
||||
$this->_node = $node;
|
||||
$this->populateVersionHistory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the node that this version history relates to
|
||||
*/
|
||||
public function getNode()
|
||||
{
|
||||
return $this->_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the versions in the version history
|
||||
*/
|
||||
public function getVersions()
|
||||
{
|
||||
return $this->_versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the version history
|
||||
*/
|
||||
private function populateVersionHistory()
|
||||
{
|
||||
// Use the web service API to get the version history for this node
|
||||
$client = WebServiceFactory::getAuthoringService($this->_node->session->repository->connectionUrl, $this->_node->session->ticket);
|
||||
$result = $client->getVersionHistory(array("node" => $this->_node->__toArray()));
|
||||
//var_dump($result);
|
||||
|
||||
// TODO populate the version history from the result of the web service call
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = 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, $one_way = 0)
|
||||
{
|
||||
// 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 = gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate("H"), gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y")));
|
||||
$expiresDate = gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate("H")+1, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once $CFG->libdir.'/alfresco/Service/WebService/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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1661,6 +1661,7 @@ class core_plugin_manager {
|
||||
'qformat' => array('blackboard', 'learnwise'),
|
||||
'enrol' => array('authorize'),
|
||||
'report' => array('search'),
|
||||
'repository' => array('alfresco'),
|
||||
'tinymce' => array('dragmath'),
|
||||
'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport'),
|
||||
'theme' => array('mymobile', 'afterburner', 'anomaly', 'arialist', 'binarius', 'boxxie', 'brick', 'formal_white',
|
||||
@@ -1876,7 +1877,7 @@ class core_plugin_manager {
|
||||
),
|
||||
|
||||
'repository' => array(
|
||||
'alfresco', 'areafiles', 'boxnet', 'coursefiles', 'dropbox', 'equella', 'filesystem',
|
||||
'areafiles', 'boxnet', 'coursefiles', 'dropbox', 'equella', 'filesystem',
|
||||
'flickr', 'flickr_public', 'googledocs', 'local', 'merlot',
|
||||
'picasa', 'recent', 'skydrive', 's3', 'upload', 'url', 'user', 'webdav',
|
||||
'wikimedia', 'youtube'
|
||||
|
||||
@@ -7,13 +7,6 @@
|
||||
<version>5.20.3</version>
|
||||
<licenseversion>2.1+</licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
<location>alfresco</location>
|
||||
<name>Alfresco</name>
|
||||
<license>GPL</license>
|
||||
<version></version>
|
||||
<licenseversion>2.0+</licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
<location>bennu</location>
|
||||
<name>Bennu</name>
|
||||
|
||||
@@ -44,6 +44,8 @@ information provided here is intended especially for developers.
|
||||
- cm_info::get_url()
|
||||
- cm_info::obtain_dynamic_data()
|
||||
Calling them through the magic method __call() will throw a coding exception.
|
||||
* The alfresco library has been removed from core. It was an old version of
|
||||
the library which was not compatible with newer versions of Alfresco.
|
||||
|
||||
=== 3.1 ===
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Plugin capabilities.
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @copyright 2009 Dongsheng Cai
|
||||
* @author Dongsheng Cai <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'repository/alfresco:view' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Upgrade.
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @copyright 2014 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade function.
|
||||
*
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_alfresco_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.9.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v3.0.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v3.1.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'repository_alfresco', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['alfresco_url'] = 'Alfresco URL';
|
||||
$string['alfrescourltext'] = 'Afresco API URL should be: http://yoursite.com/alfresco/api or http://yoursite.com/alfresco/soapapi for Alfresco 4.2.d or greater.';
|
||||
$string['alfresco:view'] = 'View alfresco repository';
|
||||
$string['configplugin'] = 'Alfresco configuration';
|
||||
$string['notitle'] = 'notitle';
|
||||
$string['password'] = 'Password';
|
||||
$string['pluginname_help'] = 'A plug-in for Alfresco CMS';
|
||||
$string['pluginname'] = 'Alfresco repository';
|
||||
$string['soapmustbeenabled'] = 'SOAP extension must be enabled for alfresco plugin';
|
||||
$string['space'] = 'Space';
|
||||
$string['username'] = 'User name';
|
||||
@@ -1,289 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This plugin is used to access alfresco repository
|
||||
*
|
||||
* @since Moodle 2.0
|
||||
* @package repository_alfresco
|
||||
* @copyright 2010 Dongsheng Cai {@link http://dongsheng.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
|
||||
/**
|
||||
* repository_alfresco class
|
||||
* This is a class used to browse files from alfresco
|
||||
*
|
||||
* @since Moodle 2.0
|
||||
* @package repository_alfresco
|
||||
* @copyright 2009 Dongsheng Cai {@link http://dongsheng.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_alfresco extends repository {
|
||||
private $ticket = null;
|
||||
private $user_session = null;
|
||||
private $store = null;
|
||||
private $alfresco;
|
||||
|
||||
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
|
||||
global $SESSION, $CFG;
|
||||
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');
|
||||
// setup alfresco
|
||||
$server_url = '';
|
||||
if (!empty($this->options['alfresco_url'])) {
|
||||
$server_url = $this->options['alfresco_url'];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
$this->alfresco = new Alfresco_Repository($this->options['alfresco_url']);
|
||||
$this->username = optional_param('al_username', '', PARAM_RAW);
|
||||
$this->password = optional_param('al_password', '', PARAM_RAW);
|
||||
try{
|
||||
// deal with user logging in
|
||||
if (empty($SESSION->{$this->sessname}) && !empty($this->username) && !empty($this->password)) {
|
||||
$this->ticket = $this->alfresco->authenticate($this->username, $this->password);
|
||||
$SESSION->{$this->sessname} = $this->ticket;
|
||||
} else {
|
||||
if (!empty($SESSION->{$this->sessname})) {
|
||||
$this->ticket = $SESSION->{$this->sessname};
|
||||
}
|
||||
}
|
||||
$this->user_session = $this->alfresco->createSession($this->ticket);
|
||||
$this->store = new SpacesStore($this->user_session);
|
||||
} catch (Exception $e) {
|
||||
$this->logout();
|
||||
}
|
||||
$this->current_node = null;
|
||||
} else {
|
||||
$this->disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function print_login() {
|
||||
if ($this->options['ajax']) {
|
||||
$user_field = new stdClass();
|
||||
$user_field->label = get_string('username', 'repository_alfresco').': ';
|
||||
$user_field->id = 'alfresco_username';
|
||||
$user_field->type = 'text';
|
||||
$user_field->name = 'al_username';
|
||||
|
||||
$passwd_field = new stdClass();
|
||||
$passwd_field->label = get_string('password', 'repository_alfresco').': ';
|
||||
$passwd_field->id = 'alfresco_password';
|
||||
$passwd_field->type = 'password';
|
||||
$passwd_field->name = 'al_password';
|
||||
|
||||
$ret = array();
|
||||
$ret['login'] = array($user_field, $passwd_field);
|
||||
return $ret;
|
||||
} else {
|
||||
echo '<table>';
|
||||
echo '<tr><td><label>'.get_string('username', 'repository_alfresco').'</label></td>';
|
||||
echo '<td><input type="text" name="al_username" /></td></tr>';
|
||||
echo '<tr><td><label>'.get_string('password', 'repository_alfresco').'</label></td>';
|
||||
echo '<td><input type="password" name="al_password" /></td></tr>';
|
||||
echo '</table>';
|
||||
echo '<input type="submit" value="Enter" />';
|
||||
}
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
global $SESSION;
|
||||
unset($SESSION->{$this->sessname});
|
||||
return $this->print_login();
|
||||
}
|
||||
|
||||
public function check_login() {
|
||||
global $SESSION;
|
||||
return !empty($SESSION->{$this->sessname});
|
||||
}
|
||||
|
||||
private function get_url($node) {
|
||||
$result = null;
|
||||
if ($node->type == "{http://www.alfresco.org/model/content/1.0}content") {
|
||||
$contentData = $node->cm_content;
|
||||
if ($contentData != null) {
|
||||
$result = $contentData->getUrl();
|
||||
}
|
||||
} else {
|
||||
$result = "index.php?".
|
||||
"&uuid=".$node->id.
|
||||
"&name=".$node->cm_name.
|
||||
"&path=".'Company Home';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file list from alfresco
|
||||
*
|
||||
* @param string $uuid a unique id of directory in alfresco
|
||||
* @param string $path path to a directory
|
||||
* @return array
|
||||
*/
|
||||
public function get_listing($uuid = '', $path = '') {
|
||||
global $CFG, $SESSION, $OUTPUT;
|
||||
$ret = array();
|
||||
$ret['dynload'] = true;
|
||||
$ret['list'] = array();
|
||||
$server_url = $this->options['alfresco_url'];
|
||||
$pattern = '#^(.*)api#';
|
||||
if ($return = preg_match($pattern, $server_url, $matches)) {
|
||||
$ret['manage'] = $matches[1].'faces/jsp/dashboards/container.jsp';
|
||||
}
|
||||
|
||||
$ret['path'] = array(array('name'=>get_string('pluginname', 'repository_alfresco'), 'path'=>''));
|
||||
|
||||
try {
|
||||
if (empty($uuid)) {
|
||||
$this->current_node = $this->store->companyHome;
|
||||
} else {
|
||||
$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";
|
||||
|
||||
// top level sites folder
|
||||
$sites_filter = "{http://www.alfresco.org/model/site/1.0}sites";
|
||||
// individual site
|
||||
$site_filter = "{http://www.alfresco.org/model/site/1.0}site";
|
||||
|
||||
foreach ($this->current_node->children as $child)
|
||||
{
|
||||
if ($child->child->type == $folder_filter or
|
||||
$child->child->type == $sites_filter or
|
||||
$child->child->type == $site_filter)
|
||||
{
|
||||
$ret['list'][] = array('title'=>$child->child->cm_name,
|
||||
'path'=>$child->child->id,
|
||||
'thumbnail'=>$OUTPUT->pix_url(file_folder_icon(90))->out(false),
|
||||
'children'=>array());
|
||||
} elseif ($child->child->type == $file_filter) {
|
||||
$ret['list'][] = array('title'=>$child->child->cm_name,
|
||||
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($child->child->cm_name, 90))->out(false),
|
||||
'source'=>$child->child->id);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
unset($SESSION->{$this->sessname});
|
||||
$ret = $this->print_login();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a file from alfresco
|
||||
*
|
||||
* @param string $uuid a unique id of directory in alfresco
|
||||
* @param string $path path to a directory
|
||||
* @return array
|
||||
*/
|
||||
public function get_file($uuid, $file = '') {
|
||||
$node = $this->user_session->getNode($this->store, $uuid);
|
||||
$url = $this->get_url($node);
|
||||
return parent::get_file($url, $file);
|
||||
}
|
||||
|
||||
public function print_search() {
|
||||
$str = parent::print_search();
|
||||
$str .= html_writer::label(get_string('space', 'repository_alfresco'),
|
||||
'repository_alfresco_space',
|
||||
false,
|
||||
array('class' => 'accesshide'));
|
||||
$str .= '<select id="repository_alfresco_space" class="alfresco-workplace" name="space">';
|
||||
foreach ($this->user_session->stores as $v) {
|
||||
$str .= '<option ';
|
||||
if ($v->__toString() === 'workspace://SpacesStore') {
|
||||
$str .= 'selected ';
|
||||
}
|
||||
$str .= 'value="';
|
||||
$str .= $v->__toString().'">';
|
||||
$str .= $v->__toString();
|
||||
$str .= '</option>';
|
||||
}
|
||||
$str .= '</select>';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for a file
|
||||
*
|
||||
* @param string $search_text
|
||||
* @return array
|
||||
*/
|
||||
public function search($search_text, $page = 0) {
|
||||
$space = optional_param('space', 'workspace://SpacesStore', PARAM_RAW);
|
||||
$currentStore = $this->user_session->getStoreFromString($space);
|
||||
$nodes = $this->user_session->query($currentStore, $search_text);
|
||||
$ret = array();
|
||||
$ret['list'] = array();
|
||||
foreach($nodes as $v) {
|
||||
$ret['list'][] = array('title'=>$v->cm_name, 'source'=>$v->id);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable mulit-instance
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_instance_option_names() {
|
||||
return array('alfresco_url');
|
||||
}
|
||||
|
||||
/**
|
||||
* define a configuration form
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function instance_config_form($mform) {
|
||||
if (!class_exists('SoapClient')) {
|
||||
$mform->addElement('static', null, get_string('notice'), get_string('soapmustbeenabled', 'repository_alfresco'));
|
||||
return false;
|
||||
}
|
||||
$mform->addElement('text', 'alfresco_url', get_string('alfresco_url', 'repository_alfresco'), array('size' => '40'));
|
||||
$mform->setType('alfresco_url', PARAM_URL);
|
||||
$mform->addElement('static', 'alfreco_url_intro', '', get_string('alfrescourltext', 'repository_alfresco'));
|
||||
$mform->addRule('alfresco_url', get_string('required'), 'required', null, 'client');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if SOAP extension enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function plugin_init() {
|
||||
if (!class_exists('SoapClient')) {
|
||||
print_error('soapmustbeenabled', 'repository_alfresco');
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public function supported_returntypes() {
|
||||
return FILE_INTERNAL;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 727 B |
@@ -1,11 +0,0 @@
|
||||
.repository_alfresco .fp-toolbar .fp-tb-search {
|
||||
width: auto;
|
||||
}
|
||||
.repository_alfresco .fp-toolbar .fp-tb-search .alfresco-workplace {
|
||||
width: 140px;
|
||||
height: 32px;
|
||||
padding: 2px 1px 1px 1px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
border-color: #bbb;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Alfresco repository data generator
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alfresco repository data generator class
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_alfresco_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['alfresco_url'])) {
|
||||
$record['alfresco_url'] = 'http://no.where.com/alfresco/api';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Version details
|
||||
*
|
||||
* @package repository
|
||||
* @subpackage alfresco
|
||||
* @copyright 2009 Dongsheng Cai
|
||||
* @author Dongsheng Cai <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016052300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016051900; // Requires this Moodle version
|
||||
$plugin->component = 'repository_alfresco'; // Full name of the plugin (used for diagnostics)
|
||||
@@ -45,7 +45,7 @@ class core_repository_generator_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// All the repository types.
|
||||
$all = array('alfresco', 'boxnet', 'coursefiles', 'dropbox', 'equella', 'filesystem', 'flickr',
|
||||
$all = array('boxnet', 'coursefiles', 'dropbox', 'equella', 'filesystem', 'flickr',
|
||||
'flickr_public', 'googledocs', 'local', 'merlot', 'picasa', 'recent', 's3', 'upload', 'url',
|
||||
'user', 'webdav', 'wikimedia', 'youtube');
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ http://docs.moodle.org/dev/Repository_API
|
||||
=== 3.2 ===
|
||||
|
||||
* The method repository::uses_post_requests() has been deprecated and must not be used anymore.
|
||||
* The alfresco repository has been moved to the plugins database. It was
|
||||
using an older version of the Alfresco SDK which is not compatible with recent versions of Alfresco.
|
||||
|
||||
=== 3.1 ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user