plugins/Nuggie.php
changeset 7 cd46e29ae699
parent 3 a050ff3d4509
child 8 160f1170aa32
equal deleted inserted replaced
6:c51809bdf6af 7:cd46e29ae699
    57   
    57   
    58   // Insert additional namespaces
    58   // Insert additional namespaces
    59   
    59   
    60   $paths->create_namespace('Blog', 'Blog:');
    60   $paths->create_namespace('Blog', 'Blog:');
    61   $paths->create_namespace('Planet', 'Planet:');
    61   $paths->create_namespace('Planet', 'Planet:');
       
    62   $paths->create_namespace('BlogPost', 'Blog_post:');
       
    63   
       
    64   // Register namespace processors
       
    65   $paths->register_namespace_processor('BlogPost', 'nuggie_blogpost_uri_handler');
       
    66   $paths->register_namespace_processor('Planet', 'nuggie_planet_uri_handler');
    62   
    67   
    63   // Create custom permissions for Nuggie
    68   // Create custom permissions for Nuggie
    64   
    69   
    65   $session->register_acl_type('nuggie_post', AUTH_DISALLOW, 'Post blog entries or create blog', Array(), 'Blog');
    70   $session->register_acl_type('nuggie_post', AUTH_DISALLOW, 'Post blog entries or create blog', Array(), 'Blog');
    66   $session->register_acl_type('nuggie_edit_own', AUTH_DISALLOW, 'Edit own blog posts', Array(), 'Blog');
    71   $session->register_acl_type('nuggie_edit_own', AUTH_DISALLOW, 'Edit own blog posts', Array(), 'Blog');
    73   $session->register_acl_type('nuggie_even_when_protected', AUTH_DISALLOW, 'Override protection on editing planets', Array(), 'Planet');
    78   $session->register_acl_type('nuggie_even_when_protected', AUTH_DISALLOW, 'Override protection on editing planets', Array(), 'Planet');
    74   $session->register_acl_type('nuggie_see_non_public', AUTH_DISALLOW, 'See non-public blogs', Array(), 'Blog');
    79   $session->register_acl_type('nuggie_see_non_public', AUTH_DISALLOW, 'See non-public blogs', Array(), 'Blog');
    75   
    80   
    76   // Extend the core permission set
    81   // Extend the core permission set
    77   
    82   
    78   $session->acl_extend_scope('read', 'Blog|Planet', $paths);
    83   $session->acl_extend_scope('read', 'Blog|Planet|BlogPost', $paths);
    79   $session->acl_extend_scope('edit_comments', 'Blog', $paths);
    84   $session->acl_extend_scope('edit_comments', 'BlogPost', $paths);
    80   $session->acl_extend_scope('post_comments', 'Blog', $paths);
    85   $session->acl_extend_scope('post_comments', 'BlogPost', $paths);
    81   $session->acl_extend_scope('mod_comments', 'Blog', $paths);
    86   $session->acl_extend_scope('mod_comments', 'BlogPost', $paths);
    82 }
    87 }
    83 
    88 
    84 $plugins->attachHook('page_type_string_set', 'nuggie_set_page_string();');
    89 $plugins->attachHook('page_type_string_set', 'nuggie_set_page_string();');
       
    90 
       
    91 require( ENANO_ROOT . '/plugins/nuggie/planet.php' );
       
    92 require( ENANO_ROOT . '/plugins/nuggie/postbit.php' );
    85 
    93 
    86 function nuggie_set_page_string()
    94 function nuggie_set_page_string()
    87 {
    95 {
    88   global $db, $session, $paths, $template, $plugins; // Common objects
    96   global $db, $session, $paths, $template, $plugins; // Common objects
    89   
    97   
   110 {
   118 {
   111   global $db, $session, $paths, $template, $plugins; // Common objects
   119   global $db, $session, $paths, $template, $plugins; // Common objects
   112   
   120   
   113   if ( $processor->namespace == 'Blog' )
   121   if ( $processor->namespace == 'Blog' )
   114   {
   122   {
   115     require( ENANO_ROOT . '/plugins/nuggie/postbit.php' );
   123     $result = nuggie_blog_uri_handler($processor);
   116     $result = nuggie_blog_uri_handler($processor->page_id);
       
   117     if ( $result === '_err_access_denied' )
   124     if ( $result === '_err_access_denied' )
   118     {
   125     {
   119       $processor->err_access_denied();
   126       $processor->err_access_denied();
   120       return true;
   127       return true;
   121     }
   128     }
   122   }
   129   }
   123   else if ( $processor->namespace == 'Planet' )
   130   else if ( $processor->namespace == 'Planet' )
   124   {
   131   {
   125     $result = nuggie_planet_uri_handler($processor->page_id);
   132     // revision 7: never called anymore
   126     if ( $result === '_err_access_denied' )
       
   127     {
       
   128       $processor->err_access_denied();
       
   129       return true;
       
   130     }
       
   131   }
   133   }
   132 }
   134 }
   133 
   135 
   134 /**
   136 /**
   135  * Sanitizes a string for a Nuggie permalink.
   137  * Sanitizes a string for a Nuggie permalink.