root/trunk/actions/communities/createEvent.action.php

Revision 1, 3.0 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25if(is_numeric($token[3]) )
26{
27    $is_membre = $db->getOne('SELECT count(id) as nb FROM user_comm WHERE id=? AND status=? AND id_comm=?', array($_SESSION['my_id'], 'ok', $token[3]));
28        if($is_membre != 1)
29    {
30        $_SESSION['error']['title'] = tr('Your are not a member of this community');
31                $_SESSION['error']['msg'] = tr('You must subscribe to this community before trying to add event');
32        header('Location: /communities/view/'.$token[3]);
33        exit();
34    }
35
36    $date = time();
37    $title = stripslashes($_POST['title']);
38    $details = stripslashes($_POST['details']);
39    $country = stripslashes($_POST['country']);
40    $city = stripslashes($_POST['city']);
41    $location = stripslashes($_POST['location']);
42    $date_event = mktime($_POST['date']['Time_Hour'], $_POST['date']['Time_Minute'], 0, $_POST['date']['Date_Month'], $_POST['date']['Date_Day'], $_POST['date']['Date_Year'] );
43    $date = time();
44
45    if(strlen($_POST['title']) < 1 || strlen($_POST['details']) < 1 || $_POST['country']=='(null)' )
46    {
47        $_POST['date'] = $date_event;
48        $_SESSION['error']['title']= tr('Incorrect event');
49                $_SESSION['error']['msg']= tr('You must fill the form with: title, date (in the future), and a country.');
50        $_SESSION['error']['post'] = array_map('stripslashes', $_POST);
51                header('Location: /communities/createEvent/'.$token[3]);
52                exit();
53    }
54
55
56    $event_values = array(
57                'id' => $_SESSION['my_id'],
58                'id_comm' => $token[3],
59                'author'  => $_SESSION['my_fname'],
60                'title'   => $title,
61        'details' => $details,
62        'location' => $location,
63        'city'    => $city,
64        'country' => $country,
65                'date_event'=> $date_event,
66                'date' => $date);
67        $result = $db->autoExecute('community_event', $event_values, DB_AUTOQUERY_INSERT);
68    if (DB::isError($result))
69            error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' '.$result->getUserInfo());
70
71}
72
73header('Location: /communities/view/'.$token[3]);
74?>
Note: See TracBrowser for help on using the browser.