From 5a35b861970955aaadc561daba0558e47a0b9169 Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Wed, 21 Sep 2011 08:18:32 +0000 Subject: [PATCH] output user's public projects and roles according to planetforge ontology --- .../include/foafprofilesPlugin.class.php | 87 +++++++++++++++++-- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/src/plugins/foafprofiles/include/foafprofilesPlugin.class.php b/src/plugins/foafprofiles/include/foafprofilesPlugin.class.php index 686fb0809d..6273a2e444 100644 --- a/src/plugins/foafprofiles/include/foafprofilesPlugin.class.php +++ b/src/plugins/foafprofiles/include/foafprofilesPlugin.class.php @@ -64,28 +64,97 @@ class foafprofilesPlugin extends Plugin { $mbox = 'mailto:'.$user_email; $mbox_sha1sum = sha1($mbox); - $params['content'] = ' + $projects = $user_obj->getGroups() ; + sortProjectList($projects) ; + $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user_obj) ; + sortRoleList($roles) ; + + $member_of_xml=''; + + $groups_xml=''; + + $projects_xml =''; + + // see if there were any groups + if (count($projects) >= 1) { + foreach ($projects as $p) { + // TODO : report also private projects if authenticated, for instance through OAuth + if($p->isPublic()) { + $project_link = util_make_link_g ($p->getUnixName(),$p->getID(),$p->getPublicName()); + $project_uri = util_make_url_g ($p->getUnixName(),$p->getID()); + // sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/ + $usergroup_uri = $project_uri .'members/'; + + $group_roles_xml = ''; + + $role_names = array () ; + foreach ($roles as $r) { + if ($r instanceof RoleExplicit + && $r->getHomeProject() != NULL + && $r->getHomeProject()->getID() == $p->getID()) { + $role_names[$r->getID()] = $r->getName() ; + $role_uri = $project_uri .'roles/'.$r->getID(); + $group_roles_xml .= ''; + } + } + + $member_of_xml .= ''; + $groups_xml .= ' + '; + + $groups_xml .= $group_roles_xml; + + $groups_xml .= ''; + $projects_xml .= ' + '. $p->getUnixName() .' + '; + + foreach ($role_names as $id => $name) { + $projects_xml .= ' + '. $name .' + '; + } + } + } + } // end if groups + + $xml_content = ' + xmlns:sioc="http://rdfs.org/sioc/ns#" + xmlns:doap="http://usefulinc.com/ns/doap#" + xmlns:planetforge="http://coclico-project.org/ontology/planetforge#"> '. $username .' - - + '; + + $xml_content .= $member_of_xml; + $xml_content .= ' + - '. $username .' + '. $user_real_name .' '. $mbox_sha1sum .' - - - '; - + '; + + $xml_content .= $groups_xml; + + $xml_content .= $projects_xml; + + $xml_content .= ''; + + $doc = new DOMDocument(); + $doc->preserveWhiteSpace = false; + $doc->formatOutput = true; + $doc->loadXML($xml_content); + + $params['content'] = $doc->saveXML(); } } } -- 2.30.2