GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (4873)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

plugins/IM/include/IMPlugin.class.php (9 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * 
4
 */
5
 define("IM_DEBUG_ON",true,true);
6
 define("IM_DEBUG_OFF",false,true);
7
require_once('common/plugin/Plugin.class.php');
8
require_once('www/include/user.php');
9
require_once('common/user/UserHelper.class.php');
10
11
require_once('JabbexFactory.class.php');
12
13
class IMPlugin extends Plugin {
14
	
15
    var $debug;
16
    /**
17
     * last data remove ====>for testing script
18
     */
19
    var $last_im_datas=array();
20
    var $last_im_datas_remove=array();
21
22
    function __construct($id,$debug=IM_DEBUG_OFF) {
23
        parent::__construct($id);
24
25
        $this->_addHook('javascript_file', 'jsFile', false);
26
        $this->_addHook('cssfile', 'cssFile', false);
27
        $this->_addHook('approve_pending_project', 'projectIsApproved', false);
28
        $this->_addHook('project_is_suspended_or_pending', 'projectIsSuspendedOrPending', false);
29
        $this->_addHook('project_is_deleted', 'projectIsDeleted', false);
30
        $this->_addHook('project_is_active', 'projectIsActive', false);
31
        $this->_addHook('project_admin_add_user', 'projectAddUser', false);
32
        $this->_addHook('project_admin_remove_user', 'projectRemoveUser', false);
33
        $this->_addHook('site_admin_option_hook', 'siteAdminHooks', false);
34
        $this->_addHook('site_admin_external_tool_hook', 'site_admin_external_tool_hook', false);
35
        $this->_addHook('site_admin_external_tool_selection_hook', 'site_admin_external_tool_selection_hook', false);
36
        $this->_addHook('account_pi_entry', 'im_process_display_user_jabber_id_in_account', false);
37
        $this->_addHook('user_home_pi_entry', 'im_process_display_user_jabber_id', false);
38
        $this->_addHook('get_user_display_name', 'im_process_display_presence', false);
39
        $this->_addHook('widget_instance', 'myPageBox', false);
40
        $this->_addHook('widgets', 'widgets', false);
41
        $this->_addHook('user_preferences_appearance', 'user_preferences_appearance', false);
42
        $this->_addHook('update_user_preferences_appearance', 'update_user_preferences_appearance', false);
43
        $this->_addHook('project_export_entry', 'provide_exportable_items', false);
44
        $this->_addHook('get_available_reference_natures', 'getAvailableReferenceNatures', false);
45
        $this->addHook(Event::SERVICE_ICON);
46
        $this->addHook(Event::SERVICES_ALLOWED_FOR_PROJECT);
47
48
        $this->debug=$debug;
49
        
50
    }
51
    
52
    function &getPluginInfo() {
53
        if (!is_a($this->pluginInfo, 'IMPluginInfo')) {
54
            require_once('IMPluginInfo.class.php');
55
            $this->pluginInfo =& new IMPluginInfo($this);
56
        }
57
        return $this->pluginInfo;
58
    }
59
60
    public function getServiceShortname() {
61
        return 'IM';
62
    }
63
    
64
    public function service_icon($params) {
65
        $params['list_of_icon_unicodes'][$this->getServiceShortname()] = '\e809';
66
    }
67
    
68
    /**
69
     * Functions used for "tests"
70
     */
71
    /**
72
     * @return string the last room name created  
73
     */
74
    function get_last_muc_room_name () {
75
		return $this->last_im_datas["muc"];
76
	}
77
	/**
78
     * @return string the last room name created  
79
     */
80
	function get_last_muc_room_name_delete () {
81
		return $this->last_im_datas_remove['muc'];
82
	}
83
	function get_last_grp_name () {
84
		return $this->last_im_datas["grp"];
85
	}
86
	function get_last_muc_room_name_locked () {
87
		return $this->last_im_datas["name_last_muc_locked"];
88
	}
89
	function get_last_muc_room_name_unlocked () {
90
		return $this->last_im_datas["name_last_muc_unlocked"];
91
	}
92
	/**
93
	 * @return string information about a member added in once muc
94
	 */
95
	function get_last_member_of_once_muc_room () {
96
		return $this->last_im_datas["names_last_member_in_muc"];
97
	}
98
	
99
	/**
100
	 * @return string information about a member added in once muc
101
	 */
102
	function get_last_remove_member_of_once_muc_room () {
103
		return $this->last_im_datas["names_remove_member_from_muc"];
104
	}
105
    /**
106
     * End functions for tests.
107
     */
108
    
109
    function cssFile($params) {
110
        // Only show the stylesheet if we're actually in the IM plugin pages.
111
        // This stops styles inadvertently clashing with the main site.
112
        if (strpos($_SERVER['REQUEST_URI'], $this->getPluginPath()) === 0 ||
113
            strpos($_SERVER['REQUEST_URI'], '/widgets/') === 0 ) {
114
            echo '<link rel="stylesheet" type="text/css" href="'.$this->getThemePath().'/css/style.css" />';
115
        }
116
    }
117
    
118
    /**
119
     * Returns an instance of jabdex
120
     * @return Jabbex object class for im processing
121
     */
122
	function _get_im_object() {
123
		return JabbexFactory::getJabbexInstance();
124
	}
125
	
126
	function _this_muc_exist($unix_project_name) {
127
		require_once("IM.class.php");
128
        require_once("IMDao.class.php");
129
		require_once('IMDataAccess.class.php');
130
        $controler = new IM($this);
131
		$dao= & new IMDao(IMDataAccess::instance($controler));
132
		$roomID = $dao->get_room_id_by_unix_name ($unix_project_name);
133
		return (isset($roomID)&&$roomID);
134
	}
135
	/**
136
	 * to get pictures path
137
	 * @return string directory path of icons
138
	 */
139
	 function get_icon_path() {
140
		$themes_dir = $this->getThemePath();
141
		$icon_path = $themes_dir.'/images/icons/';
142
		return $icon_path;
143
	}
144
    
145
    protected $_cache_presence = array();
146
	/**
147
	 * 
148
	 * send status for a geven user 
149
	 * @return string a string mapping of a img html balise .
150
	 * @param string $jid the user jabber identification .
151
	 * 
152
	 */
153
    function _get_presence_status ($jid) {
154
        $presence = $this->getPresence($jid);
155
        $purifier = Codendi_HTMLPurifier::instance();
156
        return '<img src="'.$purifier->purify($presence['icon']).'" title="'.$purifier->purify($presence['status']).'"  alt="'.$purifier->purify($presence['status']).'" border="0" height="16" width="16" style="vertical-align:top">';
157
    }
158
159
    protected $dynamicpresence_alreadydisplayed;
160
    function getDynamicPresence($jid) {
161
        $id = md5($jid);
162
        $html = '<img class="jid_'. $id .'"src="'. $this->getThemePath() .'/images/icons/blank.png" width="16" height="16" alt="" style="vertical-align:top" />';
163
        if (!$this->dynamicpresence_alreadydisplayed) {
164
            $html .= '<script type="text/javascript">'. "
165
            var plugin_im_presence = [];
166
            document.observe('dom:loaded', function() {
167
            new Ajax.Request('/plugins/IM/?action=get_presence', {
168
                parameters: {
169
                    'jids[]':plugin_im_presence
170
                },
171
                onSuccess: function(transport) {
172
                    var presences = JSON.parse(transport.responseText);
173
                    \$A(presences).each(function (presence) {
174
                        var html = '<img src=\"'+ presence.icon +'\" title=\"'+ presence.status +'\" />';
175
                        $$('.jid_'+presence.id).each(function (img) {
176
                            img.src = presence.icon;
177
                            img.alt = presence.status;
178
                            img.title = presence.status;
179
                        });
180
                    });
181
                }
182
            });
183
            });
184
            </script>";
185
        }
186
        $html .= '<script type="text/javascript">'. "
187
        plugin_im_presence[plugin_im_presence.length] = '$jid';
188
        </script>";
189
        $this->dynamicpresence_alreadydisplayed = true;
190
        return $html;
191
    }
192
    
193
    function getPresence($jid) {
194
        if (!isset($this->_cache_presence[$jid])) {
195
           if($this->_get_im_object()){
196
	            $status=$this->_get_im_object()->user_status($jid);
197
	            $img_src='';
198
	            $img_title='';
199
	            
200
	            $custom_msg = ($status["message"]) ? $status["message"] : '';
201
	            
202
	            switch($status["status"]){
203
	                case "dnd":
204
	                    $img_title= $GLOBALS['Language']->getText('plugin_im_status','dnd');
205
	                    $img_src=$this->get_icon_path ().'busy.gif';
206
	                    break;
207
	                case "away";
208
		                $img_title = $GLOBALS['Language']->getText('plugin_im_status','away');
209
		                $img_src=$this->get_icon_path ().'away.gif';
210
	                    break;
211
	                case "chat":
212
	                    $img_title = $GLOBALS['Language']->getText('plugin_im_status','chat');
213
	                    $img_src=$this->get_icon_path ().'on_line.gif';
214
	                    break;
215
	                case "xa":
216
	                    $img_title = $GLOBALS['Language']->getText('plugin_im_status','xa');
217
	                    $img_src=$this->get_icon_path ().'away.gif';
218
	                    break;
219
	                case "unavailable":
220
	                    $img_title = $GLOBALS['Language']->getText('plugin_im_status','unavailable');
221
	                    $img_src=$this->get_icon_path ().'off_line.gif';
222
	                    break;
223
	                case "available":
224
	                    $img_title = $GLOBALS['Language']->getText('plugin_im_status','available');
225
	                    $img_src=$this->get_icon_path ().'on_line.gif';
226
	                    break;
227
	                case "forbidden":
228
	                    $img_title = $GLOBALS['Language']->getText('plugin_im_status','forbidden');
229
	                    $img_src=$this->get_icon_path ().'off_line.gif';
230
	                    break;
231
	            }
232
	            
233
	            if(!empty($custom_msg)){
234
	            	$img_title = ($img_title == $custom_msg) ? $img_title : ($img_title.' - '.$custom_msg);
235
	            }
236
                $this->_cache_presence[$jid] = array(
237
                    'icon' => $img_src,
238
                    'status' => $img_title
239
                );
240
            }
241
        }
242
        return $this->_cache_presence[$jid];
243
    }
244
    
245
	
246
    function instance() {
247
        static $_plugin_instance;
248
        if (!$_plugin_instance) {
249
            $_plugin_instance = new IMPlugin($this->id);
250
        }
251
        return $_plugin_instance;
252
    }
253
    
254
	/**
255
	 * This function is called when a (or several) project(s) is (are) approved.
256
     * Action: create a muc room and a shared group for the corresponding projects
257
     *
258
	 * @param array $params : contains the array of group_id
259
	 */
260
	function projectIsApproved($params) {
261
		$this->muc_room_creation($params);
262
		$this->create_im_shared_group($params);
263
		if ($this->debug) {
264
			echo "\nIM: projectIsApproved for projects: ".$params['group_id']."<br>";
265
		}
266
	}
267
    
268
    /**
269
	 * This function is called when a project is supsended or pending
270
     * Action: lock the muc room
271
     *
272
	 * @param array $params contains the group_id ($params['group_id'])
273
	 */
274
	function projectIsSuspendedOrPending($params) {
275
		$this->im_lock_muc_room($params);
276
	}
277
    
278
    /**
279
	 * This function is called when the event "project_is_deleted" is called
280
     * Action: lock the muc room
281
     *
282
	 * @param array $param : contains the group_id ($params['group_id'])
0 ignored issues
show
There is no parameter named $param. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
283
	 * 
284
	 * Before, we deleted the MUC room, but now, we only lock it,
285
	 * because we want to be able to go back to Active status (that will unlock the MUC Room).
286
	 * 
287
	 */
288
	function projectIsDeleted($params) {
289
		$this->im_lock_muc_room($params);
290
	}
291
	
292
	/**
293
	 * This function is called when the project is set to active
294
     * Action: unlock the muc room
295
     *
296
	 * @param array $params contains the group_id ($params['group_id'])
297
	 */
298
	 function projectIsActive($params) {
299
		$this->im_unlock_muc_room($params);
300
	}
301
	
302
	/**
303
	 * This function is called when a user is added into a project
304
     * Action: add user to muc room
305
     *
306
	 * @param array $params contains the group_id, the user_id and the user_unix_name
307
	 */
308
	function projectAddUser($params) {
309
		$this->im_muc_add_member($params);
310
	}
311
	
312
	
313
	/**
314
	 * This function is called when a user is removed from a project
315
     * Action: remove user from the muc room
316
     *
317
	 * @param array $params contains the group_id and the user_id
318
	 */
319
	function projectRemoveUser($params) {
320
		$this->im_muc_remove_member($params);
321
	}
322
	
323
	/**
324
	 * Shared group creation
325
	 * @param array params data from the shared Codendi event 
326
	 */
327
	 function create_im_shared_group ($params) {
328
		$group_ids = $params['group_id'];
329
		$group_ids=explode(',',$group_ids);
330
		
331
        $project_manager = $this->getProjectManager();
332
        
333
        foreach($group_ids as $project_id){
334
	        $project = $project_manager->getProject($project_id);
335
	        $unix_project_name = $project->getUnixName();
336
	        $project_name = $project->getPublicName();
337
	        
338
            try{
339
				if($this->_get_im_object()){
340
					$this->_get_im_object()->create_shared_group($unix_project_name,$project_name);
341
					$this->last_im_datas["grp"]=$project_name;
342
				}else{
343
					if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
344
					$GLOBALS['Response']->addFeedback('error', 'IM object no available to create the shared group, '.$project_name);
345
					}
346
				}
347
			} catch(Exception $e){
348
				if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
349
					$GLOBALS['Response']->addFeedback('error', $e->getMessage());
350
				}	
351
			}
352
		}
353
		
354
	}
