Add problem reporting

This commit is contained in:
Olivier Berten 2013-11-16 17:44:35 +01:00
parent 81996e602e
commit 400d0b45ab
7 changed files with 164 additions and 14 deletions

View File

@ -16,12 +16,30 @@ if(!$c) {
}
$title = $c['incipit'];
$custom_header = <<<HEADER
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.bpopup.min.js"></script>
<style>
#popup1, #popup2 {
background-color:#fff;
border-radius:15px;
color:#000;
display:none;
padding:20px;
min-width:400px;
min-height: 80px;
}</style>
HEADER;
include('include/header.php');
if(isset($_POST['proofread']) && $_POST['proofread'] == 'Me' && $c) {
if(isset($_POST['proofread']) && $_POST['proofread'] == 'Me') {
$mysqli->query('INSERT into '.db('proofreading').' VALUES ('.$id.','.$current_user->ID.','.time().')') or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
}
if(isset($_POST['pleasefix']) && $_POST['pleasefix'] > '') {
$mysqli->query('INSERT into '.db('pleasefix').' (chant_id,pleasefix,time,'.($logged_in ? 'user_id' : 'ip').') VALUES ('.$id.',"'.$mysqli->real_escape_string($_POST['pleasefix']).'",'.time().',"'.($logged_in ? $current_user->ID : $_SERVER['REMOTE_ADDR']).'")') or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
}
$c_p = array();
$sql1 = 'SELECT * FROM '.db('chant_sources').' WHERE chant_id = '.$id.' ORDER BY source';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
@ -47,19 +65,37 @@ echo '<div id="score"><br />';
if($c['gabc'] > '') {
echo '<img src="chant_img.php?id='.$id.'" alt="" />';
} else {
if($logged_in != true) {
echo 'Yet to be transcribed. Please log-in or register if you would like to do it.';
echo 'Yet to be transcribed. ';
if($logged_in) {
echo 'Please do it !';
} else {
echo 'Please log-in or register if you would like to do it.';
}
}
echo '<br />&nbsp;</div>'."\n";
echo '<div id="info">
';
$sql = 'SELECT * FROM '.db('pleasefix').' WHERE chant_id = '.$id.' AND fixed = 0';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
echo '<h3>'.format_incipit($c['incipit']);
if($req->num_rows > 0) {
echo '<span id="push2"> <a href="#"><img src="warning.png" alt="Warning!" /></a></span>';
}
if($logged_in) {
echo ' <span class="edit"><a href="chant_edit.php?id='.$id.'">Edit</a></span>';
}
echo '</h3>
';
if($req->num_rows > 0) {
echo '<div id="popup2">';
$count = 0;
while($fix = $req->fetch_assoc()) {
if($count > 0) echo "<hr />";
echo '<p><img src="warning.png" alt="Warning!" /> '.nl2br(htmlspecialchars($fix['pleasefix']))."</p>\n";
$count++;
}
echo '</div>';
}
if($c['version'] > '') echo '<h4>Version</h4><ul><li>'.$c['version']."</li></ul>\n";
echo '<h4>Usage</h4><ul><li><span class="usage '.$c['office-part'].'">'.$txt['usage'][$c['office-part']]."</span></li></ul>\n";
@ -165,7 +201,15 @@ foreach($proof as $r) {
if(count($proof) > 0 || $logged_in) {
echo "</ul>\n";
}
echo '<p id="push1"><a href="#">Report a problem</a></p>';
$report_form = '<form action="'.$_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'').'" method="post"><textarea name="pleasefix" class="gabc"></textarea><br /><input type="submit" /></form>';
echo <<<POPUP1
<div id="popup1">
Please describe the problem:<br />
$report_form
</div>
POPUP1;
echo "<h4>Download</h4>\n<ul>\n";
$content = json_decode($c['gabc']);
if(is_string($content)) {
@ -216,5 +260,41 @@ echo $sources_img;
echo '</div>';
echo <<<SCRIPT
<script type="text/javascript">
// Semicolon (;) to ensure closing of earlier scripting
// Encapsulation
// $ is assigned to jQuery
;(function($) {
// DOM Ready
$(function() {
// Binding a click event
// From jQuery v.1.7.0 use .on() instead of .bind()
$('#push1').bind('click', function(e) {
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
$('#popup1').bPopup();
});
$('#push2').bind('click', function(e) {
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
$('#popup2').bPopup();
});
});
})(jQuery);
</script>
SCRIPT;
include('include/footer.php');
?>

View File

@ -125,7 +125,16 @@ if(!$logged_in) {
$sql = 'INSERT into '.db('changesets').' VALUES ('.$uid.','.$id.','.$t.', "Added to the database")';
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
header('Location: chant.php?id='.$id);
} elseif(count($mypost) > 3) {
} elseif(array_key_exists('comment',$mypost)) {
$chgset = explode('|',$mypost['changeset']);
$sql = 'UPDATE '.db('changesets').' SET `comment` = "'.$mysqli->real_escape_string($mypost['comment']).'" WHERE `user_id` = '.intval($chgset[2]).' AND `chant_id` = '.intval($chgset[1]).' AND `time` = '.intval($chgset[0]);
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
foreach($mypost['fix'] as $fix) {
$sql = 'UPDATE '.db('pleasefix').' SET `fixed` = 1, `fixed_by` = '.intval($chgset[2]).', `fixed_time` = '.intval($chgset[0]).' WHERE `id` = '.$fix;
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
header('Location: chant.php?id='.$id);
} elseif(count($mypost) > 0) {
$gabc = array();
for($i=0;$i<count($mypost['type']);$i++) {
if($mypost['content'][$i] > '') {
@ -216,18 +225,22 @@ if(!$logged_in) {
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
}
echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post"><input type="hidden" name="changeset" value="'.$chgset.'" />';
echo "<h4>Please describe your changes</h4>\n".'<input name="comment" style="width:640px" />'."<br />\n<input type=\"submit\" />\n</form>\n";
echo "<h4>Please describe your changes</h4>\n".'<input name="comment" style="width:640px" />'."<br />\n<h4>Does it fix one of these problems?</h4>\n";
$sql = 'SELECT * FROM '.db('pleasefix').' WHERE chant_id = '.$id.' AND fixed = 0';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
$count = 0;
while ($fix = $req->fetch_assoc()) {
if($count > 0) echo "<hr />";
echo '<p><input type="checkbox" name="fix[]" value="'.$fix['id'].'"> '.nl2br(htmlspecialchars($fix['pleasefix']))."</p>\n";
$count++;
}
echo '<input type="submit" /></form>';
if($mod) {
echo '<img src="chant_img.php?id='.$id.'&force=1" width="1" height="1" alt="" />';
}
} else {
echo "<p>No changes made</p>";
}
} elseif(count($mypost) > 0) {
$chgset = explode('|',$mypost['changeset']);
$sql = 'UPDATE '.db('changesets').' SET `comment` = "'.$mysqli->real_escape_string($mypost['comment']).'" WHERE `user_id` = '.$chgset[2].' AND `chant_id` = '.$chgset[1].' AND `time` = '.$chgset[0];
$mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
header('Location: chant.php?id='.$id);
} else {
$gabc = json_decode($c['gabc']);
if(is_string($gabc)) {

View File

@ -3,9 +3,9 @@
-- http://www.phpmyadmin.net
--
-- Client: localhost
-- Généré le: Jeu 24 Octobre 2013 à 07:46
-- Version du serveur: 10.0.4-MariaDB-1~raring-log
-- Version de PHP: 5.5.5-1+debphp.org~raring+1
-- Généré le: Sam 16 Novembre 2013 à 17:06
-- Version du serveur: 5.5.31-0ubuntu0.12.04.2
-- Version de PHP: 5.4.17RC1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
@ -116,6 +116,25 @@ CREATE TABLE IF NOT EXISTS `gregobase_chant_tags` (
-- --------------------------------------------------------
--
-- Structure de la table `gregobase_pleasefix`
--
CREATE TABLE IF NOT EXISTS `gregobase_pleasefix` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chant_id` int(11) NOT NULL,
`pleasefix` text COLLATE utf8_unicode_ci NOT NULL,
`time` int(11) NOT NULL,
`user_id` int(11) DEFAULT NULL,
`ip` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`fixed` tinyint(1) NOT NULL DEFAULT '0',
`fixed_by` int(11) NOT NULL DEFAULT '0',
`fixed_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Structure de la table `gregobase_proofreading`
--

View File

@ -10,11 +10,19 @@ echo <<<HEADER1
<title>GregoBase - $title</title>
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic' />
<link rel="stylesheet" type="text/css" href="style.css" />
HEADER1;
if(isset($custom_header)) {
echo $custom_header;
}
$login = $logged_in ? '<li class="page_item"><a href="'.wp_logout_url('http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'">Logout</a></li>' : '<li class="page_item"><a href="./wp-login.php?redirect_to='.urlencode('http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'&amp;reauth=1">Login</a></li>';
$sql = 'SELECT * FROM '.db('pleasefix').' WHERE fixed = 0';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
if($req->num_rows > 0) {
$pleasefix = '<li class="page_item"><a href="pleasefix.php" style="color:red;">Please fix</a></li>';
} else {
$pleasefix = '';
}
echo <<<HEADER2
</head>
@ -25,7 +33,7 @@ echo <<<HEADER2
<div id="description">A database of gregorian scores</div>
<div id="access">
<div class="menu"><ul class="sf-menu"><li class="page_item current_page_item"><a href="scores.php">Scores</a></li><li class="page_item"><a href="./?page_id=18">Participate</a></li><li class="page_item"><a href="./?page_id=5">Todo</a></li><li class="page_item"><a href="./?page_id=2">About</a></li>$login</ul></div>
<div class="menu"><ul class="sf-menu"><li class="page_item current_page_item"><a href="scores.php">Scores</a></li><li class="page_item"><a href="./?page_id=18">Participate</a></li><li class="page_item"><a href="./?page_id=5">Todo</a></li><li class="page_item"><a href="./?page_id=2">About</a></li>$login$pleasefix</ul></div>
</div><!-- #access -->
</div>

7
jquery.bpopup.min.js vendored Normal file
View File

@ -0,0 +1,7 @@
/*================================================================================
* @name: bPopup - if you can't get it up, use bPopup
* @author: (c)Bjoern Klinggaard (twitter@bklinggaard)
* @demo: http://dinbror.dk/bpopup
* @version: 0.9.4.min
================================================================================*/
(function(b){b.fn.bPopup=function(z,F){function K(){a.contentContainer=b(a.contentContainer||c);switch(a.content){case "iframe":var h=b('<iframe class="b-iframe" '+a.iframeAttr+"></iframe>");h.appendTo(a.contentContainer);r=c.outerHeight(!0);s=c.outerWidth(!0);A();h.attr("src",a.loadUrl);k(a.loadCallback);break;case "image":A();b("<img />").load(function(){k(a.loadCallback);G(b(this))}).attr("src",a.loadUrl).hide().appendTo(a.contentContainer);break;default:A(),b('<div class="b-ajax-wrapper"></div>').load(a.loadUrl,a.loadData,function(){k(a.loadCallback);G(b(this))}).hide().appendTo(a.contentContainer)}}function A(){a.modal&&b('<div class="b-modal '+e+'"></div>').css({backgroundColor:a.modalColor,position:"fixed",top:0,right:0,bottom:0,left:0,opacity:0,zIndex:a.zIndex+t}).appendTo(a.appendTo).fadeTo(a.speed,a.opacity);D();c.data("bPopup",a).data("id",e).css({left:"slideIn"==a.transition||"slideBack"==a.transition?"slideBack"==a.transition?g.scrollLeft()+u:-1*(v+s):l(!(!a.follow[0]&&m||f)),position:a.positionStyle||"absolute",top:"slideDown"==a.transition||"slideUp"==a.transition?"slideUp"==a.transition?g.scrollTop()+w:x+-1*r:n(!(!a.follow[1]&&p||f)),"z-index":a.zIndex+t+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo)});H(!0)}function q(){a.modal&&b(".b-modal."+c.data("id")).fadeTo(a.speed,0,function(){b(this).remove()});a.scrollBar||b("html").css("overflow","auto");b(".b-modal."+e).unbind("click");g.unbind("keydown."+e);d.unbind("."+e).data("bPopup",0<d.data("bPopup")-1?d.data("bPopup")-1:null);c.undelegate(".bClose, ."+a.closeClass,"click."+e,q).data("bPopup",null);H();return!1}function G(h){var b=h.width(),e=h.height(),d={};a.contentContainer.css({height:e,width:b});e>=c.height()&&(d.height=c.height());b>=c.width()&&(d.width=c.width());r=c.outerHeight(!0);s=c.outerWidth(!0);D();a.contentContainer.css({height:"auto",width:"auto"});d.left=l(!(!a.follow[0]&&m||f));d.top=n(!(!a.follow[1]&&p||f));c.animate(d,250,function(){h.show();B=E()})}function L(){d.data("bPopup",t);c.delegate(".bClose, ."+a.closeClass,"click."+e,q);a.modalClose&&b(".b-modal."+e).css("cursor","pointer").bind("click",q);M||!a.follow[0]&&!a.follow[1]||d.bind("scroll."+e,function(){B&&c.dequeue().animate({left:a.follow[0]?l(!f):"auto",top:a.follow[1]?n(!f):"auto"},a.followSpeed,a.followEasing)}).bind("resize."+e,function(){w=y.innerHeight||d.height();u=y.innerWidth||d.width();if(B=E())clearTimeout(I),I=setTimeout(function(){D();c.dequeue().each(function(){f?b(this).css({left:v,top:x}):b(this).animate({left:a.follow[0]?l(!0):"auto",top:a.follow[1]?n(!0):"auto"},a.followSpeed,a.followEasing)})},50)});a.escClose&&g.bind("keydown."+e,function(a){27==a.which&&q()})}function H(b){function d(e){c.css({display:"block",opacity:1}).animate(e,a.speed,a.easing,function(){J(b)})}switch(b?a.transition:a.transitionClose||a.transition){case "slideIn":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()-(s||c.outerWidth(!0))-C});break;case "slideBack":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()+u+C});break;case "slideDown":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()-(r||c.outerHeight(!0))-C});break;case "slideUp":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()+w+C});break;default:c.stop().fadeTo(a.speed,b?1:0,function(){J(b)})}}function J(b){b?(L(),k(F),a.autoClose&&setTimeout(q,a.autoClose)):(c.hide(),k(a.onClose),a.loadUrl&&(a.contentContainer.empty(),c.css({height:"auto",width:"auto"})))}function l(a){return a?v+g.scrollLeft():v}function n(a){return a?x+g.scrollTop():x}function k(a){b.isFunction(a)&&a.call(c)}function D(){x=p?a.position[1]:Math.max(0,(w-c.outerHeight(!0))/2-a.amsl);v=m?a.position[0]:(u-c.outerWidth(!0))/2;B=E()}function E(){return w>c.outerHeight(!0)&&u>c.outerWidth(!0)}b.isFunction(z)&&(F=z,z=null);var a=b.extend({},b.fn.bPopup.defaults,z);a.scrollBar||b("html").css("overflow","hidden");var c=this,g=b(document),y=window,d=b(y),w=y.innerHeight||d.height(),u=y.innerWidth||d.width(),M=/OS 6(_\d)+/i.test(navigator.userAgent),C=200,t=0,e,B,p,m,f,x,v,r,s,I;c.close=function(){a=this.data("bPopup");e="__b-popup"+d.data("bPopup")+"__";q()};return c.each(function(){b(this).data("bPopup")||(k(a.onOpen),t=(d.data("bPopup")||0)+1,e="__b-popup"+t+"__",p="auto"!==a.position[1],m="auto"!==a.position[0],f="fixed"===a.positionStyle,r=c.outerHeight(!0),s=c.outerWidth(!0),a.loadUrl?K():A())})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",autoClose:!1,closeClass:"b-close",content:"ajax",contentContainer:!1,easing:"swing",escClose:!0,follow:[!0,!0],followEasing:"swing",followSpeed:500,iframeAttr:'scrolling="no" frameborder="0"',loadCallback:!1,loadData:!1,loadUrl:!1,modal:!0,modalClose:!0,modalColor:"#000",onClose:!1,onOpen:!1,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,speed:250,transition:"fadeIn",transitionClose:!1,zIndex:9997}})(jQuery);

23
pleasefix.php Normal file
View File

@ -0,0 +1,23 @@
<?php
include('include/db.php');
$title = 'Reported problems';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql = 'SELECT * FROM '.db('pleasefix').' WHERE fixed = 0 ORDER BY `time`';
$req = $mysqli->query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.$mysqli->error);
if($req->num_rows > 0) {
while($fix = $req->fetch_assoc()) {
echo '<h4><a href="chant.php?id='.$fix['chant_id'].'">'.format_incipit(chant_from_id($fix['chant_id'])[1])."</a></h4>\n";
echo "<p><i>".nl2br(htmlspecialchars($fix['pleasefix'])).'</i> <span class="version"> (Reported on '.date("Y-m-d",$fix['time']);
if($fix['user_id']) {
$user_info = get_userdata($fix['user_id']);
echo ' by '.$user_info->display_name;
}
echo ")</span></p>\n";
}
} else {
echo "<p>No problem reported</p>\n";
}
include('include/footer.php');
?>

BIN
warning.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B