- Timestamp:
- Jun 7, 2011, 9:44:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Comments_on_Albums/include/coa_admin_comments.php
r10984 r11267 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 global $template, $conf; 5 6 load_language('plugin.lang', COA_PATH); 6 7 7 8 // +-----------------------------------------------------------------------+ 8 // Tabsheet9 // | tabsheet | 9 10 // +-----------------------------------------------------------------------+ 10 11 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); … … 14 15 'code' => 'pictures', 15 16 'label' => l10n('COA_comments_photos'), 16 ),17 ), 17 18 array( 18 19 'code' => 'albums', 19 20 'label' => l10n('COA_comments_albums'), 20 ),21 );21 ), 22 ); 22 23 23 24 $tab_codes = array_map(create_function('$a', 'return $a["code"];'), $tabs); 24 25 25 if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes)) { 26 if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes)) 27 { 26 28 $page['tab'] = $_GET['section']; 27 } else { 29 } 30 else 31 { 28 32 $page['tab'] = $tabs[0]['code']; 29 33 } 30 34 31 35 $tabsheet = new tabsheet(); 32 foreach ($tabs as $tab) { 36 foreach ($tabs as $tab) 37 { 33 38 $tabsheet->add( 34 39 $tab['code'], 35 40 $tab['label'], 36 41 get_root_url().'admin.php?page=comments&section='.$tab['code'] 37 );42 ); 38 43 } 39 44 $tabsheet->select($page['tab']); … … 41 46 42 47 43 if ($page['tab'] == 'albums') { 48 if ($page['tab'] == 'albums') 49 { 50 // clear template sended by original page 44 51 $template->clear_assign(array('ADMIN_CONTENT', 'comments', 'LIST', 'F_ACTION')); 45 52 46 53 // +-----------------------------------------------------------------------+ 47 // Actions54 // | actions | 48 55 // +-----------------------------------------------------------------------+ 49 if (!empty($_POST)) { 50 if (!empty($_POST['comments'])) { 56 if (!empty($_POST)) 57 { 58 if (empty($_POST['comments'])) 59 { 60 array_push( 61 $page['errors'], 62 l10n('Select at least one comment') 63 ); 64 } 65 else 66 { 51 67 check_input_parameter('comments', $_POST, true, PATTERN_ID); 52 68 53 if (isset($_POST['validate_albums'])) { 54 $query = 'UPDATE '.COA_TABLE.' SET 55 validated = \'true\', 56 validation_date = NOW() 57 WHERE id IN ('.implode(',', $_POST['comments']).') 58 ;'; 69 if (isset($_POST['validate_albums'])) 70 { 71 $query = ' 72 UPDATE '.COA_TABLE.' 73 SET validated = \'true\', 74 validation_date = NOW() 75 WHERE id IN ('.implode(',', $_POST['comments']).') 76 ;'; 59 77 pwg_query($query); 60 78 61 array_push($page['infos'], l10n_dec( 62 '%d user comment validated', '%d user comments validated', 63 count($_POST['comments']) 64 )); 79 array_push( 80 $page['infos'], 81 l10n_dec( 82 '%d user comment validated', '%d user comments validated', 83 count($_POST['comments']) 84 ) 85 ); 65 86 } 66 87 67 if (isset($_POST['reject_albums'])) { 68 $query = 'DELETE FROM '.COA_TABLE.' 69 WHERE id IN ('.implode(',', $_POST['comments']).') 70 ;'; 88 if (isset($_POST['reject_albums'])) 89 { 90 $query = ' 91 DELETE 92 FROM '.COA_TABLE.' 93 WHERE id IN ('.implode(',', $_POST['comments']).') 94 ;'; 71 95 pwg_query($query); 72 96 73 array_push($page['infos'], l10n_dec( 74 '%d user comment rejected', '%d user comments rejected', 75 count($_POST['comments']) 76 )); 97 array_push( 98 $page['infos'], 99 l10n_dec( 100 '%d user comment rejected', '%d user comments rejected', 101 count($_POST['comments']) 102 ) 103 ); 77 104 } 78 105 } … … 80 107 81 108 // +-----------------------------------------------------------------------+ 82 // Infos (re-assignation needed)109 // | template init | 83 110 // +-----------------------------------------------------------------------+ 84 if (count($page['infos']) != 0) { 111 112 $template->set_filename('comments', dirname(__FILE__) .'/../template/admin_comments.tpl'); 113 114 $template->assign( 115 array( 116 'F_ACTION' => get_root_url().'admin.php?page=comments&section=albums' 117 ) 118 ); 119 120 if (count($page['infos']) != 0) 121 { 85 122 $template->assign('infos', $page['infos']); 86 123 } 87 124 88 125 // +-----------------------------------------------------------------------+ 89 // Comments display126 // | comments display | 90 127 // +-----------------------------------------------------------------------+ 91 128 $list = array(); 92 129 93 $query = 'SELECT 94 com.id, 95 com.category_id, 96 com.date, 97 com.author, 98 '.$conf['user_fields']['username'].' AS username, 99 com.content, 100 cat.name 101 FROM '.COA_TABLE.' AS com 130 $query = ' 131 SELECT 132 com.id, 133 com.category_id, 134 com.date, 135 com.author, 136 '.$conf['user_fields']['username'].' AS username, 137 com.content, 138 cat.name 139 FROM '.COA_TABLE.' AS com 102 140 INNER JOIN '.CATEGORIES_TABLE.' AS cat 103 ON cat.id = com.category_id141 ON cat.id = com.category_id 104 142 LEFT JOIN '.USERS_TABLE.' AS u 105 ON u.'.$conf['user_fields']['id'].' = com.author_id106 107 108 143 ON u.'.$conf['user_fields']['id'].' = com.author_id 144 WHERE validated = \'false\' 145 ORDER BY com.date DESC 146 ;'; 109 147 $result = pwg_query($query); 110 148 111 while ($row = pwg_db_fetch_assoc($result)) { 149 while ($row = pwg_db_fetch_assoc($result)) 150 { 112 151 // author 113 if (empty($row['author_id'])) { 152 if (empty($row['author_id'])) 153 { 114 154 $author_name = $row['author']; 115 } else { 155 } 156 else 157 { 116 158 $author_name = stripslashes($row['username']); 117 159 } 118 160 119 161 // comment content 120 $template->append('comments', array( 121 'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$row['category_id'], 122 'CAT_NAME' => $row['name'], 123 'ID' => $row['id'], 124 'AUTHOR' => trigger_event('render_comment_author', $author_name), 125 'DATE' => format_date($row['date'], true), 126 'CONTENT' => trigger_event('render_comment_content',$row['content']), 127 )); 162 $template->append( 163 'comments', 164 array( 165 'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$row['category_id'], 166 'CAT_NAME' => $row['name'], 167 'ID' => $row['id'], 168 'AUTHOR' => trigger_event('render_comment_author', $author_name), 169 'DATE' => format_date($row['date'], true), 170 'CONTENT' => trigger_event('render_comment_content',$row['content']), 171 ) 172 ); 128 173 129 174 array_push($list, $row['id']); 130 175 } 131 176 132 // template133 $template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin_comments.tpl'); 134 $template->assign(array(135 'F_ACTION' => get_root_url().'admin.php?page=comments&section=albums',136 'LIST' => implode(',', $list),137 )); 177 $template->assign('LIST', implode(',', $list)); 178 179 // +-----------------------------------------------------------------------+ 180 // | sending html code | 181 // +-----------------------------------------------------------------------+ 182 138 183 $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); 184 139 185 } 140 186
Note: See TracChangeset
for help on using the changeset viewer.