@@ -34,31 +34,31 @@ |
||
34 | 34 | |
35 | 35 | $perm_desc = ""; |
36 | 36 | switch ($op ) { |
37 | -case "visibility": |
|
38 | - redirect_header("field_visibility.php", 0, _AM_SONGLIST_PROF_VISIBLE); |
|
39 | - //header("Location: visibility.php"); |
|
40 | - break; |
|
37 | + case "visibility": |
|
38 | + redirect_header("field_visibility.php", 0, _AM_SONGLIST_PROF_VISIBLE); |
|
39 | + //header("Location: visibility.php"); |
|
40 | + break; |
|
41 | 41 | |
42 | -case "edit": |
|
43 | - $title_of_form = _AM_SONGLIST_PROF_EDITABLE; |
|
44 | - $perm_name = "songlist_edit"; |
|
45 | - $restriction = "field_edit"; |
|
46 | - $anonymous = false; |
|
47 | - break; |
|
42 | + case "edit": |
|
43 | + $title_of_form = _AM_SONGLIST_PROF_EDITABLE; |
|
44 | + $perm_name = "songlist_edit"; |
|
45 | + $restriction = "field_edit"; |
|
46 | + $anonymous = false; |
|
47 | + break; |
|
48 | 48 | |
49 | -case "post": |
|
50 | - $title_of_form = _AM_SONGLIST_PROF_POST; |
|
51 | - $perm_name = "songlist_post"; |
|
52 | - $restriction = ""; |
|
53 | - $anonymous = true; |
|
54 | - break; |
|
49 | + case "post": |
|
50 | + $title_of_form = _AM_SONGLIST_PROF_POST; |
|
51 | + $perm_name = "songlist_post"; |
|
52 | + $restriction = ""; |
|
53 | + $anonymous = true; |
|
54 | + break; |
|
55 | 55 | |
56 | -case "search": |
|
57 | - $title_of_form = _AM_SONGLIST_PROF_SEARCH; |
|
58 | - $perm_name = "songlist_search"; |
|
59 | - $restriction = ""; |
|
60 | - $anonymous = true; |
|
61 | - break; |
|
56 | + case "search": |
|
57 | + $title_of_form = _AM_SONGLIST_PROF_SEARCH; |
|
58 | + $perm_name = "songlist_search"; |
|
59 | + $restriction = ""; |
|
60 | + $anonymous = true; |
|
61 | + break; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $module_id = $GLOBALS['songlistModule']->getVar('mid'); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $op = $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : "edit")); |
23 | 23 | |
24 | -include_once $GLOBALS['xoops']->path( "/class/xoopsformloader.php" ); |
|
24 | +include_once $GLOBALS['xoops']->path("/class/xoopsformloader.php"); |
|
25 | 25 | $opform = new XoopsSimpleForm('', 'opform', 'field_permissions.php', "post"); |
26 | 26 | $op_select = new XoopsFormSelect("", 'op', $op); |
27 | 27 | $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $opform->display(); |
34 | 34 | |
35 | 35 | $perm_desc = ""; |
36 | -switch ($op ) { |
|
36 | +switch ($op) { |
|
37 | 37 | case "visibility": |
38 | 38 | redirect_header("field_visibility.php", 0, _AM_SONGLIST_PROF_VISIBLE); |
39 | 39 | //header("Location: visibility.php"); |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | $module_id = $GLOBALS['songlistModule']->getVar('mid'); |
65 | -include_once $GLOBALS['xoops']->path( '/class/xoopsform/grouppermform.php' ); |
|
65 | +include_once $GLOBALS['xoops']->path('/class/xoopsform/grouppermform.php'); |
|
66 | 66 | $form = new XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/field_permissions.php', $anonymous); |
67 | 67 | |
68 | -if ( $op == "access" ) { |
|
68 | +if ($op=="access") { |
|
69 | 69 | $member_handler = xoops_gethandler('member'); |
70 | 70 | $glist = $member_handler->getGroupList(); |
71 | - foreach (array_keys($glist) as $i ) { |
|
72 | - if ( $i != XOOPS_GROUP_ANONYMOUS ) { |
|
71 | + foreach (array_keys($glist) as $i) { |
|
72 | + if ($i!=XOOPS_GROUP_ANONYMOUS) { |
|
73 | 73 | $form->addItem($i, $glist[$i]); |
74 | 74 | } |
75 | 75 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | $extras_handler = xoops_getmodulehandler('extras'); |
79 | 79 | $fields = array_merge(array(), $extras_handler->loadFields()); |
80 | 80 | |
81 | - if ( $op != "search" ) { |
|
82 | - if (is_array($fields)&&count($fields)>0) |
|
83 | - foreach (array_keys($fields) as $i ) { |
|
84 | - if ( $restriction == "" || $fields[$i]->getVar($restriction) ) { |
|
85 | - $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25) ); |
|
81 | + if ($op!="search") { |
|
82 | + if (is_array($fields) && count($fields)>0) |
|
83 | + foreach (array_keys($fields) as $i) { |
|
84 | + if ($restriction=="" || $fields[$i]->getVar($restriction)) { |
|
85 | + $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } else { |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | 'datetime', |
95 | 95 | 'timezone', |
96 | 96 | 'language'); |
97 | - if (is_array($fields)&&count($fields)>0) |
|
98 | - foreach (array_keys($fields) as $i ) { |
|
99 | - if ( in_array($fields[$i]->getVar('field_type'), $searchable_types) ) { |
|
100 | - $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25) ); |
|
97 | + if (is_array($fields) && count($fields)>0) |
|
98 | + foreach (array_keys($fields) as $i) { |
|
99 | + if (in_array($fields[$i]->getVar('field_type'), $searchable_types)) { |
|
100 | + $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -79,10 +79,11 @@ discard block |
||
79 | 79 | $fields = array_merge(array(), $extras_handler->loadFields()); |
80 | 80 | |
81 | 81 | if ( $op != "search" ) { |
82 | - if (is_array($fields)&&count($fields)>0) |
|
83 | - foreach (array_keys($fields) as $i ) { |
|
82 | + if (is_array($fields)&&count($fields)>0) { |
|
83 | + foreach (array_keys($fields) as $i ) { |
|
84 | 84 | if ( $restriction == "" || $fields[$i]->getVar($restriction) ) { |
85 | 85 | $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25) ); |
86 | + } |
|
86 | 87 | } |
87 | 88 | } |
88 | 89 | } else { |
@@ -94,10 +95,11 @@ discard block |
||
94 | 95 | 'datetime', |
95 | 96 | 'timezone', |
96 | 97 | 'language'); |
97 | - if (is_array($fields)&&count($fields)>0) |
|
98 | - foreach (array_keys($fields) as $i ) { |
|
98 | + if (is_array($fields)&&count($fields)>0) { |
|
99 | + foreach (array_keys($fields) as $i ) { |
|
99 | 100 | if ( in_array($fields[$i]->getVar('field_type'), $searchable_types) ) { |
100 | 101 | $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25) ); |
102 | + } |
|
101 | 103 | } |
102 | 104 | } |
103 | 105 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | $filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1'; |
16 | 16 | |
17 | 17 | switch($op) { |
18 | - default: |
|
19 | - case "genre": |
|
20 | - switch ($fct) |
|
21 | - { |
|
18 | + default: |
|
19 | + case "genre": |
|
20 | + switch ($fct) |
|
21 | + { |
|
22 | 22 | default: |
23 | 23 | case "list": |
24 | 24 | $indexAdmin = new ModuleAdmin(); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 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_GENRE_DELETE, $genre->getVar('name'))); |
132 | 132 | } |
133 | 133 | break; |
134 | - } |
|
134 | + } |
|
135 | 135 | break; |
136 | 136 | |
137 | 137 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | xoops_cp_header(); |
8 | 8 | |
9 | - $op = isset($_REQUEST['op'])?$_REQUEST['op']:"genre"; |
|
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'; |
|
9 | + $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "genre"; |
|
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 | 16 | |
17 | - switch($op) { |
|
17 | + switch ($op) { |
|
18 | 18 | default: |
19 | 19 | case "genre": |
20 | 20 | switch ($fct) |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $indexAdmin = new ModuleAdmin(); |
25 | 25 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
26 | 26 | |
27 | - $genre_handler =& xoops_getmodulehandler('genre', 'songlist'); |
|
27 | + $genre_handler = & xoops_getmodulehandler('genre', 'songlist'); |
|
28 | 28 | |
29 | 29 | $criteria = $genre_handler->getFilterCriteria($GLOBALS['filter']); |
30 | 30 | $ttl = $genre_handler->getCount($criteria); |
31 | - $GLOBALS['sort'] = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created'; |
|
31 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
32 | 32 | |
33 | 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 | 34 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
35 | 35 | |
36 | 36 | foreach ($genre_handler->filterFields() as $id => $key) { |
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', $genre_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
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', $genre_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $criteria->setOrder($GLOBALS['order']); |
52 | 52 | |
53 | 53 | $genres = $genre_handler->getObjects($criteria, true); |
54 | - foreach($genres as $cid => $genre) { |
|
54 | + foreach ($genres as $cid => $genre) { |
|
55 | 55 | if (is_object($genre)) |
56 | 56 | $GLOBALS['xoopsTpl']->append('genre', $genre->toArray()); |
57 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $indexAdmin = new ModuleAdmin(); |
67 | 67 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
68 | 68 | |
69 | - $genre_handler =& xoops_getmodulehandler('genre', 'songlist'); |
|
69 | + $genre_handler = & xoops_getmodulehandler('genre', 'songlist'); |
|
70 | 70 | if (isset($_REQUEST['id'])) { |
71 | 71 | $genre = $genre_handler->get(intval($_REQUEST['id'])); |
72 | 72 | } else { |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | break; |
80 | 80 | case "save": |
81 | 81 | |
82 | - $genre_handler =& xoops_getmodulehandler('genre', 'songlist'); |
|
83 | - $id=0; |
|
84 | - if ($id=intval($_REQUEST['id'])) { |
|
82 | + $genre_handler = & xoops_getmodulehandler('genre', 'songlist'); |
|
83 | + $id = 0; |
|
84 | + if ($id = intval($_REQUEST['id'])) { |
|
85 | 85 | $genre = $genre_handler->get($id); |
86 | 86 | } else { |
87 | 87 | $genre = $genre_handler->create(); |
88 | 88 | } |
89 | 89 | $genre->setVars($_POST[$id]); |
90 | 90 | |
91 | - if (!$id=$genre_handler->insert($genre)) { |
|
91 | + if (!$id = $genre_handler->insert($genre)) { |
|
92 | 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_GENRE_FAILEDTOSAVE); |
93 | 93 | exit(0); |
94 | 94 | } else { |
95 | 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_GENRE_SAVEDOKEY); |
|
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_GENRE_SAVEDOKEY); |
|
97 | 97 | else |
98 | 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_GENRE_SAVEDOKEY); |
99 | 99 | exit(0); |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | break; |
102 | 102 | case "savelist": |
103 | 103 | |
104 | - $genre_handler =& xoops_getmodulehandler('genre', 'songlist'); |
|
105 | - foreach($_REQUEST['id'] as $id) { |
|
104 | + $genre_handler = & xoops_getmodulehandler('genre', 'songlist'); |
|
105 | + foreach ($_REQUEST['id'] as $id) { |
|
106 | 106 | $genre = $genre_handler->get($id); |
107 | 107 | $genre->setVars($_POST[$id]); |
108 | 108 | if (!$genre_handler->insert($genre)) { |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | break; |
116 | 116 | case "delete": |
117 | 117 | |
118 | - $genre_handler =& xoops_getmodulehandler('genre', 'songlist'); |
|
119 | - $id=0; |
|
120 | - if (isset($_POST['id'])&&$id=intval($_POST['id'])) { |
|
118 | + $genre_handler = & xoops_getmodulehandler('genre', 'songlist'); |
|
119 | + $id = 0; |
|
120 | + if (isset($_POST['id']) && $id = intval($_POST['id'])) { |
|
121 | 121 | $genre = $genre_handler->get($id); |
122 | 122 | if (!$genre_handler->delete($genre)) { |
123 | 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_GENRE_FAILEDTODELETE); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $genres = $genre_handler->getObjects($criteria, true); |
54 | 54 | foreach($genres as $cid => $genre) { |
55 | - if (is_object($genre)) |
|
56 | - $GLOBALS['xoopsTpl']->append('genre', $genre->toArray()); |
|
55 | + if (is_object($genre)) { |
|
56 | + $GLOBALS['xoopsTpl']->append('genre', $genre->toArray()); |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | $GLOBALS['xoopsTpl']->assign('form', songlist_genre_get_form(false)); |
59 | 60 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']); |
@@ -92,10 +93,11 @@ discard block |
||
92 | 93 | 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_GENRE_FAILEDTOSAVE); |
93 | 94 | exit(0); |
94 | 95 | } 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_GENRE_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_GENRE_SAVEDOKEY); |
|
96 | + if ($_REQUEST['state'][$_REQUEST['id']]=='new') { |
|
97 | + 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_GENRE_SAVEDOKEY); |
|
98 | + } else { |
|
99 | + 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_GENRE_SAVEDOKEY); |
|
100 | + } |
|
99 | 101 | exit(0); |
100 | 102 | } |
101 | 103 | break; |
@@ -56,23 +56,23 @@ |
||
56 | 56 | include_once $GLOBALS['xoops']->path('class'.DS.'xoopsmailer.php'); |
57 | 57 | |
58 | 58 | if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ |
59 | - include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
|
60 | - }else{ |
|
61 | - echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
|
62 | - } |
|
59 | + include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
|
60 | + }else{ |
|
61 | + echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | $GLOBALS['songlistImageIcon'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons16'); |
65 | 65 | $GLOBALS['songlistImageAdmin'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons32'); |
66 | 66 | |
67 | 67 | if ($GLOBALS['xoopsUser']) { |
68 | - $moduleperm_handler = xoops_gethandler('groupperm'); |
|
69 | - if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar( 'mid' ), $GLOBALS['xoopsUser']->getGroups())) { |
|
70 | - redirect_header(XOOPS_URL, 1, _NOPERM); |
|
71 | - exit(); |
|
72 | - } |
|
68 | + $moduleperm_handler = xoops_gethandler('groupperm'); |
|
69 | + if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar( 'mid' ), $GLOBALS['xoopsUser']->getGroups())) { |
|
70 | + redirect_header(XOOPS_URL, 1, _NOPERM); |
|
71 | + exit(); |
|
72 | + } |
|
73 | 73 | } else { |
74 | - redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM); |
|
75 | - exit(); |
|
74 | + redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM); |
|
75 | + exit(); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | xoops_loadLanguage('user'); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | require_once (dirname(dirname(dirname(dirname(__FILE__)))).'/include/cp_header.php'); |
34 | 34 | |
35 | 35 | if (!defined('_CHARSET')) |
36 | - define ("_CHARSET","UTF-8"); |
|
36 | + define("_CHARSET", "UTF-8"); |
|
37 | 37 | if (!defined('_CHARSET_ISO')) |
38 | - define ("_CHARSET_ISO","ISO-8859-1"); |
|
38 | + define("_CHARSET_ISO", "ISO-8859-1"); |
|
39 | 39 | |
40 | 40 | $GLOBALS['songlistAdmin'] = true; |
41 | 41 | |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | |
56 | 56 | include_once $GLOBALS['xoops']->path('class'.DS.'xoopsmailer.php'); |
57 | 57 | |
58 | - if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ |
|
58 | + if (file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))) { |
|
59 | 59 | include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
60 | - }else{ |
|
60 | + } else { |
|
61 | 61 | echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
62 | 62 | } |
63 | 63 | |
64 | - $GLOBALS['songlistImageIcon'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons16'); |
|
65 | - $GLOBALS['songlistImageAdmin'] = XOOPS_URL .'/'. $GLOBALS['songlistModule']->getInfo('icons32'); |
|
64 | + $GLOBALS['songlistImageIcon'] = XOOPS_URL.'/'.$GLOBALS['songlistModule']->getInfo('icons16'); |
|
65 | + $GLOBALS['songlistImageAdmin'] = XOOPS_URL.'/'.$GLOBALS['songlistModule']->getInfo('icons32'); |
|
66 | 66 | |
67 | 67 | if ($GLOBALS['xoopsUser']) { |
68 | 68 | $moduleperm_handler = xoops_gethandler('groupperm'); |
69 | - if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar( 'mid' ), $GLOBALS['xoopsUser']->getGroups())) { |
|
69 | + if (!$moduleperm_handler->checkRight('module_admin', $GLOBALS['songlistModule']->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) { |
|
70 | 70 | redirect_header(XOOPS_URL, 1, _NOPERM); |
71 | 71 | exit(); |
72 | 72 | } |
73 | 73 | } else { |
74 | - redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM); |
|
74 | + redirect_header(XOOPS_URL."/user.php", 1, _NOPERM); |
|
75 | 75 | exit(); |
76 | 76 | } |
77 | 77 |
@@ -32,10 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | require_once (dirname(dirname(dirname(dirname(__FILE__)))).'/include/cp_header.php'); |
34 | 34 | |
35 | - if (!defined('_CHARSET')) |
|
36 | - define ("_CHARSET","UTF-8"); |
|
37 | - if (!defined('_CHARSET_ISO')) |
|
38 | - define ("_CHARSET_ISO","ISO-8859-1"); |
|
35 | + if (!defined('_CHARSET')) { |
|
36 | + define ("_CHARSET","UTF-8"); |
|
37 | + } |
|
38 | + if (!defined('_CHARSET_ISO')) { |
|
39 | + define ("_CHARSET_ISO","ISO-8859-1"); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $GLOBALS['songlistAdmin'] = true; |
41 | 43 | |
@@ -57,7 +59,7 @@ discard block |
||
57 | 59 | |
58 | 60 | if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ |
59 | 61 | include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); |
60 | - }else{ |
|
62 | + } else{ |
|
61 | 63 | echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); |
62 | 64 | } |
63 | 65 |
@@ -111,25 +111,25 @@ |
||
111 | 111 | if ($uploader->fetchMedia('image')) { |
112 | 112 | if (!$uploader->upload()) { |
113 | 113 | |
114 | - songlist_adminMenu(1); |
|
115 | - echo $uploader->getErrors(); |
|
114 | + songlist_adminMenu(1); |
|
115 | + echo $uploader->getErrors(); |
|
116 | 116 | songlist_footer_adminMenu(); |
117 | 117 | xoops_cp_footer(); |
118 | 118 | exit(0); |
119 | - } else { |
|
119 | + } else { |
|
120 | 120 | |
121 | - if (strlen($albums->getVar('image'))) |
|
122 | - unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
121 | + if (strlen($albums->getVar('image'))) |
|
122 | + unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
123 | 123 | |
124 | - $albums->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
125 | - $albums->setVar('image', $uploader->getSavedFileName()); |
|
126 | - @$albums_handler->insert($albums); |
|
124 | + $albums->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
125 | + $albums->setVar('image', $uploader->getSavedFileName()); |
|
126 | + @$albums_handler->insert($albums); |
|
127 | 127 | |
128 | - } |
|
128 | + } |
|
129 | 129 | } else { |
130 | 130 | |
131 | 131 | songlist_adminMenu(1); |
132 | - echo $uploader->getErrors(); |
|
132 | + echo $uploader->getErrors(); |
|
133 | 133 | songlist_footer_adminMenu(); |
134 | 134 | xoops_cp_footer(); |
135 | 135 | exit(0); |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | $filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1'; |
16 | 16 | |
17 | 17 | switch($op) { |
18 | - default: |
|
19 | - case "albums": |
|
20 | - switch ($fct) |
|
21 | - { |
|
18 | + default: |
|
19 | + case "albums": |
|
20 | + switch ($fct) |
|
21 | + { |
|
22 | 22 | default: |
23 | 23 | case "list": |
24 | 24 | $indexAdmin = new ModuleAdmin(); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | 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_ALBUMS_DELETE, $albums->getVar('title'))); |
176 | 176 | } |
177 | 177 | break; |
178 | - } |
|
178 | + } |
|
179 | 179 | break; |
180 | 180 | |
181 | 181 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | xoops_cp_header(); |
8 | 8 | |
9 | - $op = isset($_REQUEST['op'])?$_REQUEST['op']:"albums"; |
|
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'; |
|
9 | + $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "albums"; |
|
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 | 16 | |
17 | - switch($op) { |
|
17 | + switch ($op) { |
|
18 | 18 | default: |
19 | 19 | case "albums": |
20 | 20 | switch ($fct) |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $indexAdmin = new ModuleAdmin(); |
25 | 25 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
26 | 26 | |
27 | - $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
|
27 | + $albums_handler = & xoops_getmodulehandler('albums', 'songlist'); |
|
28 | 28 | |
29 | 29 | $criteria = $albums_handler->getFilterCriteria($GLOBALS['filter']); |
30 | 30 | $ttl = $albums_handler->getCount($criteria); |
31 | - $GLOBALS['sort'] = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created'; |
|
31 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
32 | 32 | |
33 | 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 | 34 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
35 | 35 | |
36 | 36 | foreach ($albums_handler->filterFields() as $id => $key) { |
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', $albums_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
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', $albums_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $criteria->setOrder($GLOBALS['order']); |
52 | 52 | |
53 | 53 | $albumss = $albums_handler->getObjects($criteria, true); |
54 | - foreach($albumss as $cid => $albums) { |
|
54 | + foreach ($albumss as $cid => $albums) { |
|
55 | 55 | if (is_object($albums)) |
56 | 56 | $GLOBALS['xoopsTpl']->append('albums', $albums->toArray()); |
57 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $indexAdmin = new ModuleAdmin(); |
67 | 67 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
68 | 68 | |
69 | - $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
|
69 | + $albums_handler = & xoops_getmodulehandler('albums', 'songlist'); |
|
70 | 70 | if (isset($_REQUEST['id'])) { |
71 | 71 | $albums = $albums_handler->get(intval($_REQUEST['id'])); |
72 | 72 | } else { |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | break; |
80 | 80 | case "save": |
81 | 81 | |
82 | - $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
|
83 | - $id=0; |
|
84 | - if ($id=intval($_REQUEST['id'])) { |
|
82 | + $albums_handler = & xoops_getmodulehandler('albums', 'songlist'); |
|
83 | + $id = 0; |
|
84 | + if ($id = intval($_REQUEST['id'])) { |
|
85 | 85 | $albums = $albums_handler->get($id); |
86 | 86 | } else { |
87 | 87 | $albums = $albums_handler->create(); |
88 | 88 | } |
89 | 89 | $albums->setVars($_POST[$id]); |
90 | 90 | |
91 | - if (!$id=$albums_handler->insert($albums)) { |
|
91 | + if (!$id = $albums_handler->insert($albums)) { |
|
92 | 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_ALBUMS_FAILEDTOSAVE); |
93 | 93 | exit(0); |
94 | 94 | } else { |
95 | 95 | |
96 | - if (isset($_FILES['image'])&&!empty($_FILES['image']['title'])) { |
|
96 | + if (isset($_FILES['image']) && !empty($_FILES['image']['title'])) { |
|
97 | 97 | |
98 | 98 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
99 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
100 | - foreach(explode('/', $folders) as $folder) { |
|
101 | - $path .= DS . $folder; |
|
99 | + foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
100 | + foreach (explode('/', $folders) as $folder) { |
|
101 | + $path .= DS.$folder; |
|
102 | 102 | mkdir($path, 0777); |
103 | 103 | } |
104 | 104 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | include_once($GLOBALS['xoops']->path('modules/songlist/include/uploader.php')); |
107 | 107 | $albums = $albums_handler->get($id); |
108 | 108 | $uploader = new SonglistMediaUploader($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), $GLOBALS['songlistModuleConfig']['filesize_upload'], 0, 0, explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions'])); |
109 | - $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0,20), 13)); |
|
109 | + $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0, 20), 13)); |
|
110 | 110 | |
111 | 111 | if ($uploader->fetchMedia('image')) { |
112 | 112 | if (!$uploader->upload()) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | if ($_REQUEST['state'][$_REQUEST['id']]=='new') |
140 | - 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_ALBUMS_SAVEDOKEY); |
|
140 | + 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_ALBUMS_SAVEDOKEY); |
|
141 | 141 | else |
142 | 142 | 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_ALBUMS_SAVEDOKEY); |
143 | 143 | exit(0); |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | break; |
146 | 146 | case "savelist": |
147 | 147 | |
148 | - $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
|
149 | - foreach($_REQUEST['id'] as $id) { |
|
148 | + $albums_handler = & xoops_getmodulehandler('albums', 'songlist'); |
|
149 | + foreach ($_REQUEST['id'] as $id) { |
|
150 | 150 | $albums = $albums_handler->get($id); |
151 | 151 | $albums->setVars($_POST[$id]); |
152 | 152 | if (!$albums_handler->insert($albums)) { |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | break; |
160 | 160 | case "delete": |
161 | 161 | |
162 | - $albums_handler =& xoops_getmodulehandler('albums', 'songlist'); |
|
163 | - $id=0; |
|
164 | - if (isset($_POST['id'])&&$id=intval($_POST['id'])) { |
|
162 | + $albums_handler = & xoops_getmodulehandler('albums', 'songlist'); |
|
163 | + $id = 0; |
|
164 | + if (isset($_POST['id']) && $id = intval($_POST['id'])) { |
|
165 | 165 | $albums = $albums_handler->get($id); |
166 | 166 | if (!$albums_handler->delete($albums)) { |
167 | 167 | 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_ALBUMS_FAILEDTODELETE); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $albumss = $albums_handler->getObjects($criteria, true); |
54 | 54 | foreach($albumss as $cid => $albums) { |
55 | - if (is_object($albums)) |
|
56 | - $GLOBALS['xoopsTpl']->append('albums', $albums->toArray()); |
|
55 | + if (is_object($albums)) { |
|
56 | + $GLOBALS['xoopsTpl']->append('albums', $albums->toArray()); |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | $GLOBALS['xoopsTpl']->assign('form', songlist_albums_get_form(false)); |
59 | 60 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']); |
@@ -96,9 +97,10 @@ discard block |
||
96 | 97 | if (isset($_FILES['image'])&&!empty($_FILES['image']['title'])) { |
97 | 98 | |
98 | 99 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
99 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
100 | - foreach(explode('/', $folders) as $folder) { |
|
100 | + foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
|
101 | + foreach(explode('/', $folders) as $folder) { |
|
101 | 102 | $path .= DS . $folder; |
103 | + } |
|
102 | 104 | mkdir($path, 0777); |
103 | 105 | } |
104 | 106 | } |
@@ -118,8 +120,9 @@ discard block |
||
118 | 120 | exit(0); |
119 | 121 | } else { |
120 | 122 | |
121 | - if (strlen($albums->getVar('image'))) |
|
122 | - unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
123 | + if (strlen($albums->getVar('image'))) { |
|
124 | + unlink($GLOBALS['xoops']->path($albums->getVar('path')).$albums->getVar('image')); |
|
125 | + } |
|
123 | 126 | |
124 | 127 | $albums->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
125 | 128 | $albums->setVar('image', $uploader->getSavedFileName()); |
@@ -136,10 +139,11 @@ discard block |
||
136 | 139 | } |
137 | 140 | } |
138 | 141 | |
139 | - if ($_REQUEST['state'][$_REQUEST['id']]=='new') |
|
140 | - 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_ALBUMS_SAVEDOKEY); |
|
141 | - else |
|
142 | - 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_ALBUMS_SAVEDOKEY); |
|
142 | + if ($_REQUEST['state'][$_REQUEST['id']]=='new') { |
|
143 | + 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_ALBUMS_SAVEDOKEY); |
|
144 | + } else { |
|
145 | + 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_ALBUMS_SAVEDOKEY); |
|
146 | + } |
|
143 | 147 | exit(0); |
144 | 148 | } |
145 | 149 | break; |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | case "actiona": |
23 | 23 | |
24 | 24 | if (isset($_SESSION['xmlfile'])) { |
25 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
26 | - exit; |
|
25 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
26 | + exit; |
|
27 | 27 | } |
28 | 28 | $indexAdmin = new ModuleAdmin(); |
29 | 29 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | if ($uploader->fetchMedia('xmlfile')) { |
54 | 54 | if (!$uploader->upload()) { |
55 | 55 | |
56 | - echo $uploader->getErrors(); |
|
56 | + echo $uploader->getErrors(); |
|
57 | 57 | songlist_footer_adminMenu(); |
58 | 58 | xoops_cp_footer(); |
59 | 59 | exit(0); |
60 | - } else { |
|
61 | - $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
62 | - redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
63 | - exit; |
|
64 | - } |
|
60 | + } else { |
|
61 | + $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
62 | + redirect_header($_SERVER['PHP_SELF'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
63 | + exit; |
|
64 | + } |
|
65 | 65 | } else { |
66 | 66 | |
67 | - echo $uploader->getErrors(); |
|
67 | + echo $uploader->getErrors(); |
|
68 | 68 | songlist_footer_adminMenu(); |
69 | 69 | xoops_cp_footer(); |
70 | 70 | exit(0); |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | $filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1'; |
16 | 16 | |
17 | 17 | switch($op) { |
18 | - case "import": |
|
19 | - switch ($fct) |
|
20 | - { |
|
18 | + case "import": |
|
19 | + switch ($fct) |
|
20 | + { |
|
21 | 21 | default: |
22 | 22 | case "actiona": |
23 | 23 | |
@@ -158,101 +158,101 @@ discard block |
||
158 | 158 | $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
159 | 159 | break; |
160 | 160 | } |
161 | - $object->setVar('name', $data[$_POST['artist']]); |
|
162 | - $aid = $artists_handler->insert($object); |
|
163 | - $aids[$aid] = $aid; |
|
161 | + $object->setVar('name', $data[$_POST['artist']]); |
|
162 | + $aid = $artists_handler->insert($object); |
|
163 | + $aids[$aid] = $aid; |
|
164 | + } |
|
165 | + } |
|
166 | + } |
|
167 | + $abid = 0; |
|
168 | + if (strlen($_POST['album'])>0&&!empty($data[$_POST['album']])) { |
|
169 | + $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
170 | + if ($albums_handler->getCount($criteria)>0) { |
|
171 | + $objects = $albums_handler->getObjects($criteria, false); |
|
172 | + $abid = $objects[0]->getVar('aid'); |
|
173 | + } else { |
|
174 | + $object = $albums_handler->create(); |
|
175 | + $object->setVar('cid', $cid); |
|
176 | + $object->setVar('aids', $aids); |
|
177 | + $object->setVar('name', $data[$_POST['album']]); |
|
178 | + $abid = $albums_handler->insert($object); |
|
179 | + } |
|
180 | + } |
|
181 | + $sid = 0; |
|
182 | + if (strlen($_POST['songid'])>0&&!empty($data[$_POST['songid']])) { |
|
183 | + $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
184 | + if ($songs_handler->getCount($criteria)>0) { |
|
185 | + $objects = $songs_handler->getObjects($criteria, false); |
|
186 | + $object = $objects[0]->getVar('sid'); |
|
187 | + } else { |
|
188 | + $object = $songs_handler->create(); |
|
164 | 189 | } |
190 | + if ($object->getVar('cid')>0&&$cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
191 | + if ($object->getVar('gid')>0&&$gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
192 | + if (count($object->getVar('aids'))>0&&count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
193 | + if ($object->getVar('abid')>0&&$abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
194 | + $object->setVar('songid', $data[$_POST['songid']]); |
|
195 | + $object->setVar('title', $data[$_POST['title']]); |
|
196 | + $object->setVar('lyrics', str_replace("\n", "<br/>\n", $data[$_POST['lyrics']])); |
|
197 | + $sid = $songs_handler->insert($object); |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + } else { |
|
202 | + foreach ($xmlarray as $recid => $data) { |
|
203 | + $gid = 0; |
|
204 | + if (strlen($_POST['genre'])>0&&!empty($data[$_POST['genre']])) { |
|
205 | + $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
206 | + if ($genre_handler->getCount($criteria)>0) { |
|
207 | + $objects = $genre_handler->getObjects($criteria, false); |
|
208 | + $gid = $objects[0]->getVar('gid'); |
|
209 | + } else { |
|
210 | + $object = $genre_handler->create(); |
|
211 | + $object->setVar('name', $data[$_POST['genre']]); |
|
212 | + $gid = $genre_handler->insert($object); |
|
165 | 213 | } |
166 | - } |
|
167 | - $abid = 0; |
|
168 | - if (strlen($_POST['album'])>0&&!empty($data[$_POST['album']])) { |
|
169 | - $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
170 | - if ($albums_handler->getCount($criteria)>0) { |
|
171 | - $objects = $albums_handler->getObjects($criteria, false); |
|
172 | - $abid = $objects[0]->getVar('aid'); |
|
214 | + } |
|
215 | + $vid = 0; |
|
216 | + if (strlen($_POST['voice'])>0&&!empty($data[$_POST['voice']])) { |
|
217 | + $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
218 | + if ($voice_handler->getCount($criteria)>0) { |
|
219 | + $objects = $voice_handler->getObjects($criteria, false); |
|
220 | + $gid = $objects[0]->getVar('vid'); |
|
173 | 221 | } else { |
174 | - $object = $albums_handler->create(); |
|
175 | - $object->setVar('cid', $cid); |
|
176 | - $object->setVar('aids', $aids); |
|
177 | - $object->setVar('name', $data[$_POST['album']]); |
|
178 | - $abid = $albums_handler->insert($object); |
|
222 | + $object = $voice_handler->create(); |
|
223 | + $object->setVar('name', $data[$_POST['voice']]); |
|
224 | + $gid = $voice_handler->insert($object); |
|
179 | 225 | } |
180 | - } |
|
181 | - $sid = 0; |
|
182 | - if (strlen($_POST['songid'])>0&&!empty($data[$_POST['songid']])) { |
|
183 | - $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
184 | - if ($songs_handler->getCount($criteria)>0) { |
|
185 | - $objects = $songs_handler->getObjects($criteria, false); |
|
186 | - $object = $objects[0]->getVar('sid'); |
|
226 | + } |
|
227 | + $cid = 0; |
|
228 | + if (strlen($_POST['category'])>0&&!empty($data[$_POST['category']])) { |
|
229 | + $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
230 | + if ($category_handler->getCount($criteria)>0) { |
|
231 | + $objects = $category_handler->getObjects($criteria, false); |
|
232 | + $cid = $objects[0]->getVar('cid'); |
|
187 | 233 | } else { |
188 | - $object = $songs_handler->create(); |
|
189 | - } |
|
190 | - if ($object->getVar('cid')>0&&$cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
191 | - if ($object->getVar('gid')>0&&$gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
192 | - if (count($object->getVar('aids'))>0&&count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
193 | - if ($object->getVar('abid')>0&&$abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
194 | - $object->setVar('songid', $data[$_POST['songid']]); |
|
195 | - $object->setVar('title', $data[$_POST['title']]); |
|
196 | - $object->setVar('lyrics', str_replace("\n", "<br/>\n", $data[$_POST['lyrics']])); |
|
197 | - $sid = $songs_handler->insert($object); |
|
234 | + $object = $category_handler->create(); |
|
235 | + $object->setVar('name', $data[$_POST['category']]); |
|
236 | + $cid = $category_handler->insert($object); |
|
237 | + } |
|
198 | 238 | } |
199 | - } |
|
200 | - } |
|
201 | - } else { |
|
202 | - foreach ($xmlarray as $recid => $data) { |
|
203 | - $gid = 0; |
|
204 | - if (strlen($_POST['genre'])>0&&!empty($data[$_POST['genre']])) { |
|
205 | - $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
206 | - if ($genre_handler->getCount($criteria)>0) { |
|
207 | - $objects = $genre_handler->getObjects($criteria, false); |
|
208 | - $gid = $objects[0]->getVar('gid'); |
|
209 | - } else { |
|
210 | - $object = $genre_handler->create(); |
|
211 | - $object->setVar('name', $data[$_POST['genre']]); |
|
212 | - $gid = $genre_handler->insert($object); |
|
213 | - } |
|
214 | - } |
|
215 | - $vid = 0; |
|
216 | - if (strlen($_POST['voice'])>0&&!empty($data[$_POST['voice']])) { |
|
217 | - $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
218 | - if ($voice_handler->getCount($criteria)>0) { |
|
219 | - $objects = $voice_handler->getObjects($criteria, false); |
|
220 | - $gid = $objects[0]->getVar('vid'); |
|
221 | - } else { |
|
222 | - $object = $voice_handler->create(); |
|
223 | - $object->setVar('name', $data[$_POST['voice']]); |
|
224 | - $gid = $voice_handler->insert($object); |
|
225 | - } |
|
226 | - } |
|
227 | - $cid = 0; |
|
228 | - if (strlen($_POST['category'])>0&&!empty($data[$_POST['category']])) { |
|
229 | - $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
230 | - if ($category_handler->getCount($criteria)>0) { |
|
231 | - $objects = $category_handler->getObjects($criteria, false); |
|
232 | - $cid = $objects[0]->getVar('cid'); |
|
233 | - } else { |
|
234 | - $object = $category_handler->create(); |
|
235 | - $object->setVar('name', $data[$_POST['category']]); |
|
236 | - $cid = $category_handler->insert($object); |
|
237 | - } |
|
238 | - } |
|
239 | - $aids = array(); |
|
240 | - if (strlen($_POST['artist'])>0&&!empty($data[$_POST['artist']])) { |
|
241 | - foreach(explode(',', $data[$_POST['artist']]) as $artist) { |
|
242 | - $criteria = new Criteria('`name`', $artist); |
|
243 | - if ($artists_handler->getCount($criteria)>0) { |
|
244 | - $objects = $artists_handler->getObjects($criteria, false); |
|
245 | - $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
246 | - } else { |
|
247 | - $object = $artists_handler->create(); |
|
248 | - switch($data[$_POST['singer']]) { |
|
239 | + $aids = array(); |
|
240 | + if (strlen($_POST['artist'])>0&&!empty($data[$_POST['artist']])) { |
|
241 | + foreach(explode(',', $data[$_POST['artist']]) as $artist) { |
|
242 | + $criteria = new Criteria('`name`', $artist); |
|
243 | + if ($artists_handler->getCount($criteria)>0) { |
|
244 | + $objects = $artists_handler->getObjects($criteria, false); |
|
245 | + $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
246 | + } else { |
|
247 | + $object = $artists_handler->create(); |
|
248 | + switch($data[$_POST['singer']]) { |
|
249 | 249 | case $_POST['duet']: |
250 | 250 | $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
251 | 251 | break; |
252 | 252 | case $_POST['solo']: |
253 | 253 | $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
254 | 254 | break; |
255 | - } |
|
255 | + } |
|
256 | 256 | $object->setVar('cid', $cid); |
257 | 257 | $object->setVar('name', $data[$_POST['artist']]); |
258 | 258 | $aid = $artists_handler->insert($object); |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | xoops_cp_header(); |
8 | 8 | |
9 | - $op = isset($_REQUEST['op'])?$_REQUEST['op']:"dashboard"; |
|
10 | - $fct = isset($_REQUEST['fct'])?$_REQUEST['fct']:""; |
|
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'; |
|
9 | + $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "dashboard"; |
|
10 | + $fct = isset($_REQUEST['fct']) ? $_REQUEST['fct'] : ""; |
|
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 | 16 | |
17 | - switch($op) { |
|
17 | + switch ($op) { |
|
18 | 18 | case "import": |
19 | 19 | switch ($fct) |
20 | 20 | { |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | case "upload": |
37 | 37 | |
38 | - if (isset($_FILES['xmlfile'])&&!empty($_FILES['xmlfile']['title'])) { |
|
38 | + if (isset($_FILES['xmlfile']) && !empty($_FILES['xmlfile']['title'])) { |
|
39 | 39 | |
40 | 40 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
41 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
42 | - foreach(explode('/', $folders) as $folder) { |
|
43 | - $path .= DS . $folder; |
|
41 | + foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
42 | + foreach (explode('/', $folders) as $folder) { |
|
43 | + $path .= DS.$folder; |
|
44 | 44 | mkdir($path, 0777); |
45 | 45 | } |
46 | 46 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | include_once($GLOBALS['xoops']->path('modules/songlist/include/uploader.php')); |
49 | 49 | $albums = $albums_handler->get($id); |
50 | 50 | $uploader = new SonglistMediaUploader($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity', 'text/xml xml xsl', 'text/xml-external-parsed-entity'), 1024*1024*32, 0, 0, array('xml')); |
51 | - $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0,20), 13)); |
|
51 | + $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0, 20), 13)); |
|
52 | 52 | |
53 | 53 | if ($uploader->fetchMedia('xmlfile')) { |
54 | 54 | if (!$uploader->upload()) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $category_handler = xoops_getmodulehandler('category', 'songlist'); |
92 | 92 | |
93 | 93 | $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])); |
94 | - $mb = floor($filesize / 1024 / 1024); |
|
94 | + $mb = floor($filesize/1024/1024); |
|
95 | 95 | if ($mb>32) { |
96 | 96 | set_ini('memory_limit', ($mb+128).'M'); |
97 | 97 | } |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | $xmlarray = songlist_xml2array(file_get_contents($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])), false, 'tag'); |
101 | 101 | |
102 | 102 | if (strlen($_POST['collection'])>0) { |
103 | - foreach($xmlarray[$_POST['collection']] as $id => $record) { |
|
103 | + foreach ($xmlarray[$_POST['collection']] as $id => $record) { |
|
104 | 104 | foreach ($record as $recid => $data) { |
105 | 105 | $gid = 0; |
106 | - if (strlen($_POST['genre'])>0&&!empty($data[$_POST['genre']])) { |
|
107 | - $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
106 | + if (strlen($_POST['genre'])>0 && !empty($data[$_POST['genre']])) { |
|
107 | + $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
108 | 108 | if ($genre_handler->getCount($criteria)>0) { |
109 | 109 | $objects = $genre_handler->getObjects($criteria, false); |
110 | 110 | $gid = $objects[0]->getVar('gid'); |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | $vid = 0; |
119 | - if (strlen($_POST['voice'])>0&&!empty($data[$_POST['voice']])) { |
|
120 | - $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
119 | + if (strlen($_POST['voice'])>0 && !empty($data[$_POST['voice']])) { |
|
120 | + $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
121 | 121 | if ($voice_handler->getCount($criteria)>0) { |
122 | 122 | $objects = $voice_handler->getObjects($criteria, false); |
123 | 123 | $gid = $objects[0]->getVar('vid'); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | $cid = 0; |
132 | - if (strlen($_POST['category'])>0&&!empty($data[$_POST['category']])) { |
|
133 | - $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
132 | + if (strlen($_POST['category'])>0 && !empty($data[$_POST['category']])) { |
|
133 | + $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
134 | 134 | if ($category_handler->getCount($criteria)>0) { |
135 | 135 | $objects = $category_handler->getObjects($criteria, false); |
136 | 136 | $cid = $objects[0]->getVar('cid'); |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | } |
142 | 142 | } |
143 | 143 | $aids = array(); |
144 | - if (strlen($_POST['artist'])>0&&!empty($data[$_POST['artist']])) { |
|
145 | - foreach(explode(',', $data[$_POST['artist']]) as $artist) { |
|
146 | - $criteria = new Criteria('`name`', $artist); |
|
144 | + if (strlen($_POST['artist'])>0 && !empty($data[$_POST['artist']])) { |
|
145 | + foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
146 | + $criteria = new Criteria('`name`', $artist); |
|
147 | 147 | if ($artists_handler->getCount($criteria)>0) { |
148 | 148 | $objects = $artists_handler->getObjects($criteria, false); |
149 | 149 | $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
150 | 150 | } else { |
151 | 151 | $object = $artists_handler->create(); |
152 | 152 | $object->setVar('cid', $cid); |
153 | - switch($data[$_POST['singer']]) { |
|
153 | + switch ($data[$_POST['singer']]) { |
|
154 | 154 | case $_POST['duet']: |
155 | 155 | $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
156 | 156 | break; |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | $abid = 0; |
168 | - if (strlen($_POST['album'])>0&&!empty($data[$_POST['album']])) { |
|
169 | - $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
168 | + if (strlen($_POST['album'])>0 && !empty($data[$_POST['album']])) { |
|
169 | + $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
170 | 170 | if ($albums_handler->getCount($criteria)>0) { |
171 | 171 | $objects = $albums_handler->getObjects($criteria, false); |
172 | 172 | $abid = $objects[0]->getVar('aid'); |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | $sid = 0; |
182 | - if (strlen($_POST['songid'])>0&&!empty($data[$_POST['songid']])) { |
|
183 | - $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
182 | + if (strlen($_POST['songid'])>0 && !empty($data[$_POST['songid']])) { |
|
183 | + $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
184 | 184 | if ($songs_handler->getCount($criteria)>0) { |
185 | 185 | $objects = $songs_handler->getObjects($criteria, false); |
186 | 186 | $object = $objects[0]->getVar('sid'); |
187 | 187 | } else { |
188 | 188 | $object = $songs_handler->create(); |
189 | 189 | } |
190 | - if ($object->getVar('cid')>0&&$cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
191 | - if ($object->getVar('gid')>0&&$gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
192 | - if (count($object->getVar('aids'))>0&&count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
193 | - if ($object->getVar('abid')>0&&$abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
190 | + if ($object->getVar('cid')>0 && $cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
191 | + if ($object->getVar('gid')>0 && $gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
192 | + if (count($object->getVar('aids'))>0 && count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
193 | + if ($object->getVar('abid')>0 && $abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
194 | 194 | $object->setVar('songid', $data[$_POST['songid']]); |
195 | 195 | $object->setVar('title', $data[$_POST['title']]); |
196 | 196 | $object->setVar('lyrics', str_replace("\n", "<br/>\n", $data[$_POST['lyrics']])); |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | } else { |
202 | 202 | foreach ($xmlarray as $recid => $data) { |
203 | 203 | $gid = 0; |
204 | - if (strlen($_POST['genre'])>0&&!empty($data[$_POST['genre']])) { |
|
205 | - $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
204 | + if (strlen($_POST['genre'])>0 && !empty($data[$_POST['genre']])) { |
|
205 | + $criteria = new Criteria('`name`', $data[$_POST['genre']]); |
|
206 | 206 | if ($genre_handler->getCount($criteria)>0) { |
207 | 207 | $objects = $genre_handler->getObjects($criteria, false); |
208 | 208 | $gid = $objects[0]->getVar('gid'); |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | $vid = 0; |
216 | - if (strlen($_POST['voice'])>0&&!empty($data[$_POST['voice']])) { |
|
217 | - $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
216 | + if (strlen($_POST['voice'])>0 && !empty($data[$_POST['voice']])) { |
|
217 | + $criteria = new Criteria('`name`', $data[$_POST['voice']]); |
|
218 | 218 | if ($voice_handler->getCount($criteria)>0) { |
219 | 219 | $objects = $voice_handler->getObjects($criteria, false); |
220 | 220 | $gid = $objects[0]->getVar('vid'); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | } |
226 | 226 | } |
227 | 227 | $cid = 0; |
228 | - if (strlen($_POST['category'])>0&&!empty($data[$_POST['category']])) { |
|
229 | - $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
228 | + if (strlen($_POST['category'])>0 && !empty($data[$_POST['category']])) { |
|
229 | + $criteria = new Criteria('`name`', $data[$_POST['category']]); |
|
230 | 230 | if ($category_handler->getCount($criteria)>0) { |
231 | 231 | $objects = $category_handler->getObjects($criteria, false); |
232 | 232 | $cid = $objects[0]->getVar('cid'); |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | } |
238 | 238 | } |
239 | 239 | $aids = array(); |
240 | - if (strlen($_POST['artist'])>0&&!empty($data[$_POST['artist']])) { |
|
241 | - foreach(explode(',', $data[$_POST['artist']]) as $artist) { |
|
242 | - $criteria = new Criteria('`name`', $artist); |
|
240 | + if (strlen($_POST['artist'])>0 && !empty($data[$_POST['artist']])) { |
|
241 | + foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
242 | + $criteria = new Criteria('`name`', $artist); |
|
243 | 243 | if ($artists_handler->getCount($criteria)>0) { |
244 | 244 | $objects = $artists_handler->getObjects($criteria, false); |
245 | 245 | $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
246 | 246 | } else { |
247 | 247 | $object = $artists_handler->create(); |
248 | - switch($data[$_POST['singer']]) { |
|
248 | + switch ($data[$_POST['singer']]) { |
|
249 | 249 | case $_POST['duet']: |
250 | 250 | $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
251 | 251 | break; |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | $abid = 0; |
264 | - if (strlen($_POST['album'])>0&&!empty($data[$_POST['album']])) { |
|
265 | - $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
264 | + if (strlen($_POST['album'])>0 && !empty($data[$_POST['album']])) { |
|
265 | + $criteria = new Criteria('`name`', $data[$_POST['album']]); |
|
266 | 266 | if ($albums_handler->getCount($criteria)>0) { |
267 | 267 | $objects = $albums_handler->getObjects($criteria, false); |
268 | 268 | $abid = $objects[0]->getVar('aid'); |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | } |
276 | 276 | } |
277 | 277 | $sid = 0; |
278 | - if (strlen($_POST['songid'])>0&&!empty($data[$_POST['songid']])) { |
|
279 | - $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
278 | + if (strlen($_POST['songid'])>0 && !empty($data[$_POST['songid']])) { |
|
279 | + $criteria = new Criteria('`songid`', $data[$_POST['songid']]); |
|
280 | 280 | if ($songs_handler->getCount($criteria)>0) { |
281 | 281 | $objects = $songs_handler->getObjects($criteria, false); |
282 | 282 | $object = $objects[0]->getVar('sid'); |
283 | 283 | } else { |
284 | 284 | $object = $songs_handler->create(); |
285 | 285 | } |
286 | - if ($object->getVar('cid')>0&&$cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
287 | - if ($object->getVar('gid')>0&&$gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
288 | - if (count($object->getVar('aids'))>0&&count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
289 | - if ($object->getVar('abid')>0&&$abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
286 | + if ($object->getVar('cid')>0 && $cid>0) { $object->setVar('cid', $cid); } else { $object->setVar('cid', $cid); } |
|
287 | + if ($object->getVar('gid')>0 && $gid>0) { $object->setVar('gid', $gid); } else { $object->setVar('gid', $gid); } |
|
288 | + if (count($object->getVar('aids'))>0 && count($aids)>0) { $object->setVar('aids', $aids); } else { $object->setVar('aids', $aids); } |
|
289 | + if ($object->getVar('abid')>0 && $abid>0) { $object->setVar('abid', $abid); } else { $object->setVar('abid', $abid); } |
|
290 | 290 | $object->setVar('songid', $data[$_POST['songid']]); |
291 | 291 | $object->setVar('title', $data[$_POST['title']]); |
292 | 292 | $object->setVar('lyrics', str_replace("\n", "<br/>\n", $data[$_POST['lyrics']])); |
@@ -38,9 +38,10 @@ |
||
38 | 38 | if (isset($_FILES['xmlfile'])&&!empty($_FILES['xmlfile']['title'])) { |
39 | 39 | |
40 | 40 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
41 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
42 | - foreach(explode('/', $folders) as $folder) { |
|
41 | + foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
|
42 | + foreach(explode('/', $folders) as $folder) { |
|
43 | 43 | $path .= DS . $folder; |
44 | + } |
|
44 | 45 | mkdir($path, 0777); |
45 | 46 | } |
46 | 47 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | $GLOBALS['songlistModule'] = $module_handler->getByDirname('songlist'); |
5 | 5 | $GLOBALS['songlistModuleConfig'] = $config_handler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
6 | 6 | |
7 | -$i=0; |
|
7 | +$i = 0; |
|
8 | 8 | $adminmenu[$i]['title'] = _MI_SONGLIST_ADMENU_DASHBOARD; |
9 | 9 | $adminmenu[$i]['icon'] = '../../'.$GLOBALS['songlistModule']->getInfo('icons32').'/home.png'; |
10 | 10 | $adminmenu[$i]['image'] = '../../'.$GLOBALS['songlistModule']->getInfo('icons32').'/home.png'; |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | $filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1'; |
16 | 16 | |
17 | 17 | switch($op) { |
18 | - default: |
|
19 | - case "songs": |
|
20 | - switch ($fct) |
|
21 | - { |
|
18 | + default: |
|
19 | + case "songs": |
|
20 | + switch ($fct) |
|
21 | + { |
|
22 | 22 | default: |
23 | 23 | case "list": |
24 | 24 | $indexAdmin = new ModuleAdmin(); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | 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_SONGS_DELETE, $songs->getVar('name'))); |
225 | 225 | } |
226 | 226 | break; |
227 | - } |
|
227 | + } |
|
228 | 228 | break; |
229 | 229 | |
230 | 230 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | xoops_cp_header(); |
8 | 8 | |
9 | - $op = isset($_REQUEST['op'])?$_REQUEST['op']:"songs"; |
|
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'; |
|
9 | + $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "songs"; |
|
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 | 16 | |
17 | - switch($op) { |
|
17 | + switch ($op) { |
|
18 | 18 | default: |
19 | 19 | case "songs": |
20 | 20 | switch ($fct) |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $indexAdmin = new ModuleAdmin(); |
25 | 25 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
26 | 26 | |
27 | - $songs_handler =& xoops_getmodulehandler('songs', 'songlist'); |
|
27 | + $songs_handler = & xoops_getmodulehandler('songs', 'songlist'); |
|
28 | 28 | |
29 | 29 | $criteria = $songs_handler->getFilterCriteria($GLOBALS['filter']); |
30 | 30 | $ttl = $songs_handler->getCount($criteria); |
31 | - $GLOBALS['sort'] = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created'; |
|
31 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
32 | 32 | |
33 | 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 | 34 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
35 | 35 | |
36 | 36 | foreach ($songs_handler->filterFields() as $id => $key) { |
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', $songs_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
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', $songs_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $criteria->setOrder($GLOBALS['order']); |
52 | 52 | |
53 | 53 | $songss = $songs_handler->getObjects($criteria, true); |
54 | - foreach($songss as $cid => $songs) { |
|
54 | + foreach ($songss as $cid => $songs) { |
|
55 | 55 | if (is_object($songs)) |
56 | 56 | $GLOBALS['xoopsTpl']->append('songs', $songs->toArray()); |
57 | 57 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | $indexAdmin = new ModuleAdmin(); |
67 | 67 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
68 | 68 | |
69 | - include_once $GLOBALS['xoops']->path( "/class/pagenav.php" ); |
|
69 | + include_once $GLOBALS['xoops']->path("/class/pagenav.php"); |
|
70 | 70 | |
71 | - $songs_handler =& xoops_getmodulehandler('songs', 'songlist'); |
|
71 | + $songs_handler = & xoops_getmodulehandler('songs', 'songlist'); |
|
72 | 72 | if (isset($_REQUEST['id'])) { |
73 | 73 | $songs = $songs_handler->get(intval($_REQUEST['id'])); |
74 | 74 | } else { |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | break; |
82 | 82 | case "save": |
83 | 83 | |
84 | - $songs_handler =& xoops_getmodulehandler('songs', 'songlist'); |
|
84 | + $songs_handler = & xoops_getmodulehandler('songs', 'songlist'); |
|
85 | 85 | $extras_handler = xoops_getmodulehandler('extras', 'songlist'); |
86 | - $id=0; |
|
87 | - if ($id=intval($_REQUEST['id'])) { |
|
86 | + $id = 0; |
|
87 | + if ($id = intval($_REQUEST['id'])) { |
|
88 | 88 | $songs = $songs_handler->get($id); |
89 | 89 | } else { |
90 | 90 | $songs = $songs_handler->create(); |
91 | 91 | } |
92 | 92 | $songs->setVars($_POST[$id]); |
93 | 93 | |
94 | - if (isset($_FILES['mp3'.$id])&&!empty($_FILES['mp3'.$id]['title'])) { |
|
94 | + if (isset($_FILES['mp3'.$id]) && !empty($_FILES['mp3'.$id]['title'])) { |
|
95 | 95 | |
96 | 96 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
97 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
98 | - foreach(explode('/', $folders) as $folder) { |
|
99 | - $path .= DS . $folder; |
|
97 | + foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
98 | + foreach (explode('/', $folders) as $folder) { |
|
99 | + $path .= DS.$folder; |
|
100 | 100 | mkdir($path, 0777); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | include_once($GLOBALS['xoops']->path('modules/songlist/include/uploader.php')); |
105 | 105 | $uploader = new SonglistMediaUploader($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), $GLOBALS['songlistModuleConfig']['mp3_filesize'], 0, 0, explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions'])); |
106 | - $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0,20), 13)); |
|
106 | + $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0, 20), 13)); |
|
107 | 107 | |
108 | 108 | if ($uploader->fetchMedia('mp3'.$id)) { |
109 | 109 | if (!$uploader->upload()) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | exit(0); |
131 | 131 | } |
132 | 132 | } |
133 | - if (!$id=$songs_handler->insert($songs)) { |
|
133 | + if (!$id = $songs_handler->insert($songs)) { |
|
134 | 134 | 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_SONGS_FAILEDTOSAVE); |
135 | 135 | exit(0); |
136 | 136 | } else { |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | $extra->setVar('sid', $id); |
140 | 140 | $extras_handler->insert($extra); |
141 | 141 | |
142 | - if ($GLOBALS['songlistModuleConfig']['tags']&&file_exists(XOOPS_ROOT_PATH . '/modules/tag/class/tag.php')) { |
|
142 | + if ($GLOBALS['songlistModuleConfig']['tags'] && file_exists(XOOPS_ROOT_PATH.'/modules/tag/class/tag.php')) { |
|
143 | 143 | $tag_handler = xoops_getmodulehandler('tag', 'tag'); |
144 | 144 | $tag_handler->updateByItem($_POST['tags'], $id, $GLOBALS['songlistModule']->getVar("dirname"), $songs->getVar('cid')); |
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | 148 | if ($_REQUEST['state'][$_REQUEST['id']]=='new') |
149 | - 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_SONGS_SAVEDOKEY); |
|
149 | + 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_SONGS_SAVEDOKEY); |
|
150 | 150 | else |
151 | 151 | 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_SONGS_SAVEDOKEY); |
152 | 152 | exit(0); |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | case "savelist": |
156 | 156 | print_r($_FILES); |
157 | 157 | exit; |
158 | - $songs_handler =& xoops_getmodulehandler('songs', 'songlist'); |
|
159 | - foreach($_REQUEST['id'] as $id) { |
|
158 | + $songs_handler = & xoops_getmodulehandler('songs', 'songlist'); |
|
159 | + foreach ($_REQUEST['id'] as $id) { |
|
160 | 160 | $songs = $songs_handler->get($id); |
161 | 161 | $songs->setVars($_POST[$id]); |
162 | - if (isset($_FILES['mp3'.$id])&&!empty($_FILES['mp3'.$id]['title'])) { |
|
162 | + if (isset($_FILES['mp3'.$id]) && !empty($_FILES['mp3'.$id]['title'])) { |
|
163 | 163 | |
164 | 164 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
165 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
166 | - foreach(explode('/', $folders) as $folder) { |
|
167 | - $path .= DS . $folder; |
|
165 | + foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
166 | + foreach (explode('/', $folders) as $folder) { |
|
167 | + $path .= DS.$folder; |
|
168 | 168 | mkdir($path, 0777); |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | include_once($GLOBALS['xoops']->path('modules/songlist/include/uploader.php')); |
173 | 173 | $uploader = new SonglistMediaUploader($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), $GLOBALS['songlistModuleConfig']['mp3_filesize'], 0, 0, explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions'])); |
174 | - $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0,20), 13)); |
|
174 | + $uploader->setPrefix(substr(md5(microtime(true)), mt_rand(0, 20), 13)); |
|
175 | 175 | |
176 | 176 | if ($uploader->fetchMedia('mp3'.$id)) { |
177 | 177 | if (!$uploader->upload()) { |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | break; |
209 | 209 | case "delete": |
210 | 210 | |
211 | - $songs_handler =& xoops_getmodulehandler('songs', 'songlist'); |
|
212 | - $id=0; |
|
213 | - if (isset($_POST['id'])&&$id=intval($_POST['id'])) { |
|
211 | + $songs_handler = & xoops_getmodulehandler('songs', 'songlist'); |
|
212 | + $id = 0; |
|
213 | + if (isset($_POST['id']) && $id = intval($_POST['id'])) { |
|
214 | 214 | $songs = $songs_handler->get($id); |
215 | 215 | if (!$songs_handler->delete($songs)) { |
216 | 216 | 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_SONGS_FAILEDTODELETE); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $songss = $songs_handler->getObjects($criteria, true); |
54 | 54 | foreach($songss as $cid => $songs) { |
55 | - if (is_object($songs)) |
|
56 | - $GLOBALS['xoopsTpl']->append('songs', $songs->toArray()); |
|
55 | + if (is_object($songs)) { |
|
56 | + $GLOBALS['xoopsTpl']->append('songs', $songs->toArray()); |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | $GLOBALS['xoopsTpl']->assign('form', songlist_songs_get_form(false)); |
59 | 60 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']); |
@@ -94,9 +95,10 @@ discard block |
||
94 | 95 | if (isset($_FILES['mp3'.$id])&&!empty($_FILES['mp3'.$id]['title'])) { |
95 | 96 | |
96 | 97 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
97 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
98 | - foreach(explode('/', $folders) as $folder) { |
|
98 | + foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
|
99 | + foreach(explode('/', $folders) as $folder) { |
|
99 | 100 | $path .= DS . $folder; |
101 | + } |
|
100 | 102 | mkdir($path, 0777); |
101 | 103 | } |
102 | 104 | } |
@@ -115,8 +117,9 @@ discard block |
||
115 | 117 | exit(0); |
116 | 118 | } else { |
117 | 119 | |
118 | - if (strlen($songs->getVar('mp3'))) |
|
119 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
120 | + if (strlen($songs->getVar('mp3'))) { |
|
121 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | $songs->setVar('mp3', XOOPS_URL.'/'.str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']).$uploader->getSavedFileName()); |
122 | 125 | |
@@ -145,10 +148,11 @@ discard block |
||
145 | 148 | } |
146 | 149 | |
147 | 150 | |
148 | - if ($_REQUEST['state'][$_REQUEST['id']]=='new') |
|
149 | - 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_SONGS_SAVEDOKEY); |
|
150 | - else |
|
151 | - 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_SONGS_SAVEDOKEY); |
|
151 | + if ($_REQUEST['state'][$_REQUEST['id']]=='new') { |
|
152 | + 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_SONGS_SAVEDOKEY); |
|
153 | + } else { |
|
154 | + 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_SONGS_SAVEDOKEY); |
|
155 | + } |
|
152 | 156 | exit(0); |
153 | 157 | } |
154 | 158 | break; |
@@ -162,9 +166,10 @@ discard block |
||
162 | 166 | if (isset($_FILES['mp3'.$id])&&!empty($_FILES['mp3'.$id]['title'])) { |
163 | 167 | |
164 | 168 | if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
165 | - foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) |
|
166 | - foreach(explode('/', $folders) as $folder) { |
|
169 | + foreach(explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
|
170 | + foreach(explode('/', $folders) as $folder) { |
|
167 | 171 | $path .= DS . $folder; |
172 | + } |
|
168 | 173 | mkdir($path, 0777); |
169 | 174 | } |
170 | 175 | } |
@@ -183,8 +188,9 @@ discard block |
||
183 | 188 | exit(0); |
184 | 189 | } else { |
185 | 190 | |
186 | - if (strlen($songs->getVar('mp3'))) |
|
187 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
191 | + if (strlen($songs->getVar('mp3'))) { |
|
192 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
193 | + } |
|
188 | 194 | |
189 | 195 | $songs->setVar('mp3', XOOPS_URL.'/'.str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']).$uploader->getSavedFileName()); |
190 | 196 |
@@ -8,289 +8,289 @@ |
||
8 | 8 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? "edit" : 'list'))); |
9 | 9 | $field_handler = xoops_getmodulehandler('field', 'songlist'); |
10 | 10 | switch( $op ) { |
11 | -default: |
|
12 | -case "list": |
|
13 | - $indexAdmin = new ModuleAdmin(); |
|
14 | - echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
11 | + default: |
|
12 | + case "list": |
|
13 | + $indexAdmin = new ModuleAdmin(); |
|
14 | + echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
15 | 15 | |
16 | - $fields = $field_handler->getObjects(NULL, false, false); |
|
16 | + $fields = $field_handler->getObjects(NULL, false, false); |
|
17 | 17 | |
18 | - $module_handler = xoops_gethandler('module'); |
|
19 | - $modules = $module_handler->getObjects(null, true); |
|
18 | + $module_handler = xoops_gethandler('module'); |
|
19 | + $modules = $module_handler->getObjects(null, true); |
|
20 | 20 | |
21 | - $categories = array(); |
|
22 | - $weights = array(); |
|
21 | + $categories = array(); |
|
22 | + $weights = array(); |
|
23 | 23 | |
24 | - $GLOBALS['categoryHandler'] = xoops_getmodulehandler('category'); |
|
25 | - $criteria = new CriteriaCompo(); |
|
26 | - $criteria->setSort('weight'); |
|
27 | - if ($categorys = $GLOBALS['categoryHandler']->getObjects($criteria, true)) { |
|
28 | - unset($criteria); |
|
24 | + $GLOBALS['categoryHandler'] = xoops_getmodulehandler('category'); |
|
25 | + $criteria = new CriteriaCompo(); |
|
26 | + $criteria->setSort('weight'); |
|
27 | + if ($categorys = $GLOBALS['categoryHandler']->getObjects($criteria, true)) { |
|
28 | + unset($criteria); |
|
29 | 29 | |
30 | - $categories[0] = array('cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT); |
|
31 | - if ( count($categorys) > 0 ) { |
|
32 | - foreach (array_keys($categorys) as $i ) { |
|
33 | - $categories[$categorys[$i]->getVar('cid')] = array('cid' => $categorys[$i]->getVar('cid'), 'name' => $categorys[$i]->getVar('name')); |
|
30 | + $categories[0] = array('cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT); |
|
31 | + if ( count($categorys) > 0 ) { |
|
32 | + foreach (array_keys($categorys) as $i ) { |
|
33 | + $categories[$categorys[$i]->getVar('cid')] = array('cid' => $categorys[$i]->getVar('cid'), 'name' => $categorys[$i]->getVar('name')); |
|
34 | + } |
|
34 | 35 | } |
36 | + $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
35 | 37 | } |
36 | - $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
37 | - } |
|
38 | 38 | |
39 | - $valuetypes = array(XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
40 | - XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
41 | - XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
42 | - XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
43 | - XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
44 | - XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
45 | - XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
46 | - XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE); |
|
39 | + $valuetypes = array(XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
40 | + XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
41 | + XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
42 | + XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
43 | + XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
44 | + XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
45 | + XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
46 | + XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE); |
|
47 | 47 | |
48 | - $fieldtypes = array('checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
49 | - 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
50 | - 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
51 | - 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
52 | - 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
53 | - 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
54 | - 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
55 | - 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
56 | - 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
57 | - 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
58 | - 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
59 | - 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
60 | - 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
61 | - 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
62 | - 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
63 | - 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
64 | - 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
65 | - 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
66 | - 'rank' => _AM_SONGLIST_FIELDS_RANK); |
|
48 | + $fieldtypes = array('checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
49 | + 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
50 | + 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
51 | + 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
52 | + 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
53 | + 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
54 | + 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
55 | + 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
56 | + 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
57 | + 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
58 | + 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
59 | + 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
60 | + 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
61 | + 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
62 | + 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
63 | + 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
64 | + 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
65 | + 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
66 | + 'rank' => _AM_SONGLIST_FIELDS_RANK); |
|
67 | 67 | |
68 | - foreach (array_keys($fields) as $i ) { |
|
69 | - $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
70 | - $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
71 | - $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
72 | - $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
73 | - $fieldcategories[$i][] = $fields[$i]; |
|
74 | - $weights[$i] = $fields[$i]['field_weight']; |
|
75 | - } |
|
76 | - //sort fields order in categories |
|
77 | - foreach (array_keys($fields) as $i ) { |
|
78 | - array_multisort($weights[$i], SORT_ASC, array_keys($fieldcategories[$i]), SORT_ASC, $categories[$i]); |
|
79 | - } |
|
80 | - ksort($categories); |
|
81 | - $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
82 | - $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML() ); |
|
83 | - $template_main = "songlist_cpanel_fieldlist.html"; |
|
84 | - break; |
|
68 | + foreach (array_keys($fields) as $i ) { |
|
69 | + $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
70 | + $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
71 | + $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
72 | + $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
73 | + $fieldcategories[$i][] = $fields[$i]; |
|
74 | + $weights[$i] = $fields[$i]['field_weight']; |
|
75 | + } |
|
76 | + //sort fields order in categories |
|
77 | + foreach (array_keys($fields) as $i ) { |
|
78 | + array_multisort($weights[$i], SORT_ASC, array_keys($fieldcategories[$i]), SORT_ASC, $categories[$i]); |
|
79 | + } |
|
80 | + ksort($categories); |
|
81 | + $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
82 | + $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML() ); |
|
83 | + $template_main = "songlist_cpanel_fieldlist.html"; |
|
84 | + break; |
|
85 | 85 | |
86 | -case "new": |
|
86 | + case "new": |
|
87 | 87 | |
88 | - $indexAdmin = new ModuleAdmin(); |
|
89 | - echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
90 | - $obj = $field_handler->create(); |
|
91 | - $form = songlist_getFieldForm($obj); |
|
92 | - $form->display(); |
|
93 | - break; |
|
88 | + $indexAdmin = new ModuleAdmin(); |
|
89 | + echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
90 | + $obj = $field_handler->create(); |
|
91 | + $form = songlist_getFieldForm($obj); |
|
92 | + $form->display(); |
|
93 | + break; |
|
94 | 94 | |
95 | -case "edit": |
|
95 | + case "edit": |
|
96 | 96 | |
97 | - $indexAdmin = new ModuleAdmin(); |
|
98 | - echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
99 | - $obj = $field_handler->get($_REQUEST['id']); |
|
100 | - if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
101 | - redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
102 | - } |
|
103 | - $form = songlist_getFieldForm($obj); |
|
104 | - $form->display(); |
|
105 | - break; |
|
97 | + $indexAdmin = new ModuleAdmin(); |
|
98 | + echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
99 | + $obj = $field_handler->get($_REQUEST['id']); |
|
100 | + if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
101 | + redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
102 | + } |
|
103 | + $form = songlist_getFieldForm($obj); |
|
104 | + $form->display(); |
|
105 | + break; |
|
106 | 106 | |
107 | -case "reorder": |
|
107 | + case "reorder": |
|
108 | 108 | |
109 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
110 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
111 | - } |
|
112 | - |
|
113 | - if ( isset($_POST['field_ids']) && count($_POST['field_ids']) > 0 ) { |
|
114 | - $oldweight = $_POST['oldweight']; |
|
115 | - $oldcat = $_POST['oldcat']; |
|
116 | - $oldcategories = $_POST['oldcategories']; |
|
117 | - $categories = $_POST['categories']; |
|
118 | - $weight = $_POST['weight']; |
|
119 | - $ids = array(); |
|
120 | - foreach ($_POST['field_ids'] as $field_id ) { |
|
121 | - if ( $oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id]))) ) { |
|
122 | - //if field has changed |
|
123 | - $ids[] = intval($field_id); |
|
124 | - } |
|
109 | + if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
110 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
125 | 111 | } |
126 | - if ( count($ids) > 0 ) { |
|
127 | - $errors = array(); |
|
128 | - //if there are changed fields, fetch the fieldcategory objects |
|
129 | - $field_handler = xoops_getmodulehandler('field'); |
|
130 | - $fields = $field_handler->getObjects(new Criteria('field_id', "(" . implode(',', $ids) . ")", "IN"), true); |
|
131 | - foreach ($ids as $i ) { |
|
132 | - $fields[$i]->setVar('field_weight', intval($weight[$i]) ); |
|
133 | - $fields[$i]->setVar('cids', $categories[$i] ); |
|
134 | - if ( !$field_handler->insert($fields[$i]) ) { |
|
135 | - $errors = array_merge($errors, $fields[$i]->getErrors() ); |
|
112 | + |
|
113 | + if ( isset($_POST['field_ids']) && count($_POST['field_ids']) > 0 ) { |
|
114 | + $oldweight = $_POST['oldweight']; |
|
115 | + $oldcat = $_POST['oldcat']; |
|
116 | + $oldcategories = $_POST['oldcategories']; |
|
117 | + $categories = $_POST['categories']; |
|
118 | + $weight = $_POST['weight']; |
|
119 | + $ids = array(); |
|
120 | + foreach ($_POST['field_ids'] as $field_id ) { |
|
121 | + if ( $oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id]))) ) { |
|
122 | + //if field has changed |
|
123 | + $ids[] = intval($field_id); |
|
136 | 124 | } |
137 | 125 | } |
138 | - if ( count($errors) == 0 ) { |
|
139 | - //no errors |
|
140 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
141 | - } else { |
|
142 | - redirect_header('field.php', 3, implode('<br />', $errors) ); |
|
126 | + if ( count($ids) > 0 ) { |
|
127 | + $errors = array(); |
|
128 | + //if there are changed fields, fetch the fieldcategory objects |
|
129 | + $field_handler = xoops_getmodulehandler('field'); |
|
130 | + $fields = $field_handler->getObjects(new Criteria('field_id', "(" . implode(',', $ids) . ")", "IN"), true); |
|
131 | + foreach ($ids as $i ) { |
|
132 | + $fields[$i]->setVar('field_weight', intval($weight[$i]) ); |
|
133 | + $fields[$i]->setVar('cids', $categories[$i] ); |
|
134 | + if ( !$field_handler->insert($fields[$i]) ) { |
|
135 | + $errors = array_merge($errors, $fields[$i]->getErrors() ); |
|
136 | + } |
|
137 | + } |
|
138 | + if ( count($errors) == 0 ) { |
|
139 | + //no errors |
|
140 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
141 | + } else { |
|
142 | + redirect_header('field.php', 3, implode('<br />', $errors) ); |
|
143 | + } |
|
143 | 144 | } |
144 | 145 | } |
145 | - } |
|
146 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
147 | - break; |
|
146 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
147 | + break; |
|
148 | 148 | |
149 | -case "save": |
|
150 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
151 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
152 | - } |
|
153 | - $redirect_to_edit = false; |
|
154 | - if ( isset($_REQUEST['id']) ) { |
|
155 | - $obj = $field_handler->get($_REQUEST['id']); |
|
156 | - if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
157 | - redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
158 | - } |
|
159 | - } else { |
|
160 | - $obj = $field_handler->create(); |
|
161 | - $obj->setVar('field_name', $_REQUEST['field_name']); |
|
162 | - $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
163 | - $obj->setVar('field_show', 1); |
|
164 | - $obj->setVar('field_edit', 1); |
|
165 | - $obj->setVar('field_config', 1); |
|
166 | - $redirect_to_edit = true; |
|
167 | - } |
|
168 | - $obj->setVar('field_title', $_REQUEST['field_title']); |
|
169 | - $obj->setVar('field_description', $_REQUEST['field_description']); |
|
170 | - if ( $obj->getVar('field_config') ) { |
|
171 | - $obj->setVar('field_type', $_REQUEST['field_type']); |
|
172 | - if ( isset($_REQUEST['field_valuetype']) ) { |
|
173 | - $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
149 | + case "save": |
|
150 | + if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
151 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
174 | 152 | } |
175 | - $options = $obj->getVar('field_options'); |
|
176 | - |
|
177 | - if ( isset($_REQUEST['removeOptions']) && is_array($_REQUEST['removeOptions']) ) { |
|
178 | - foreach ($_REQUEST['removeOptions'] as $index ) { |
|
179 | - unset($options[$index]); |
|
153 | + $redirect_to_edit = false; |
|
154 | + if ( isset($_REQUEST['id']) ) { |
|
155 | + $obj = $field_handler->get($_REQUEST['id']); |
|
156 | + if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
157 | + redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
180 | 158 | } |
159 | + } else { |
|
160 | + $obj = $field_handler->create(); |
|
161 | + $obj->setVar('field_name', $_REQUEST['field_name']); |
|
162 | + $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
163 | + $obj->setVar('field_show', 1); |
|
164 | + $obj->setVar('field_edit', 1); |
|
165 | + $obj->setVar('field_config', 1); |
|
181 | 166 | $redirect_to_edit = true; |
182 | 167 | } |
168 | + $obj->setVar('field_title', $_REQUEST['field_title']); |
|
169 | + $obj->setVar('field_description', $_REQUEST['field_description']); |
|
170 | + if ( $obj->getVar('field_config') ) { |
|
171 | + $obj->setVar('field_type', $_REQUEST['field_type']); |
|
172 | + if ( isset($_REQUEST['field_valuetype']) ) { |
|
173 | + $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
174 | + } |
|
175 | + $options = $obj->getVar('field_options'); |
|
183 | 176 | |
184 | - if ( !empty($_REQUEST['addOption']) ) { |
|
185 | - foreach ($_REQUEST['addOption'] as $option ) { |
|
186 | - if ( empty($option['value']) ) continue; |
|
187 | - $options[$option['key']] = $option['value']; |
|
177 | + if ( isset($_REQUEST['removeOptions']) && is_array($_REQUEST['removeOptions']) ) { |
|
178 | + foreach ($_REQUEST['removeOptions'] as $index ) { |
|
179 | + unset($options[$index]); |
|
180 | + } |
|
188 | 181 | $redirect_to_edit = true; |
189 | 182 | } |
183 | + |
|
184 | + if ( !empty($_REQUEST['addOption']) ) { |
|
185 | + foreach ($_REQUEST['addOption'] as $option ) { |
|
186 | + if ( empty($option['value']) ) continue; |
|
187 | + $options[$option['key']] = $option['value']; |
|
188 | + $redirect_to_edit = true; |
|
189 | + } |
|
190 | + } |
|
191 | + $obj->setVar('field_options', $options); |
|
190 | 192 | } |
191 | - $obj->setVar('field_options', $options); |
|
192 | - } |
|
193 | - if ( $obj->getVar('field_edit') ) { |
|
194 | - $required = isset($_REQUEST['field_required']) ? $_REQUEST['field_required'] : 0; |
|
195 | - $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
196 | - if ( isset($_REQUEST['field_maxlength']) ) { |
|
197 | - $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
198 | - } |
|
199 | - if ( isset($_REQUEST['field_default']) ) { |
|
200 | - $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
201 | - //Check for multiple selections |
|
202 | - if ( is_array($field_default) ) { |
|
203 | - $obj->setVar('field_default', serialize($field_default) ); |
|
204 | - } else { |
|
205 | - $obj->setVar('field_default', $field_default); |
|
193 | + if ( $obj->getVar('field_edit') ) { |
|
194 | + $required = isset($_REQUEST['field_required']) ? $_REQUEST['field_required'] : 0; |
|
195 | + $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
196 | + if ( isset($_REQUEST['field_maxlength']) ) { |
|
197 | + $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
198 | + } |
|
199 | + if ( isset($_REQUEST['field_default']) ) { |
|
200 | + $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
201 | + //Check for multiple selections |
|
202 | + if ( is_array($field_default) ) { |
|
203 | + $obj->setVar('field_default', serialize($field_default) ); |
|
204 | + } else { |
|
205 | + $obj->setVar('field_default', $field_default); |
|
206 | + } |
|
206 | 207 | } |
207 | 208 | } |
208 | - } |
|
209 | 209 | |
210 | - $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
211 | - $obj->setVar('cids', $_REQUEST['cids']); |
|
210 | + $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
211 | + $obj->setVar('cids', $_REQUEST['cids']); |
|
212 | 212 | |
213 | - if ( $field_handler->insert($obj) ) { |
|
213 | + if ( $field_handler->insert($obj) ) { |
|
214 | 214 | |
215 | - $groupperm_handler = xoops_gethandler('groupperm'); |
|
215 | + $groupperm_handler = xoops_gethandler('groupperm'); |
|
216 | 216 | |
217 | - $perm_arr = array(); |
|
218 | - if ( $obj->getVar('field_show') ) { |
|
219 | - $perm_arr[] = 'songlist_show'; |
|
220 | - $perm_arr[] = 'songlist_visible'; |
|
221 | - } |
|
222 | - if ( $obj->getVar('field_edit') ) { |
|
223 | - $perm_arr[] = 'songlist_edit'; |
|
224 | - } |
|
225 | - if ( $obj->getVar('field_edit') || $obj->getVar('field_show') ) { |
|
226 | - $perm_arr[] = 'songlist_search'; |
|
227 | - } |
|
228 | - if ( count($perm_arr) > 0 ) { |
|
229 | - foreach ($perm_arr as $perm ) { |
|
230 | - $criteria = new CriteriaCompo(new Criteria('gperm_name', $perm) ); |
|
231 | - $criteria->add(new Criteria('gperm_itemid', intval($obj->getVar('field_id') )) ); |
|
232 | - $criteria->add(new Criteria('gperm_modid', intval($GLOBALS['songlistModule']->getVar('mid') )) ); |
|
233 | - if ( isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm]) ) { |
|
234 | - $perms = $groupperm_handler->getObjects($criteria); |
|
235 | - if ( count($perms) > 0 ) { |
|
236 | - foreach (array_keys($perms) as $i ) { |
|
237 | - $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
217 | + $perm_arr = array(); |
|
218 | + if ( $obj->getVar('field_show') ) { |
|
219 | + $perm_arr[] = 'songlist_show'; |
|
220 | + $perm_arr[] = 'songlist_visible'; |
|
221 | + } |
|
222 | + if ( $obj->getVar('field_edit') ) { |
|
223 | + $perm_arr[] = 'songlist_edit'; |
|
224 | + } |
|
225 | + if ( $obj->getVar('field_edit') || $obj->getVar('field_show') ) { |
|
226 | + $perm_arr[] = 'songlist_search'; |
|
227 | + } |
|
228 | + if ( count($perm_arr) > 0 ) { |
|
229 | + foreach ($perm_arr as $perm ) { |
|
230 | + $criteria = new CriteriaCompo(new Criteria('gperm_name', $perm) ); |
|
231 | + $criteria->add(new Criteria('gperm_itemid', intval($obj->getVar('field_id') )) ); |
|
232 | + $criteria->add(new Criteria('gperm_modid', intval($GLOBALS['songlistModule']->getVar('mid') )) ); |
|
233 | + if ( isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm]) ) { |
|
234 | + $perms = $groupperm_handler->getObjects($criteria); |
|
235 | + if ( count($perms) > 0 ) { |
|
236 | + foreach (array_keys($perms) as $i ) { |
|
237 | + $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
238 | + } |
|
239 | + } else { |
|
240 | + $groups = array(); |
|
238 | 241 | } |
239 | - } else { |
|
240 | - $groups = array(); |
|
241 | - } |
|
242 | - foreach ($_REQUEST[$perm] as $grouoid ) { |
|
243 | - $grouoid = intval($grouoid); |
|
244 | - if ( !isset($groups[$grouoid]) ) { |
|
245 | - $perm_obj = $groupperm_handler->create(); |
|
246 | - $perm_obj->setVar('gperm_name', $perm); |
|
247 | - $perm_obj->setVar('gperm_itemid', intval($obj->getVar('field_id') )); |
|
248 | - $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
249 | - $perm_obj->setVar('gperm_groupid', $grouoid); |
|
250 | - $groupperm_handler->insert($perm_obj); |
|
251 | - unset($perm_obj); |
|
242 | + foreach ($_REQUEST[$perm] as $grouoid ) { |
|
243 | + $grouoid = intval($grouoid); |
|
244 | + if ( !isset($groups[$grouoid]) ) { |
|
245 | + $perm_obj = $groupperm_handler->create(); |
|
246 | + $perm_obj->setVar('gperm_name', $perm); |
|
247 | + $perm_obj->setVar('gperm_itemid', intval($obj->getVar('field_id') )); |
|
248 | + $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
249 | + $perm_obj->setVar('gperm_groupid', $grouoid); |
|
250 | + $groupperm_handler->insert($perm_obj); |
|
251 | + unset($perm_obj); |
|
252 | + } |
|
252 | 253 | } |
253 | - } |
|
254 | - $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
255 | - if ( count($removed_groups) > 0 ) { |
|
256 | - $criteria->add(new Criteria('gperm_groupid', "(".implode(',', $removed_groups).")", "IN") ); |
|
254 | + $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
255 | + if ( count($removed_groups) > 0 ) { |
|
256 | + $criteria->add(new Criteria('gperm_groupid', "(".implode(',', $removed_groups).")", "IN") ); |
|
257 | + $groupperm_handler->deleteAll($criteria); |
|
258 | + } |
|
259 | + unset($groups); |
|
260 | + |
|
261 | + } else { |
|
257 | 262 | $groupperm_handler->deleteAll($criteria); |
258 | 263 | } |
259 | - unset($groups); |
|
260 | - |
|
261 | - } else { |
|
262 | - $groupperm_handler->deleteAll($criteria); |
|
264 | + unset($criteria); |
|
263 | 265 | } |
264 | - unset($criteria); |
|
265 | 266 | } |
267 | + $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
268 | + redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
266 | 269 | } |
267 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
268 | - redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
269 | - } |
|
270 | 270 | |
271 | - echo $obj->getHtmlErrors(); |
|
272 | - $form = songlist_getFieldForm($obj); |
|
273 | - $form->display(); |
|
274 | - break; |
|
271 | + echo $obj->getHtmlErrors(); |
|
272 | + $form = songlist_getFieldForm($obj); |
|
273 | + $form->display(); |
|
274 | + break; |
|
275 | 275 | |
276 | -case "delete": |
|
277 | - $obj = $field_handler->get($_REQUEST['id']); |
|
278 | - if ( !$obj->getVar('field_config') ) { |
|
279 | - redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
280 | - } |
|
281 | - if ( isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1 ) { |
|
282 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
283 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
276 | + case "delete": |
|
277 | + $obj = $field_handler->get($_REQUEST['id']); |
|
278 | + if ( !$obj->getVar('field_config') ) { |
|
279 | + redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
284 | 280 | } |
285 | - if ( $field_handler->delete($obj) ) { |
|
286 | - redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
281 | + if ( isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1 ) { |
|
282 | + if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
283 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
284 | + } |
|
285 | + if ( $field_handler->delete($obj) ) { |
|
286 | + redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
287 | + } else { |
|
288 | + echo $obj->getHtmlErrors(); |
|
289 | + } |
|
287 | 290 | } else { |
288 | - echo $obj->getHtmlErrors(); |
|
291 | + xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title') )); |
|
289 | 292 | } |
290 | - } else { |
|
291 | - xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title') )); |
|
292 | - } |
|
293 | - break; |
|
293 | + break; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | if ( isset($template_main) ) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? "edit" : 'list'))); |
9 | 9 | $field_handler = xoops_getmodulehandler('field', 'songlist'); |
10 | -switch( $op ) { |
|
10 | +switch ($op) { |
|
11 | 11 | default: |
12 | 12 | case "list": |
13 | 13 | $indexAdmin = new ModuleAdmin(); |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | unset($criteria); |
29 | 29 | |
30 | 30 | $categories[0] = array('cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT); |
31 | - if ( count($categorys) > 0 ) { |
|
32 | - foreach (array_keys($categorys) as $i ) { |
|
31 | + if (count($categorys)>0) { |
|
32 | + foreach (array_keys($categorys) as $i) { |
|
33 | 33 | $categories[$categorys[$i]->getVar('cid')] = array('cid' => $categorys[$i]->getVar('cid'), 'name' => $categorys[$i]->getVar('name')); |
34 | 34 | } |
35 | 35 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
66 | 66 | 'rank' => _AM_SONGLIST_FIELDS_RANK); |
67 | 67 | |
68 | - foreach (array_keys($fields) as $i ) { |
|
68 | + foreach (array_keys($fields) as $i) { |
|
69 | 69 | $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
70 | 70 | $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
71 | 71 | $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | $weights[$i] = $fields[$i]['field_weight']; |
75 | 75 | } |
76 | 76 | //sort fields order in categories |
77 | - foreach (array_keys($fields) as $i ) { |
|
77 | + foreach (array_keys($fields) as $i) { |
|
78 | 78 | array_multisort($weights[$i], SORT_ASC, array_keys($fieldcategories[$i]), SORT_ASC, $categories[$i]); |
79 | 79 | } |
80 | 80 | ksort($categories); |
81 | 81 | $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
82 | - $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML() ); |
|
82 | + $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
83 | 83 | $template_main = "songlist_cpanel_fieldlist.html"; |
84 | 84 | break; |
85 | 85 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $indexAdmin = new ModuleAdmin(); |
98 | 98 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
99 | 99 | $obj = $field_handler->get($_REQUEST['id']); |
100 | - if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
100 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
101 | 101 | redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
102 | 102 | } |
103 | 103 | $form = songlist_getFieldForm($obj); |
@@ -106,60 +106,60 @@ discard block |
||
106 | 106 | |
107 | 107 | case "reorder": |
108 | 108 | |
109 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
110 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
109 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
110 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
111 | 111 | } |
112 | 112 | |
113 | - if ( isset($_POST['field_ids']) && count($_POST['field_ids']) > 0 ) { |
|
113 | + if (isset($_POST['field_ids']) && count($_POST['field_ids'])>0) { |
|
114 | 114 | $oldweight = $_POST['oldweight']; |
115 | 115 | $oldcat = $_POST['oldcat']; |
116 | 116 | $oldcategories = $_POST['oldcategories']; |
117 | 117 | $categories = $_POST['categories']; |
118 | 118 | $weight = $_POST['weight']; |
119 | 119 | $ids = array(); |
120 | - foreach ($_POST['field_ids'] as $field_id ) { |
|
121 | - if ( $oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id]))) ) { |
|
120 | + foreach ($_POST['field_ids'] as $field_id) { |
|
121 | + if ($oldweight[$field_id]!=$weight[$field_id] || $oldcat[$field_id]!=$category[$field_id] || count($oldcategories[$field_id])!=count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
122 | 122 | //if field has changed |
123 | 123 | $ids[] = intval($field_id); |
124 | 124 | } |
125 | 125 | } |
126 | - if ( count($ids) > 0 ) { |
|
126 | + if (count($ids)>0) { |
|
127 | 127 | $errors = array(); |
128 | 128 | //if there are changed fields, fetch the fieldcategory objects |
129 | 129 | $field_handler = xoops_getmodulehandler('field'); |
130 | - $fields = $field_handler->getObjects(new Criteria('field_id', "(" . implode(',', $ids) . ")", "IN"), true); |
|
131 | - foreach ($ids as $i ) { |
|
132 | - $fields[$i]->setVar('field_weight', intval($weight[$i]) ); |
|
133 | - $fields[$i]->setVar('cids', $categories[$i] ); |
|
134 | - if ( !$field_handler->insert($fields[$i]) ) { |
|
135 | - $errors = array_merge($errors, $fields[$i]->getErrors() ); |
|
130 | + $fields = $field_handler->getObjects(new Criteria('field_id', "(".implode(',', $ids).")", "IN"), true); |
|
131 | + foreach ($ids as $i) { |
|
132 | + $fields[$i]->setVar('field_weight', intval($weight[$i])); |
|
133 | + $fields[$i]->setVar('cids', $categories[$i]); |
|
134 | + if (!$field_handler->insert($fields[$i])) { |
|
135 | + $errors = array_merge($errors, $fields[$i]->getErrors()); |
|
136 | 136 | } |
137 | 137 | } |
138 | - if ( count($errors) == 0 ) { |
|
138 | + if (count($errors)==0) { |
|
139 | 139 | //no errors |
140 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
140 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
141 | 141 | } else { |
142 | - redirect_header('field.php', 3, implode('<br />', $errors) ); |
|
142 | + redirect_header('field.php', 3, implode('<br />', $errors)); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
146 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS) ); |
|
146 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
147 | 147 | break; |
148 | 148 | |
149 | 149 | case "save": |
150 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
151 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
150 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
151 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
152 | 152 | } |
153 | 153 | $redirect_to_edit = false; |
154 | - if ( isset($_REQUEST['id']) ) { |
|
154 | + if (isset($_REQUEST['id'])) { |
|
155 | 155 | $obj = $field_handler->get($_REQUEST['id']); |
156 | - if ( !$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit') ) { //If no configs exist |
|
156 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
157 | 157 | redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
158 | 158 | } |
159 | 159 | } else { |
160 | 160 | $obj = $field_handler->create(); |
161 | 161 | $obj->setVar('field_name', $_REQUEST['field_name']); |
162 | - $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
162 | + $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid')); |
|
163 | 163 | $obj->setVar('field_show', 1); |
164 | 164 | $obj->setVar('field_edit', 1); |
165 | 165 | $obj->setVar('field_config', 1); |
@@ -167,40 +167,40 @@ discard block |
||
167 | 167 | } |
168 | 168 | $obj->setVar('field_title', $_REQUEST['field_title']); |
169 | 169 | $obj->setVar('field_description', $_REQUEST['field_description']); |
170 | - if ( $obj->getVar('field_config') ) { |
|
170 | + if ($obj->getVar('field_config')) { |
|
171 | 171 | $obj->setVar('field_type', $_REQUEST['field_type']); |
172 | - if ( isset($_REQUEST['field_valuetype']) ) { |
|
172 | + if (isset($_REQUEST['field_valuetype'])) { |
|
173 | 173 | $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
174 | 174 | } |
175 | 175 | $options = $obj->getVar('field_options'); |
176 | 176 | |
177 | - if ( isset($_REQUEST['removeOptions']) && is_array($_REQUEST['removeOptions']) ) { |
|
178 | - foreach ($_REQUEST['removeOptions'] as $index ) { |
|
177 | + if (isset($_REQUEST['removeOptions']) && is_array($_REQUEST['removeOptions'])) { |
|
178 | + foreach ($_REQUEST['removeOptions'] as $index) { |
|
179 | 179 | unset($options[$index]); |
180 | 180 | } |
181 | 181 | $redirect_to_edit = true; |
182 | 182 | } |
183 | 183 | |
184 | - if ( !empty($_REQUEST['addOption']) ) { |
|
185 | - foreach ($_REQUEST['addOption'] as $option ) { |
|
186 | - if ( empty($option['value']) ) continue; |
|
184 | + if (!empty($_REQUEST['addOption'])) { |
|
185 | + foreach ($_REQUEST['addOption'] as $option) { |
|
186 | + if (empty($option['value'])) continue; |
|
187 | 187 | $options[$option['key']] = $option['value']; |
188 | 188 | $redirect_to_edit = true; |
189 | 189 | } |
190 | 190 | } |
191 | 191 | $obj->setVar('field_options', $options); |
192 | 192 | } |
193 | - if ( $obj->getVar('field_edit') ) { |
|
193 | + if ($obj->getVar('field_edit')) { |
|
194 | 194 | $required = isset($_REQUEST['field_required']) ? $_REQUEST['field_required'] : 0; |
195 | 195 | $obj->setVar('field_required', $required); //0 = no, 1 = yes |
196 | - if ( isset($_REQUEST['field_maxlength']) ) { |
|
196 | + if (isset($_REQUEST['field_maxlength'])) { |
|
197 | 197 | $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
198 | 198 | } |
199 | - if ( isset($_REQUEST['field_default']) ) { |
|
199 | + if (isset($_REQUEST['field_default'])) { |
|
200 | 200 | $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
201 | 201 | //Check for multiple selections |
202 | - if ( is_array($field_default) ) { |
|
203 | - $obj->setVar('field_default', serialize($field_default) ); |
|
202 | + if (is_array($field_default)) { |
|
203 | + $obj->setVar('field_default', serialize($field_default)); |
|
204 | 204 | } else { |
205 | 205 | $obj->setVar('field_default', $field_default); |
206 | 206 | } |
@@ -210,50 +210,50 @@ discard block |
||
210 | 210 | $obj->setVar('field_weight', $_REQUEST['field_weight']); |
211 | 211 | $obj->setVar('cids', $_REQUEST['cids']); |
212 | 212 | |
213 | - if ( $field_handler->insert($obj) ) { |
|
213 | + if ($field_handler->insert($obj)) { |
|
214 | 214 | |
215 | 215 | $groupperm_handler = xoops_gethandler('groupperm'); |
216 | 216 | |
217 | 217 | $perm_arr = array(); |
218 | - if ( $obj->getVar('field_show') ) { |
|
218 | + if ($obj->getVar('field_show')) { |
|
219 | 219 | $perm_arr[] = 'songlist_show'; |
220 | 220 | $perm_arr[] = 'songlist_visible'; |
221 | 221 | } |
222 | - if ( $obj->getVar('field_edit') ) { |
|
222 | + if ($obj->getVar('field_edit')) { |
|
223 | 223 | $perm_arr[] = 'songlist_edit'; |
224 | 224 | } |
225 | - if ( $obj->getVar('field_edit') || $obj->getVar('field_show') ) { |
|
225 | + if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
|
226 | 226 | $perm_arr[] = 'songlist_search'; |
227 | 227 | } |
228 | - if ( count($perm_arr) > 0 ) { |
|
229 | - foreach ($perm_arr as $perm ) { |
|
230 | - $criteria = new CriteriaCompo(new Criteria('gperm_name', $perm) ); |
|
231 | - $criteria->add(new Criteria('gperm_itemid', intval($obj->getVar('field_id') )) ); |
|
232 | - $criteria->add(new Criteria('gperm_modid', intval($GLOBALS['songlistModule']->getVar('mid') )) ); |
|
233 | - if ( isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm]) ) { |
|
228 | + if (count($perm_arr)>0) { |
|
229 | + foreach ($perm_arr as $perm) { |
|
230 | + $criteria = new CriteriaCompo(new Criteria('gperm_name', $perm)); |
|
231 | + $criteria->add(new Criteria('gperm_itemid', intval($obj->getVar('field_id')))); |
|
232 | + $criteria->add(new Criteria('gperm_modid', intval($GLOBALS['songlistModule']->getVar('mid')))); |
|
233 | + if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
|
234 | 234 | $perms = $groupperm_handler->getObjects($criteria); |
235 | - if ( count($perms) > 0 ) { |
|
236 | - foreach (array_keys($perms) as $i ) { |
|
235 | + if (count($perms)>0) { |
|
236 | + foreach (array_keys($perms) as $i) { |
|
237 | 237 | $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
238 | 238 | } |
239 | 239 | } else { |
240 | 240 | $groups = array(); |
241 | 241 | } |
242 | - foreach ($_REQUEST[$perm] as $grouoid ) { |
|
242 | + foreach ($_REQUEST[$perm] as $grouoid) { |
|
243 | 243 | $grouoid = intval($grouoid); |
244 | - if ( !isset($groups[$grouoid]) ) { |
|
244 | + if (!isset($groups[$grouoid])) { |
|
245 | 245 | $perm_obj = $groupperm_handler->create(); |
246 | 246 | $perm_obj->setVar('gperm_name', $perm); |
247 | - $perm_obj->setVar('gperm_itemid', intval($obj->getVar('field_id') )); |
|
248 | - $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid') ); |
|
247 | + $perm_obj->setVar('gperm_itemid', intval($obj->getVar('field_id'))); |
|
248 | + $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
|
249 | 249 | $perm_obj->setVar('gperm_groupid', $grouoid); |
250 | 250 | $groupperm_handler->insert($perm_obj); |
251 | 251 | unset($perm_obj); |
252 | 252 | } |
253 | 253 | } |
254 | 254 | $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
255 | - if ( count($removed_groups) > 0 ) { |
|
256 | - $criteria->add(new Criteria('gperm_groupid', "(".implode(',', $removed_groups).")", "IN") ); |
|
255 | + if (count($removed_groups)>0) { |
|
256 | + $criteria->add(new Criteria('gperm_groupid', "(".implode(',', $removed_groups).")", "IN")); |
|
257 | 257 | $groupperm_handler->deleteAll($criteria); |
258 | 258 | } |
259 | 259 | unset($groups); |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | unset($criteria); |
265 | 265 | } |
266 | 266 | } |
267 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
268 | - redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
267 | + $url = $redirect_to_edit ? 'field.php?op=edit&id='.$obj->getVar('field_id') : 'field.php'; |
|
268 | + redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | echo $obj->getHtmlErrors(); |
@@ -275,25 +275,25 @@ discard block |
||
275 | 275 | |
276 | 276 | case "delete": |
277 | 277 | $obj = $field_handler->get($_REQUEST['id']); |
278 | - if ( !$obj->getVar('field_config') ) { |
|
278 | + if (!$obj->getVar('field_config')) { |
|
279 | 279 | redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
280 | 280 | } |
281 | - if ( isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1 ) { |
|
282 | - if ( !$GLOBALS['xoopsSecurity']->check() ) { |
|
283 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() )); |
|
281 | + if (isset($_REQUEST['ok']) && $_REQUEST['ok']==1) { |
|
282 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
283 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
284 | 284 | } |
285 | - if ( $field_handler->delete($obj) ) { |
|
286 | - redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD) ); |
|
285 | + if ($field_handler->delete($obj)) { |
|
286 | + redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
287 | 287 | } else { |
288 | 288 | echo $obj->getHtmlErrors(); |
289 | 289 | } |
290 | 290 | } else { |
291 | - xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title') )); |
|
291 | + xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title'))); |
|
292 | 292 | } |
293 | 293 | break; |
294 | 294 | } |
295 | 295 | |
296 | -if ( isset($template_main) ) { |
|
296 | +if (isset($template_main)) { |
|
297 | 297 | $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
298 | 298 | } |
299 | 299 |
@@ -183,7 +183,9 @@ |
||
183 | 183 | |
184 | 184 | if ( !empty($_REQUEST['addOption']) ) { |
185 | 185 | foreach ($_REQUEST['addOption'] as $option ) { |
186 | - if ( empty($option['value']) ) continue; |
|
186 | + if ( empty($option['value']) ) { |
|
187 | + continue; |
|
188 | + } |
|
187 | 189 | $options[$option['key']] = $option['value']; |
188 | 190 | $redirect_to_edit = true; |
189 | 191 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | $filter = !empty($_REQUEST['filter'])?''.$_REQUEST['filter'].'':'1,1'; |
16 | 16 | |
17 | 17 | switch($op) { |
18 | - default: |
|
19 | - case "voice": |
|
20 | - switch ($fct) |
|
21 | - { |
|
18 | + default: |
|
19 | + case "voice": |
|
20 | + switch ($fct) |
|
21 | + { |
|
22 | 22 | default: |
23 | 23 | case "list": |
24 | 24 | $indexAdmin = new ModuleAdmin(); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 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_VOICE_DELETE, $voice->getVar('name'))); |
132 | 132 | } |
133 | 133 | break; |
134 | - } |
|
134 | + } |
|
135 | 135 | break; |
136 | 136 | |
137 | 137 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | |
7 | 7 | xoops_cp_header(); |
8 | 8 | |
9 | - $op = isset($_REQUEST['op'])?$_REQUEST['op']:"voice"; |
|
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'; |
|
9 | + $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "voice"; |
|
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 | 16 | |
17 | - switch($op) { |
|
17 | + switch ($op) { |
|
18 | 18 | default: |
19 | 19 | case "voice": |
20 | 20 | switch ($fct) |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $indexAdmin = new ModuleAdmin(); |
25 | 25 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
26 | 26 | |
27 | - $voice_handler =& xoops_getmodulehandler('voice', 'songlist'); |
|
27 | + $voice_handler = & xoops_getmodulehandler('voice', 'songlist'); |
|
28 | 28 | |
29 | 29 | $criteria = $voice_handler->getFilterCriteria($GLOBALS['filter']); |
30 | 30 | $ttl = $voice_handler->getCount($criteria); |
31 | - $GLOBALS['sort'] = !empty($_REQUEST['sort'])?''.$_REQUEST['sort'].'':'created'; |
|
31 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
32 | 32 | |
33 | 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 | 34 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
35 | 35 | |
36 | 36 | foreach ($voice_handler->filterFields() as $id => $key) { |
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', $voice_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
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', $voice_handler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $criteria->setOrder($GLOBALS['order']); |
52 | 52 | |
53 | 53 | $voices = $voice_handler->getObjects($criteria, true); |
54 | - foreach($voices as $cid => $voice) { |
|
54 | + foreach ($voices as $cid => $voice) { |
|
55 | 55 | if (is_object($voice)) |
56 | 56 | $GLOBALS['xoopsTpl']->append('voice', $voice->toArray()); |
57 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $indexAdmin = new ModuleAdmin(); |
67 | 67 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
68 | 68 | |
69 | - $voice_handler =& xoops_getmodulehandler('voice', 'songlist'); |
|
69 | + $voice_handler = & xoops_getmodulehandler('voice', 'songlist'); |
|
70 | 70 | if (isset($_REQUEST['id'])) { |
71 | 71 | $voice = $voice_handler->get(intval($_REQUEST['id'])); |
72 | 72 | } else { |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | break; |
80 | 80 | case "save": |
81 | 81 | |
82 | - $voice_handler =& xoops_getmodulehandler('voice', 'songlist'); |
|
83 | - $id=0; |
|
84 | - if ($id=intval($_REQUEST['id'])) { |
|
82 | + $voice_handler = & xoops_getmodulehandler('voice', 'songlist'); |
|
83 | + $id = 0; |
|
84 | + if ($id = intval($_REQUEST['id'])) { |
|
85 | 85 | $voice = $voice_handler->get($id); |
86 | 86 | } else { |
87 | 87 | $voice = $voice_handler->create(); |
88 | 88 | } |
89 | 89 | $voice->setVars($_POST[$id]); |
90 | 90 | |
91 | - if (!$id=$voice_handler->insert($voice)) { |
|
91 | + if (!$id = $voice_handler->insert($voice)) { |
|
92 | 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_VOICE_FAILEDTOSAVE); |
93 | 93 | exit(0); |
94 | 94 | } else { |
95 | 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_VOICE_SAVEDOKEY); |
|
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_VOICE_SAVEDOKEY); |
|
97 | 97 | else |
98 | 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_VOICE_SAVEDOKEY); |
99 | 99 | exit(0); |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | break; |
102 | 102 | case "savelist": |
103 | 103 | |
104 | - $voice_handler =& xoops_getmodulehandler('voice', 'songlist'); |
|
105 | - foreach($_REQUEST['id'] as $id) { |
|
104 | + $voice_handler = & xoops_getmodulehandler('voice', 'songlist'); |
|
105 | + foreach ($_REQUEST['id'] as $id) { |
|
106 | 106 | $voice = $voice_handler->get($id); |
107 | 107 | $voice->setVars($_POST[$id]); |
108 | 108 | if (!$voice_handler->insert($voice)) { |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | break; |
116 | 116 | case "delete": |
117 | 117 | |
118 | - $voice_handler =& xoops_getmodulehandler('voice', 'songlist'); |
|
119 | - $id=0; |
|
120 | - if (isset($_POST['id'])&&$id=intval($_POST['id'])) { |
|
118 | + $voice_handler = & xoops_getmodulehandler('voice', 'songlist'); |
|
119 | + $id = 0; |
|
120 | + if (isset($_POST['id']) && $id = intval($_POST['id'])) { |
|
121 | 121 | $voice = $voice_handler->get($id); |
122 | 122 | if (!$voice_handler->delete($voice)) { |
123 | 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_VOICE_FAILEDTODELETE); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $voices = $voice_handler->getObjects($criteria, true); |
54 | 54 | foreach($voices as $cid => $voice) { |
55 | - if (is_object($voice)) |
|
56 | - $GLOBALS['xoopsTpl']->append('voice', $voice->toArray()); |
|
55 | + if (is_object($voice)) { |
|
56 | + $GLOBALS['xoopsTpl']->append('voice', $voice->toArray()); |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | $GLOBALS['xoopsTpl']->assign('form', songlist_voice_get_form(false)); |
59 | 60 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['PHP_SELF']); |
@@ -92,10 +93,11 @@ discard block |
||
92 | 93 | 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_VOICE_FAILEDTOSAVE); |
93 | 94 | exit(0); |
94 | 95 | } 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_VOICE_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_VOICE_SAVEDOKEY); |
|
96 | + if ($_REQUEST['state'][$_REQUEST['id']]=='new') { |
|
97 | + 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_VOICE_SAVEDOKEY); |
|
98 | + } else { |
|
99 | + 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_VOICE_SAVEDOKEY); |
|
100 | + } |
|
99 | 101 | exit(0); |
100 | 102 | } |
101 | 103 | break; |