355
	/**
356
	 * Is called by "muc_room_creation ($params)" to create a muc room.
357
	 * @param array $params :contains the data which comes from the envent listened.
358
	 */
359
    function muc_room_creation($params) {
360
		$group_ids = $params['group_id'];
361
		$group_ids=explode(',',$group_ids);
362
		//var_dump($group_ids);
363
        
364
        $project_manager = $this->getProjectManager();
365
        $user_manager = $this->getUserManager();
366
        
367
		foreach($group_ids as $val){
368
	        $project = $project_manager->getProject($val);
369
	        $unix_group_name = $project->getUnixName();
370
	        $group_name=($project->getPublicName()?$project->getPublicName():$unix_group_name);
371
	        $group_description = $project->getDescription();
372
	        if(!(isset($group_description)&&$group_description!=null)){
373
				$group_description='No description';
374
			}
375
	        $project_members_ids = $project->getMembersId();
376
            $group_Owner_object = $user_manager->getUserById($project_members_ids[0]);
377
	        $group_Owner_name = $group_Owner_object->getName();
378
            if(!$this->_this_muc_exist ($unix_group_name)){
379
				try{
380
					if($this->_get_im_object()){
381
						$this->_get_im_object()->create_muc_room($unix_group_name, $group_name, $group_description, $group_Owner_name);
382
						$this->last_im_datas["muc"]=$group_name;
383
					}else{
384
						if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
385
						$GLOBALS['Response']->addFeedback('error', 'IM object no available to create the shared group, '.$group_name);
386
						}
387
					}
388
				} catch(Exception $e){
389
					if(!$this->debug){
390
						$GLOBALS['Response']->addFeedback('error', 'MUC creation: '.$e->getMessage());
391
					}	
392
				}
393
			}
394
		}
