Branch work

This commit is contained in:
nikolark committed 2014-08-11 13:52:35 +02:00
1 parent a492f02ce4
commit 929a64e428
7 files changed
+270 -116

No files matched your search

+1
View File
@@ -92,6 +92,7 @@ $query = $conn->quoteSmart($query);
// Search query // Search query
// TODO allow users with permission to search all users (not filter active group) // TODO allow users with permission to search all users (not filter active group)
// TODO: group memberships should be "AND-ed" together somehow
$user_search_query = "CONCAT(UPPER(u.firstname), ' ', UPPER(u.lastname)) LIKE $query $user_search_query = "CONCAT(UPPER(u.firstname), ' ', UPPER(u.lastname)) LIKE $query
OR CONCAT(UPPER(u.firstname), ' ', UPPER(u.lastname)) LIKE $query OR CONCAT(UPPER(u.firstname), ' ', UPPER(u.lastname)) LIKE $query
OR UPPER(u.username) LIKE $query OR UPPER(u.username) LIKE $query
+119
View File
@@ -0,0 +1,119 @@
<?php
/* SMS purchase activation form
*
* TODO possible to activate expired memberships?
*/
set_include_path("../includes/");
require_once("../inside/credentials.php");
require_once("../inside/functions.php");
require_once("../inside/migration/ldap_api_functions.php");
require_once("DB.php");
require_once("../snapporder/lib/functions.php");
require_once("../snapporder/config.php");
/* Connect to database */
$options = array( 'debug' => 2, 'portability' => DB_PORTABILITY_ALL );
$conn = DB::connect(getDSN(), $options);
if(DB :: isError($conn)) {
echo $conn->toString();
set_response_code(500);
echo 'Could not connect to DB';
die();
}
$conn->setFetchMode(DB_FETCHMODE_ASSOC);
// empty default form values
$validation_errors = "";
$firstname = "";
$lastname = "";
$email = "";
$activation_code = "";
$phone = "";
if( isset($_GET['n']) ) {
// phone
$phone = $_GET['n'];
}
if( isset($_GET['c']) ) {
// code
$activation_code = $_GET['c'];
}
if( isset($_POST['submit']) ) {
$data = NULL;
try {
$data = validate_sms_form($_POST); // can throw
} catch(ValidationException $e) {
$validation_errors = $e->getMessage();
/* Refill form values*/
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
}
if($data !== NULL) {
try {
// persist
save_sms_form($data);
$user = get_user($data['userid']);
// send warm and fuzzy welcome email
send_registration_email($data); // same as on new snapporder membership
$url = $data['registration_url'];
// redirect to confirmation page
redirect("/snapporder/$url");
die();
} catch(InsideDatabaseException $e) {
echo $e->getMessage();
die();
}
}
}
?>
<?php include("../snapporder/header.php"); ?>
<div class="container">
<h1 class="title">Registrer medlemskap kjøpt på SMS</h1>
<em class="subtitle">på Det Norske Studentersamfund</em>
<header class="about">
<p>Hei, for at medlemskapet du har kjøpt på SMS skal være gyldig, så <strong>må</strong> du registerere deg med navn og epost.</p>
<p class="imperative">Fullfør registreringen din ved å angi <em>telefonnummer, aktiveringskode, fornanavn</em> og <em>epost</em>.</p>
</header>
<section class="register-sms">
<?php if(strlen($validation_errors) > 0 ) {
echo "<span class=\"error\">$validation_errors</span>";
} else {
echo "<span class=\"error hidden\"></span>";
} ?>
<form method="post">
<div class="activation-form">
<!-- Profile -->
<div class="form-row">
<label for="id_phone">Telefonnummer:</label><input id="id_phone" type="text" name="phone" placeholder="Telefonnummer" value="<?php echo $phone; ?>"/>
</div>
<div class="form-row">
<label for="id_activation_code">Aktiveringskode:</label><input id="id_activation_code" type="text" name="activation_code" placeholder="Aktiveringskode" value="<?php echo $activation_code; ?>"/>
</div>
<div class="form-row">
<label for="id_firstname">Fornavn:</label><input id="id_firstname" type="text" name="firstname" placeholder="Fornavn" value="<?php echo $firstname; ?>"/>
</div>
<div class="form-row">
<label for="id_lastname">Etternavn:</label><input id="id_lastname" type="text" name="lastname" placeholder="Etternavn" value="<?php echo $lastname; ?>"/>
</div>
<div class="form-row">
<label for="id_email">Epost:</label><input id="id_email" type="email" name="email" placeholder="Passord" value="<?php echo $email; ?>"/>
</div>
<button type="submit" name="submit" class="btn-submit">Registrer medlemskapet mitt</button>
</form>
</section>
<?php include("../snapporder/footer.php"); ?>
+1 -1
View File
@@ -1 +1 @@
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}body{margin:0;}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}audio,canvas,progress,video{display:inline-block;vertical-align:baseline;}audio:not([controls]){display:none;height:0;}[hidden],template{display:none;}a{background:transparent;}a:active,a:hover{outline:0;}abbr[title]{border-bottom:1px dotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}h1{font-size:2em;margin:0.67em 0;}mark{background:#ff0;color:#000;}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}figure{margin:1em 40px;}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0;}pre{overflow:auto;}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em;}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0;}button{overflow:visible;}button,select{text-transform:none;}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;}button[disabled],html input[disabled]{cursor:default;}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}input{line-height:normal;}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0;}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend{border:0;padding:0;}textarea{overflow:auto;}optgroup{font-weight:bold;}table{border-collapse:collapse;border-spacing:0;}td,th{padding:0;}meta.foundation-version{font-family:"/5.2.3/";}meta.foundation-mq-small{font-family:"/only screen/";width:0em;}meta.foundation-mq-medium{font-family:"/only screen and (min-width:40.063em)/";width:40.063em;}meta.foundation-mq-large{font-family:"/only screen and (min-width:64.063em)/";width:64.063em;}meta.foundation-mq-xlarge{font-family:"/only screen and (min-width:90.063em)/";width:90.063em;}meta.foundation-mq-xxlarge{font-family:"/only screen and (min-width:120.063em)/";width:120.063em;}meta.foundation-data-attribute-namespace{font-family:false;}html,body{height:100%;}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html,body{font-size:100%;}body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative;cursor:default;}a:hover{cursor:pointer;}img{max-width:100%;height:auto;}img{-ms-interpolation-mode:bicubic;}#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none !important;}.left{float:left !important;}.right{float:right !important;}.clearfix:before,.clearfix:after{content:" ";display:table;}.clearfix:after{clear:both;}.hide{display:none;}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img{display:inline-block;vertical-align:middle;}textarea{height:auto;min-height:50px;}select{width:100%;}.row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5rem;}.row:before,.row:after{content:" ";display:table;}.row:after{clear:both;}.row.collapse>.column,.row.collapse>.columns{padding-left:0;padding-right:0;}.row.collapse .row{margin-left:0;margin-right:0;}.row .row{width:auto;margin-left:-0.9375rem;margin-right:-0.9375rem;margin-top:0;margin-bottom:0;max-width:none;}.row .row:before,.row .row:after{content:" ";display:table;}.row .row:after{clear:both;}.row .row.collapse{width:auto;margin:0;max-width:none;}.row .row.collapse:before,.row .row.collapse:after{content:" ";display:table;}.row .row.collapse:after{clear:both;}.column,.columns{padding-left:0.9375rem;padding-right:0.9375rem;width:100%;float:left;}@media only screen{.small-push-0{position:relative;left:0%;right:auto;}.small-pull-0{position:relative;right:0%;left:auto;}.small-push-1{position:relative;left:8.3333333333%;right:auto;}.small-pull-1{position:relative;right:8.3333333333%;left:auto;}.small-push-2{position:relative;left:16.6666666667%;right:auto;}.small-pull-2{position:relative;right:16.6666666667%;left:auto;}.small-push-3{position:relative;left:25%;right:auto;}.small-pull-3{position:relative;right:25%;left:auto;}.small-push-4{position:relative;left:33.3333333333%;right:auto;}.small-pull-4{position:relative;right:33.3333333333%;left:auto;}.small-push-5{positLine truncated /*! normalize.css v3.0.1 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}body{margin:0;}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}audio,canvas,progress,video{display:inline-block;vertical-align:baseline;}audio:not([controls]){display:none;height:0;}[hidden],template{display:none;}a{background:transparent;}a:active,a:hover{outline:0;}abbr[title]{border-bottom:1px dotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}h1{font-size:2em;margin:0.67em 0;}mark{background:#ff0;color:#000;}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}figure{margin:1em 40px;}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0;}pre{overflow:auto;}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em;}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0;}button{overflow:visible;}button,select{text-transform:none;}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;}button[disabled],html input[disabled]{cursor:default;}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}input{line-height:normal;}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0;}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend{border:0;padding:0;}textarea{overflow:auto;}optgroup{font-weight:bold;}table{border-collapse:collapse;border-spacing:0;}td,th{padding:0;}meta.foundation-version{font-family:"/5.2.3/";}meta.foundation-mq-small{font-family:"/only screen/";width:0em;}meta.foundation-mq-medium{font-family:"/only screen and (min-width:40.063em)/";width:40.063em;}meta.foundation-mq-large{font-family:"/only screen and (min-width:64.063em)/";width:64.063em;}meta.foundation-mq-xlarge{font-family:"/only screen and (min-width:90.063em)/";width:90.063em;}meta.foundation-mq-xxlarge{font-family:"/only screen and (min-width:120.063em)/";width:120.063em;}meta.foundation-data-attribute-namespace{font-family:false;}html,body{height:100%;}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html,body{font-size:100%;}body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative;cursor:default;}a:hover{cursor:pointer;}img{max-width:100%;height:auto;}img{-ms-interpolation-mode:bicubic;}#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none !important;}.left{float:left !important;}.right{float:right !important;}.clearfix:before,.clearfix:after{content:" ";display:table;}.clearfix:after{clear:both;}.hide{display:none;}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img{display:inline-block;vertical-align:middle;}textarea{height:auto;min-height:50px;}select{width:100%;}.row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5rem;}.row:before,.row:after{content:" ";display:table;}.row:after{clear:both;}.row.collapse>.column,.row.collapse>.columns{padding-left:0;padding-right:0;}.row.collapse .row{margin-left:0;margin-right:0;}.row .row{width:auto;margin-left:-0.9375rem;margin-right:-0.9375rem;margin-top:0;margin-bottom:0;max-width:none;}.row .row:before,.row .row:after{content:" ";display:table;}.row .row:after{clear:both;}.row .row.collapse{width:auto;margin:0;max-width:none;}.row .row.collapse:before,.row .row.collapse:after{content:" ";display:table;}.row .row.collapse:after{clear:both;}.column,.columns{padding-left:0.9375rem;padding-right:0.9375rem;width:100%;float:left;}@media only screen{.small-push-0{position:relative;left:0%;right:auto;}.small-pull-0{position:relative;right:0%;left:auto;}.small-push-1{position:relative;left:8.3333333333%;right:auto;}.small-pull-1{position:relative;right:8.3333333333%;left:auto;}.small-push-2{position:relative;left:16.6666666667%;right:auto;}.small-pull-2{position:relative;right:16.6666666667%;left:auto;}.small-push-3{position:relative;left:25%;right:auto;}.small-pull-3{position:relative;right:25%;left:auto;}.small-push-4{position:relative;left:33.3333333333%;right:auto;}.small-pull-4{position:relative;right:33.3333333333%;left:auto;}.small-push-5{positLine truncated
-1
View File
@@ -1,6 +1,5 @@
<footer> <footer>
<a href="https://studentersamfundet.no" title="Det Norske Studentersamfund"><img src="/snapporder/img/logo.png" width="100" height="100" class="logo"></a> <a href="https://studentersamfundet.no" title="Det Norske Studentersamfund"><img src="/snapporder/img/logo.png" width="100" height="100" class="logo"></a>
<img src="/snapporder/img/snapporder_logo_dark_liggende.png">
</footer> </footer>
</div> </div>
+3 -3
View File
@@ -5,10 +5,10 @@
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>Aktiver medlemskapet ditt hos Det Norske Studentersamfund</title> <title>Aktiver medlemskapet ditt hos Det Norske Studentersamfund</title>
<link href='//fonts.googleapis.com/css?family=Arvo:700' rel='stylesheet' type='text/css'> <link href='//fonts.googleapis.com/css?family=Arvo:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" media="all" href="css/style.css" /> <link rel="stylesheet" type="text/css" media="all" href="../snapporder/css/style.css" />
<script src="js/jquery-1.11.0.js"></script> <script src="../snapporder/js/jquery-1.11.0.js"></script>
<script src="js/activate.js"></script> <script src="../snapporder/js/activate.js"></script>
<!-- GA? --> <!-- GA? -->
+38 -6
View File
@@ -16,7 +16,7 @@ function generate_username($data) {
return $firstname.$lastname.$rand; return $firstname.$lastname.$rand;
} }
function add_user($data) { function add_user($data, $source) {
global $conn; global $conn;
/* User table */ /* User table */
@@ -26,7 +26,7 @@ function add_user($data) {
/* Add our own initial values */ /* Add our own initial values */
$data['username'] = generate_username($data); $data['username'] = generate_username($data);
$data['source'] = "snapporder"; $data['source'] = $source;
$data['registration_status'] = "partial"; $data['registration_status'] = "partial";
@@ -73,9 +73,9 @@ function add_user($data) {
log_userupdate($user_id, "User registered."); // for legacy log_userupdate($user_id, "User registered."); // for legacy
if( isset($data['membership_trial']) && $in_autumn) { if( isset($data['membership_trial']) && $in_autumn) {
log_userupdate($user_id, "Medlemskap registrert via SnappOrder. Gratis medlemskap (".$data['membership_trial'].")."); log_userupdate($user_id, "Medlemskap registrert via $source. Gratis medlemskap (".$data['membership_trial'].").");
} else { } else {
log_userupdate($user_id, "Medlemskap registrert via SnappOrder."); log_userupdate($user_id, "Medlemskap registrert via $source.");
} }
return $user_id; return $user_id;
@@ -197,9 +197,9 @@ function renew_user($data) {
} }
if( isset($data['membership_trial']) && $in_autumn) { if( isset($data['membership_trial']) && $in_autumn) {
log_userupdate($user_id, "Medlemskap registrert via SnappOrder ($source). Gratis medlemskap (".$data['membership_trial'].")."); log_userupdate($user_id, "Medlemskap registrert via $source. Gratis medlemskap (".$data['membership_trial'].").");
} else { } else {
log_userupdate($user_id, "Medlemskap fornyet via SnappOrder ($source)."); log_userupdate($user_id, "Medlemskap fornyet via $source.");
} }
return; return;
@@ -516,6 +516,28 @@ function validate_activation_form($data) {
return $data; return $data;
} }
function validate_sms_form($data) {
// lookup phonenumber
$data['phone'] = clean_phonenumber($data['phone']);
if( !valid_phonenumber($data['phone']) ) {
throw new ValidationException("Ugyldig telefonnummer");
}
$user_id = getUseridFromPhone($data['phone']);
if( $user_id !== false ) {
throw new ValidationException("Telefonnummeret er allerede registrert i bruk.");
}
// lookup code and phonenumber tuple
$phone = substr($data['phone'], 0, 3);
// TODO: you are here
// get purchased from date
return $data;
}
function save_sms_form($data) {
add_user($data, "sms");
}
function save_activation_form($data) { function save_activation_form($data) {
update_user($data); update_user($data);
update_user_groups($data); update_user_groups($data);
@@ -532,6 +554,16 @@ function save_activation_form($data) {
return true; return true;
} }
function is_valid_sms_activation_code($phone, $code) {
$sql = "SELECT * FROM din_sms_sent AS s WHERE s.activation_code=$code AND s.reciever=$phone";
$res = $conn->query($sql);
if( DB::isError($res) ) {
throw new InsideDatabaseException($res->getMessage().". DEBUG: ".$res->getDebugInfo());
}
if($res->numRows() === 0) {
return false;
}
}
/* The purpose of this email is: /* The purpose of this email is:
* - to store the registration_url in the users inbox * - to store the registration_url in the users inbox
+108 -105
View File
@@ -67,114 +67,117 @@ body {
text-align: right; text-align: right;
} }
} }
.activation { .activation,
.register-sms {
@include grid-column(12); @include grid-column(12);
@media #{$medium-up} { @include grid-column(6); } @media #{$medium-up} { @include grid-column(6); }
span.error {
margin-bottom: 0;
&.hidden {
display: none !important;
}
}
.activation-form {
label {
font-weight: bold;
display: inline-block;
width: 30%;
line-height: $row-height;
&.no-width {
font-weight: normal;
display: inline-block;
width: auto;
border-bottom: 0;
line-height: 1;
}
}
.form-row {
border-bottom: 1px solid #ccc;
}
input[type=text],
input[type=password] {
display: inline-block;
width: 70%;
background-color: white;
border: 0;
text-shadow: none;
height: $row-height;
margin: 0;
}
select {
display: inline-block;
width: 70%;
background-color: white;
border: 0;
padding-left: 0;
height: $row-height;
outline: 0;
margin: 0;
&[name=day],
&[name=month],
&[name=year] {
width: 23.333333333333%;
}
}
input[name=zipcode],
.area-wrap {
width: 33.33333%;
}
.area-wrap {
display: inline-block;
padding-left: 4px;
}
label[for=id_newsletter] {
border-bottom: 0;
}
.newsletter-text {
display: inline-block;
width: 70%;
border-bottom: 0;
height: $row-height;
input {
margin: 0;
margin-right: 4px;
}
}
.username-row {
position: relative;
}
input[name=username] {
}
.username-check {
position: absolute;
pointer-events: none;
right: 0;
top: 0;
width: 46px;
height: 46px;
z-index: 4;
background-image: url('../img/icon-check.png');
background-size: 50% 50%;
background-position: center center;
background-repeat: no-repeat;
visibility: hidden;
&.check {
background-image: url('../img/icon-check.png');
visibility: visible;
}
&.failed {
background-image: url('../img/icon-failed.png');
visibility: visible;
}
}
}
} }
span.error {
margin-bottom: 0;
&.hidden {
display: none !important;
}
}
.activation-form {
label {
font-weight: bold;
display: inline-block;
width: 30%;
line-height: $row-height;
&.no-width {
font-weight: normal;
display: inline-block;
width: auto;
border-bottom: 0;
line-height: 1;
}
}
.form-row {
border-bottom: 1px solid #ccc;
}
input[type=text],
input[type=email],
input[type=password] {
display: inline-block;
width: 70%;
background-color: white;
border: 0;
text-shadow: none;
height: $row-height;
margin: 0;
}
select {
display: inline-block;
width: 70%;
background-color: white;
border: 0;
padding-left: 0;
height: $row-height;
outline: 0;
margin: 0;
&[name=day],
&[name=month],
&[name=year] {
width: 23.333333333333%;
}
}
input[name=zipcode],
.area-wrap {
width: 33.33333%;
}
.area-wrap {
display: inline-block;
padding-left: 4px;
}
label[for=id_newsletter] {
border-bottom: 0;
}
.newsletter-text {
display: inline-block;
width: 70%;
border-bottom: 0;
height: $row-height;
input {
margin: 0;
margin-right: 4px;
}
}
.username-row {
position: relative;
}
input[name=username] {
}
.username-check {
position: absolute;
pointer-events: none;
right: 0;
top: 0;
width: 46px;
height: 46px;
z-index: 4;
background-image: url('../img/icon-check.png');
background-size: 50% 50%;
background-position: center center;
background-repeat: no-repeat;
visibility: hidden;
&.check {
background-image: url('../img/icon-check.png');
visibility: visible;
}
&.failed {
background-image: url('../img/icon-failed.png');
visibility: visible;
}
}
}
.btn-submit { .btn-submit {
display: block; display: block;
width: 100%; width: 100%;