?> <h1><?php echo gettext('Edit Page:'); ?> <em><?php checkForEmptyTitle($result->getTitle(), 'page', false); ?> </em></h1> <?php if ($result->getDatetime() >= date('Y-m-d H:i:s')) { echo ' <small><strong id="scheduldedpublishing">' . gettext('(Page scheduled for publishing)') . '</strong></small>'; if ($result->getShow() != 1) { echo '<p class="scheduledate"><small>' . gettext('Note: Scheduled publishing is not active unless the page is also set to <em>published</em>') . '</small></p>'; } } if ($result->getPassword()) { echo '<p class="notebox">' . gettext('<strong>Note:</strong> This page is password protected.') . '</p>'; } } } } if ($result->loaded || $result->transient) { if ($result->transient) { ?> <form class="dirty-check" method="post" name="addnews" action="admin-edit.php?<?php echo $admintype; ?> &save"> <?php XSRFToken('save'); } else {
/** * Prints the checkboxes to select and/or show the category of an news article on the edit or add page * * @param int $id ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added. * @param string $option "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned. */ function printCategorySelection($id = '', $option = '') { global $_zp_zenpage; $selected = ''; echo "<ul class='zenpagechecklist'>\n"; $all_cats = $_zp_zenpage->getAllCategories(false); foreach ($all_cats as $cats) { $catobj = new ZenpageCategory($cats['titlelink']); if ($option != "all") { $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $id . " AND cat_id = " . $catobj->getID()); if ($cat2news['cat_id'] != "") { $selected = "checked ='checked'"; } } $catname = $catobj->getTitle(); $catlink = $catobj->getTitlelink(); if ($catobj->getPassword()) { $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />'; } else { $protected = ''; } $catid = $catobj->getID(); echo "<li class=\"hasimage\" ><label for='cat" . $catid . "'><input name='cat" . $catid . "' id='cat" . $catid . "' type='checkbox' value='" . $catid . "' " . $selected . " />" . $catname . " " . $protected . "</label></li>\n"; } echo "</ul>\n"; }
/** * Checks if user is allowed to access news category * @param $hint * @param $show */ function checkforGuest(&$hint = NULL, &$show = NULL) { if (!parent::checkForGuest()) { return false; } $obj = $this; $hash = $this->getPassword(); while (empty($hash) && !is_null($obj)) { $parentID = $obj->getParentID(); if (empty($parentID)) { $obj = NULL; } else { $sql = 'SELECT `titlelink` FROM ' . prefix('news_categories') . ' WHERE `id`=' . $parentID; $result = query_single_row($sql); $obj = new ZenpageCategory($result['titlelink']); $hash = $obj->getPassword(); } } if (empty($hash)) { // no password required return 'zp_public_access'; } else { $authType = "zp_category_auth_" . $this->getID(); $saved_auth = zp_getCookie($authType); if ($saved_auth == $hash) { return $authType; } else { $user = $this->getUser(); if (!empty($user)) { $show = true; } $hint = $this->getPasswordHint(); return false; } } }
/** * Checks if an article is in a password protected category and returns TRUE or FALSE * NOTE: This function does not check if the password has been entered! Use checkAccess() for that. * * @param bool $only set to true to know if the news article belongs only to protected categories (i.e. it is protected) * * @return array */ function inProtectedCategory($only = false) { $categories = $this->getCategories(); if (!empty($categories)) { foreach ($categories as $cat) { $catobj = new ZenpageCategory($cat['titlelink']); $password = $catobj->getPassword(); if (!empty($password)) { if (!$only) { return true; } } else { if ($only) { return false; } } } return $only; } return false; }