395
	}
396
	
397
    /**
398
     * to lock an MUC room
399
     * @param array params:contains the data which comes from the envent listened (group_id her ).
400
     */
401
    public function im_lock_muc_room($params){
402
        $project_manager = $this->getProjectManager();
403
        $project_id = $params['group_id'];
404
        $project = $project_manager->getProject($project_id);
405
        $unix_project_name = $project->getUnixName();
406
        $project_name = $project->getPublicName();
407
        
408
		if($this->_this_muc_exist ($unix_project_name)){
409
			try{
410
				if($this->_get_im_object()){
411
					$this->_get_im_object()->lock_muc_room($unix_project_name);
412
					$this->last_im_datas["name_last_muc_locked"]=$unix_project_name;
413
				}else{
414
						if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
415
						$GLOBALS['Response']->addFeedback('error', 'IM object no available to create the shared group, '.$project_name);
416
						}
417
					}
418
			} catch(Exception $e){
419
				if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
420
					$GLOBALS['Response']->addFeedback('error', $e->getMessage());
421
				}	
422
			}
423
		}else{
424
			//if muc not exist i do nothing about IM
425
		}
426
       
427
     }
428
  
429
   /**
430
    * unlock a MUC room created and locked by "lock_muc_room($unix_project_name)".
431
    * @param array $params :contains the data which comes from the envent listened.
432
    */
