cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Space with PHPLibrary

juanc82
Champ in-the-making
Champ in-the-making
Hi.

First of all, congratulations for your PHP iniciative it will be great for us PHP developers.

Now I have two questions:

1)how can I create a space via php library? Is it with a query using CML?
2)how can I give permissions to users on that space?

I'm not sure how can I do this. If it can't be done via the actual library, it will be of great help to receive some hints.

Thanks a lot.
10 REPLIES 10

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Thanks for the kind comments.

Yes, in order to create a space you will need to use CML and to assign permissions you will need to use the AccessControl web service.

These are both available in 1.2, but only the stub have been generated fro the PHP library, there are not the helper interfaces that are available for some of the other services.

This means you'll have to a bit of work, calling the PHP stubs directly in order to so this.

Hope this helps,
Cheers,
Roy

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Support for CML in the PHP library has been contributed.

Checkout the latest code from the PHP forge project to try it out.

Cheers,
Roy

juanc82
Champ in-the-making
Champ in-the-making
Hi Roy

Thanks for the annoucement.

I've been wondering how to create the space with CML. I've been looking at the code and also comparing it with the one in Java but i don't arrive to the code that actually will let me create a space from a PHP application.

I've noticed that the new version of the library includes the update method but i don't now how to build a CML statement (in this case an CMLCreate statement) in order to pass it to this function.

Any hints?

Thanks a lot

eron123
Champ in-the-making
Champ in-the-making
Here is some sample code for creating Stores:

$storename = "New Store";
$properties[0] = new NamedValue( "{http://www.alfresco.org/model/content/1.0}name", $storename);
$properties[1] = new NamedValue( "{http://www.alfresco.org/model/content/1.0}title", $storename);
$properties[2] = new NamedValue("{http://www.alfresco.org/model/content/1.0}description", "test");
$reference = new Reference($store, $focus->settings['alfresco_space'] );
$parentreference = new ParentReference($store, $reference->getUuid(), $reference->getPath(), ASSOC_CONTAINS,  createQNameString( NAMESPACE_CONTENT_MODEL, $storename) );
$create = new CMLCreate($storename, $parentreference, TYPE_FOLDER, $properties);
$cml = new CML();
$cmllist[0] = $create;
$cml->setCreate($create );

$results = @$repository_service->update($cml);

khalylmk
Champ in-the-making
Champ in-the-making
hello,
is the creation/upload content similar to this code?

thx

eron123
Champ in-the-making
Champ in-the-making
Unfortunately I'm not sure the PHP library upload code works or is complete. I'd lov to see a sample if someone can get it working?

khalylmk
Champ in-the-making
Champ in-the-making
Hi,
in fact the best i could do is to overwrite the contents of a certain file with the contents of another (uploaded) file. now i only need to get to create a node within a store to be able to write to it…  Smiley Sad there's still the process of checking out and checking in…

i tried creating a new content node, with the following, but i'm getting an error. Hope someone could help me out:!

$properties[0] = new NamedValue( "{http://www.alfresco.org/model/content/1.0}name',false, $contentname, null);
$properties[1] = new NamedValue( "{http://www.alfresco.org/model/content/1.0}title", false, $contentname, null);
$properties[2] = new NamedValue("{http://www.alfresco.org/model/content/1.0}description", false, "test", null);
//$reference = new Reference($store, $focus->settings['alfresco_space'] );
$parentreference = new ParentReference($store, $reference->getUuid(), $reference->getPath(), ASSOC_CONTAINS,  createQNameString( NAMESPACE_CONTENT_MODEL, $contentname) );
$create = new CMLCreate($contentname, $parentreference, TYPE_CONTENT, $properties);
$cml = new CML();
$cmllist[0] = $create;
$cml->setCreate($create ); 

$results = $repository_service->update($cml);


error:

Error: couldn't build response
Stack trace: #0 D:\PROJECT\WORK\web\TEST\lib\alfresco\RepositoryService.php(109): BaseService->checkForError(Object(SOAP_Fault)) #1 D:\PROJECT\WORK\web\TEST\modules\alfresco\addNode.php5(107): RepositoryService->update(Object(CML)) #2

marcus
Champ in-the-making
Champ in-the-making
How did you go about uploading new content from a file?

ga_katie
Champ in-the-making
Champ in-the-making
it doesn't seem like there is anything about CML or NamedValue in the 1.4 version

has the method of adding a space/content changed?

there doesn't seem to be any sample code around for creating data.

could anyone provide an example of adding a space or creating content?