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

Revision 1, 3.2 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
25
26if(is_numeric($token[3]))
27{
28    $id_cat = $db->getOne('SELECT id_cat FROM community WHERE id=? AND id_comm=?', array($_SESSION['my_id'], $token[3]));
29
30    $community_values = array();
31
32    foreach(array_keys($table_fields['communities']) as $key)
33    {
34        if(array_key_exists($key, $_POST) )
35        {
36            $_POST[$key] = trim($_POST[$key]);
37            $value="";
38            if( is_array($_POST[$key]) )
39                $value = implode(",", $_POST[$key]);
40            elseif( $_POST[$key] == "(null)" || $_POST[$key] == "" || $_POST[$key] == "http://")
41                $value = NULL;
42            else
43                $value = $_POST[$key];
44
45            if(($key == 'name' ||
46                $key == 'categorie' ||
47                $key == 'moderated' ||
48                $key == 'description' ) &&
49               is_null($value))
50            {
51                header('Location: /error/record_comm');
52                exit();
53            }
54
55            if(is_null($value))
56                $community_values[$key] = NULL;
57            else
58                $community_values[$key] = stripslashes($value);
59
60        }
61    }
62
63    $result =& $db->autoExecute('community', $community_values, DB_AUTOQUERY_UPDATE, "id='".$_SESSION['my_id']."' AND id_comm='".$token[3]."'");
64    if (DB::isError($result))
65        error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' '.$result->getMessage());
66    elseif($db->affectedRows() == 1)
67    {
68        $db->query('DELETE FROM community_keyword WHERE id_comm=?', array($token[3]));
69
70        $array_description = explode(' ', $community_values['description']);
71        $array_name = explode(' ', $community_values['name']);
72
73        $array = array_merge($array_description, $array_name);
74
75        foreach($array as $elemt)
76        {
77            $elemt = ereg_replace("(.*)s$", "\\1", $elemt);
78
79            if(strlen($elemt)>2)
80            {
81                $sndx = get_mysql_soundex($elemt);
82                $db->query('INSERT INTO community_keyword SET key_sndx=?, id_comm=?, id_cat=?', array($sndx, $token[3], $id_cat));
83            }
84        }
85        if($id_cat != $community_values['id_cat'])
86        {
87            $db->query('UPDATE community_cat SET nb_communities=nb_communities-1 WHERE id_cat=?', $id_cat);
88            $db->query('UPDATE community_cat SET nb_communities=nb_communities+1 WHERE id_cat=?', $community_values['id_cat']);
89        }
90    }
91   
92
93    upload_image($_FILES, 'logo', $_SESSION['my_id'], $token[3], BASEPATH, "/comm_logos", true"/comm_logos/thumb", array(231,255,189));
94}
95
96header('Location: /communities/view/'.$token[3]);
97
98?>
Note: See TracBrowser for help on using the browser.