Passed
Push — master ( 84c1d9...4b5f27 )
by Michael
15:53 queued 12:17
created

htdocs/modules/songlist/admin/artists.php (11 issues)

1
<?php
2
	
3
	include('header.php');
4
		
5
	xoops_loadLanguage('admin', 'songlist');
6
	
7
	xoops_cp_header();
8
	
9
	$op = isset($_REQUEST['op'])?$_REQUEST['op']:"artists";
10
	$fct = isset($_REQUEST['fct'])?$_REQUEST['fct']:"list";
11
	$limit = !empty($_REQUEST['limit'])?intval($_REQUEST['limit']):30;
12
	$start = !empty($_REQUEST['start'])?intval($_REQUEST['start']):0;
13
	$order = !empty($_REQUEST['order'])?$_REQUEST['order']:'DESC';
14
	$sort = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created';
15
	$filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1';
16
	
17
	switch($op) {
18
	default:
19
	case "artists":
20
		switch ($fct)
21
		{
22
			default:
23
			case "list":				
24
				$indexAdmin = new ModuleAdmin();
25
				echo $indexAdmin->addNavigation(basename(__FILE__));
26
				
27
				$artists_handler =& xoops_getmodulehandler('artists', 'songlist');
28
					
29
				$criteria = $artists_handler->getFilterCriteria($GLOBALS['filter']);
0 ignored issues
show
The method getFilterCriteria() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

29
				/** @scrutinizer ignore-call */ 
30
    $criteria = $artists_handler->getFilterCriteria($GLOBALS['filter']);
Loading history...
30
				$ttl = $artists_handler->getCount($criteria);
0 ignored issues
show
The method getCount() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsGroupHandler or XoopsConfigCategoryHandler or XoopsRankHandler or XoopsBlockHandler or XoopsImageSetHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

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

30
				/** @scrutinizer ignore-call */ 
31
    $ttl = $artists_handler->getCount($criteria);
Loading history...
31
				$GLOBALS['sort'] = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created';
32
									
33
				$pagenav = new XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']);
34
				$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
35
		
36
				foreach ($artists_handler->filterFields() as $id => $key) {
0 ignored issues
show
The method filterFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

36
				foreach ($artists_handler->/** @scrutinizer ignore-call */ filterFields() as $id => $key) {
Loading history...
37
					$GLOBALS['xoopsTpl']->assign(strtolower(str_replace('-','_',$key).'_th'), '<a href="'.$_SERVER['PHP_SELF'].'?start='.$GLOBALS['start'].'&limit='.$GLOBALS['limit'].'&sort='.$key.'&order='.(($key==$GLOBALS['sort'])?($GLOBALS['order']=='DESC'?'ASC':'DESC'):$GLOBALS['order']).'&op='.$GLOBALS['op'].'&filter='.$GLOBALS['filter'].'">'.(defined('_AM_SONGLIST_TH_'.strtoupper(str_replace('-','_',$key)))?constant('_AM_SONGLIST_TH_'.strtoupper(str_replace('-','_',$key))):'_AM_SONGLIST_TH_'.strtoupper(str_replace('-','_',$key))).'</a>');
38
					$GLOBALS['xoopsTpl']->assign('filter_'.strtolower(str_replace('-','_',$key)).'_th', $artists_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
0 ignored issues
show
The method getFilterForm() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

38
					$GLOBALS['xoopsTpl']->assign('filter_'.strtolower(str_replace('-','_',$key)).'_th', $artists_handler->/** @scrutinizer ignore-call */ getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
Loading history...
39
				}
40
				
41
				$GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
42
				$GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']);
43
				$GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']);
44
				$GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']);
45
				$GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']);
46
				$GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
47
									
48
				$criteria->setStart($GLOBALS['start']);
49
				$criteria->setLimit($GLOBALS['limit']);
50
				$criteria->setSort('`'.$GLOBALS['sort'].'`');
51
				$criteria->setOrder($GLOBALS['order']);
52
					
53
				$artists = $artists_handler->getObjects($criteria, true);
0 ignored issues
show
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

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

53
				/** @scrutinizer ignore-call */ 
54
    $artists = $artists_handler->getObjects($criteria, true);
Loading history...
54
				foreach($artists as $cid => $artist) {
55
					if (is_object($artist))					
56
						$GLOBALS['xoopsTpl']->append('artists', $artist->toArray());
57
				}
58
				$GLOBALS['xoopsTpl']->assign('form', songlist_artists_get_form(false));
59
				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']);
60
				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_list.html');
61
				break;		
62
				
63
			case "new":
64
			case "edit":
65
				
66
				$indexAdmin = new ModuleAdmin();
67
				echo $indexAdmin->addNavigation(basename(__FILE__));
68
											
69
				$artists_handler =& xoops_getmodulehandler('artists', 'songlist');
70
				if (isset($_REQUEST['id'])) {
71
					$artists = $artists_handler->get(intval($_REQUEST['id']));
72
				} else {
73
					$artists = $artists_handler->create();
74
				}
75
				
76
				$GLOBALS['xoopsTpl']->assign('form', $artists->getForm());
0 ignored issues
show
The method getForm() does not exist on XoopsObject. It seems like you code against a sub-type of XoopsObject such as SonglistAlbums or XoopsModules\Songlist\Votes or XoopsModules\Songlist\Genre or SonglistUtf8map or XoopsModules\Songlist\Voice or SystemSmilies or SonglistVotes or SystemBanner or SonglistGenre or XoopsModules\Songlist\Requests or SonglistVoice or SystemBannerclient or XoopsModules\Songlist\Category or XoopsModules\Songlist\Utf8map or XoopsModules\Songlist\Songs or SonglistArtists or SonglistSongs or ProfileCategory or SonglistRequests or SystemUserrank or XoopsModules\Songlist\Albums or SonglistCategory or Utf8map or XoopsModules\Songlist\Artists or SystemGroup or SystemBlock or SystemAvatar or SystemUsers. ( Ignorable by Annotation )

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

76
				$GLOBALS['xoopsTpl']->assign('form', $artists->/** @scrutinizer ignore-call */ getForm());
Loading history...
77
				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']);
78
				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_edit.html');
79
				break;
80
			case "save":
81
				
82
				$artists_handler =& xoops_getmodulehandler('artists', 'songlist');
83
				$id=0;
84
				if ($id=intval($_REQUEST['id'])) {
85
					$artists = $artists_handler->get($id);
86
				} else {
87
					$artists = $artists_handler->create();
88
				}
89
				$artists->setVars($_POST[$id]);
90
				
91
				if (!$id=$artists_handler->insert($artists)) {
0 ignored issues
show
Are you sure the assignment to $id is correct as $artists_handler->insert($artists) targeting XoopsObjectHandler::insert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
92
					redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_FAILEDTOSAVE);
93
					exit(0);
94
				} else {
95
					if ($_REQUEST['state'][$_REQUEST['id']]=='new')
96
						redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'] . '&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY);
97
					else 
98
						redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY);
99
					exit(0);
100
				}
101
				break;
102
			case "savelist":
103
				
104
				$artists_handler =& xoops_getmodulehandler('artists', 'songlist');
105
				foreach($_REQUEST['id'] as $id) {
106
					$artists = $artists_handler->get($id);
107
					$artists->setVars($_POST[$id]);
108
					if (!$artists_handler->insert($artists)) {
0 ignored issues
show
Are you sure the usage of $artists_handler->insert($artists) targeting XoopsObjectHandler::insert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
109
						redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_FAILEDTOSAVE);
110
						exit(0);
111
					} 
112
				}
113
				redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY);
