alanfluff
2/2/2013 - 9:31 PM

ProcessWire: PHP: Complex user checking code.php

<?php
//This just blew my mind
//
//User has field 'userPages'[Pagefield type], where administrator added parts of whole tree avail. to user.
//This checks whether current page (wrapped in object) or any of its parents was added to this 'userPages'
//(thus current page or anything higher in the hierarchy gives user the access)
//wow.

$access =
  count(
    Wire::getFuel('user')->userPages->find(
       'id='.$this->page->parents()
               ->append($this->page)
     )
   ) > 0;