Exemple #1
0
/**
 * Changes street name in database by its ID
 * 
 * @param int $streetid
 * @param string $streetname
 * 
 * @return void
 */
function zb_AddressChangeStreetName($streetid, $streetname)
{
    $streetid = vf($streetid, 3);
    $streetname = zb_AddressFilterStreet($streetname);
    $streetname = mysql_real_escape_string($streetname);
    $query = "UPDATE `street` SET `streetname` = '" . $streetname . "' WHERE `id`= '" . $streetid . "' ;";
    nr_query($query);
    log_register('CHANGE AddressStreetName [' . $streetid . '] `' . $streetname . '`');
}
Exemple #2
0
<?php

// check for right of current admin on this module
if (cfr('STREETS')) {
    if (isset($_POST['newstreetname'])) {
        $newstreetname = trim($_POST['newstreetname']);
        $newstreetname = zb_AddressFilterStreet($newstreetname);
        $newstreetcityid = $_POST['citysel'];
        if (isset($_POST['newstreetalias'])) {
            $newstreetalias = trim($_POST['newstreetalias']);
        } else {
            $newstreetalias = '';
        }
        if (!empty($newstreetname)) {
            //check for existing same street in city
            $existingStreets_raw = zb_AddressGetStreetAllDataByCity($newstreetcityid);
            $existingStreets = array();
            if (!empty($existingStreets_raw)) {
                foreach ($existingStreets_raw as $ix => $eachstreetdata) {
                    $existingStreets[] = strtolower_utf8($eachstreetdata['streetname']);
                }
            }
            if (!in_array(strtolower_utf8($newstreetname), $existingStreets)) {
                zb_AddressCreateStreet($newstreetcityid, $newstreetname, $newstreetalias);
            } else {
                show_error(__('The same street already exists'));
            }
        } else {
            show_error(__('Empty street name'));
        }
    }