114
				exit(0);
115
				break;				
116
			case "delete":	
117
							
118
				$artists_handler =& xoops_getmodulehandler('artists', 'songlist');
119
				$id=0;
120
				if (isset($_POST['id'])&&$id=intval($_POST['id'])) {
121
					$artists = $artists_handler->get($id);
122
					if (!$artists_handler->delete($artists)) {
0 ignored issues
show
Are you sure the usage of $artists_handler->delete($artists) targeting XoopsObjectHandler::delete() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
123
						redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_FAILEDTODELETE);
124
						exit(0);
125
					} else {
126
						redirect_header($_SERVER['PHP_SELF'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ARTISTS_DELETED);
127
						exit(0);
128
					}
129
				} else {
130
					$artists = $artists_handler->get(intval($_REQUEST['id']));
131
					xoops_confirm(array('id'=>$_REQUEST['id'], 'op'=>$_REQUEST['op'], 'fct'=>$_REQUEST['fct'], 'limit'=>$_REQUEST['limit'], 'start'=>$_REQUEST['start'], 'order'=>$_REQUEST['order'], 'sort'=>$_REQUEST['sort'], 'filter'=>$_REQUEST['filter']), $_SERVER['PHP_SELF'], sprintf(_AM_SONGLIST_MSG_ARTISTS_DELETE, $artists->getVar('name')));
0 ignored issues
show
It seems like $artists->getVar('name') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

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

131
					xoops_confirm(array('id'=>$_REQUEST['id'], 'op'=>$_REQUEST['op'], 'fct'=>$_REQUEST['fct'], 'limit'=>$_REQUEST['limit'], 'start'=>$_REQUEST['start'], 'order'=>$_REQUEST['order'], 'sort'=>$_REQUEST['sort'], 'filter'=>$_REQUEST['filter']), $_SERVER['PHP_SELF'], sprintf(_AM_SONGLIST_MSG_ARTISTS_DELETE, /** @scrutinizer ignore-type */ $artists->getVar('name')));
Loading history...
132
				}
133
				break;
134
		}
135
		break;
136
				
137
	}
138
	
139
	xoops_cp_footer();
140
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...