1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184:
<?php
$plugin_is_filter = 900 | THEME_PLUGIN;
$plugin_description = gettext("Provides a means for users to login/out from your theme pages.");
$plugin_author = "Stephen Billard (sbillard)";
$plugin_category = gettext('Users');
$option_interface = 'user_logout_options';
if (isset($_zp_gallery_page) && getOption('user_logout_login_form') > 1) {
setOption('colorbox_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1, false);
require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/colorbox_js.php');
if (!zp_has_filter('theme_head', 'colorbox::css')) {
zp_register_filter('theme_head', 'colorbox::css');
}
}
class user_logout_options {
function __construct() {
setOptionDefault('user_logout_login_form', 0);
}
function getOptionsSupported() {
return array(gettext('Login form') => array('key' => 'user_logout_login_form', 'type' => OPTION_TYPE_RADIO,
'buttons' => array(gettext('None') => 0, gettext('Form') => 1, gettext('Colorbox') => 2),
'desc' => gettext('If the user is not logged-in display an <em>in-line</em> logon form or a link to a modal <em>Colorbox</em> form.'))
);
}
function handleOption($option, $currentValue) {
}
}
if (in_context(ZP_INDEX)) {
if (isset($_GET['userlog'])) {
if ($_GET['userlog'] == 0) {
if (!$location = Zenphoto_Authority::handleLogout()) {
$__redirect = array();
if (in_context(ZP_ALBUM)) {
$__redirect['album'] = $_zp_current_album->name;
}
if (in_context(ZP_IMAGE)) {
$__redirect['image'] = $_zp_current_image->filename;
}
if (in_context(ZP_ZENPAGE_PAGE)) {
$__redirect['title'] = $_zp_current_zenpage_page->getTitlelink();
}
if (in_context(ZP_ZENPAGE_NEWS_ARTICLE)) {
$__redirect['title'] = $_zp_current_zenpage_news->getTitlelink();
}
if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
$__redirect['category'] = $_zp_current_category->getTitlelink();
}
if (isset($_GET['p'])) {
$__redirect['p'] = sanitize($_GET['p']);
}
if (isset($_GET['searchfields'])) {
$__redirect['searchfields'] = sanitize($_GET['searchfields']);
}
if (isset($_GET['words'])) {
$__redirect['words'] = sanitize($_GET['words']);
}
if (isset($_GET['date'])) {
$__redirect['date'] = sanitize($_GET['date']);
}
if (isset($_GET['title'])) {
$__redirect['title'] = sanitize($_GET['title']);
}
if (isset($_GET['page'])) {
$__redirect['page'] = sanitize($_GET['page']);
}
$params = '';
if (!empty($__redirect)) {
foreach ($__redirect as $param => $value) {
$params .= '&' . $param . '=' . $value;
}
}
$location = FULLWEBPATH . '/index.php?fromlogout' . $params;
}
redirectURL($location);
}
}
}
function printUserLogin_out($before = '', $after = '', $showLoginForm = NULL, $logouttext = NULL) {
global $_zp_gallery, $__redirect, $_zp_current_admin_obj, $_zp_login_error, $_zp_gallery_page;
$excludedPages = array('password.php', 'register.php', 'favorites.php', '404.php');
$logintext = gettext('Login');
if (is_null($logouttext))
$logouttext = gettext("Logout");
$params = array("'userlog=0'");
if (!empty($__redirect)) {
foreach ($__redirect as $param => $value) {
$params[] .= "'" . $param . '=' . urlencode($value) . "'";
}
}
if (is_null($showLoginForm)) {
$showLoginForm = getOption('user_logout_login_form');
}
if (is_object($_zp_current_admin_obj)) {
if (!$_zp_current_admin_obj->logout_link) {
return;
}
}
$cookies = Zenphoto_Authority::getAuthCookies();
if (empty($cookies) || !zp_loggedin()) {
if (!in_array($_zp_gallery_page, $excludedPages)) {
switch ($showLoginForm) {
case 1:
?>
<div class="passwordform">
<?php printPasswordForm('', true, false); ?>
</div>
<?php
break;
case 2:
if ((getOption('colorbox_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page))) && (zp_has_filter('theme_head', 'colorbox::css'))) { ?>
<script type="text/javascript">
$(document).ready(function() {
$(".logonlink").colorbox({
inline: true,
innerWidth: "400px",
href: "#passwordform",
close: '<?php echo gettext("close"); ?>',
open: $('#passwordform_enclosure .errorbox').length
});
});
</script>
<?php if ($before) { echo '<span class="beforetext">' . html_encodeTagged($before) . '</span>'; } ?>
<a href="#" class="logonlink" title="<?php echo $logintext; ?>"><?php echo $logintext; ?></a>
<span id="passwordform_enclosure" style="display:none">
<div class="passwordform">
<?php printPasswordForm('', true, false); ?>
</div>
</span>
<?php if ($after) { echo '<span class="aftertext">' . html_encodeTagged($after) . '</span>'; }
}
break;
default:
if ($loginlink = zp_apply_filter('login_link',getCustomPageURL('password'))) {
if ($before) { echo '<span class="beforetext">' . html_encodeTagged($before) . '</span>'; } ?>
<a href="<?php echo $loginlink; ?>" class="logonlink" title="<?php echo $logintext; ?>"><?php echo $logintext; ?></a>
<?php if ($after) { echo '<span class="aftertext">' . html_encodeTagged($after) . '</span>'; }
}
}
}
} else {
if ($before) { echo '<span class="beforetext">' . html_encodeTagged($before) . '</span>'; }
$logoutlink = "javascript:launchScript('" . FULLWEBPATH . "/',[" . implode(',', $params) . "]);";
?>
<a class="logoutlink" href="<?php echo $logoutlink; ?>" title="<?php echo $logouttext; ?>"><?php echo $logouttext; ?></a>
<?php if ($after) { echo '<span class="aftertext">' . html_encodeTagged($after) . '</span>'; }
}
}
?>