Ejemplo n.º 1
0
 public function testCreateSession()
 {
     $repository = new Repository();
     $ticket = $repository->authenticate("admin", "admin");
     $session = $repository->createSession($ticket);
     $this->assertNotNull($session);
     $this->assertEquals("http://localhost:8080/alfresco/api", $session->repository->connectionUrl);
     $this->assertEquals($ticket, $session->ticket);
     // TODO for now if no ticket is provided a null session is returned
     $session2 = $repository->createSession();
     $this->assertNull($session2);
 }
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     // Get the url of the Alfresco repository from the Joosco plugin
     // That's why the Joosco plugin needs to be installed and configured before the component
     $plugin =& JPluginHelper::getPlugin('authentication', 'joosco');
     $pluginParams = new JParameter($plugin->params);
     // Here we connect to the Repository
     $repositoryUrl = $pluginParams->get('alf-url');
     $repository = new Repository($repositoryUrl);
     // The ticket is created by the plugin when a user connects
     $ticket = $_SESSION["ticket"];
     $session = $repository->createSession($ticket);
     $store = new SpacesStore($session);
     $currentNode = null;
     $uuid = null;
     $uuid =& JRequest::getVar('uuid');
     if (!isset($uuid)) {
         $currentNode = $store->companyHome;
         $path = 'Company Home';
     } else {
         $currentNode = $session->getNode($store, JRequest::getVar('uuid'));
         $path = JRequest::getVar('path') . '|' . JRequest::getVar('uuid') . '|' . JRequest::getVar('name');
     }
     // Pass the values to the rest of the template
     $this->assignRef('path', $path);
     $this->assignRef('session', $session);
     $this->assignRef('store', $store);
     $this->assignRef('currentNode', $currentNode);
     $this->assignRef('option', JRequest::getVar('option'));
     $this->assignRef('view', JRequest::getVar('view'));
     $this->assignRef('itemid', JRequest::getVar('Itemid'));
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 protected function getConnection()
 {
     if ($this->alfresco == null) {
         if (!empty($this->alfrescoUrl)) {
             $repository = new Repository($this->alfrescoUrl);
             try {
                 $ticket = $repository->authenticate($this->alfrescoUser, $this->alfrescoPass);
             } catch (Exception $e) {
                 za()->log()->err("Failed authenticating to Alfresco");
                 return;
             }
             $this->alfresco = $repository->createSession($ticket);
             $this->spacesStore = new SpacesStore($this->alfresco);
         }
     }
     return $this->alfresco;
 }
 * Note: any changes to this file should be uploaded to the wiki
 */
// Include the required Alfresco PHP API objects
if (isset($_SERVER["ALF_AVAILABLE"]) == false) {
    require_once "Alfresco/Service/Repository.php";
    require_once "Alfresco/Service/Session.php";
    require_once "Alfresco/Service/SpacesStore.php";
}
// Specify the connection details
$repositoryUrl = "http://localhost:8080/alfresco/api";
$userName = "******";
$password = "******";
// Authenticate the user and create a session
$repository = new Repository($repositoryUrl);
$ticket = $repository->authenticate($userName, $password);
$session = $repository->createSession($ticket);
// Create a reference to the 'SpacesStore'
$spacesStore = new SpacesStore($session);
// Use a serach to get the content node we are updating
$nodes = $session->query($spacesStore, "PATH:\"app:company_home/app:guest_home/cm:Alfresco-Tutorial.pdf\"");
$contentNode = $nodes[0];
// Update the property if the form has been posted with the correct details
if (isset($_REQUEST["update"]) == true) {
    // Set the updated title and decription values
    $contentNode->cm_title = $_REQUEST["title"];
    $contentNode->cm_description = $_REQUEST["description"];
    // Save the session.  This ensures that the updates are presisted back to the repository.
    // If this save call is not made the changes made will be lost when the session object is destroyed.
    $session->save();
}
?>
Ejemplo n.º 5
0
    // Put the ticket into the session for later use
    $_SESSION["alfTicket"] = $alfTicket;
} else {
    if (isset($_SESSION["alfTicket"]) == true) {
        // Get the ticket out of the session
        $alfTicket = $_SESSION["alfTicket"];
    }
}
// If we don't have a ticket redirect to the login page somehow
if ($alfTicket == null) {
    // Redirect to the login page
    header("Location: " . $loginURL);
    exit;
}
// Create an alfresco session that can be used
$alfSession = $alfRepository->createSession($alfTicket);
// Create a reference to the media wiki node
if ($alfWikiSpaceNodeRef != null) {
    $alfMediaWikiNode = $alfSession->getNodeFromString($alfWikiSpaceNodeRef);
} else {
    // Use the default wiki node
    $nodes = $alfSession->query(new SpacesStore($alfSession), "TYPE:\"mw:mediaWiki\"");
    if (sizeof($nodes) == 0) {
        // Redirect to the login page, since we can't find the mediaWiki space (probably means incorrect permissions)
        header("Location: " . $loginURL);
        exit;
    }
    $alfMediaWikiNode = $nodes[0];
    $alfWikiSpaceNodeRef = $alfMediaWikiNode->__toString();
}
// Validate the ticket (checks you have correct permissions on the wiki space and that the ticket is valid)
Ejemplo n.º 6
0
<?php

$repository = new Repository();
$stores = $repository->createSession()->stores;
?>
<html>

<head>
</head>

<body>
	<h1>List of stores</h1>
	<ul>	
<?php 
foreach ($stores as $store) {
    echo "<li>" . $store->scheme . "://" . $store->address . "</li>\n";
}
?>
    
	</ul>

</body>

</html>