mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-34400-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
249996281a
@ -1,17 +1,46 @@
|
||||
|
||||
== CHANGELOG ==
|
||||
1. Rename class name , see Service/Repository.php & Service/WebService/AlfrescoWebService.php
|
||||
2. Change library path name
|
||||
3. In Alfresco_Repository class construct function, set _port to 80 if it is not specified
|
||||
4. MDL-20876 - replaced deprecated split() with explode()
|
||||
|
||||
== Alfresco PHP Libarary ==
|
||||
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()
|
||||
|
||||
== Alfresco PHP Library ==
|
||||
|
||||
Installation and developer documentation for the Alfresco PHP Library can be found on the Alfresco Wiki.
|
||||
Get the source from http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/modules/php-sdk
|
||||
Get the source from http://code.google.com/p/alfresco-php-sdk/
|
||||
|
||||
== Documentation Links ==
|
||||
|
||||
Installation Instructions - http://wiki.alfresco.com/wiki/Alfresco_PHP_Library_Installation_Instructions
|
||||
MediaWiki Integration Installation Instructions - http://wiki.alfresco.com/wiki/Alfresco_MediaWiki_Installation_Instructions
|
||||
PHP API Documentation - http://wiki.alfresco.com/wiki/Alfresco_PHP_API
|
||||
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,57 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?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,147 +1,141 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<?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,76 +1,70 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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,292 +1,285 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
// change by moodle
|
||||
require_once($CFG->libdir."/alfresco/Service/Functions.php");
|
||||
|
||||
class ContentData extends BaseObject
|
||||
{
|
||||
private $_isPopulated = false;
|
||||
private $_isDirty = false;
|
||||
|
||||
private $_node;
|
||||
private $_property;
|
||||
|
||||
private $_mimetype;
|
||||
private $_size;
|
||||
private $_encoding;
|
||||
private $_url;
|
||||
private $_newContent;
|
||||
private $_newFileContent;
|
||||
|
||||
public function __construct($node, $property, $mimetype=null, $encoding=null, $size=-1)
|
||||
{
|
||||
$this->_node = $node;
|
||||
$this->_property = $property;
|
||||
$this->_mimetype = $mimetype;
|
||||
$this->_encoding = $encoding;
|
||||
if ($size != -1)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
$this->_isPopulated = false;
|
||||
}
|
||||
|
||||
public function setPropertyDetails($node, $property)
|
||||
{
|
||||
$this->_node = $node;
|
||||
$this->_property = $property;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$this->populateContentData();
|
||||
return "mimetype=".$this->mimetype."|encoding=".$this->encoding."|size=".$this->size;
|
||||
}
|
||||
|
||||
public function getNode()
|
||||
{
|
||||
return $this->_node;
|
||||
}
|
||||
|
||||
public function getProperty()
|
||||
{
|
||||
return $this->_property;
|
||||
}
|
||||
|
||||
public function getIsDirty()
|
||||
{
|
||||
return $this->_isDirty;
|
||||
}
|
||||
|
||||
public function getMimetype()
|
||||
{
|
||||
$this->populateContentData();
|
||||
return $this->_mimetype;
|
||||
}
|
||||
|
||||
public function setMimetype($mimetype)
|
||||
{
|
||||
$this->populateContentData();
|
||||
$this->_mimetype = $mimetype;
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
$this->populateContentData();
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
public function getEncoding()
|
||||
{
|
||||
$this->populateContentData();
|
||||
return $this->_encoding;
|
||||
}
|
||||
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
$this->populateContentData();
|
||||
$this->_encoding = $encoding;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
// TODO what should be returned if the content has been updated??
|
||||
|
||||
$this->populateContentData();
|
||||
$result = null;
|
||||
if ($this->_url != null)
|
||||
{
|
||||
$result = $this->_url."?ticket=".$this->_node->session->ticket;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getGuestUrl()
|
||||
{
|
||||
// TODO what should be returned if the content has been updated??
|
||||
|
||||
$this->populateContentData();
|
||||
$result = null;
|
||||
if ($this->_url != null)
|
||||
{
|
||||
$result = $this->_url."?guest=true";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$this->populateContentData();
|
||||
|
||||
$result = null;
|
||||
if ($this->_isDirty == true)
|
||||
{
|
||||
if ($this->_newFileContent != null)
|
||||
{
|
||||
$handle = fopen($this->_newFileContent, "rb");
|
||||
$result = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
}
|
||||
else if ($this->_newContent != null)
|
||||
{
|
||||
$result = $this->_newContent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->getUrl() != null)
|
||||
{
|
||||
$handle = fopen($this->getUrl(), "rb");
|
||||
$result = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->populateContentData();
|
||||
$this->_isDirty = true;
|
||||
$this->_newContent = $content;
|
||||
}
|
||||
|
||||
public function writeContentFromFile($fileName)
|
||||
{
|
||||
$this->populateContentData();
|
||||
$this->_isDirty = true;
|
||||
$this->_newFileContent = $fileName;
|
||||
}
|
||||
|
||||
public function readContentToFile($fileName)
|
||||
{
|
||||
$handle = fopen($fileName, "wb");
|
||||
fwrite($handle, $this->getContent());
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
public function onBeforeSave(&$statements, $where)
|
||||
{
|
||||
if ($this->_isDirty == true)
|
||||
{
|
||||
// Check mimetype has been set
|
||||
if ($this->_mimetype == null)
|
||||
{
|
||||
throw new Exception("A mime type for the content property ".$this->_property." on node ".$this->_node->__toString()." must be set");
|
||||
}
|
||||
|
||||
// If a file has been specified then read content from there
|
||||
//$content = null;
|
||||
if ($this->_newFileContent != null)
|
||||
{
|
||||
// Upload the content to the repository
|
||||
$contentData = upload_file($this->node->session, $this->_newFileContent, $this->_mimetype, $this->_encoding);
|
||||
|
||||
// Set the content property value
|
||||
$this->addStatement(
|
||||
$statements,
|
||||
"update",
|
||||
array("property" => array(
|
||||
"name" => $this->property,
|
||||
"isMultiValue" => false,
|
||||
"value" => $contentData)) + $where);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the writeContent statement
|
||||
$this->addStatement(
|
||||
$statements,
|
||||
"writeContent",
|
||||
array(
|
||||
"property" => $this->_property,
|
||||
"content" => $this->_newContent,
|
||||
"format" => array(
|
||||
"mimetype" => $this->_mimetype,
|
||||
"encoding" => $this->_encoding)) +
|
||||
$where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAfterSave()
|
||||
{
|
||||
$this->_isDirty = false;
|
||||
$this->_isPopulated = false;
|
||||
$this->_mimetype = null;
|
||||
$this->__size = null;
|
||||
$this->__encoding = null;
|
||||
$this->__url = null;
|
||||
$this->__newContent = null;
|
||||
}
|
||||
|
||||
private function populateContentData()
|
||||
{
|
||||
//echo "isPopulated:".$this->_isPopulated."; node:".$this->_node."; property:".$this->_property."<br>";
|
||||
if ($this->_isPopulated == false && $this->_node != null && $this->_property != null && $this->_node->isNewNode == false)
|
||||
{
|
||||
$result = $this->_node->session->contentService->read( array(
|
||||
"items" => array(
|
||||
"nodes" => array(
|
||||
"store" => $this->_node->store->__toArray(),
|
||||
"uuid" => $this->_node->id)),
|
||||
"property" => $this->_property) );
|
||||
if (isset($result->content) == true)
|
||||
{
|
||||
if (isset($result->content->length) == true)
|
||||
{
|
||||
$this->_size = $result->content->length;
|
||||
}
|
||||
if (isset($result->content->format->mimetype) == true)
|
||||
{
|
||||
$this->_mimetype = $result->content->format->mimetype;
|
||||
}
|
||||
if (isset($result->content->format->encoding) == true)
|
||||
{
|
||||
$this->_encoding = $result->content->format->encoding;
|
||||
}
|
||||
if (isset($result->content->url) == true)
|
||||
{
|
||||
$this->_url = $result->content->url;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_isPopulated = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function addStatement(&$statements, $statement, $body)
|
||||
{
|
||||
$result = array();
|
||||
if (array_key_exists($statement, $statements) == true)
|
||||
{
|
||||
$result = $statements[$statement];
|
||||
}
|
||||
$result[] = $body;
|
||||
$statements[$statement] = $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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,115 +1,108 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
// change by moodle
|
||||
require_once($CFG->libdir."/alfresco/Service/Repository.php");
|
||||
require_once($CFG->libdir."/alfresco/Service/Session.php");
|
||||
|
||||
/**
|
||||
* Uploads a file into content store and returns the content data string which
|
||||
* can be used to populate a content property.
|
||||
*
|
||||
* @param $session the session
|
||||
* @param $filePath the file location
|
||||
* @return String the content data that can be used to update the content property
|
||||
*/
|
||||
function upload_file($session, $filePath, $mimetype=null, $encoding=null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
// Check for the existance of the file
|
||||
if (file_exists($filePath) == false)
|
||||
{
|
||||
throw new Exception("The file ".$filePath."does no exist.");
|
||||
}
|
||||
|
||||
// Get the file name and size
|
||||
$fileName = basename($filePath);
|
||||
$fileSize = filesize($filePath);
|
||||
|
||||
// Get the address and the
|
||||
$host = $session->repository->host;
|
||||
$port = $session->repository->port;
|
||||
|
||||
// Get the IP address for the target host
|
||||
$address = gethostbyname($host);
|
||||
|
||||
// Create a TCP/IP socket
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
if ($socket === false)
|
||||
{
|
||||
throw new Exception ("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
|
||||
}
|
||||
|
||||
// Connect the socket to the repository
|
||||
$result = socket_connect($socket, $address, $port);
|
||||
if ($result === false)
|
||||
{
|
||||
throw new Exception("socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)));
|
||||
}
|
||||
|
||||
// Write the request header onto the socket
|
||||
$url = "/alfresco/upload/".urlencode($fileName)."?ticket=".$session->ticket;
|
||||
if ($mimetype != null)
|
||||
{
|
||||
// Add mimetype if specified
|
||||
$url .= "&mimetype=".$mimetype;
|
||||
}
|
||||
if ($encoding != null)
|
||||
{
|
||||
// Add encoding if specified
|
||||
$url .= "&encoding=".$encoding;
|
||||
}
|
||||
$in = "PUT ".$url." HTTP/1.1\r\n".
|
||||
"Content-Length: ".$fileSize."\r\n".
|
||||
"Host: ".$address.":".$port."\r\n".
|
||||
"Connection: Keep-Alive\r\n".
|
||||
"\r\n";
|
||||
socket_write($socket, $in, strlen($in));
|
||||
|
||||
// Write the content found in the file onto the socket
|
||||
$handle = fopen($filePath, "r");
|
||||
while (feof($handle) == false)
|
||||
{
|
||||
$content = fread($handle, 1024);
|
||||
socket_write($socket, $content, strlen($content));
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
// Read the response
|
||||
$recv = socket_read ($socket, 2048, PHP_BINARY_READ);
|
||||
$index = strpos($recv, "contentUrl");
|
||||
if ($index !== false)
|
||||
{
|
||||
$result = substr($recv, $index);
|
||||
}
|
||||
|
||||
// Close the socket
|
||||
socket_close($socket);
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
<?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,90 +1,84 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
require_once "LoggerConfig.php";
|
||||
|
||||
class Logger
|
||||
{
|
||||
private $componentName;
|
||||
|
||||
public function __construct($componentName = null)
|
||||
{
|
||||
$this->componentName = $componentName;
|
||||
}
|
||||
|
||||
public function isDebugEnabled()
|
||||
{
|
||||
return $this->isEnabled(DEBUG);
|
||||
}
|
||||
|
||||
public function debug($message)
|
||||
{
|
||||
$this->write(DEBUG, $message);
|
||||
}
|
||||
|
||||
public function isWarningEnabled()
|
||||
{
|
||||
return $this->isEnabled(WARNING);
|
||||
}
|
||||
|
||||
public function warning($message)
|
||||
{
|
||||
$this->write(WARNING, $message);
|
||||
}
|
||||
|
||||
public function isInformationEnabled()
|
||||
{
|
||||
return $this->isEnabled(INFORMATION);
|
||||
}
|
||||
|
||||
public function information($message)
|
||||
{
|
||||
$this->write(INFORMATION, $message);
|
||||
}
|
||||
|
||||
private function isEnabled($logLevel)
|
||||
{
|
||||
global $componentLogLevels, $defaultLogLevel;
|
||||
|
||||
$logLevels = $defaultLogLevel;
|
||||
if ($this->componentName != null && isset($componentLogLevels[$this->componentName]) == true)
|
||||
{
|
||||
$logLevels = $componentLogLevels[$this->componentName];
|
||||
}
|
||||
|
||||
return in_array($logLevel, $logLevels);
|
||||
}
|
||||
|
||||
private function write($logLevel, $message)
|
||||
{
|
||||
global $logFile;
|
||||
|
||||
$handle = fopen($logFile, "a");
|
||||
fwrite($handle, $logLevel." ".date("G:i:s d/m/Y")." - ".$message."\r\n");
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-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,44 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
define("DEBUG", "Debug");
|
||||
define("WARNING", "Warning");
|
||||
define("INFO", "Information");
|
||||
|
||||
$debugLevel = array(DEBUG, WARNING, INFO);
|
||||
$warningLevel = array(WARNING, INFO);
|
||||
$infoLevel = array(INFO);
|
||||
$noneLevel = array();
|
||||
|
||||
$defaultLogLevel = $infoLevel;
|
||||
|
||||
$logFile = "c:/work/AlfrescoPHPLog.txt";
|
||||
$componentLogLevels = array(
|
||||
"integration.mediawiki.ExternalStoreAlfresco" => $debugLevel
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-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,121 +1,115 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,139 +1,131 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
// change by moodle
|
||||
require_once $CFG->libdir.'/alfresco/Service/WebService/WebServiceFactory.php';
|
||||
require_once $CFG->libdir.'/alfresco/Service/BaseObject.php';
|
||||
|
||||
if (isset($_SESSION) == false)
|
||||
{
|
||||
// Start the session
|
||||
session_start();
|
||||
}
|
||||
|
||||
// change by moodle
|
||||
class Alfresco_Repository extends BaseObject
|
||||
{
|
||||
private $_connectionUrl;
|
||||
private $_host;
|
||||
private $_port;
|
||||
|
||||
public function __construct($connectionUrl="http://localhost:8080/alfresco/api")
|
||||
{
|
||||
$this->_connectionUrl = $connectionUrl;
|
||||
$parts = parse_url($connectionUrl);
|
||||
$this->_host = $parts["host"];
|
||||
if (empty($parts["port"])) {
|
||||
$this->_port = 80;
|
||||
} else {
|
||||
$this->_port = $parts["port"];
|
||||
}
|
||||
}
|
||||
|
||||
public function getConnectionUrl()
|
||||
{
|
||||
return $this->_connectionUrl;
|
||||
}
|
||||
|
||||
public function getHost()
|
||||
{
|
||||
return $this->_host;
|
||||
}
|
||||
|
||||
public function getPort()
|
||||
{
|
||||
return $this->_port;
|
||||
}
|
||||
|
||||
public function authenticate($userName, $password)
|
||||
{
|
||||
// TODO need to handle exceptions!
|
||||
|
||||
$authenticationService = WebServiceFactory::getAuthenticationService($this->_connectionUrl);
|
||||
$result = $authenticationService->startSession(array (
|
||||
"username" => $userName,
|
||||
"password" => $password
|
||||
));
|
||||
|
||||
// Get the ticket and sessionId
|
||||
$ticket = $result->startSessionReturn->ticket;
|
||||
$sessionId = $result->startSessionReturn->sessionid;
|
||||
|
||||
// Store the session id for later use
|
||||
if ($sessionId != null)
|
||||
{
|
||||
$sessionIds = null;
|
||||
if (isset($_SESSION["sessionIds"]) == false)
|
||||
{
|
||||
$sessionIds = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sessionIds = $_SESSION["sessionIds"];
|
||||
}
|
||||
$sessionIds[$ticket] = $sessionId;
|
||||
$_SESSION["sessionIds"] = $sessionIds;
|
||||
}
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
public function createSession($ticket=null)
|
||||
{
|
||||
$session = null;
|
||||
|
||||
if ($ticket == null)
|
||||
{
|
||||
// TODO get ticket from some well known location ie: the $_SESSION
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO would be nice to be able to check that the ticket is still valid!
|
||||
|
||||
// Create new session
|
||||
$session = new Session($this, $ticket);
|
||||
}
|
||||
|
||||
return $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given ticket, returns the realated session id, null if one can not be found.
|
||||
*/
|
||||
public static function getSessionId($ticket)
|
||||
{
|
||||
$result = null;
|
||||
if (isset($_SESSION["sessionIds"]) == true)
|
||||
{
|
||||
$result = $_SESSION["sessionIds"][$ticket];
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?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,277 +1,271 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
require_once 'Store.php';
|
||||
require_once 'Node.php';
|
||||
require_once '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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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,54 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
require_once 'Store.php';
|
||||
require_once '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;
|
||||
}
|
||||
}
|
||||
<?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,81 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
require_once 'BaseObject.php';
|
||||
require_once '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;
|
||||
}
|
||||
}
|
||||
<?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,200 +1,194 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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,80 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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,118 +1,111 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
class AlfrescoWebService extends SoapClient
|
||||
{
|
||||
private $securityExtNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
|
||||
private $wsUtilityNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
|
||||
private $passwordType = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
|
||||
|
||||
private $ticket;
|
||||
|
||||
public function __construct($wsdl, $options = array('trace' => true, 'exceptions' => true), $ticket = null)
|
||||
{
|
||||
// Store the current ticket
|
||||
$this->ticket = $ticket;
|
||||
|
||||
// Call the base class
|
||||
parent::__construct($wsdl, $options);
|
||||
}
|
||||
|
||||
public function __call($function_name, $arguments=array())
|
||||
{
|
||||
return $this->__soapCall($function_name, $arguments);
|
||||
}
|
||||
|
||||
public function __soapCall($function_name, $arguments=array(), $options=array(), $input_headers=array(), $output_headers=array())
|
||||
{
|
||||
if (isset($this->ticket))
|
||||
{
|
||||
// Automatically add a security header
|
||||
$input_headers[] = new SoapHeader($this->securityExtNS, "Security", null, 1);
|
||||
|
||||
// Set the JSESSION cookie value
|
||||
// change by moodle
|
||||
$sessionId = Alfresco_Repository::getSessionId($this->ticket);
|
||||
if ($sessionId != null)
|
||||
{
|
||||
$this->__setCookie("JSESSIONID", $sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
|
||||
}
|
||||
|
||||
public function __doRequest($request, $location, $action, $version)
|
||||
{
|
||||
// If this request requires authentication we have to manually construct the
|
||||
// security headers.
|
||||
if (isset($this->ticket))
|
||||
{
|
||||
$dom = new DOMDocument("1.0");
|
||||
$dom->loadXML($request);
|
||||
|
||||
$securityHeader = $dom->getElementsByTagName("Security");
|
||||
|
||||
if ($securityHeader->length != 1)
|
||||
{
|
||||
throw new Exception("Expected length: 1, Received: " . $securityHeader->length . ". No Security Header, or more than one element called Security!");
|
||||
}
|
||||
|
||||
$securityHeader = $securityHeader->item(0);
|
||||
|
||||
// Construct Timestamp Header
|
||||
$timeStamp = $dom->createElementNS($this->wsUtilityNS, "Timestamp");
|
||||
$createdDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y")));
|
||||
$expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y")));
|
||||
$created = new DOMElement("Created", $createdDate, $this->wsUtilityNS);
|
||||
$expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS);
|
||||
$timeStamp->appendChild($created);
|
||||
$timeStamp->appendChild($expires);
|
||||
|
||||
// Construct UsernameToken Header
|
||||
$userNameToken = $dom->createElementNS($this->securityExtNS, "UsernameToken");
|
||||
$userName = new DOMElement("Username", "username", $this->securityExtNS);
|
||||
$passWord = $dom->createElementNS($this->securityExtNS, "Password");
|
||||
$typeAttr = new DOMAttr("Type", $this->passwordType);
|
||||
$passWord->appendChild($typeAttr);
|
||||
$passWord->appendChild($dom->createTextNode($this->ticket));
|
||||
$userNameToken->appendChild($userName);
|
||||
$userNameToken->appendChild($passWord);
|
||||
|
||||
// Construct Security Header
|
||||
$securityHeader->appendChild($timeStamp);
|
||||
$securityHeader->appendChild($userNameToken);
|
||||
|
||||
// Save the XML Request
|
||||
$request = $dom->saveXML();
|
||||
}
|
||||
|
||||
return parent::__doRequest($request, $location, $action, $version);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?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 = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y")));
|
||||
$expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y")));
|
||||
$created = new DOMElement("Created", $createdDate, $this->wsUtilityNS);
|
||||
$expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS);
|
||||
$timeStamp->appendChild($created);
|
||||
$timeStamp->appendChild($expires);
|
||||
|
||||
// Construct UsernameToken Header
|
||||
$userNameToken = $dom->createElementNS($this->securityExtNS, "UsernameToken");
|
||||
$userName = new DOMElement("Username", "username", $this->securityExtNS);
|
||||
$passWord = $dom->createElementNS($this->securityExtNS, "Password");
|
||||
$typeAttr = new DOMAttr("Type", $this->passwordType);
|
||||
$passWord->appendChild($typeAttr);
|
||||
$passWord->appendChild($dom->createTextNode($this->ticket));
|
||||
$userNameToken->appendChild($userName);
|
||||
$userNameToken->appendChild($passWord);
|
||||
|
||||
// Construct Security Header
|
||||
$securityHeader->appendChild($timeStamp);
|
||||
$securityHeader->appendChild($userNameToken);
|
||||
|
||||
// Save the XML Request
|
||||
$request = $dom->saveXML();
|
||||
}
|
||||
|
||||
return parent::__doRequest($request, $location, $action, $version);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,64 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
// changed by moodle
|
||||
require_once ($CFG->libdir.'/alfresco/Service/WebService/AlfrescoWebService.php');
|
||||
|
||||
class WebServiceFactory
|
||||
{
|
||||
public static function getAuthenticationService($path)
|
||||
{
|
||||
$path .= '/AuthenticationService?wsdl';
|
||||
return new AlfrescoWebService($path, array('location'=>$path));
|
||||
}
|
||||
|
||||
public static function getRepositoryService($path, $ticket)
|
||||
{
|
||||
$path .= '/RepositoryService?wsdl';
|
||||
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
|
||||
}
|
||||
|
||||
public static function getContentService($path, $ticket)
|
||||
{
|
||||
$path .= '/ContentService?wsdl';
|
||||
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
|
||||
}
|
||||
|
||||
public static function getAdministrationService($path, $ticket)
|
||||
{
|
||||
$path .= '/AdministrationService?wsdl';
|
||||
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
|
||||
}
|
||||
|
||||
public static function getAuthoringService($path, $ticket)
|
||||
{
|
||||
$path .= '/AuthoringService?wsdl';
|
||||
return new AlfrescoWebService($path, array('location'=>$path), $ticket);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user