-
Notifications
You must be signed in to change notification settings - Fork 61
/
peer.php
171 lines (139 loc) · 7.17 KB
/
peer.php
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
<?php
/**
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
* The Apereo Foundation licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* peer page, allows for the peer review of a template
*
* @author Patrick Lockley
* @version 1.0
* @package
*/
require_once(dirname(__FILE__) . "/config.php");
_load_language_file("/peer.inc");
require $xerte_toolkits_site->php_library_path . "display_library.php";
function show_peer_template_form($row, $retouremail)
{
global $xerte_toolkits_site;
$helptext = XERTE_PEER_TEXTAREA_INSTRUCTIONS;
$helptext = str_replace("{creator}", $row['firstname'] . ' ' . $row['surname'], $helptext);
$helptext = str_replace("{url}", $xerte_toolkits_site->site_url, $helptext);
$helptext = str_replace("{email}", $retouremail, $helptext);
?>
<html>
<head>
<script type="text/javascript" language="Javascript" src="website_code/scripts/peer.js"></script>
<script type="text/javascript" language="Javascript" src="website_code/scripts/ajax_management.js"></script>
<script type="text/javascript" src="modules/xerte/parent_templates/Nottingham/common_html5/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" language="Javascript" src="modules/xerte/parent_templates/Nottingham/common_html5/js/featherlight/featherlight.min.js"></script>
<link rel="stylesheet" href="modules/xerte/parent_templates/Nottingham/common_html5/js/featherlight/featherlight.min.css" type="text/css" />
</head>
<body style="#ffffff;">
<div style="width:95%; margin:0 auto;">
<div style="font-family:verdana,tahoma,arial; font-size:11pt">
<h1 style="margin-top:1em;"><?php echo XERTE_PEER_DESCRIPTION; ?></h1>
<p><?php echo XERTE_PEER_GUIDANCE; ?> <a href="show_peer.php" data-featherlight="iframe" data-featherlight-iframe-style="display:block;border:none;height:85vh;width:85vw;"><?php echo XERTE_PEER_LIGHTBOX; ?></a></p>
</div>
<div style="width:24%; display:inline-block; position: fixed;">
<!--form name="peer" action="javascript:send_review('<?php //echo $retouremail; ?>','<?php //echo $row['template_id']; ?>')" method="post" enctype="text/plain"-->
<form name="peer" action="javascript:send_review()" method="post" enctype="text/plain">
<textarea style="width:100%; height:70vh;" name="response"><?php echo $helptext; ?></textarea>
<br/>
<button type="submit" class="xerte_button"><?php echo XERTE_PEER_BUTTON_SEND; ?></button>
</form>
<a name="feedbackform"><p style="color:red;" id="pv_feedback"></p></a>
</div> <iframe src="show_peer.php" style="width:74%; height:80%; margin-left: 27%; border:none;"></iframe>
</div>
</div>
</body>
</html>
<?php
}
function show_peer_login_form($mesg="")
{
echo "<html>\n";
echo "<body style=\"#ffffff;\">\n";
echo " <div style=\"width:900px; margin:0 auto; font-family:verdana,tahoma,arial; font-size:11pt\">\n";
echo " <b>" . XERTE_PEER_DESCRIPTION . "</b><br>" . XERTE_PEER_GUIDANCE . "\n";
echo "<p><form method=\"post\" action=\"\">\n";
echo "<p>" . XERTE_PEER_PASSWORD . " <input type=\"password\" size=\"20\" maxlength=\"36\" name=\"password\" /> <button type=\"submit\">" . XERTE_PEER_LOGIN_BUTTON . "</button></p>\n";
if (strlen($mesg)>0)
{
echo "<p>" . $mesg . "</p>";
}
echo "</div></body></html>";
}
/**
* Check the template ID is a number
*/
if(empty($_GET['template_id']) || !is_numeric($_GET['template_id'])) {
die("Invalid template id");
}
$template_id = (int) $_GET['template_id'];
$query_to_check_peer = "select * from " . $xerte_toolkits_site->database_table_prefix . "additional_sharing where sharing_type=\"peer\" and template_id=\"" . $template_id . "\"";
$query_for_peer_response = db_query_one("SELECT * FROM {$xerte_toolkits_site->database_table_prefix}additional_sharing WHERE sharing_type = ? AND template_id = ?", array('peer', $template_id));
/**
* The number of rows being not equal to 0, indicates peer review has been set up.
*/
if(!empty($query_for_peer_response)) {
$query_for_play_content = "select otd.template_name, otd.parent_template, ld.username, ld.surname, ld.firstname, otd.template_framework, tr.user_id, tr.folder, tr.template_id, td.access_to_whom, td.date_modified, td.date_created, td.number_of_uses, td.extra_flags";
$query_for_play_content .= " from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails otd, " . $xerte_toolkits_site->database_table_prefix . "templaterights tr, " . $xerte_toolkits_site->database_table_prefix . "templatedetails td, " . $xerte_toolkits_site->database_table_prefix . "logindetails ld";
$query_for_play_content .= " where td.template_type_id = otd.template_type_id and td.creator_id = ld.login_id and tr.template_id = td.template_id and tr.template_id=" . $template_id . " and (role='creator' or role='co-author')";
$row_play = db_query_one($query_for_play_content);
/**
* Peer review needs a password, so check if anything has been posted
*/
require $xerte_toolkits_site->php_library_path . "screen_size_library.php";
require $xerte_toolkits_site->root_file_path . "modules/" . $row_play['template_framework'] . "/peer.php";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
/**
* Check the password againsr the value in the database
*/
$extra = explode("," , $query_for_peer_response['extra'],2);
$passwd = $extra[0];
if (count($extra) > 1)
{
$retouremail = $extra[1];
}
else
{
$retouremail = $_SESSION['toolkits_logon_username'];
if (strlen($xerte_toolkits_site->email_to_add_to_username)>0)
{
$retouremail .= '@' . $xerte_toolkits_site->email_to_add_to_username;
}
}
if($_POST['password'] == $passwd) {
/**
* Output the code
*/
$_SESSION['template_id'] = $template_id;
$_SESSION['retouremail'] = $retouremail;
show_peer_template_form($row_play, $retouremail);
}else{
show_peer_login_form(PEER_LOGON_FAIL);
}
}else{
/**
* Nothing posted so output the password string
*/
show_peer_login_form();
// echo $xerte_toolkits_site->peer_form_string;
}
}else{
dont_show_template();
}