author | Dan |
Wed, 17 Oct 2007 23:44:22 -0400 | |
changeset 4 | c31210950118 |
parent 3 | 88b85b9b9272 |
child 5 | 6eea55374f5b |
permissions | -rwxr-xr-x |
0 | 1 |
<?php |
2 |
/* |
|
3 |
Plugin Name: Decir |
|
4 |
Plugin URI: javascript: // No URL yet, stay tuned! |
|
5 |
Description: Decir is an advanced bulletin board system (forum) for Enano. |
|
6 |
Author: Dan Fuhry |
|
7 |
Version: 0.1 |
|
8 |
Author URI: http://www.enanocms.org/ |
|
9 |
*/ |
|
10 |
||
11 |
/* |
|
12 |
* Decir |
|
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 |
define('ENANO_DECIR_VERSION', '0.1'); |
|
24 |
define('DECIR_ROOT', ENANO_ROOT . '/decir'); |
|
25 |
||
26 |
$plugins->attachHook('acl_rule_init', 'decir_early_init($this, $session);'); |
|
27 |
$plugins->attachHook('base_classes_initted', ' |
|
28 |
$paths->add_page(Array( |
|
29 |
\'name\'=>\'Forum\', |
|
30 |
\'urlname\'=>\'Forum\', |
|
31 |
\'namespace\'=>\'Special\', |
|
32 |
\'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
33 |
)); |
|
34 |
'); |
|
35 |
||
36 |
function decir_early_init(&$paths, &$session) |
|
37 |
{ |
|
38 |
$paths->addAdminNode('Decir forum configuration', 'General settings', 'DecirGeneral'); |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
39 |
$paths->create_namespace('DecirForum', $paths->nslist['Special'] . 'Forum/ViewForum/'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
40 |
$paths->create_namespace('DecirPost', $paths->nslist['Special'] . 'Forum/Post/'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
41 |
$paths->create_namespace('DecirTopic', $paths->nslist['Special'] . 'Forum/Topic/'); |
0 | 42 |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
43 |
// Decir's ACL rules |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
44 |
|
0 | 45 |
$session->register_acl_type('decir_see_forum', AUTH_ALLOW, 'See forum in index', Array('read'), 'DecirForum'); |
46 |
$session->register_acl_type('decir_view_forum', AUTH_ALLOW, 'View forum', Array('decir_see_forum'), 'DecirForum'); |
|
47 |
$session->register_acl_type('decir_post', AUTH_ALLOW, 'Post new topics', Array('decir_view_forum'), 'DecirForum'); |
|
48 |
$session->register_acl_type('decir_reply', AUTH_ALLOW, 'Reply to topics', Array('decir_post'), 'DecirTopic'); |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
49 |
$session->register_acl_type('decir_edit_own', AUTH_ALLOW, 'Edit own posts', Array('decir_post'), 'DecirPost'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
50 |
$session->register_acl_type('decir_edit_other', AUTH_DISALLOW, 'Edit others\' posts', Array('decir_post'), 'DecirPost'); |
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
51 |
$session->register_acl_type('decir_delete_own_post_soft', AUTH_ALLOW, 'Delete own posts (soft)', Array('decir_edit_own'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
52 |
$session->register_acl_type('decir_delete_own_post_hard', AUTH_DISALLOW, 'Delete own posts (hard)', Array('decir_delete_own_post_soft'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
53 |
$session->register_acl_type('decir_delete_other_post_soft', AUTH_DISALLOW, 'Delete others\' posts (soft)', Array('decir_edit_other'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
54 |
$session->register_acl_type('decir_delete_other_post_hard', AUTH_DISALLOW, 'Delete others\' posts (hard)', Array('decir_delete_other_post_soft'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
55 |
$session->register_acl_type('decir_undelete_own_post', AUTH_DISALLOW, 'Undelete own posts', Array('decir_edit_own'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
56 |
$session->register_acl_type('decir_undelete_other_post', AUTH_DISALLOW, 'Undelete others\' posts', Array('decir_edit_other'), 'DecirPost'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
57 |
$session->register_acl_type('decir_undelete_own_topic', AUTH_DISALLOW, 'Undelete own topics', Array('read'), 'DecirTopic'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
58 |
$session->register_acl_type('decir_undelete_other_topic', AUTH_DISALLOW, 'Undelete others\' topics', Array('read'), 'DecirTopic'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
59 |
$session->register_acl_type('decir_see_deleted_post', AUTH_ALLOW, 'See placeholders for deleted posts', Array('read'), 'Special|DecirPost|DecirTopic|DecirForum'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
60 |
$session->register_acl_type('decir_see_deleted_post_full', AUTH_DISALLOW, 'Read the full contents of deleted posts', Array('decir_see_deleted_post'), 'Special|DecirPost|DecirTopic|DecirForum'); |
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
61 |
$session->register_acl_type('decir_see_deleted_topic', AUTH_ALLOW, 'See placeholders for deleted topics', Array('read'), 'DecirTopic|DecirForum'); |
4
c31210950118
Some access controls implemented... we'll see how well this works
Dan
parents:
3
diff
changeset
|
62 |
$session->register_acl_type('decir_see_deleted_topic_full', AUTH_DISALLOW, 'Read the full contents of deleted topics', Array('decir_see_deleted_topic'), 'Special|DecirTopic|DecirForum'); |
0 | 63 |
} |
64 |
||
65 |
function page_Special_Forum() |
|
66 |
{ |
|
67 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
68 |
||
69 |
if ( getConfig('decir_version') != ENANO_DECIR_VERSION || isset($_POST['do_install_finish']) ) |
|
70 |
{ |
|
71 |
require(DECIR_ROOT . '/install.php'); |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
72 |
return false; |
0 | 73 |
} |
74 |
||
75 |
$act = strtolower( ( $n = $paths->getParam(0) ) ? $n : 'Index' ); |
|
76 |
||
77 |
$curdir = getcwd(); |
|
78 |
chdir(DECIR_ROOT); |
|
79 |
||
80 |
switch($act) |
|
81 |
{ |
|
82 |
case 'index': |
|
83 |
default: |
|
84 |
require('forum_index.php'); |
|
85 |
break; |
|
86 |
case 'viewforum': |
|
87 |
require('viewforum.php'); |
|
88 |
break; |
|
89 |
case 'topic': |
|
90 |
case 'post': |
|
91 |
case 'viewtopic': |
|
92 |
require('viewtopic.php'); |
|
93 |
break; |
|
94 |
case 'new': |
|
95 |
require('posting.php'); |
|
96 |
break; |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
97 |
case 'edit': |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
98 |
require('edit.php'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
99 |
break; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
100 |
case 'delete': |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
101 |
require('delete.php'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
102 |
break; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
103 |
case 'restoretopic': |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
104 |
require('restoretopic.php'); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
105 |
break; |
0 | 106 |
} |
107 |
||
108 |
chdir($curdir); |
|
109 |
||
110 |
} |
|
111 |
||
112 |
function page_Admin_DecirGeneral() |
|
113 |
{ |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
114 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
115 |
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
116 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
117 |
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
118 |
return; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
119 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
120 |
|
0 | 121 |
echo 'Hello world!'; |
122 |
} |
|
123 |
||
124 |
?> |