cancel
Showing results for 
Search instead for 
Did you mean: 

How to use PHP to retrieve user information?

lehaihua444
Champ in-the-making
Champ in-the-making
Hi all,

I am trying to retrieve all user information in my database using php. Is this possible with the PHP library?  If so, can anyone provide any guidelines?

I found this post (http://forums.alfresco.com/en/viewtopic.php?f=21&t=9791) with an Administration class for accessing user details, but I could not get it work.  Is this on the right track on how to achieve my goal?

Thanks in advance.
11 REPLIES 11

gyro_gearless
Champ in-the-making
Champ in-the-making
Hi!

First of all, if you want to seriously use PHP for client-side scripting, you should use our {hacked,improved} version of the PHP API available at

http://www.sugarforge.org/frs/?group_id=860 (dubbed Alfredo-PHPAPI).

I suppose the version of the PHP API coming with Alfresco is seriously flawed and will perhaps not even work…  Smiley Surprised

There is no explicit support for user management, but you may try some Lucene query like

TYPE:"cmSmiley Tongueerson" AND @cm\:name:"Jones"

to fetch the user objects (not tested, but the query should work)

HTH
Gyro

harris
Champ in-the-making
Champ in-the-making
can you tell me what is meaning of Lucene query?
I don't understand how to fetch the user objects?

ddanninger
Champ in-the-making
Champ in-the-making
"Apache Lucene" is a full-featured text search engine it is implemented in Alfresco

Apache Lucene -> http://lucene.apache.org/java/docs/
Alfresco Search - Lucene [Wiki] -> http://wiki.alfresco.com/wiki/Search#Lucene

If you use the Standard Alfresco PHP Libary you can make a lucene query like:


    $nodeId = "//PUT HERE UR NODEID";

    $repositoryUrl = "http://localhost:8080/alfresco/api";
    $userName = "admin";
    $password = "admin";

    $repository = new Repository($repositoryUrl);
    $ticket = $repository->authenticate($userName, $password);
    $session = $repository->createSession($ticket);

    $spacesStore = new SpacesStore($session);

    //$result = $session->query($spacesStore, "PUT HERE YOUR LUCENE QUERY");
  
    // FOR EXAMPLE -> QUERY OF Gyro.Gearless:
    $result = $session->query($spacesStore, "TYPE:\"cm:person\" AND @cm\:name:\"Jones\"");

I hope i could help you.

Best regards
Dominik

ddanninger
Champ in-the-making
Champ in-the-making
If you will use php to retrive for user information , you will use MYsql data.

I cant get what you mean?

cboita
Champ in-the-making
Champ in-the-making
I have the same problem.

I have an integration with a Joomla website. And I want to show user information in User Account, on this website.
offshoredevelopment, do you mean we have to connect to Alfresco DB and get this information directly?

Anyone tried to use Alfredo-PHPAPI?

What can we do to get this info with PHP?


Thanks

gyro_gearless
Champ in-the-making
Champ in-the-making
So here is a simple script to retrieve a users cmSmiley Tongueerson object and dump its properties:


<?php

define('sugarEntry', TRUE);

$apiRoot = dirname(__FILE__) . '/../src';

set_include_path($apiRoot . PATH_SEPARATOR . get_include_path());

print "Include path set to [" . get_include_path() . "}\n";

require_once "Alfresco/Service/Repository.php";
require_once "Alfresco/Service/Session.php";
require_once "Alfresco/Service/SpacesStore.php";

require_once "config.php";

$timestamp = time();

$repository = new AlfRepository($repositoryUrl);
$ticket = $repository->authenticate($userName, $password);

print "Alfresco ticket is $ticket\n";

$session = $repository->createSession($ticket);
$spacesStore = new AlfSpacesStore($session);


$personNodes = $session->query($spacesStore, 'TYPE:"cm:person" AND @cm\\:userName:"wolland"');


foreach ($personNodes as $gyro) {

    print "– Properties ————–\n";

    $gyroProps = $gyro->getProperties();

    foreach($gyroProps as $k => $v) {
        print ": $k -> $v\n";
    }

    print "– Aspects —————–\n";
    $aspects = $gyro->getAspects();
    foreach ($aspects as $a) {
        print ": $a\n";
    }
}

?>

where config.php contains the required login parameters:


<?php
$repositoryUrl = "http://conman1.acmecorp.net:8080/alfresco/api";
$userName = "admin";
$password = "töp$€(re7";
?>



HTH
Gyro

cboita
Champ in-the-making
Champ in-the-making
thanks for your reply. that's it!

ddanninger
Champ in-the-making
Champ in-the-making
Or you can also have a Look in the Post:

http://forums.alfresco.com/en/viewtopic.php?f=21&t=9390

I wrote a simple Class for the AdministrationService to get the Users and their informations.

gomer321
Champ in-the-making
Champ in-the-making
Thanks for the link. I found out  a bunch of stuff the historic mainstreet innat I so needed. Finally the issue is fixed. Smiley Happy