433
   	function im_unlock_muc_room($params) {
434
        $project_manager = $this->getProjectManager();
435
		$project_id = $params['group_id'];
436
        $project = $project_manager->getProject($project_id);
437
        $unix_project_name = $project->getUnixName();
438
        $project_name = $project->getPublicName();
439
		
440
		if($this->_this_muc_exist ($unix_project_name)){
441
			try{
442
				if($this->_get_im_object()){
443
					$this->_get_im_object()->unlock_muc_room($unix_project_name);
444
					$this->last_im_datas["name_last_muc_unlocked"]=$unix_project_name;
445
				}else{
446
						if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
447
						$GLOBALS['Response']->addFeedback('error', 'IM object no available to unlock muc, '.$project_name);
448
						}
449
					}
450
			} catch(Exception $e){
451
				if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
452
						$GLOBALS['Response']->addFeedback('error', $e->getMessage());
453
					}	
454
			}
455
			}
456
		
457
 		}
458
 	
0 ignored issues
show
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
459
 	/**
0 ignored issues
show
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
460
 	 * function called in im_process_delete_muc_room($params) to delete an muc room.
461
 	 * @param array $params :contains the data which comes from the envent listened.
462
 	 */
463
 	function im_delete_muc_room($params) {
464
		$project_manager = $this->getProjectManager();
465
		$project_id = $params['group_id'];
466
        $project = $project_manager->getProject($project_id);
467
        $unix_project_name = $project->getUnixName();
468
        $project_name = $project->getPublicName();
469
        if($this->_this_muc_exist ($unix_project_name)){
470
	        try{
471
	        $this->_get_im_object()->delete_muc_room($unix_project_name);
472
	        $this->last_im_datas_remove['muc']=$unix_project_name;
473
	        }catch(Exception $e){
474
	        	if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
475
					$GLOBALS['Response']->addFeedback('error', $e->getMessage());
476
				}	
477
	        }
478
        }
