Resource icon

Password Protected Nodes 1.2.9

No permission to download

Liam W

in memoriam 1998-2020
Liam W submitted a new resource:

Password Protected Nodes - Password protect forums and pages!

This addon was paid for as a custom (paid) development request, however the requester has allowed it to be released to the public :)

This addon will allow you to add a password to page and forum nodes, which will have to be entered when the node is accessed.

The password is stored in a cookie (encrypted), so that it doesn't have to be entered all the time the node is accessed.

Read more about this resource...
 
Great, just another addon overwriting the complete method and breaking all other addons extending the same class...:P

You should really avoid to do this, pls:)

PHP:
<?php

class PasswordProtectedForums_Extend_ControllerAdmin_Page extends XFCP_PasswordProtectedForums_Extend_ControllerAdmin_Page
{
   /* (non-PHPdoc)
    * @see XenForo_ControllerAdmin_Page::actionSave()
    */
   public function actionSave()
   {
     // TODO Auto-generated method stub
     $this->_assertPostOnly();

     if ($this->_input->filterSingle('delete', XenForo_Input::STRING))
     {
       return $this->responseReroute('XenForo_ControllerAdmin_Page', 'deleteConfirm');
     }

     $pageData = $this->_input->filter(array(
       'title' => XenForo_Input::STRING,
       'description' => XenForo_Input::STRING,
       'node_name' => XenForo_Input::STRING,
       'node_type_id' => XenForo_Input::BINARY,
       'parent_node_id' => XenForo_Input::UINT,
       'display_order' => XenForo_Input::UINT,
       'display_in_list' => XenForo_Input::UINT,
       'style_id' => XenForo_Input::UINT,
       'log_visits' => XenForo_Input::UINT,
       'list_siblings' => XenForo_Input::UINT,
       'list_children' => XenForo_Input::UINT,
       'callback_class' => XenForo_Input::STRING,
       'callback_method' => XenForo_Input::STRING,
       'node_password' => XenForo_Input::STRING,
     ));

     if (!$this->_input->filterSingle('style_override', XenForo_Input::UINT))
     {
       $pageData['style_id'] = 0;
     }

     $nodeId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);

     $pageData['modified_date'] = XenForo_Application::$time;

     $nodeId = $this->_getPageModel()->savePage(
       $pageData,
       $this->_input->filterSingle('template', XenForo_Input::STRING),
       $nodeId,
       $this->_input->filterSingle('template_id', XenForo_Input::UINT)
     );

     return $this->responseRedirect(
       XenForo_ControllerResponse_Redirect::SUCCESS,
       XenForo_Link::buildAdminLink('nodes') . $this->getLastHash($nodeId)
     );
   }

}

//class XFCP_PasswordProtectedForums_Extend_ControllerAdmin_Page extends XenForo_ControllerAdmin_Page {}
 
Last edited:
Great, just another addon overwriting the complete method and breaking all other addons extending the same class...:p

You should really avoid to do this, pls:)

PHP:
<?php

class PasswordProtectedForums_Extend_ControllerAdmin_Page extends XFCP_PasswordProtectedForums_Extend_ControllerAdmin_Page
{
   /* (non-PHPdoc)
    * @see XenForo_ControllerAdmin_Page::actionSave()
    */
   public function actionSave()
   {
     // TODO Auto-generated method stub
     $this->_assertPostOnly();

     if ($this->_input->filterSingle('delete', XenForo_Input::STRING))
     {
       return $this->responseReroute('XenForo_ControllerAdmin_Page', 'deleteConfirm');
     }

     $pageData = $this->_input->filter(array(
       'title' => XenForo_Input::STRING,
       'description' => XenForo_Input::STRING,
       'node_name' => XenForo_Input::STRING,
       'node_type_id' => XenForo_Input::BINARY,
       'parent_node_id' => XenForo_Input::UINT,
       'display_order' => XenForo_Input::UINT,
       'display_in_list' => XenForo_Input::UINT,
       'style_id' => XenForo_Input::UINT,
       'log_visits' => XenForo_Input::UINT,
       'list_siblings' => XenForo_Input::UINT,
       'list_children' => XenForo_Input::UINT,
       'callback_class' => XenForo_Input::STRING,
       'callback_method' => XenForo_Input::STRING,
       'node_password' => XenForo_Input::STRING,
     ));

     if (!$this->_input->filterSingle('style_override', XenForo_Input::UINT))
     {
       $pageData['style_id'] = 0;
     }

     $nodeId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);

     $pageData['modified_date'] = XenForo_Application::$time;

     $nodeId = $this->_getPageModel()->savePage(
       $pageData,
       $this->_input->filterSingle('template', XenForo_Input::STRING),
       $nodeId,
       $this->_input->filterSingle('template_id', XenForo_Input::UINT)
     );

     return $this->responseRedirect(
       XenForo_ControllerResponse_Redirect::SUCCESS,
       XenForo_Link::buildAdminLink('nodes') . $this->getLastHash($nodeId)
     );
   }

}

//class XFCP_PasswordProtectedForums_Extend_ControllerAdmin_Page extends XenForo_ControllerAdmin_Page {}

Actually, i did. But I couldn't for the life of me think of a way to.make it work when calling parent, as it would result in duplicated entried or errors.

I did try!

If you have any ideas, I'm all ears!
 
What's the problem? I'm not a dev so I'm unable to fully understand what's the point...

When using the class proxy feature, xenForo doesn't use the default class - it uses classes from addons, that extend each other, finally extending the main xenForo class.

If one of those addon classes don't call the parent function/class (the class it's extending) the the chain is broken, and other addons code won't be run.

It's a bad thing to do, and I try to avoid it as much as possible, but sometimes I just can't figure out a way to make it work without not calling the parent.

Make sense?

Liam
 
Hi, when i click on the Last post by XXXX, i have access to the post and i don't need the password !

Can you fix this bug ?
 
Top Bottom