/** * 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 = new ZenpagePage($result['titlelink']); $hash = $pageobj->getPassword(); } } if (empty($hash)) { // no password required return 'zp_public_access'; } else { $authType = "zp_page_auth_" . $pageobj->get('id'); $saved_auth = zp_getCookie($authType); if ($saved_auth == $hash) { return $authType; } else { $user = $pageobj->getUser(); $show = !empty($user); $hint = $pageobj->getPasswordHint(); return false; } } }
/** * 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 = new ZenpageCategory($cat['titlelink']); $guestaccess = $catobj->checkforGuest($hint, $show); if ($guestaccess) { return $guestaccess; } } } return false; }