|
1 <?php |
|
2 |
|
3 /* |
|
4 * Nuggie |
|
5 * Version 0.1 |
|
6 * Copyright (C) 2007 Dan Fuhry |
|
7 * |
|
8 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
9 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
13 */ |
|
14 |
|
15 /** |
|
16 * Displays a planet as requested by a PageProcessor instance. |
|
17 * @param string The page_id from PageProcessor. |
|
18 */ |
|
19 |
|
20 function nuggie_planet_uri_handler($page) |
|
21 { |
|
22 global $db, $session, $paths, $template, $plugins; // Common objects |
|
23 |
|
24 $planet_id = $page->page_id; |
|
25 |
|
26 // |
|
27 // VALIDATION |
|
28 // |
|
29 |
|
30 // Fetch ACLs |
|
31 $perms = $session->fetch_page_acl($planet_id, 'Planet'); |
|
32 |
|
33 // Obtain planet info |
|
34 $q = $db->sql_query('SELECT p.planet_id, p.planet_name, p.planet_subtitle, p.planet_creator, p.planet_public, p.planet_visible, m.mapping_type, m.mapping_value ' . "\n" |
|
35 . ' FROM ' . table_prefix . "planets AS p\n" |
|
36 . " LEFT JOIN " . table_prefix . "planets_mapping AS m\n" |
|
37 . " ON ( p.planet_id = m.planet_id )\n" |
|
38 . " WHERE p.planet_name = '" . $db->escape(sanitize_page_id($planet_id)) . "';"); |
|
39 if ( !$q ) |
|
40 $db->_die(); |
|
41 |
|
42 if ( $db->numrows() < 1 ) |
|
43 { |
|
44 // planet not found, fall out |
|
45 return false; |
|
46 } |
|
47 |
|
48 // fetch first row, then seek back to the first result to allow mapping fetching later |
|
49 $planet_data = $db->fetchrow(); |
|
50 $db->sql_data_seek(0); |
|
51 |
|
52 // check author and publicity |
|
53 if ( $planet_data['planet_creator'] != $session->user_id && !$planet_data['planet_public'] ) |
|
54 { |
|
55 return $page->err_access_denied(); |
|
56 } |
|
57 |
|
58 // ACL check |
|
59 if ( !$perms->get_permissions('read') ) |
|
60 { |
|
61 return $page->err_access_denied(); |
|
62 } |
|
63 |
|
64 // fetch mappings to prepare to select the actual blog data |
|
65 echo 'WiP'; |
|
66 } |
|
67 |
|
68 ?> |