479
	}
480
	
481
	/**
482
 	 * function called in im_process_muc_add_member($params) to add a member in a given muc room.
483
 	 * @param array $params :contains the data which comes from the envent listened.
484
 	 */
485
	function im_muc_add_member($params) {
486
		$user_unix_name=$params['user_unix_name'];
487
		
488
        $project_manager = $this->getProjectManager();
489
		$group_id =$params['group_id'];
490
		$project = $project_manager->getProject($group_id);
491
        $group_name = $project->getUnixName();
492
        if($this->_this_muc_exist ($group_name)){
493
			try{
494
				$this->_get_im_object()->muc_add_member($group_name, $user_unix_name);
495
				$this->last_im_datas["names_last_member_in_muc"]=$user_unix_name." is added in the muc :".$group_name;
496
			} catch(Exception $e){
497
				if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
498
					$GLOBALS['Response']->addFeedback('error', $e->getMessage());
499
				}	
500
			}
501
        }
502
		
503
	}
504
	/**
505
	 * to remove a member on a muc
506
	 * @param array $params:contains the data which comes from the envent listened.
0 ignored issues
show
There is no parameter named $params:contains. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
507
	 */
508
	public function im_muc_remove_member($params){
509
		//group infos
510
		$group_id =$params['group_id'];
511
        $project_manager = $this->getProjectManager();
512
		$project = $project_manager->getProject($group_id);
513
        $unix_group_name = $project->getUnixName();
514
        //user infos
515
        $user_id=$params['user_id'];
516
        
517
        $user = $this->getUserManager()->getUserById($user_id);
518
        $user_unix_name=$user->getUserName();
519
        if($this->_this_muc_exist ($unix_group_name)){
520
	        try{
521
				$this->_get_im_object()->muc_remove_member($unix_group_name,$user_unix_name);
522
				$this->last_im_datas["names_remove_member_from_muc"]=$user_unix_name." is remove from the muc :".$unix_group_name;
523
			} catch(Exception $e){
524
				if(!$this->debug){//because when $this->debug is ON(true) we done fonctional test and $GLOBALS['Response'] is not known
525
					$GLOBALS['Response']->addFeedback('error', $e->getMessage());
526
				}	
527
			}
528
        }
529
	}
530
	
531
	/**
532
	 * for hook administration :display an URL to access IM administration.
533
	 * @param array $params:contains the data which comes from the envent listened.
0 ignored issues
show
There is no parameter named $params:contains. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
534
	 */
