[30050] | 1 | <?php |
---|
| 2 | |
---|
| 3 | defined('MRP_PATH') or die('Hacking attempt!'); |
---|
| 4 | |
---|
| 5 | global $conf, $template, $page; |
---|
| 6 | |
---|
| 7 | if (isset($_POST['submit'])) |
---|
| 8 | { |
---|
[31852] | 9 | $conf['MRP'] = array( |
---|
| 10 | 'randompicture_preload' => $conf['MRP']['randompicture_preload'], |
---|
| 11 | 'square' => isset($_POST['square']), |
---|
| 12 | ); |
---|
| 13 | if (isset($_POST['height'])) |
---|
| 14 | $conf['MRP']['height'] = $_POST['height']; |
---|
| 15 | else |
---|
| 16 | $conf['MRP']['height'] = 0; |
---|
| 17 | if (isset($_POST['title'])) |
---|
| 18 | $conf['MRP']['title'] = $_POST['title']; |
---|
| 19 | else |
---|
| 20 | $conf['MRP']['title'] = ''; |
---|
| 21 | if (isset($_POST['delay'])) |
---|
| 22 | $conf['MRP']['delay'] = $_POST['delay']*1000; |
---|
| 23 | else |
---|
| 24 | $conf['MRP']['delay'] = 0; |
---|
[30050] | 25 | |
---|
[31852] | 26 | if (isset($_POST['apply_to_albums']) and in_array($_POST['apply_to_albums'], array('all', 'list'))) |
---|
| 27 | { |
---|
| 28 | $conf['MRP']['apply_to_albums'] = $_POST['apply_to_albums']; |
---|
| 29 | if ($_POST['apply_to_albums'] == 'list') |
---|
| 30 | { |
---|
| 31 | check_input_parameter('albums', $_POST, true, PATTERN_ID); |
---|
| 32 | |
---|
| 33 | if (empty($_POST['albums'])) |
---|
| 34 | $_POST['albums'][] = -1; |
---|
| 35 | |
---|
| 36 | $query = 'UPDATE '.CATEGORIES_TABLE.' SET menurandomphoto_active=\'false\' WHERE id NOT IN ('.implode(',', $_POST['albums']).');'; |
---|
| 37 | pwg_query($query); |
---|
| 38 | |
---|
| 39 | $query = 'UPDATE '.CATEGORIES_TABLE.' SET menurandomphoto_active=\'true\' WHERE id IN ('.implode(',', $_POST['albums']).');'; |
---|
| 40 | pwg_query($query); |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | conf_update_param('MRP', serialize($conf['MRP'])); |
---|
| 45 | $page['infos'][] = l10n('Information data registered in database'); |
---|
[30050] | 46 | } |
---|
| 47 | |
---|
[31852] | 48 | // make sure we have the extra column (update vs copy new version over old one) |
---|
| 49 | $result = pwg_query('SHOW COLUMNS FROM `'.CATEGORIES_TABLE.'` LIKE "menurandomphoto_active";'); |
---|
| 50 | if (!pwg_db_num_rows($result)) |
---|
| 51 | { |
---|
| 52 | $page['errors'][] = l10n('MenuRandomPhoto seems not to be installed/configured properly. Please remove and reinstall.'); |
---|
| 53 | return; |
---|
| 54 | } |
---|
[30050] | 55 | |
---|
[31852] | 56 | // associate to albums |
---|
| 57 | $query = 'SELECT id FROM '.CATEGORIES_TABLE.' WHERE menurandomphoto_active=\'true\';'; |
---|
| 58 | $mrp_albums = array_from_query($query, 'id'); |
---|
| 59 | |
---|
| 60 | $query = 'SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.';'; |
---|
| 61 | display_select_cat_wrapper($query, $mrp_albums, 'album_options'); |
---|
| 62 | |
---|
| 63 | $template->assign(array('MRP' => $conf['MRP'])); |
---|
| 64 | |
---|
[30050] | 65 | $template->set_filename('plugin_admin_content', realpath(MRP_PATH . 'template/admin.tpl')); |
---|
| 66 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|