Beispiel #1
0
 /**
  * Checks if user is allowed to access the page
  * @param $hint
  * @param $show
  */
 function checkforGuest(&$hint = NULL, &$show = NULL)
 {
     if (!parent::checkForGuest()) {
         return false;
     }
     $pageobj = $this;
     $hash = $pageobj->getPassword();
     while (empty($hash) && !is_null($pageobj)) {
         $parentID = $pageobj->getParentID();
         if (empty($parentID)) {
             $pageobj = NULL;
         } else {
             $sql = 'SELECT `titlelink` FROM ' . prefix('pages') . ' WHERE `id`=' . $parentID;
             $result = query_single_row($sql);
             $pageobj = newPage($result['titlelink']);
             $hash = $pageobj->getPassword();
         }
     }
     if (empty($hash)) {
         // no password required
         return 'zp_public_access';
     } else {
         $authType = "zp_page_auth_" . $pageobj->getID();
         $saved_auth = zp_getCookie($authType);
         if ($saved_auth == $hash) {
             return $authType;
         } else {
             $user = $pageobj->getUser();
             $show = !empty($user);
             $hint = $pageobj->getPasswordHint();
             return false;
         }
     }
 }
Beispiel #2
0
 /**
  * See if a guest is logged on to the news category.
  * Note: If any belonging category is plublic or he is logged on, then success.
  * @param $hint
  * @param $show
  */
 function checkforGuest(&$hint = NULL, &$show = NULL)
 {
     if (!parent::checkForGuest()) {
         return false;
     }
     $categories = $this->getCategories();
     if (empty($categories)) {
         //	cannot be protected!
         return 'zp_public_access';
     } else {
         foreach ($categories as $cat) {
             $catobj = newCategory($cat['titlelink']);
             $guestaccess = $catobj->checkforGuest($hint, $show);
             if ($guestaccess) {
                 return $guestaccess;
             }
         }
     }
     return false;
 }