'pictures', 'label' => l10n('Photos'), ), array( 'code' => 'albums', 'label' => l10n('Albums'), ), ); $tab_codes = array_map(create_function('$a', 'return $a["code"];'), $tabs); if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes)) { $page['tab'] = $_GET['section']; } else { $page['tab'] = $tabs[0]['code']; } $tabsheet = new tabsheet(); foreach ($tabs as $tab) { $tabsheet->add( $tab['code'], $tab['label'], get_root_url().'admin.php?page=comments&section='.$tab['code'] ); } $tabsheet->select($page['tab']); $tabsheet->assign(); if ($page['tab'] == 'albums') { $template->clear_assign(array('ADMIN_CONTENT', 'comments', 'LIST', 'F_ACTION')); // +-----------------------------------------------------------------------+ // Actions // +-----------------------------------------------------------------------+ if (!empty($_POST)) { if (!empty($_POST['comments'])) { check_input_parameter('comments', $_POST, true, PATTERN_ID); if (isset($_POST['validate_albums'])) { $query = 'UPDATE '.COA_TABLE.' SET validated = \'true\', validation_date = NOW() WHERE id IN ('.implode(',', $_POST['comments']).') ;'; pwg_query($query); array_push($page['infos'], l10n_dec( '%d user comment validated', '%d user comments validated', count($_POST['comments']) )); } if (isset($_POST['reject_albums'])) { $query = 'DELETE FROM '.COA_TABLE.' WHERE id IN ('.implode(',', $_POST['comments']).') ;'; pwg_query($query); array_push($page['infos'], l10n_dec( '%d user comment rejected', '%d user comments rejected', count($_POST['comments']) )); } } } // +-----------------------------------------------------------------------+ // Infos (re-assignation needed) // +-----------------------------------------------------------------------+ if (count($page['infos']) != 0) { $template->assign('infos', $page['infos']); } // +-----------------------------------------------------------------------+ // Comments display // +-----------------------------------------------------------------------+ $list = array(); $query = 'SELECT c.id, c.category_id, c.date, c.author, '.$conf['user_fields']['username'].' AS username, c.content, i.name FROM '.COA_TABLE.' AS c INNER JOIN '.CATEGORIES_TABLE.' AS i ON i.id = c.category_id LEFT JOIN '.USERS_TABLE.' AS u ON u.'.$conf['user_fields']['id'].' = c.author_id WHERE validated = \'false\' ORDER BY c.date DESC ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { if (empty($row['author_id'])) { $author_name = $row['author']; } else { $author_name = stripslashes($row['username']); } $template->append('comments', array( 'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$row['category_id'], 'CAT_NAME' => $row['name'], 'ID' => $row['id'], 'AUTHOR' => trigger_event('render_comment_author', $author_name), 'DATE' => format_date($row['date'], true), 'CONTENT' => trigger_event('render_comment_content',$row['content']), )); array_push($list, $row['id']); } // template $template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin_comments.tpl'); $template->assign(array( 'F_ACTION' => get_root_url().'admin.php?page=comments&section=albums', 'LIST' => implode(',', $list), )); $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); } ?>