535
 	function siteAdminHooks($params) {
536
       global $Language;
537
       $link_title= $GLOBALS['Language']->getText('plugin_im','link_im_admin_title');
538
       echo '<li><a href="'.$this->getPluginPath().'/">'.$link_title.'</a></li>';
539
    }
540
 	
0 ignored issues
show
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
541
    function site_admin_external_tool_hook($params) {
542
       global $Language;
543
        echo '<li><A href="externaltools.php?tool=openfire">'.
544
        $GLOBALS['Language']->getText('plugin_im','link_im_admin_tool').
545
        '</A></li>';
546
547
    }
548
        
549
     function site_admin_external_tool_selection_hook($params) {
550
      if ($params['tool']=='openfire') {
551
                $params['title']="OpenFire Administration";
552
                $params['src']='http://'.$GLOBALS['sys_default_domain'].':9090';
553
            }
554
    }
555
556
 	 function im_process_display_jabber_id($eParams) {
557
	    global $Language;
558
		$plugin= & IMPlugin::instance() ;
559
		$pm=$plugin->_getPluginManager();
560
		$entry_label['jid']='';
561
		$entry_value['jid']='';
562
		if(!$pm->isPluginAvailable($plugin)){
563
			//nothing to do actualy 
564
		}else{
565
			$im_object=$this->_get_im_object();
566
			$jabberConf=$im_object->get_server_conf();
567
			$server_dns=$jabberConf['server_dns'];
568
			
569
			$user_login = $this->getUserManager()->getUserById($eParams['user_id'])->getName();
570
			
571
			$jid_value=$user_login.'@'.$server_dns;
572
			$label=$GLOBALS['Language']->getText('plugin_im','im_user_login');
573
			//var_dump($label);
574
			$entry_label['jid'] = $label;
575
            if ( ! $this->getUserManager()->getCurrentUser()->getPreference('plugin_im_hide_users_presence')) {
576
                $entry_value['jid'] = $this->_get_presence_status ($jid_value) .' ';
577
            }
578
            $entry_value['jid'] .= $jid_value;
579
			$entry_change['jid']="";
580
			$eParams['entry_label'] = $entry_label;
581
            $eParams['entry_value'] =$entry_value;
582
            $eParams['entry_change'] =$entry_change;
583
		}
584
	}
585
	/**
586
	 * to display an user's jabber identification JID in web interface personnal page
587
	 * @param array $eParams:contains the data which comes from the envent listened.
0 ignored issues
show
There is no parameter named $eParams:contains. Did you maybe mean $eParams?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
588
	 */
589
 	function im_process_display_user_jabber_id ($eParams) {
590
		$this->im_process_display_jabber_id ($eParams);
591
	}
592
	
593
	/**
594
	 * to display an user's jabber identification JID in web interface developper profil
595
	 * @param array $eParams:contains the data which comes from the envent listened.
0 ignored issues
show
There is no parameter named $eParams:contains. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
596
	 */
597
	function im_process_display_user_jabber_id_in_account (array $params) {
598
            $im_object  = $this->_get_im_object();
599
            $jabberConf = $im_object->get_server_conf();
600
            $value      = $params['user']->getName().'@'.$jabberConf['server_dns'];
601
            if ( ! $params['user']->getPreference('plugin_im_hide_users_presence')) {
602
                $value = $this->_get_presence_status ($value) .' ';
603
            }
604
            $params['user_info'][] = new User_ImmutableInfoPresenter(
605
                $GLOBALS['Language']->getText('plugin_im','im_user_login'),
606
                $value
607
            );
608
	}
609
	
610
611
    function getDisplayPresence($user_id, $user_name, $realname) {
612
        $user_helper = UserHelper::instance();
613
        $hp = Codendi_HTMLPurifier::instance();
614
        $im_object = $this->_get_im_object();
615
        if(isset($im_object)&&$im_object){
616
	        $jabberConf = $im_object->get_server_conf();
617
	        
618
	        $server_dns = $jabberConf['server_dns'];
619
	        
620
	        $jid_value = $user_name.'@'.$server_dns;
621
	        $adm_port_im = $jabberConf['webadmin_unsec_port'];
622
	        
623
	        $presence = $this->getDynamicPresence ($jid_value);
624
        }else{
625
        	$presence='';
626
        }
627
        
628
        return $presence . $hp->purify($user_helper->getDisplayName($user_name, $realname));
629
    }
