return group_get_object(db_result($res, 0, 'group_id'), $res);
}
-/**\r
- * get_public_active_projects_asc() - Get a list of rows for public active projects (initially in trove/full_list)\r
- *\r
- * @param int Opional Maximum number of rows to limit query length \r
+/**
+ * get_public_active_projects_asc() - Get a list of rows for public active projects (initially in trove/full_list)
+ *
+ * @param int Opional Maximum number of rows to limit query length
*/
-function get_public_active_projects_asc($max_query_limit = -1) {\r
-\r
- $res_grp = db_query_params ('\r
- SELECT group_id, group_name, unix_group_name, short_description, register_time\r
- FROM groups\r
- WHERE status = $1 AND type_id=1 AND group_id>4 AND register_time > 0\r
- ORDER BY group_name ASC\r
- ',\r
- array ('A'),\r
- $max_query_limit);\r
- $projects = array();\r
- while ($row_grp = db_fetch_array($res_grp)) {\r
- if (!forge_check_perm ('project_read', $row_grp['group_id'])) {\r
- continue ;\r
- }\r
- $projects[] = $row_grp;\r
- }\r
- return $projects;\r
-}\r
+function get_public_active_projects_asc($max_query_limit = -1) {
+
+ $res_grp = db_query_params ('
+ SELECT group_id, group_name, unix_group_name, short_description, register_time
+ FROM groups
+ WHERE status = $1 AND type_id=1 AND group_id>4 AND register_time > 0
+ ORDER BY group_name ASC
+ ',
+ array ('A'),
+ $max_query_limit);
+ $projects = array();
+ while ($row_grp = db_fetch_array($res_grp)) {
+ if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
+ continue ;
+ }
+ $projects[] = $row_grp;
+ }
+ return $projects;
+}
class Group extends Error {
$roles = RBACEngine::getInstance()->getAvailableRolesForUser($user_obj) ;
sortRoleList($roles) ;
- // Construct an ARC2_Resource containing the project's RDF (DOAP) description\r
- $ns = array(\r
- 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\r
+ // Construct an ARC2_Resource containing the project's RDF (DOAP) description
+ $ns = array(
+ 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'foaf' => 'http://xmlns.com/foaf/0.1/',
'sioc' => 'http://rdfs.org/sioc/ns#',
- 'doap' => 'http://usefulinc.com/ns/doap#',\r
+ 'doap' => 'http://usefulinc.com/ns/doap#',
'dcterms' => 'http://purl.org/dc/terms/',
- 'planetforge' => 'http://coclico-project.org/ontology/planetforge#'\r
- );\r
- \r
- $conf = array(\r
- 'ns' => $ns\r
+ 'planetforge' => 'http://coclico-project.org/ontology/planetforge#'
+ );
+
+ $conf = array(
+ 'ns' => $ns
);
// First, let's deal with the account
$account_res = ARC2::getResource($conf);
$account_uri = util_make_url_u($username, $user_obj->getID());
- $account_uri = rtrim($account_uri,'/');\r
+ $account_uri = rtrim($account_uri,'/');
$person_uri = $account_uri . '#person';
$account_res->setURI( $account_uri );
- // $account_res->setRel('rdf:type', 'foaf:OnlineAccount');\r
+ // $account_res->setRel('rdf:type', 'foaf:OnlineAccount');
rdfutils_setPropToUri($account_res, 'rdf:type', 'foaf:OnlineAccount');
rdfutils_setPropToUri($account_res, 'foaf:accountServiceHomepage', $account_uri . '/');
$account_res->setProp('foaf:accountName', $username);
rdfutils_setPropToUri($account_res, 'foaf:accountProfilePage', $account_uri);
$groups_index = array();
- $projects_index = array();\r
+ $projects_index = array();
$roles_index = array();
- $usergroups_uris = array();\r
- // see if there were any groups\r
- if (count($projects) >= 1) {\r
- foreach ($projects as $p) {\r
- // TODO : report also private projects if authenticated, for instance through OAuth\r
- if($p->isPublic()) {\r
- $project_link = util_make_link_g ($p->getUnixName(),$p->getID(),$p->getPublicName());\r
- $project_uri = util_make_url_g ($p->getUnixName(),$p->getID());\r
- // sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/\r
- $usergroup_uri = $project_uri .'members/';\r
-\r
- $role_names = array();\r
+ $usergroups_uris = array();
+ // 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/';
+
+ $role_names = array();
$usergroups_uris[] = $usergroup_uri;
$usergroup_res = ARC2::getResource($conf);
$usergroup_res->setURI( $usergroup_uri );
rdfutils_setPropToUri($usergroup_res, 'rdf:type', 'sioc:UserGroup');
- rdfutils_setPropToUri($usergroup_res, 'sioc:usergroup_of', $project_uri);\r
-
- $roles_uris = array();\r
- foreach ($roles as $r) {\r
- if ($r instanceof RoleExplicit\r
- && $r->getHomeProject() != NULL\r
- && $r->getHomeProject()->getID() == $p->getID()) {\r
- $role_names[$r->getID()] = $r->getName() ;\r
- $role_uri = $project_uri .'roles/'.$r->getID();\r
+ rdfutils_setPropToUri($usergroup_res, 'sioc:usergroup_of', $project_uri);
+
+ $roles_uris = 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();
- $roles_uris[] = $role_uri;\r
- }\r
+ $roles_uris[] = $role_uri;
+ }
}
- rdfutils_setPropToUri($usergroup_res, 'planetforge:group_has_function', $roles_uris);\r
+ rdfutils_setPropToUri($usergroup_res, 'planetforge:group_has_function', $roles_uris);
- $project_res = ARC2::getResource($conf);\r
- $project_res->setURI( $project_uri );\r
- rdfutils_setPropToUri($project_res, 'rdf:type', 'planetforge:ForgeProject');\r
+ $project_res = ARC2::getResource($conf);
+ $project_res->setURI( $project_uri );
+ rdfutils_setPropToUri($project_res, 'rdf:type', 'planetforge:ForgeProject');
$project_res->setProp('doap:name', $p->getUnixName());
$projects_index = ARC2::getMergedIndex($projects_index, $project_res->index);
- \r
- \r
+
+
foreach ($role_names as $id => $name) {
- $role_res = ARC2::getResource($conf);\r
- $role_res->setURI( $project_uri .'roles/'.$id );\r
- rdfutils_setPropToUri($role_res, 'rdf:type', 'sioc:Role');\r
+ $role_res = ARC2::getResource($conf);
+ $role_res->setURI( $project_uri .'roles/'.$id );
+ rdfutils_setPropToUri($role_res, 'rdf:type', 'sioc:Role');
$role_res->setProp('sioc:name', $name);
- \r
- $roles_index = ARC2::getMergedIndex($roles_index, $role_res->index);\r
+
+ $roles_index = ARC2::getMergedIndex($roles_index, $role_res->index);
}
$groups_index = ARC2::getMergedIndex($groups_index, $usergroup_res->index);
- \r
- }\r
- }\r
- } // end if groups\r
- rdfutils_setPropToUri($account_res, 'sioc:member_of', $usergroups_uris);\r
+
+ }
+ }
+ } // end if groups
+ rdfutils_setPropToUri($account_res, 'sioc:member_of', $usergroups_uris);
// next, deal with the person
- $person_res = ARC2::getResource($conf);\r
- \r
+ $person_res = ARC2::getResource($conf);
+
$person_res->setURI( $person_uri );
rdfutils_setPropToUri($person_res, 'rdf:type', 'foaf:Person');
$person_res->setProp('foaf:name', $user_real_name);
rdfutils_setPropToUri($person_res, 'foaf:holdsAccount', $account_uri);
$person_res->setProp('foaf:mbox_sha1sum', $mbox_sha1sum);
- // merge the two sets of triples\r
- $merged_index = ARC2::getMergedIndex($account_res->index, $person_res->index);\r
+ // merge the two sets of triples
+ $merged_index = ARC2::getMergedIndex($account_res->index, $person_res->index);
$merged_index = ARC2::getMergedIndex($merged_index, $groups_index);
$merged_index = ARC2::getMergedIndex($merged_index, $projects_index);
$merged_index = ARC2::getMergedIndex($merged_index, $roles_index);
- \r
- $conf = array(\r
- 'ns' => $ns,\r
- 'serializer_type_nodes' => true\r
- );\r
- \r
- $ser = ARC2::getRDFXMLSerializer($conf);\r
- \r
- /* Serialize a resource index */\r
- $doc = $ser->getSerializedIndex($merged_index);\r
- \r
+
+ $conf = array(
+ 'ns' => $ns,
+ 'serializer_type_nodes' => true
+ );
+
+ $ser = ARC2::getRDFXMLSerializer($conf);
+
+ /* Serialize a resource index */
+ $doc = $ser->getSerializedIndex($merged_index);
+
$params['content'] = $doc . "\n";
}
}