| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | if(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 | |
|---|
| 73 | header('Location: /communities/view/'.$token[3]); |
|---|
| 74 | ?> |
|---|