This file is indexed.

/usr/share/gforge/plugins/compactpreview/include/CompactPreviewPlugin.class.php is in fusionforge-plugin-compactpreview 5.3.2+20141104-3+deb8u3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php

/**
 * CompactPreviewPlugin Class
 *
 *
 * This file is part of FusionForge.
 *
 * FusionForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * FusionForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

class CompactPreviewPlugin extends Plugin {

	public function __construct($id=0) {
		$this->Plugin($id) ;
		$this->name = "compactpreview";
		$this->text = "CompactPreview!"; // To show in the tabs, use...
		$this->_addHook("user_link_with_tooltip"); // override the way user links are done (for user compact preview support)
		$this->_addHook("project_link_with_tooltip");
		$this->_addHook("javascript_file"); // Add js files for oslc plugin
		$this->_addHook("javascript"); // Add js initialization code
		$this->_addHook("cssfile");
		$this->_addHook("script_accepted_types");
		$this->_addHook("content_negociated_user_home");
		$this->_addHook("content_negociated_project_home");

	}

	// hook methods

	/**
	 * override util_display_user() with modified version to display compact preview popup on user links
	 * @param array $params hook params (return in $params['user_link'])
	 */
	function user_link_with_tooltip (&$params) {
		//
		require_once dirname( __FILE__ ) . '/CompactResource.class.php';
		$cR = CompactResource::createCompactResource($params);
		$params['user_link'] = $cR->getResourceLink();
	}

	/**
	 * override util_make_link_g() with modified version to display compact preview popup on project links
	 * @param array $params hook params (return in $params['user_link'])
	 */
	function project_link_with_tooltip (&$params) {
		require_once dirname( __FILE__ ) . '/CompactResource.class.php';
		$cR = CompactResource::createCompactResource($params);
		$params['group_link'] = $cR->getResourceLink();
	}

	function javascript_file (&$params) {
		// The userTooltip.js script is used by the compact preview feature (see content_negociated_user_home)
		html_use_jquery();
		// provides support for the popup for compact preview
		use_javascript('/plugins/'.$this->name.'/scripts/oslcTooltip.js');
	}

	function javascript (&$params) {
		// make sure jquery won't conflict with prototype
		$params['return'] = 'jQuery.noConflict();';
	}

	function cssfile (&$params) {
		use_stylesheet('/plugins/'.$this->name.'/css/oslcTooltipStyle.css');
	}

	/**
	 * Declaration of which content-negociation alternatives are provided by this plugin
	 * @param unknown_type $params
	 */
	function script_accepted_types (&$params) {
		$script = $params['script'];
		if ($script == 'user_home' || $script == 'project_home') {
			// we do support content-negociation on /users and /project with the following accept header values
			// for OSLC compact-preview
			$params['accepted_types'][] = 'application/x-oslc-compact+xml';
			// for fusionforge compact preview
			$params['accepted_types'][] = 'application/x-fusionforge-compact+html';
		}
	}

	function display_user_html_compact_preview($username, $title = false) {
		global $gfwww;

		require_once $gfwww.'include/user_profile.php';

		$user_obj = user_get_object_by_name($username);

		$user_real_name = $user_obj->getRealName();
		$user_id = $user_obj->getID();

		$html = '<html>
						<head>
						<title>User: '. $user_real_name .' (Identifier: '. $user_id .')</title>
						</head>
						<body>';

		$html .= user_personal_information($user_obj, true, $title);
		$html .= '</body>
						</html>';

		return $html;

	}

	function display_project_html_compact_preview($project, $title) {

		$project_obj = group_get_object_by_name($project);

		$public_name = $project_obj->getPublicName();
		$unix_name = $project_obj->getUnixName();
		$id = $project_obj->getID();
		$home_page = util_make_url ("/projects/$unix_name/");
		$description = $project_obj->getDescription();
		$start_date = $project_obj->getStartDate();
		$status = $project_obj->getStatus();
		switch ($status){
			case 'A':
				$project_status = 'Active';
				break;
			case 'H':
				$project_status = 'Hold';
				break;
			case 'P':
				$project_status = 'Pending';
				break;
			case 'I':
				$project_status = 'Incomplete';
				break;
			default:
				break;
		}
		if ($project_obj->isPublic()) {
			$public = 'Yes';
		} else {
			$public = 'No';
		}

		$html='<html>
		<head>
		<title>Project: '. $public_name .' ('. $unix_name .')</title>
		</head>
		<body>
			<table>

				<tr>
					<td colspan="2"><i>'. $title .'</i></td>
				</tr>
				<tr>
					'/* <td rowspan="8"><img src="/plugins/compactpreview/images/userTooltip/oslc.png" />
					</td>*/.'
					<td><b>Project name:</b>

					 '. $public_name .'</td>
				</tr>
				<tr>
					<td><b>Project short name:</b>

					 '. $unix_name .'</td>
				</tr>
				<tr>
					<td><b>Identifier:</b>

					  '. $id .'</td>
				</tr>
				<tr>
					<td><b>Started since:</b>

					 '. date(_('Y-m-d H:i'), $start_date) .'</td>
				</tr>
				<tr>
					<td><b>Status:</b>

					  '. $project_status .'</td>
				</tr>
				<tr>
					<td><b>Is Public:</b>

					  '. $public .'</td>
				</tr>
				<tr>
					<td><b>Description:</b>

					  '. $description .'</td>
				</tr>
				<tr>
					<td><small><b>Home Page:</b> <a href="'. $home_page .'">'. $home_page .'
						</a> </small></td>
				</tr>

			</table>
		</body>
		</html>';

		return $html;

	}

	function content_negociated_user_home (&$params) {

		$username = $params['username'];
		$accept = $params['accept'];
		$param['content'] = false;

		switch ($accept) {
			// if want some OSLC compact-preview, provide the document pointing to the compact-preview
			case 'application/x-oslc-compact+xml' : {
				$params['content_type'] = 'application/x-oslc-compact+xml';
				$params['content'] = '<?xml version="1.0"?>
					<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#">
					  <oslc:Compact rdf:about="/plugins/oslc/compact/user/'. $username .'">
					    <dcterms:title>'. $username . '</dcterms:title>
					    <oslc:shortTitle>'. $username . '</oslc:shortTitle>
					    <oslc:smallPreview>
					      <oslc:Preview>
					        <oslc:document rdf:ressource="/plugins/'.$this->name.'/user.php?user='. $username .'"/>
					        <oslc:hintWidth>500px</oslc:hintWidth>
					        <oslc:hintHeight>150px</oslc:hintHeight>
					      </oslc:Preview>
					    </oslc:smallPreview>
					  </oslc:Compact>
					</rdf:RDF>';
				break;
			}
			// if want direct compact-preview rendering
			case 'application/x-fusionforge-compact+html' : {
				$params['content_type'] = 'text/html';
				$title = _('Compact preview of local user');
				$params['content'] = $this->display_user_html_compact_preview($username, $title);
				break;
			}
		}
	}

	function content_negociated_project_home (&$params) {

		$projectname = $params['groupname'];
		$accept = $params['accept'];
		switch ($accept) {
			// if want some OSLC compact-preview, provide the document pointing to the compact-preview
			case 'application/x-oslc-compact+xml' : {
				$params['content_type'] = 'application/x-oslc-compact+xml';
				$params['content'] = '<?xml version="1.0"?>
					<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#">
  						<oslc:Compact rdf:about="/plugins/oslc/compact/project/'. $projectname .'">
    						<dcterms:title>'. $projectname . '</dcterms:title>
    						<oslc:shortTitle>'. $projectname . '</oslc:shortTitle>
    						<oslc:smallPreview>
      							<oslc:Preview>
        							<oslc:document rdf:ressource="/plugins/'.$this->name.'/project.php?project='. $projectname .'"/>
        							<oslc:hintWidth>500px</oslc:hintWidth>
        							<oslc:hintHeight>150px</oslc:hintHeight>
      							</oslc:Preview>
    						</oslc:smallPreview>
  						</oslc:Compact>
					</rdf:RDF>';
				break;
			}
			// if want direct compact-preview rendering
			case 'application/x-fusionforge-compact+html' : {
				$params['content_type'] = 'text/html';
				$title = _('Compact preview of local project');
				$params['content'] = $this->display_project_html_compact_preview($projectname, $title);
				break;
			}
		}
	}
}

// Local Variables:
// mode: php
// c-file-style: "bsd"
// End: