6 * Copyright 2011, Olivier Berger & Institut Telecom
8 * This program was developped in the frame of the COCLICO project
9 * (http://www.coclico-project.org/) with financial support of the Paris
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 class doaprdfPlugin extends Plugin {
29 public function __construct($id=0) {
31 $this->name = "doaprdf";
32 $this->text = "DoaPRDF!"; // To show in the tabs, use...
33 //$this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
34 //$this->_addHook("usermenu");
35 //$this->_addHook("groupmenu"); // To put into the project tabs
36 //$this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
37 //$this->_addHook("groupisactivecheckboxpost"); //
38 //$this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
39 //$this->_addHook("userisactivecheckboxpost"); //
40 //$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
41 $this->_addHook("script_accepted_types");
42 $this->_addHook("content_negociated_project_home");
46 function CallHook ($hookname, &$params) {
47 global $use_doaprdfplugin,$G_SESSION,$HTML;
48 if ($hookname == "usermenu") {
49 $text = $this->text; // this is what shows in the tab
50 if ($G_SESSION->usesPlugin("doaprdf")) {
51 $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
52 echo ' | ' . $HTML->PrintSubMenu (array ($text),
53 array ('/plugins/doaprdf/index.php' . $param ));
55 } elseif ($hookname == "groupmenu") {
56 $group_id=$params['group'];
57 $project = &group_get_object($group_id);
58 if (!$project || !is_object($project)) {
61 if ($project->isError()) {
64 if (!$project->isProject()) {
67 if ( $project->usesPlugin ( $this->name ) ) {
68 $params['TITLES'][]=$this->text;
69 $params['DIRS'][]=util_make_url ('/plugins/doaprdf/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name) ; // we indicate the part we're calling is the project one
71 $params['TITLES'][]=$this->text." is [Off]";
74 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
75 } elseif ($hookname == "groupisactivecheckbox") {
76 //Check if the group is active
77 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
78 $group_id=$params['group'];
79 $group = &group_get_object($group_id);
82 echo ' <input type="checkbox" name="use_doaprdfplugin" value="1" ';
83 // checked or unchecked?
84 if ( $group->usesPlugin ( $this->name ) ) {
90 echo "<strong>Use ".$this->text." Plugin</strong>";
93 } elseif ($hookname == "groupisactivecheckboxpost") {
94 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
95 $group_id=$params['group'];
96 $group = &group_get_object($group_id);
97 $use_doaprdfplugin = getStringFromRequest('use_doaprdfplugin');
98 if ( $use_doaprdfplugin == 1 ) {
99 $group->setPluginUse ( $this->name );
101 $group->setPluginUse ( $this->name, false );
103 } elseif ($hookname == "user_personal_links") {
104 // this displays the link in the user's profile page to it's personal DoaPRDF (if you want other sto access it, youll have to change the permissions in the index.php
105 $userid = $params['user_id'];
106 $user = user_get_object($userid);
107 $text = $params['text'];
108 //check if the user has the plugin activated
109 if ($user->usesPlugin($this->name)) {
111 echo util_make_link ("/plugins/doaprdf/index.php?id=$userid&type=user&pluginname=".$this->name,
112 _('View Personal DoaPRDF')
116 } elseif ($hookname == "project_admin_plugins") {
117 // this displays the link in the project admin options page to it's DoaPRDF administration
118 $group_id = $params['group_id'];
119 $group = &group_get_object($group_id);
120 if ( $group->usesPlugin ( $this->name ) ) {
121 echo '<p>'.util_make_link ("/plugins/doaprdf/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
122 _('DoaPRDF Admin')).'</p>' ;
125 elseif ($hookname == "blahblahblah") {
132 * Declares itself as accepting RDF XML on /users
133 * @param unknown_type $params
135 function script_accepted_types (&$params) {
136 $script = $params['script'];
137 if ($script == 'project_home') {
138 $params['accepted_types'][] = 'application/rdf+xml';
143 * Outputs user's FOAF profile
144 * @param unknown_type $params
146 function content_negociated_project_home (&$params) {
147 $projectname = $params['groupname'];
148 $accept = $params['accept'];
150 if($accept == 'application/rdf+xml') {
151 $params['content_type'] = 'application/rdf+xml';
153 $params['content'] = '<?xml version="1.0"?>
155 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
156 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
157 xmlns:doap="http://usefulinc.com/ns/doap#">
159 <doap:Project rdf:about="">
160 <doap:name>'. $projectname .'</doap:name>
171 // c-file-style: "bsd"