Вы находитесь на странице: 1из 17

Bendsoft Camelot PHP Tools for

SharePoint

Version 1.0 RC1

info@bendsoft.com
www.bendsoft.com

COPYRIGHT
Copyright 2010 Bendsoft. All rights reserved.
Bendsoft reserves the right to make changes to software and documentation without notice.
For the most recent version of documentation, visit the Bendsoft web site at
www.bendsoft.com.

PROPRIETARY NOTICES
Bendsoft is a trademark of Bendsoft
Microsoft, SharePoint and Microsoft Office SharePoint Server are trademarks of Microsoft,
Inc. All other trademarks are the property of their respective owners.
ISSUE DATE: October 2010

CAMELOT PHP TOOLS LICENSE


Copyright 2010 Bendsoft. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY BENDSOFT ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL BENDSOFT OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing
official policies, either expressed or implied, of Bendsoft.

Table of Contents
Preface..........................................................................................................................................................................5
Intended audience....................................................................................................................................................5
Prerequisites.............................................................................................................................................................5
Introduction to Bendsoft Camelot PHP Tools..........................................................................................................6
Brief technology overview......................................................................................................................................6
Camelot .NET Connector for Microsoft SharePoint.........................................................................................6
Licensing............................................................................................................................................................6
Camelot .NET Connector.............................................................................................................................6
Camelot PHP Tools.......................................................................................................................................6
Other Bendsoft Products...............................................................................................................................6
A quick overview of example usage.......................................................................................................................6
Simple List Synchronisation.........................................................................................................................7
Insert data from a web form to a SharePoint list..........................................................................................7
Setting up a database..................................................................................................................................................8
Tables.......................................................................................................................................................................8
camelot_dump....................................................................................................................................................8
Setting up......................................................................................................................................................8
camelot_list........................................................................................................................................................8
Setting up......................................................................................................................................................8
camelot_content.................................................................................................................................................9
Setting up......................................................................................................................................................9
Classes..........................................................................................................................................................................9
ORM........................................................................................................................................................................9
Package receiving..................................................................................................................................................10
Package handling...................................................................................................................................................10
Package reading.....................................................................................................................................................10
Packets........................................................................................................................................................................10
Requirements.........................................................................................................................................................10
Schema and content packets..................................................................................................................................11
Schemas......................................................................................................................................................11
Example schema....................................................................................................................................11
Sorting order..........................................................................................................................................12
Content........................................................................................................................................................12
Example content....................................................................................................................................12
Storing...................................................................................................................................................................13
Examples and Tutorials............................................................................................................................................13

Receiving SharePoint Data....................................................................................................................................13


Example packages......................................................................................................................................13
Decode and handle an inserted Packet..................................................................................................................13
Taking a sneak peak at packages................................................................................................................13
Storing a SharePoint list and it's contents .................................................................................................14
Display lists and their data....................................................................................................................................14
Display stored SharePoint lists...................................................................................................................14
Variants..................................................................................................................................................15
Display stored SharePoint Data..................................................................................................................15
Variants..................................................................................................................................................16
Response and error messages..................................................................................................................................16
100-199, PacketReceiver messages.......................................................................................................................16
200-299, PacketHandling messages......................................................................................................................17
300-399, PacketReader messages.........................................................................................................................17

Preface
This documentation explains how to use Bendsoft Camelot PHP Tools along with Camelot
.NET Connector for Microsoft SharePoint. It describes basic handling, available classes and
provides usage examples.
Note! You need a valid Bendsoft Camelot .NET Connector License to use the PHP Tools. Check
the prerequisites chapter for further information.

Intended audience
This guide is intended for developers. Depending on the functionality to be used, readers
should have specific knowledge in the following areas:
Object Oriented PHP development
SOAP
Basic knowledge of Microsoft Office SharePoint Server (MOSS) data structure
Camelot .NET Connector for Microsoft SharePoint
SQL
XML

