Issues (4868)

inc/class.addressbook_favorite_portlet.inc.php (2 issues)

Severity
1
<?php
2
/**
3
 * Egroupware - Addressbook - A portlet for displaying a list of entries
4
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
5
 * @package addressbook
6
 * @subpackage home
7
 * @link http://www.egroupware.org
8
 * @author Nathan Gray
9
 * @version $Id$
10
 */
11
12
use EGroupware\Api;
13
use EGroupware\Api\Framework;
14
use EGroupware\Api\Acl;
15
use EGroupware\Api\Etemplate;
16
17
/**
18
 * The addressbook_list_portlet uses a nextmatch / favorite
19
 * to display a list of entries.
20
 */
21
class addressbook_favorite_portlet extends home_favorite_portlet
22
{
23
24
	/**
25
	 * Construct the portlet
26
	 *
27
	 */
28
	public function __construct(Array &$context = array(), &$need_reload = false)
29
	{
30
		$context['appname'] = 'addressbook';
31
32
		// Let parent handle the basic stuff
33
		parent::__construct($context,$need_reload);
34
35
		$ui = new addressbook_ui();
36
37
		$this->context['template'] = 'addressbook.index.rows';
38
		$this->context['sel_options'] = array();
39
		foreach($ui->content_types as $tid => $data)
40
		{
41
			$this->context['sel_options']['tid'][$tid] = $data['name'];
42
		}
43
		$this->nm_settings += array(
44
			'get_rows'	=> 'addressbook_favorite_portlet::get_rows',
45
			// Use a different template so it can be accessed from client side
46
			'template'	=> 'addressbook.index.rows',
47
			'default_cols'   => 'n_fileas_n_given_n_family_n_family_n_given_org_name_n_family_n_given_n_fileas,'.
48
				'tel_work_tel_cell_tel_home,url_email_email_home',
49
		);
50
	}
51
52
	public function exec($id = null, Etemplate &$etemplate = null)
53
	{
54
		$ui = new addressbook_ui();
55
		$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All'));
56
		$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none')));
57
		$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
0 ignored issues
show
The call to addressbook_ui::get_actions() has too many arguments starting with $this->nm_settings['org_view']. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
		/** @scrutinizer ignore-call */ 
58
  $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
58
59
		parent::exec($id, $etemplate);
60
	}
61
62
	/**
63
	 * Override from addressbook to clear the app header
64
	 *
65
	 * @param type $query
66
	 * @param type $rows
67
	 * @param type $readonlys
68
	 * @return integer Total rows found
69
	 */
70
	public static function get_rows(&$query, &$rows, &$readonlys)
71
	{
72
		$ui = new addressbook_ui();
73
		$total = $ui->get_rows($query, $rows, $readonlys);
74
		unset($GLOBALS['egw_info']['flags']['app_header']);
75
		return $total;
76
	}
77
78
	/**
79
	 * Here we need to handle any incoming data.  Setup is done in the constructor,
80
	 * output is handled by parent.
81
	 *
82
	 * @param type $id
83
	 * @param Etemplate $etemplate
84
	 */
85
	public static function process($values = array())
86
	{
87
		parent::process($values);
88
		$ui = new addressbook_ui();
89
		if (is_array($values) && !empty($values['nm']['action']))
90
		{
91
			if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
92
			{
93
				Framework::message(lang('You need to select some entries first'));
94
			}
95
			else
96
			{
97
				// Some processing to add values in for links and cats
98
				$success = $failed = $action_msg = $msg = null;
99
				if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
100
						$success,$failed,$action_msg,'index',$msg,$values['nm']['checkboxes']))
101
				{
102
					$msg .= lang('%1 contact(s) %2',$success,$action_msg);
0 ignored issues
show
The call to lang() has too many arguments starting with $success. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
					$msg .= /** @scrutinizer ignore-call */ lang('%1 contact(s) %2',$success,$action_msg);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
103
					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
104
					foreach($values['nm']['selected'] as &$id)
105
					{
106
						$id = 'addressbook::'.$id;
107
					}
108
					// Directly request an update - this will get addressbook tab too
109
					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
110
				}
111
				elseif(is_null($msg))
112
				{
113
					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
114
					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
115
				}
116
				elseif($msg)
117
				{
118
					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
119
					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
120
				}
121
				unset($values['nm']['action']);
122
				unset($values['nm']['select_all']);
123
			}
124
		}
125
	}
126
 }