630
631
        function myPageBox($params) {
632
            if ($params['widget'] == 'plugin_im_myroster') {
633
                require_once('IM_Widget_MyRoster.class.php');
634
                $params['instance'] = new IM_Widget_MyRoster($this);
635
            }
636
        }
637
        function widgets($params) {
638
            require_once('common/widget/WidgetLayoutManager.class.php');
639
            if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USER) {
640
                $params['codendi_widgets'][] = 'plugin_im_myroster';
641
            }
642
        }
643
644
        function user_preferences_appearance($params) {
645
            $input = '<label class="checkbox" for="plugin_im_display_users_presence">';
646
            $input .= '<input type="hidden" name="plugin_im_display_users_presence" value="0" />';
647
            $input .= '<input type="checkbox" id="plugin_im_display_users_presence" name="plugin_im_display_users_presence" value="1" ';
648
            if ( ! $this->getUserManager()->getCurrentUser()->getPreference('plugin_im_hide_users_presence')) {
649
                $input .= 'checked="checked"';
650
            }
651
            $input .= '/>';
652
            $input .= $GLOBALS['Language']->getText('plugin_im', 'user_appearance_pref_display_users_presence');
653
            $input .= '</label>';
654
            
655
            $params['preferences'][] = array(
656
                'name'  => $GLOBALS['Language']->getText('plugin_im', 'user_appearance_pref_name'),
657
                'value' => $input
658
            );
659
        }
660
        
661
        /**
662
         * Only display presence for active (non restricted users)
663
         *
664
         * @param $params
665
         */
666
        function update_user_preferences_appearance($params) {
667
            if (!$this->getUserManager()->getCurrentUser()->isRestricted() && $params['request']->exist('plugin_im_display_users_presence')) {
668
                if ($params['request']->get('plugin_im_display_users_presence')) {
669
                    $this->getUserManager()->getCurrentUser()->delPreference('plugin_im_hide_users_presence');
670
                } else {
671
                    $this->getUserManager()->getCurrentUser()->setPreference('plugin_im_hide_users_presence', '1');
672
                }
673
            }
674
        }
675
        
676
        function provide_exportable_items($exportable_items) {
677
            $exportable_items['labels']['im_muc_logs']            = $GLOBALS['Language']->getText('plugin_im', 'muc_logs_title');
678
            $exportable_items['data_export_links']['im_muc_logs'] = '/plugins/IM/?log_start_date=&log_end_date=&action=muc_logs&type=export&group_id='.$exportable_items['group_id'];
679
        }
680
        
681
	/**
682
 	 * display project members presence 
683
 	 * @param array $params:contains the data which comes from the envent listened.
0 ignored issues
show
There is no parameter named $params:contains. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
684
 	 */
685
	function im_process_display_presence ($params) {
686
        $user = $this->getUserManager()->getCurrentUser();
687
        if ($user->isloggedIn() && !$this->getUserManager()->getCurrentUser()->isRestricted() && (! $user->getPreference('plugin_im_hide_users_presence'))) { 
688
            $params['user_display_name'] = $this->getDisplayPresence($params['user_id'], $params['user_name'], $params['realname']);
689
        }
690
	}
691
692
    function jsFile($params) {
693
        // Only include the js files if we're actually in the IM pages.
694
        // This stops styles inadvertently clashing with the main site.
695
        if (strpos($_SERVER['REQUEST_URI'], $this->getPluginPath()) === 0) {
696
        	$GLOBALS['HTML']->includeCalendarScripts();
697
            echo '<script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>'."\n";
698
        }
699
    }
700
    
701
    function getAvailableReferenceNatures($params) {
702
        $im_plugin_reference_natures = array(
703
            'im_chat'  => array('keyword' => 'chat', 'label' => $GLOBALS['Language']->getText('plugin_im', 'reference_chat_nature_key')));
704
        $params['natures'] = array_merge($params['natures'], $im_plugin_reference_natures);
705
    }
706
    
707
 	function process() {	
708
        require_once('IM.class.php');
709
        $controler =& new IM($this);
710
        $controler->process();
711
    }
712
    
713
    
714
    function getUserManager() {
715
        return UserManager::instance();
716
    }
717
    function getProjectManager() {
718
        return ProjectManager::instance();
719
    }
720
    
721
}
722
?>
723