plugins/Decir.php
changeset 0 902822492a68
equal deleted inserted replaced
-1:000000000000 0:902822492a68
       
     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');
       
    39   $paths->nslist['DecirForum']  = $paths->nslist['Special'] . 'Forum/ViewForum/';
       
    40   $paths->nslist['DecirPost']   = $paths->nslist['Special'] . 'Forum/Post/';
       
    41   $paths->nslist['DecirTopic']  = $paths->nslist['Special'] . 'Forum/Topic/';
       
    42   
       
    43   $session->register_acl_type('decir_see_forum',  AUTH_ALLOW, 'See forum in index', Array('read'),             'DecirForum');
       
    44   $session->register_acl_type('decir_view_forum', AUTH_ALLOW, 'View forum',         Array('decir_see_forum'),  'DecirForum');
       
    45   $session->register_acl_type('decir_post',       AUTH_ALLOW, 'Post new topics',    Array('decir_view_forum'), 'DecirForum');
       
    46   $session->register_acl_type('decir_reply',      AUTH_ALLOW, 'Reply to topics',    Array('decir_post'),       'DecirTopic');
       
    47 }
       
    48 
       
    49 function page_Special_Forum()
       
    50 {
       
    51   global $db, $session, $paths, $template, $plugins; // Common objects
       
    52   
       
    53   if ( getConfig('decir_version') != ENANO_DECIR_VERSION || isset($_POST['do_install_finish']) )
       
    54   {
       
    55     require(DECIR_ROOT . '/install.php');
       
    56   }
       
    57   
       
    58   $act = strtolower( ( $n = $paths->getParam(0) ) ? $n : 'Index' );
       
    59   
       
    60   $curdir = getcwd();
       
    61   chdir(DECIR_ROOT);
       
    62   
       
    63   switch($act)
       
    64   {
       
    65     case 'index':
       
    66     default:
       
    67       require('forum_index.php');
       
    68       break;
       
    69     case 'viewforum':
       
    70       require('viewforum.php');
       
    71       break;
       
    72     case 'topic':
       
    73     case 'post':
       
    74     case 'viewtopic':
       
    75       require('viewtopic.php');
       
    76       break;
       
    77     case 'new':
       
    78       require('posting.php');
       
    79       break;
       
    80   }
       
    81   
       
    82   chdir($curdir);
       
    83   
       
    84 }
       
    85 
       
    86 function page_Admin_DecirGeneral()
       
    87 {
       
    88   global $db, $session, $paths, $template, $plugins; if($session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN) { header('Location: '.makeUrl($paths->nslist['Special'].'Administration'.urlSeparator.'noheaders')); die('Hacking attempt'); }
       
    89   echo 'Hello world!';
       
    90 }
       
    91 
       
    92 ?>