foreveralone

foreveralone Commit Details


Date:2016-02-27 16:59:47 (8 years 9 months ago)
Author:Natalie Adams
Branch:master
Commit:233f5a1538da4091de53f6fc30396fff3fedb51b
Parents: f7928b101429ee42b6c7c916f8bec14a97f61b7f
Message:Issue 122: Add button to override match

Changes:

File differences

web/application/controllers/base.php
1111
1212
1313
14
15
16
17
18
19
20
21
2214
2315
24
16
2517
2618
2719
......
4032
4133
4234
35
4336
4437
4538
......
5043
5144
5245
46
5347
5448
5549
protected $sessionData = null;
protected $loginRequired = true;
protected $sessionRequired = true;
protected function isLoggedIn() {
if (!$this->sessionData && !isset($this->sessionData->userId)) {
header("Location: /login");
return false;
} else {
return true;
}
}
protected function loadRender($template, $parameters=array()) {
$newParameters = array_merge($parameters, ["session" => $this->sessionData, "config" => $this->config, "user" => $this->user]);
$newParameters = array_merge($parameters, ["session" => $this->session, "config" => $this->config, "user" => $this->user]);
return parent::loadRender($template, $newParameters);
}
$this->session->ip = $_SERVER["REMOTE_ADDR"];
$this->session->userAgent = $_SERVER["HTTP_USER_AGENT"];
$this->session->sessionid = $sessionId;
$this->session->random = 0;
$this->session->save();
setcookie("session", $sessionId, 2147483647, "/");
}
$this->session->ip = $_SERVER["REMOTE_ADDR"];
$this->session->userAgent = $_SERVER["HTTP_USER_AGENT"];
$this->session->sessionid = $sessionId;
$this->session->random = 0;
$this->session->id = $this->session->save();
setcookie("session", $sessionId, 2147483647, "/");
}
web/application/controllers/main.php
5353
5454
5555
56
57
58
59
60
61
62
63
64
5665
5766
5867
......
127136
128137
129138
130
139
131140
132141
133142
}
}
public function togglerandom() {
if ($_POST["random"] == "true") {
$this->session->random = 1;
} else {
$this->session->random = 0;
}
$this->session->save();
}
public function send() {
$message = new application\models\Messages();
$message->user_from = $this->session->id;
}
// If no match was made - match with first session
if ($firstResult && !$result) {
if ($firstResult && !$result && $this->session->random) {
$firstResult->waiting = 0;
$firstResult->to_user = $this->session->id;
$this->session->to_user = $firstResult->id;
web/application/migrations/1.php
1313
1414
1515
16
16
17
1718
data TEXT,
waiting TINYINT(1),
to_user INTEGER,
lastPing INTEGER
lastPing INTEGER,
random TINYINT(1)
)");
web/application/models/sessions.php
1010
1111
1212
13
1314
1415
1516
public $waiting;
public $to_user;
public $lastPing;
public $random;
public function setData($key, $val) {
$raw = json_decode($this->data, true);
web/application/views/chat.html
11
22
33
4
5
6
7
8
4
5
6
7
8
9
10
11
12
13
14
15
16
917
1018
1119
1220
1321
22
23
24
25
26
27
28
1429
1530
1631
{% extends "base.html" %}
{% block content %}
<div class="centered" id="container">
<textarea disabled="disabled" autocomplete="off" cols="100" rows="25" id="chat"></textarea>
<br>
<input autocomplete="off" style="width: 725px;" placeholder="Your message here..." type="text" id="input">
<div class="centered">
<div class="checkbox">
<label> <input type="checkbox" id="random"
title="Checking this box will match you with anyone - including those that don't match what you are looking for"
{% if session.random %}checked="checked"{% endif %}
>
Match random users</label>
</div>
<div id="container">
<textarea disabled="disabled" autocomplete="off" cols="100" rows="25" id="chat"></textarea>
<br>
<input autocomplete="off" style="width: 725px;" placeholder="Your message here..." type="text" id="input">
</div>
</div>
<script type="text/javascript">
$(function () {
$("#random").tooltip();
$("#random").change(function (e) {
console.log(e);
$.post("./main/togglerandom", {random: $(this).is(":checked")});
});
var searching = true;
function appendChat(text) {
var chatVal = $("#chat").val();

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06345s using 20 queries.