plugins/Decir.php
changeset 5 6eea55374f5b
parent 4 c31210950118
child 6 3f66ec435f08
equal deleted inserted replaced
4:c31210950118 5:6eea55374f5b
    34   ');
    34   ');
    35 
    35 
    36 function decir_early_init(&$paths, &$session)
    36 function decir_early_init(&$paths, &$session)
    37 {
    37 {
    38   $paths->addAdminNode('Decir forum configuration', 'General settings', 'DecirGeneral');
    38   $paths->addAdminNode('Decir forum configuration', 'General settings', 'DecirGeneral');
    39   $paths->create_namespace('DecirForum', $paths->nslist['Special'] . 'Forum/ViewForum/');
    39   $paths->nslist['DecirForum']  = $paths->nslist['Special'] . 'Forum/ViewForum/';
    40   $paths->create_namespace('DecirPost',  $paths->nslist['Special'] . 'Forum/Post/');
    40   $paths->nslist['DecirPost']   = $paths->nslist['Special'] . 'Forum/Post/';
    41   $paths->create_namespace('DecirTopic', $paths->nslist['Special'] . 'Forum/Topic/');
    41   $paths->nslist['DecirTopic']  = $paths->nslist['Special'] . 'Forum/Topic/';
    42   
       
    43   // Decir's ACL rules
       
    44   
    42   
    45   $session->register_acl_type('decir_see_forum',  AUTH_ALLOW, 'See forum in index', Array('read'),             'DecirForum');
    43   $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');
    44   $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');
    45   $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');
    46   $session->register_acl_type('decir_reply',      AUTH_ALLOW, 'Reply to topics',    Array('decir_post'),       'DecirTopic');
    49   $session->register_acl_type('decir_edit_own',   AUTH_ALLOW, 'Edit own posts',     Array('decir_post'),       'DecirPost');
       
    50   $session->register_acl_type('decir_edit_other', AUTH_DISALLOW, 'Edit others\' posts', Array('decir_post'),   'DecirPost');
       
    51   $session->register_acl_type('decir_delete_own_post_soft', AUTH_ALLOW, 'Delete own posts (soft)', Array('decir_edit_own'), 'DecirPost');
       
    52   $session->register_acl_type('decir_delete_own_post_hard', AUTH_DISALLOW, 'Delete own posts (hard)', Array('decir_delete_own_post_soft'), 'DecirPost');
       
    53   $session->register_acl_type('decir_delete_other_post_soft', AUTH_DISALLOW, 'Delete others\' posts (soft)', Array('decir_edit_other'), 'DecirPost');
       
    54   $session->register_acl_type('decir_delete_other_post_hard', AUTH_DISALLOW, 'Delete others\' posts (hard)', Array('decir_delete_other_post_soft'), 'DecirPost');
       
    55   $session->register_acl_type('decir_undelete_own_post', AUTH_DISALLOW, 'Undelete own posts', Array('decir_edit_own'), 'DecirPost');
       
    56   $session->register_acl_type('decir_undelete_other_post', AUTH_DISALLOW, 'Undelete others\' posts', Array('decir_edit_other'), 'DecirPost');
       
    57   $session->register_acl_type('decir_undelete_own_topic', AUTH_DISALLOW, 'Undelete own topics', Array('read'), 'DecirTopic');
       
    58   $session->register_acl_type('decir_undelete_other_topic', AUTH_DISALLOW, 'Undelete others\' topics', Array('read'), 'DecirTopic');
       
    59   $session->register_acl_type('decir_see_deleted_post', AUTH_ALLOW, 'See placeholders for deleted posts', Array('read'), 'Special|DecirPost|DecirTopic|DecirForum');
       
    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');
       
    61   $session->register_acl_type('decir_see_deleted_topic', AUTH_ALLOW, 'See placeholders for deleted topics', Array('read'), 'DecirTopic|DecirForum');
       
    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');
       
    63 }
    47 }
    64 
    48 
    65 function page_Special_Forum()
    49 function page_Special_Forum()
    66 {
    50 {
    67   global $db, $session, $paths, $template, $plugins; // Common objects
    51   global $db, $session, $paths, $template, $plugins; // Common objects
    92       require('viewtopic.php');
    76       require('viewtopic.php');
    93       break;
    77       break;
    94     case 'new':
    78     case 'new':
    95       require('posting.php');
    79       require('posting.php');
    96       break;
    80       break;
    97     case 'edit':
       
    98       require('edit.php');
       
    99       break;
       
   100     case 'delete':
       
   101       require('delete.php');
       
   102       break;
       
   103     case 'restoretopic':
       
   104       require('restoretopic.php');
       
   105       break;
       
   106   }
    81   }
   107   
    82   
   108   chdir($curdir);
    83   chdir($curdir);
   109   
    84   
   110 }
    85 }
   111 
    86 
   112 function page_Admin_DecirGeneral()
    87 function page_Admin_DecirGeneral()
   113 {
    88 {
   114   global $db, $session, $paths, $template, $plugins; // Common objects
    89   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'); }
   115   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
       
   116   {
       
   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>';
       
   118     return;
       
   119   }
       
   120   
       
   121   echo 'Hello world!';
    90   echo 'Hello world!';
   122 }
    91 }
   123 
    92 
   124 ?>
    93 ?>