forked from alixandru/q2a-open-login
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa-open-layer.php
More file actions
145 lines (111 loc) · 4 KB
/
Copy pathqa-open-layer.php
File metadata and controls
145 lines (111 loc) · 4 KB
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
<?php
/*
Question2Answer (c) Gideon Greenspan
Open Login Plugin (c) Alex Lixandru
http://www.question2answer.org/
File: qa-plugin/open-login/qa-open-layer.php
Version: 3.0.0
Description: Extends current theme with additional functionalities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
class qa_html_theme_layer extends qa_html_theme_base
{
function doctype() {
parent::doctype();
if(QA_FINAL_EXTERNAL_USERS) {
return;
}
// check if logged in
$handle = qa_get_logged_in_handle();
if (isset($handle)) {
if(qa_request() == '' && count($_GET) > 0) {
// Check if we need to associate another provider
$this->process_login();
}
// see if the account pages are accessed
$tmpl = array( 'account', 'favorites' );
$user_pages = array('user', 'user-wall', 'user-activity',
'user-questions', 'user-answers' );
$logins_page = qa_request() == 'logins' && !qa_get('confirm');
$urlhandle = qa_request_part(1);
if ( in_array($this->template, $tmpl) || $logins_page ||
(in_array($this->template, $user_pages) && $handle == $urlhandle) ) {
// add a navigation item
$this->content['navigation']['sub']['logins'] = array(
'label' => qa_lang_html('plugin_open/my_logins_nav'),
'url' => qa_path_html('logins'),
'selected' => $logins_page
);
return;
}
} else {
$title = qa_lang_html('plugin_open/login_title');
$descr = qa_lang_html('plugin_open/login_description');
// hide login/register links from navigation on any page
if(qa_opt('open_login_hideform') == '1') {
unset($this->content['navigation']['user']['login']);
unset($this->content['navigation']['user']['register']);
}
// then check if login/register pages are accessed
$tmpl = array( 'register', 'login' );
if ( !in_array($this->template, $tmpl) ) {
return;
}
// hide regular login/register form on those pages only
if(qa_opt('open_login_hideform') == '1') {
$this->content['title'] = $title;
$this->content['form'] = null;
}
// add some custom text
if(!empty($this->content['custom'])) {
$content = str_ireplace('<BR>', '', $this->content['custom']);
$this->content['custom'] = "<div><p>$descr</p>$content</div>";
if($this->content['form'] != null) {
$this->content['custom'] = "<br /><br /><h1>$title</h1>{$this->content['custom']}";
}
}
}
}
function head_css() {
parent::head_css();
$hidecss = qa_opt('open_login_css') == '1';
$zocial = qa_opt('open_login_zocial') == '1';
if (!$hidecss) {
// display CSS inline
$path = QA_HTML_THEME_LAYER_URLTOROOT;
$this->output('<style type="text/css"><!--');
$this->output(@file_get_contents( QA_HTML_THEME_LAYER_URLTOROOT . 'qa-open-login.css'));
$this->output('//--></style>');
if($zocial) {
$this->output('<style type="text/css"><!--');
$this->output("@import url('{$path}css/zocial.css');");
$this->output('//--></style>');
}
}
}
function process_login() {
$action = null;
$key = null;
if( !empty($_REQUEST['hauth_start']) ) {
$key = trim(strip_tags($_REQUEST['hauth_start']));
$action = 'process';
} else if( !empty($_REQUEST['hauth_done']) ) {
$key = trim(strip_tags($_REQUEST['hauth_done']));
$action = 'process';
}
if($key == null || $action == null) {
return false;
}
require_once( QA_HTML_THEME_LAYER_URLTOROOT . "Hybrid/Auth.php" );
require_once( QA_HTML_THEME_LAYER_URLTOROOT . "Hybrid/Endpoint.php" );
Hybrid_Endpoint::process();
}
}