예제 #1
0
    function edit()
    {
        $sql = 'SELECT path FROM {{modules}} WHERE id=' . $_POST['module'];
        $module = DB::getOne($sql);
        $sql = '
			DELETE FROM {{multival}} 
			WHERE data IN (SELECT id FROM {{data}} WHERE tree=' . $_POST['tree'] . ')
		';
        DB::exec($sql);
        $sql = '
			DELETE FROM {{relations}} 
			WHERE modul1=\'data\' 
				AND id1 IN (SELECT id FROM {{data}} WHERE tree=' . $_POST['tree'] . ' AND type<>\'gallery\')
		';
        DB::exec($sql);
        $sql = '
			DELETE FROM {{data}}
			WHERE tree=' . $_POST['tree'] . '
				AND type<>\'gallery\'
		';
        DB::exec($sql);
        $i = 0;
        if ($_POST['data']) {
            foreach ($_POST['data'] as $key => $item) {
                Fields::Insert($_POST['tree'], $_POST['module'], $key, $item, $_POST['fieldtypes'][$i], $i);
                $i++;
            }
        }
        Tree::editTree($_POST['tree']);
    }
예제 #2
0
    public function edit()
    {
        $fields = array();
        $sql = '
			DELETE FROM {{multival}} 
			WHERE data IN (SELECT id FROM {{data}} WHERE tree=' . $_POST['tree'] . ')
		';
        DB::exec($sql);
        $sql = '
			DELETE FROM {{relations}} 
			WHERE modul1=\'data\' 
				AND id1 IN (SELECT id FROM {{data}} WHERE tree=' . $_POST['tree'] . ' AND type<>\'gallery\')
		';
        DB::exec($sql);
        $sql = '
			DELETE FROM {{data}}
			WHERE tree=' . $_POST['tree'] . '
				AND type<>\'gallery\'
		';
        DB::exec($sql);
        $module = Module::getModuleById($_POST['module']);
        Tree::editTree($_POST['tree']);
        if (isset($_POST['data']['price'])) {
            $fields['price'] = $_POST['data']['price'] == '' ? 0 : $_POST['data']['price'];
        }
        if (isset($_POST['data']['subprice'])) {
            $fields['subprice'] = $_POST['data']['subprice'] == '' ? 0 : $_POST['data']['subprice'];
        }
        if (isset($_POST['data']['vendor'])) {
            $fields['vendor'] = $_POST['data']['vendor'] == '' ? 0 : $_POST['data']['vendor'];
        }
        if (isset($_POST['data']['available'])) {
            $fields['available'] = $_POST['data']['available'] == '' ? 0 : $_POST['data']['available'];
        }
        if (isset($_POST['data']['bid'])) {
            $fields['bid'] = $_POST['data']['bid'] == '' ? 0 : $_POST['data']['bid'];
        }
        if (isset($_POST['data']['cbid'])) {
            $fields['cbid'] = $_POST['data']['cbid'] == '' ? 0 : $_POST['data']['cbid'];
        }
        if (isset($_POST['data']['manufacturer_warranty'])) {
            $fields['manufacturer_warranty'] = $_POST['data']['manufacturer_warranty'] == '' ? 0 : $_POST['data']['manufacturer_warranty'];
        }
        foreach (OneSSA::$catalogStandart as $item) {
            if (array_key_exists($item, $fields) === false) {
                $fields[$item] = trim($_POST['data'][$item]);
            }
        }
        $sql = '
			UPDATE {{catalog}}
			SET 
		';
        foreach ($fields as $key => $item) {
            if (strpos($item, '<') === false || strpos($item, '>') === false) {
                $item = str_replace('"', '&quot;', str_replace("'", '&rsquo;', $item));
            }
            $sql .= $key . '=\'' . $item . '\',';
        }
        $sql = substr($sql, 0, strlen($sql) - 1);
        $sql .= '
			WHERE tree=' . $_POST['tree'] . '
		';
        $dataId = DB::exec($sql);
        $i = 0;
        //print_r($_POST);
        foreach ($_POST['data'] as $key => $item) {
            if (!in_array($key, OneSSA::$catalogStandart)) {
                Fields::Insert($_POST['tree'], $_POST['module'], $key, $item, $_POST['fieldtypes'][$i], $i);
            }
            $i++;
        }
        $i = 0;
        if (!empty($_POST['features'])) {
            foreach ($_POST['features'] as $key => $item) {
                Fields::insertFeatures($_POST['tree'], $_POST['featuresid'][$i], $key, $_POST['featurestype'][$i], $item, $i);
                $i++;
            }
        }
    }