/extremedating/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/extremedating/trunk

« back to all changes in this revision

Viewing changes to php/showinterest.php

  • Committer: Gustav Hartvigsson
  • Date: 2013-04-15 17:15:56 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20130415171556-q5zcc5mdle93vm1q
code cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?PHP
 
2
/*
 
3
    ExtremeDating - a Hackathon 2013 project.
 
4
    Copyright (C) 2013 Gustav Hartvigsson <gustav.hartvigsson@gmail.com>
 
5
    Copyright (C) 2013 Daniel Johansson <maila@danieljohansson.nu>
 
6
 
 
7
 
 
8
    This program is free software: you can redistribute it and/or modify
 
9
    it under the terms of the GNU Affero General Public License as
 
10
    published by the Free Software Foundation, either version 3 of the
 
11
    License, or (at your option) any later version.
 
12
 
 
13
    This program is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
    GNU Affero General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Affero General Public License
 
19
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
if($profilename != $username) {
 
22
        $relationinfo = $db->query("SELECT * from dateInterests WHERE(user1='$username' AND user2='$profilename')");
 
23
        $relationquery = $relationinfo->fetchAll();
 
24
  $newusername = $db->query("SELECT firstName, surName FROM Users WHERE loginName = '{$profilename}'");
 
25
  $newusername = $newusername->fetchAll();
 
26
  $newusername = $newusername[0]['firstName'] . " " . $newusername[0]['surName'];
 
27
        if($relationquery != array()) {
 
28
    ?>
 
29
                <p>Du har visat intresse för en lunchdejt med den här personen<p />
 
30
                <form method="POST" action="">
 
31
                <button type="Submit" name="Unsubscribe">Sluta visa intresse</button>
 
32
                </form>
 
33
    <?php
 
34
                $relationinfo = $db->query("SELECT * from dateInterests WHERE(user1='$profilename' AND user2='$username')");
 
35
                $relationquery = $relationinfo->fetchAll();
 
36
                if($relationquery != array()) {
 
37
                        echo $newusername . ' vill gärna äta lunch med dig också, skicka ett mail och bestäm träff!';
 
38
                        include 'planlunch.php';
 
39
                        include 'showlunchsuggestions.php';
 
40
                }
 
41
        } else {
 
42
    ?>
 
43
                <p>Vill du gå på lunch med den här personen?</p>
 
44
                <form method="POST" action="">
 
45
                <button type="Submit" name="Subscribe">Visa intresse</button>
 
46
                </form>
 
47
    <?php
 
48
        }
 
49
        if (isset($_POST['Subscribe'])) {
 
50
                $relationinfo = $db->query("SELECT * from dateInterests WHERE(user1='$username' AND user2='$profilename')");
 
51
                $relationquery = $relationinfo->fetchAll();
 
52
                if($relationquery == array()) {
 
53
                        $db->exec("INSERT INTO dateInterests VALUES ('$username', '$profilename')");
 
54
                        echo '<p>Du har visat intresse för lunch med personen</p>';
 
55
                        sleep(.5);
 
56
                        header("Location:./profile.php?uid=" . $profilename);
 
57
                }
 
58
        }
 
59
        if (isset($_POST['Unsubscribe'])) 
 
60
        { 
 
61
                $db->exec("DELETE FROM dateInterests WHERE (user1='$username' AND user2='$profilename')");
 
62
                echo '<p>Du har slutat visa intresse för lunch med personen</p>'; 
 
63
                sleep(.5);
 
64
                header("Location:./profile.php?uid=" . $profilename);
 
65
        }
 
66
}