|
1 <?php |
|
2 /* |
|
3 Plugin Name: Nuggie |
|
4 Plugin URI: http://enanocms.org/Nuggie |
|
5 Description: Nuggie provides a complete blogging suite for Enano-based websites. Named after Scottish water sprites. |
|
6 Author: Dan Fuhry |
|
7 Version: 0.1 |
|
8 Author URI: http://enanocms.org/ |
|
9 */ |
|
10 |
|
11 /* |
|
12 * Nuggie |
|
13 * Version 0.1 |
|
14 * Copyright (C) 2007 Dan Fuhry |
|
15 * |
|
16 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
17 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
18 * |
|
19 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
20 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
21 */ |
|
22 |
|
23 global $db, $session, $paths, $template, $plugins; // Common objects |
|
24 |
|
25 if ( getConfig('nuggie_installed') != '1' ) |
|
26 { |
|
27 $plugins->attachHook('base_classes_initted', ' |
|
28 $paths->add_page(Array( |
|
29 \'name\'=>\'Install Nuggie\', |
|
30 \'urlname\'=>\'NuggieInstall\', |
|
31 \'namespace\'=>\'Special\', |
|
32 \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
33 )); |
|
34 '); |
|
35 require( ENANO_ROOT . '/plugins/nuggie/install.php' ); |
|
36 } |
|
37 |
|
38 $plugins->attachHook('base_classes_initted', ' |
|
39 list($page_id, $namespace) = RenderMan::strToPageId($paths->get_pageid_from_url()); |
|
40 |
|
41 if ( $page_id == "Preferences" && $namespace == "Special" ) |
|
42 { |
|
43 require( ENANO_ROOT . "/plugins/nuggie/usercp.php" ); |
|
44 } |
|
45 '); |
|
46 |
|
47 $plugins->attachHook('acl_rule_init', 'nuggie_namespace_setup();'); |
|
48 |
|
49 function nuggie_namespace_setup() |
|
50 { |
|
51 global $db, $session, $paths, $template, $plugins; // Common objects |
|
52 |
|
53 // Insert additional namespaces |
|
54 |
|
55 $paths->create_namespace('Blog', 'Blog:'); |
|
56 $paths->create_namespace('Planet', 'Planet:'); |
|
57 |
|
58 // Create custom permissions for Nuggie |
|
59 |
|
60 $session->register_acl_type('nuggie_post', AUTH_DISALLOW, 'Post blog entries or create blog', Array(), 'Blog'); |
|
61 $session->register_acl_type('nuggie_edit_own', AUTH_DISALLOW, 'Edit own blog posts', Array(), 'Blog'); |
|
62 $session->register_acl_type('nuggie_edit_other', AUTH_DISALLOW, 'Edit others\' blog posts', Array(), 'Blog'); |
|
63 $session->register_acl_type('nuggie_create_planet', AUTH_DISALLOW, 'Create new planets', Array(), 'Planet'); |
|
64 $session->register_acl_type('nuggie_publicize_planet', AUTH_DISALLOW, 'Make own planets searchable', Array('nuggie_create_planet'), 'Planet'); |
|
65 $session->register_acl_type('nuggie_protect_planet', AUTH_DISALLOW, 'Protect planets from public modification', Array(), 'Planet'); |
|
66 $session->register_acl_type('nuggie_edit_planet_own', AUTH_DISALLOW, 'Edit own planets', Array(), 'Planet'); |
|
67 $session->register_acl_type('nuggie_edit_planet_other', AUTH_DISALLOW, 'Edit others\' planets', Array(), 'Planet'); |
|
68 $session->register_acl_type('nuggie_even_when_protected', AUTH_DISALLOW, 'Override protection on editing planets', Array(), 'Planet'); |
|
69 $session->register_acl_type('nuggie_see_non_public', AUTH_DISALLOW, 'See non-public blogs', Array(), 'Blog'); |
|
70 |
|
71 // Extend the core permission set |
|
72 |
|
73 $session->acl_extend_scope('read', 'Blog|Planet', $paths); |
|
74 $session->acl_extend_scope('edit_comments', 'Blog', $paths); |
|
75 $session->acl_extend_scope('post_comments', 'Blog', $paths); |
|
76 $session->acl_extend_scope('mod_comments', 'Blog', $paths); |
|
77 } |
|
78 |
|
79 $plugins->attachHook('page_type_string_set', 'nuggie_set_page_string();'); |
|
80 |
|
81 function nuggie_set_page_string() |
|
82 { |
|
83 global $db, $session, $paths, $template, $plugins; // Common objects |
|
84 |
|
85 if ( $paths->namespace == 'Blog' ) |
|
86 { |
|
87 $paths->cpage['comments_on'] = 0; |
|
88 $template->namespace_string = 'blog'; |
|
89 if ( strstr($paths->cpage['urlname_nons'], '/') ) |
|
90 { |
|
91 $paths->cpage['comments_on'] = 1; |
|
92 $template->namespace_string = 'blog post'; |
|
93 } |
|
94 } |
|
95 else if ( $paths->namespace == 'Planet' ) |
|
96 { |
|
97 $paths->cpage['comments_on'] = 0; |
|
98 $template->namespace_string = 'planet'; |
|
99 } |
|
100 } |
|
101 |
|
102 $plugins->attachHook('page_not_found', 'nuggie_handle_namespace($this);'); |
|
103 |
|
104 function nuggie_handle_namespace($processor) |
|
105 { |
|
106 global $db, $session, $paths, $template, $plugins; // Common objects |
|
107 |
|
108 if ( $processor->namespace == 'Blog' ) |
|
109 { |
|
110 require( ENANO_ROOT . '/plugins/nuggie/postbit.php' ); |
|
111 $result = nuggie_blog_uri_handler($processor->page_id); |
|
112 if ( $result === '_err_access_denied' ) |
|
113 { |
|
114 $processor->err_access_denied(); |
|
115 return true; |
|
116 } |
|
117 } |
|
118 else if ( $processor->namespace == 'Planet' ) |
|
119 { |
|
120 $result = nuggie_planet_uri_handler($processor->page_id); |
|
121 if ( $result === '_err_access_denied' ) |
|
122 { |
|
123 $processor->err_access_denied(); |
|
124 return true; |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 /** |
|
130 * Sanitizes a string for a Nuggie permalink. |
|
131 * @param string String to sanitize |
|
132 * @return string |
|
133 */ |
|
134 |
|
135 function nuggie_sanitize_title($title) |
|
136 { |
|
137 // Placeholder for now - this may become more elaborate in the future, we'll see |
|
138 return sanitize_page_id($title); |
|
139 } |
|
140 |
|
141 ?> |