7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 class oslcPlugin extends Plugin {
25 public function __construct($id=0) {
28 $this->text = "oslc"; // To show in the tabs, use...
29 $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
30 $this->_addHook("usermenu");
31 $this->_addHook("groupmenu"); // To put into the project tabs
32 $this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
33 $this->_addHook("groupisactivecheckboxpost"); //
34 $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
35 $this->_addHook("userisactivecheckboxpost"); //
36 $this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
37 $this->_addHook("project_rdf_metadata"); // will provide some RDF metadata for the project's DOAP profile to 'doaprdf' plugin
40 function CallHook ($hookname, &$params) {
41 global $use_oslcplugin,$G_SESSION,$HTML;
42 if ($hookname == "usermenu") {
43 $text = $this->text; // this is what shows in the tab
44 if ($G_SESSION->usesPlugin("oslc")) {
45 $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
46 echo $HTML->PrintSubMenu (array ($text),
47 array ('/plugins/oslc/index.php' . $param ));
49 } elseif ($hookname == "groupmenu") {
50 $group_id=$params['group'];
51 $project = &group_get_object($group_id);
52 if (!$project || !is_object($project)) {
55 if ($project->isError()) {
58 if (!$project->isProject()) {
61 if ( $project->usesPlugin ( $this->name ) ) {
62 $params['TITLES'][]=$this->text;
63 $params['DIRS'][]=util_make_uri('/plugins/oslc/');
64 $params['ADMIN'][]='';
66 $params['TITLES'][]=$this->text." is [Off]";
68 $params['ADMIN'][]='';
70 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
71 } elseif ($hookname == "groupisactivecheckbox") {
72 //Check if the group is active
73 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
74 $group_id=$params['group'];
75 $group = &group_get_object($group_id);
78 echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
79 // checked or unchecked?
80 if ( $group->usesPlugin ( $this->name ) ) {
86 echo "<strong>Use ".$this->text." Plugin</strong>";
89 } elseif ($hookname == "groupisactivecheckboxpost") {
90 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
91 $group_id=$params['group'];
92 $group = &group_get_object($group_id);
93 $use_oslcplugin = getStringFromRequest('use_oslcplugin');
94 if ( $use_oslcplugin == 1 ) {
95 $group->setPluginUse ( $this->name );
97 $group->setPluginUse ( $this->name, false );
99 } elseif ($hookname == "userisactivecheckbox") {
100 //check if user is active
101 // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
102 $user = $params['user'];
105 echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
106 // checked or unchecked?
107 if ( $user->usesPlugin ( $this->name ) ) {
110 echo " /> Use ".$this->text." Plugin";
113 } elseif ($hookname == "userisactivecheckboxpost") {
114 // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
115 $user = $params['user'];
116 $use_oslcplugin = getStringFromRequest('use_oslcplugin');
117 if ( $use_oslcplugin == 1 ) {
118 $user->setPluginUse ( $this->name );
120 $user->setPluginUse ( $this->name, false );
124 echo ' <input type="checkbox" name="use_oslcplugin" value="1" ';
125 // checked or unchecked?
126 if ( $user->usesPlugin ( $this->name ) ) {
129 echo " /> Use ".$this->text." Plugin";
132 } elseif ($hookname == "user_personal_links") {
133 // this displays the link in the user's profile page to it's personal oslc (if you want other sto access it, youll have to change the permissions in the index.php
134 $userid = $params['user_id'];
135 $user = user_get_object($userid);
136 $text = $params['text'];
137 //check if the user has the plugin activated
138 if ($user->usesPlugin($this->name)) {
140 echo util_make_link ("/plugins/oslc/index.php?id=$userid&type=user&pluginname=".$this->name,
141 _('View Personal oslc')
145 } elseif ($hookname == "project_admin_plugins") {
146 // this displays the link in the project admin options page to it's oslc administration
147 $group_id = $params['group_id'];
148 $group = &group_get_object($group_id);
149 if ( $group->usesPlugin ( $this->name ) ) {
150 echo '<p>'.util_make_link ("/plugins/oslc/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
151 _('oslc Admin')).'</p>' ;
154 elseif($hookname == "project_rdf_metadata") {
156 $group_id=$params['group'];
157 $serviceprovider = util_make_url ("/plugins/oslc/cm/oslc-cm-services/".$group_id);
159 if (! $params['prefixes']['http://open-services.net/ns/core#']) {
160 $params['prefixes']['http://open-services.net/ns/core#'] = 'oslc';
162 $params['xml'][] = '<oslc:serviceProvider rdf:resource="'.$serviceprovider.'"/>';
164 elseif ($hookname == "blahblahblah") {
172 // c-file-style: "bsd"