Prerequisites
To use Bendsoft Camelot PHP Tools you need
Microsoft Office SharePoint Server (MOSS)
(http://sharepoint.microsoft.com/)
A Bendsoft Camelot .NET Connector License
(http://www.bendsoft.com/licensing/)
Bendsoft Camelot Synchronisation Service
(Free tool, available at http://www.bendsoft.com/downloads/)
AND/OR
Bendsoft Content Dump Generator Web Part
(Free tool, available at http://www.bendsoft.com/downloads/)
A web server capable of running PHP5 source code
- Apache2 recommended (http://www.apache.org)
MySQL Server (5.x)
(http://www.mysql.com)

Note! Support for the PostgreSQL database is under development.

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

Introduction to Bendsoft Camelot PHP Tools


Bendsoft Camelot PHP Tools is a versatile collection of PHP objects that offers a way to
decompile and read data sent from a SharePoint installation with the Camelot .NET
Connector for Microsoft SharePoint.

Brief technology overview


Camelot .NET Connector for Microsoft SharePoint
Camelot .NET Connector is basically an ADO.NET interpreter for the Microsoft Office
SharePoint Server (MOSS). The Camelot .NET Connector utilises MOSS built in API to
obtain access to all data, which enables several advantages
Secure integrations
Easy to set up access rights (done in the ad connected to SharePoint or in the
SharePoint installation itself)
SharePoint is still in control of the data structure

Licensing
Camelot .NET Connector
The Camelot .NET Connector is not free or anywise included in any free licensing. License
agreements can be found at http://www.bendsoft.com/licensing/.

Camelot PHP Tools


Camelot PHP Tools is free software under FreeBSD license. All licensing details can be found
at http://www.bendsoft.com/licensing/

Other Bendsoft Products


We try to keep most of our products open and free under BSD/MIT or GPL licenses. But in
some cases we need funding and maintenance is expensive. For full licensing details of all
Bendsoft Products please visit http://www.bendsoft.com/licensing/.

A quick overview of example usage


In this section we will list a few common usages of Bendsoft Camelot PHP Tools and
Camelot .NET Connector. More examples available in the knowledge base on
http://www.bendsoft.com/.

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

Simple List Synchronisation


In the most simple case, but also one of the more
common, you just want to publish a list or content
therein to your website. This is a way to actually use
MOSS1 as a Web-CMS2 for parts of or an entire web
site.

Example usages, publish


News
Articles
Press Releases

Insert data from a web form to a


SharePoint list
Camelot PHP Tools enables the feature to insert data
from a web form directly to a MOSS list. There are
several ways of making this integration with
Camelot. The recommended variant, and most
secure, is via a .net web service who receives the
form data which is posted via Camelot PHP Tools
and NuSOAP (or similar SOAP solution). Encryption
can be achieved with SSL or shared keys.

Example usages, retrieve


Contact forms
Questionnaires
Support and ticketing

Microsoft Office SharePoint Server (http://sharepoint.microsoft.com/)

Web Content Management Systemm, WCMS (http://en.wikipedia.org/wiki/Web_content_management_system)

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

Setting up a database
The current version Camelot PHP Tools only supports MySQL. We are developing support
for other databases, PostgreSQL among others.

Tables
Since Camelot PHP Tools utilise XML structure for synchronised list data the table structure
becomes rather easy and straight forward.
In this version there are three tables.
camelot_dump
camelot_list
camelot_content

camelot_dump
The camelot_dump table contains the actual dump packets from Camelot .NET Connector,
you can read more about packets in the Packets section.

Setting up
CREATE TABLE `camelot_dump` (
`camelot_dump_id` bigint(20) NOT NULL auto_increment,
`camelot_dump_packet` longtext NOT NULL,
`camelot_dump_ip` varchar(255) default NULL,
`camelot_dump_date` datetime default NULL,
`camelot_dump_packet_md5` varchar(255) default NULL,
PRIMARY KEY (`camelot_dump_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Note! Use your preferred ENGINE and AUTO_INCREMENT start parameters.

camelot_list
The camelot_list table contains the disaggregated MOSS lists and it's schema.

Setting up
CREATE TABLE `camelot_list` (
`camelot_list_id` int(11) NOT NULL auto_increment,
`camelot_list_id_external` varchar(255) NOT NULL,
`camelot_list_title` varchar(255) default NULL,
`camelot_list_description` text,
`camelot_list_schema` longtext,
`camelot_list_date_modified` datetime default NULL,
`camelot_list_date_lastdeleted` datetime default NULL,
`camelot_list_date_created` datetime default NULL,
`camelot_list_itemcount` int(11) default NULL,
`camelot_list_ip` varchar(255) default NULL,
`camelot_list_status` tinyint(4) default NULL,
PRIMARY KEY (`camelot_list_id`)
Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

9
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Note! Use your preferred ENGINE and AUTO_INCREMENT start parameters.

camelot_content
The camelot_content contains the actual rows of the list.

Setting up
CREATE TABLE `camelot_content` (
`camelot_content_id` int(11) NOT NULL auto_increment,
`camelot_content_camelot_list_id` int(11) default NULL,
`camelot_content_camelot_list_id_external` varchar(255) default NULL,
`camelot_content_row_index` varchar(255) default NULL,
`camelot_content_content` longtext,
PRIMARY KEY (`camelot_content_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Note! Use your preferred ENGINE and AUTO_INCREMENT start parameters.

Classes
The PHP Classes are built to be agile and simple since the fields of usage isn't really defined
and that we like to keep this project open and emphasise the possibilities for creative
solutions. Feel free to leave suggestions and improvements to phptools@bendsoft.com.
The classes are separated in the following pattern
ORM databases and tables.
Receiving packages
Handling of packages
Read and output data

ORM
This version contains four main database classes
Db
CamelotDump
CamelotList
CamelotContent
Class name

File

Information

Db

db.php

The db class contains all necessary


tools to interface towards the
database.

CamelotDump

tbl.dump.php

Communicates with the corresponding


table

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

10
CamelotList

tbl.list.php

Communicates with the corresponding


table

CamelotContent

tbl.content.php

Communicates with the corresponding


table

Package receiving
Class to handle the insert of SharePoint data from the Camelot .NET Connector
Class name

File

Information

PacketReceiver

class.packet.receiver.php

Extends CamelotDump

Package handling
These classes are used to decode, insert and handle dump data
Class name

File

Information

DecodeDump

class.packet.handler.php

Extends CamelotDump

InsertList

class.packet.handler.php

Extends CamelotList

InsertContent

class.packet.handler.php

Extends CamelotContent

Package reading
These classes are used to read and format inserted data
Class name

File

Information

SharePointListReader

class.packet.reader.php

Extends CamelotList

SharePointContentReader

class.packet.reader.php

Extends CamelotContent

Packets
Requirements
As of this version the Camelot PHP Tools only reads assembled packets from either the
Camelot Synchronisation Service or the Dump Generator Web Part.

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

11

Schema and content packets


A Camelot Packet consist of the schema and the contents of a SharePoint list view put
together as XML.
<Packet>
<Schema>

</Schema>
<Content>

</Content>
</Packet>

Schemas
Schemas contains in-depth information about each field represented in the list view.

Example schema
<Field Name="ContentType">
<ID>c042a256-787d-4a6f-8a8a-cf6ab767f12d</ID>
<DisplayName>Content Type</DisplayName>
<Type>Text</Type>
<Required>False</Required>
<ReadOnly>True</ReadOnly>
<PrimaryKey>False</PrimaryKey>
<Percentage>False</Percentage>
<RichText>False</RichText>
<VisibleInView>True</VisibleInView>
<AppendOnly>False</AppendOnly>
<FillInChoice>False</FillInChoice>
<HTMLEncode>False</HTMLEncode>
<Mult>False</Mult>
<Filterable>True</Filterable>
<Sortable>True</Sortable>
<Group>_Hidden</Group>
</Field>
<Field Name="Title">
<ID>fa564e0f-0c70-4ab9-b863-0177e6ddd247</ID>
<DisplayName>Title</DisplayName>
<Type>Text</Type>
<Required>True</Required>
<ReadOnly>False</ReadOnly>
<PrimaryKey>False</PrimaryKey>
<Percentage>False</Percentage>
<RichText>False</RichText>
<VisibleInView>True</VisibleInView>
<AppendOnly>False</AppendOnly>
<FillInChoice>False</FillInChoice>
<HTMLEncode>False</HTMLEncode>
<Mult>False</Mult>
<Filterable>True</Filterable>
<Sortable>True</Sortable>
</Field>
<Field ...

There is a complete documentation of available SharePoint field types at msdn


Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

12

http://msdn.microsoft.com/en-us/library/dd588183(office.11).aspx.
The Camelot .NET Connector specific field types are available in the SPC documentation
http://www.bendsoft.com/#/camelot.

Sorting order
By default the sorting order of the SharePoint list view is kept in the schema and each list
view has its own schema. All output through the PHP Tools are based on this rule, if you wish
to change the sorting order the most simple and logic way to do so is to change the sorting
order in SharePoint before exporting the data or to rearrange the fields in the schemas
(camelot_list.camelot_list_schemas).

Content
All content is stored in a similar manner as the schemas but only contain the content fields.

Example content
<Row Index="0">
<ContentType>Item</ContentType>
<Title>First article</Title>
<Ingress>...</Ingress>
<Article>...</Article>
<Start_x0020_publish>2010-05-14 22:00:00</Start_x0020_publish>
<Stop_x0020_publish/>
<Publish_x0020_to_x0020_external_>true</Publish_x0020_to_x0020_external
_>
</Row>
<Row Index="1">
<ContentType>Item</ContentType>
<Title>Dorum lorom</Title>
<Ingress>...</Ingress>
<Article>...</Article>
<Start_x0020_publish>2010-05-15 13:00:00</Start_x0020_publish>
<Stop_x0020_publish/>
<Publish_x0020_to_x0020_external_>true</Publish_x0020_to_x0020_external
_>
</Row>
<Row Index="2">
<ContentType>Item</ContentType>
<Title>...</Title>
<Ingress>...</Ingress>
<Article/>
<Start_x0020_publish>2010-05-05 10:00:00</Start_x0020_publish>
<Stop_x0020_publish>2010-06-05 00:00:00</Stop_x0020_publish>
<Publish_x0020_to_x0020_external_>true</Publish_x0020_to_x0020_external
_>
</Row>
Note! All text content are escaped (external entities, xml-secure).

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

13

Storing
PHP Tools stores packets in the camelot_dump table. Use the PacketReceiver class to
store packets.
For further examples, see the Receiving SharePoint Data section in Examples and Tutorials.

Examples and Tutorials


The following section shows some usage examples of Camelot PHP Tools.

Receiving SharePoint Data


Data sent from the Bendsoft Camelot Synchronisation Service or collected with the Content
Dump Generator Web Part should be inserted with the PacketReceiver class.
<?php
require_once 'classes/class.packet.receiver.php';
$PacketReceiver = new PacketReceiver();
$packet_number = $PacketReceiver->insert_packet($packet);
// The $packet_number is the value of camelot_dump.camelot_dump_id
// column.
?>
Note! To insert packets you must set up the camelot_dump table as described in this
documentation.

Example packages
We have several example packets available for download at
http://www.bendsoft.com/#/downloads/phptools

Decode and handle an inserted Packet


The Camelot PHP Tools offers a set of classes and functions to handle packets generated with
the Synchronisation Service or Dump Generator.

Taking a sneak peak at packages


<?php
require_once 'classes/class.packet.handler.php';
$DecodeDump = new DecodeDump();
$packet = $DecodeDump->get_packet($packet_number);
$packet = $DecodeDump->decode_packet($packet);
// Sneak a bit
Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

14
print_r($packet);
?>

The packet has now been decoded and have turned into a SimpleXMLElement Object and can
be processed with normal property selectors and array iterators.
Note! This does not insert anything in the database, it only read and decode data from the
camelot_dump table in the database.

Storing a SharePoint list and it's contents


Split up and store list schemas and contents in the database.
<?php
require_once 'classes/class.packet.handler.php';
// Supply the packet_number (camelot_dump.camelot_dump_id)
// Returns the new schema id
$InsertList = new InsertList();
$new_list_id = $InsertList->insert_list($packet_number);
?>

This action separates the packet to the tables camelot_list and camelot_content. You are
allowed to insert the same list more than once. The latest inserted version is always marked as
active in the camelot_list.camelot_list_status field.
Note! To perform this operation you must set up the camelot_list and camelot_content tables as
described in this documentation.

Display lists and their data


By default we include Twig templates to output data with SharePoint PHP Tools. A complete
reference for Twig can be found at it's project page http://www.twig-project.org/.

Display stored SharePoint lists


<?php
require_once 'classes/class.packet.reader.php';
require_once 'twig/lib/Twig/Autoloader.php';
$SharePointList = new SharePointListReader();
// Get all lists from the database
$lists = $SharePointList->show_lists(null, null);
// Load the template framework
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates'); // template folder
$twig = new Twig_Environment($loader);
// State which template to use (sp2010.html, sp2007.html, ...)
$template = $twig->loadTemplate('sp2010.html');
// Send data to template
echo $template->render(array(

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

15
'list_header' => $lists->_headers,
'list_content' => $lists->_content
));
?>
Note! This only lists the available lists, not the content data.

Variants
The show_lists method is versatile and supports the most obvious selections by default. The
method looks like this
/**
* Function to show lists with some preselected data
*
* @access
public
* @param int|string $id Optional, if stated as int it selects the
camelot_list_id, if string it selects the camelot_list_id_external
(SharePoint Guid)
* @param int $status Can be 1, 0 or not stated (null). 1 means currently
active, 0 is all inactive and if not stated ($status = '') all items are
selected
* @return object
*/
function show_lists($id = null, $status = 1) {

As of this version you can make selections based on id or status. The id can either be an
integer or a SharePoint Guid.
Select the list item who has camelot_list_id 7, ignoring if it's active or not
$lists = $SharePointList->show_lists(7, null);

Select all inactive list items


$lists = $SharePointList->show_lists(null, 0);

Select an active list with SharePoint Guid a436e57e-5274-4375-a7fa-767f1160a52c


$lists = $SharePointList->show_lists('a436e57e-5274-4375-a7fa767f1160a52c', 1);

Display stored SharePoint Data


<?php
require_once 'classes/class.packet.reader.php';
require_once 'twig/lib/Twig/Autoloader.php';
$SharePointContent = new SharePointContentReader();
// Select which list to retrieve
$list = $SharePointContent->get_list_data($list_id);
// Load the template framework
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates'); // Template folder
$twig = new Twig_Environment($loader);

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

16
// State which template to use (sp2010.html, sp2007.html, ...)
$template = $twig->loadTemplate('sp2007.html');
// Send data to template
echo $template->render(array(
'list_header' => $list->_schema->display_name,
'list_content' => $list->_content
));
?>

Variants
The get_list_data method supplies a number of options. The method looks like this
/**
* Method to get list data
*
* @access public
* @param int|string $id Required, if stated as int it selects the
camelot_list_id, if string it selects the camelot_list_id_external
(SharePoint Guid)
* @param int $status Can be 1, 0 or not stated. 1 means currently
active, 0 is all inactive and if not stated ($status = '') all items are
selected
* @param string $columns What columns to show, semicolon separated
attribute_name. Default shows everything.
* @return object with data
*/
function get_list_data($id, $status = 1, $colums = null) {

As of this version you can make selections based on id or status and state which columns you
want to list. The id can either be an integer or a SharePoint Guid, the column names stated
must be the attribute_name.
To select the active list with SharePoint Guid a436e57e-5274-4375-a7fa-767f1160a52c and
list Title, Ingress, Article, and Start Publish simply state something like this
$list = $SharePointContent->get_list_data('a436e57e-5274-4375-a7fa767f1160a52c',1,'Title;Ingress;Article;Start_x0020_publish');

Response and error messages


PHP Tools standard response and error messages.

100-199, PacketReceiver messages


Msg

Information

Function

100

Checksum already exist, skipping


packet insert.

PacketReceiver.insert_packet

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

17

200-299, PacketHandling messages


Msg

Information

Function

200

Packet data missing.

DecodeDump.decode_packet

201

Bad id, must be numerical

DecodeDump.get_packet

202

Bad id, must be numerical

InsertList.insert_list

203

Bad id, must be numerical

InsertContent.insert_content

204

Bad list_id, must be numerical

InsertContent.insert_content

300-399, PacketReader messages


Msg

Information

Function

300

Bad Guid

SharePointListReader.show_lists

301

No data in list

SharePointContentReader.sort_content

302

Missing sorting array

SharePointContentReader.sort_content

303

Missing id or Guid

SharePointContentReader.get_schema

304

Missing id or Guid

SharePointContentReader.get_content

Camelot PHP Tools for Microsoft SharePoint - Documentation, Ver 1.0 RC1, www.bendsoft.com

Вам также может понравиться