Example #1
0
function con_config_side_save($idcat, $idside, $idtpl, $idtplconf, $idsidelang, $idcatside, $idcatnew, $author, $title, $meta_keywords, $summary, $online, $user_protected, $view, $created, $lastmodified, $startdate, $starttime, $enddate, $endtime, $meta_author, $meta_description, $meta_robots, $meta_redirect_time, $meta_redirect, $meta_redirect_url, $rewrite_use_automatic, $rewrite_url, $idlay, $use_redirect = true)
{
    global $db, $client, $sess, $perm, $lang, $cms_db, $cfg_client, $cms_lang, $val_ct;
    global $idcatside, $idside;
    if (!(is_numeric($idtpl) || is_int($idtpl))) {
        return;
    }
    if (!(is_numeric($idtplconf) || is_int($idtplconf))) {
        return;
    }
    if (empty($title)) {
        $title = $cms_lang['con_defaulttitle'];
    }
    $rewrite_use_automatic = $rewrite_use_automatic > 0 ? 1 : 0;
    rewriteGenerateMapping();
    if ($rewrite_use_automatic) {
        $rewrite_url = rewriteGenerateUrlString($title);
        $rewrite_url = rewriteMakeUniqueStringForLang('idcatside', $idcatside, $rewrite_url);
    } else {
        $rewrite_url = rewriteGenerateUrlString($rewrite_url, true);
    }
    // idcatside für rechte
    $idcatside_for_rights = $idcatside;
    $idcat_for_rights = $idcat;
    if (!is_array($idcatnew)) {
        $idcatnew['0'] = $idcat;
    }
    $start = createDate($startdate, $starttime);
    $end = createDate($enddate, $endtime);
    $meta_redirect = $meta_redirect == '1' ? '1' : '0';
    $meta_redirect_url = $meta_redirect_url == 'http://' || $meta_redirect_url == '' ? '' : $meta_redirect_url;
    set_magic_quotes_gpc($title);
    set_magic_quotes_gpc($summary);
    set_magic_quotes_gpc($meta_author);
    set_magic_quotes_gpc($meta_description);
    set_magic_quotes_gpc($meta_keywords);
    set_magic_quotes_gpc($meta_robots);
    set_magic_quotes_gpc($meta_redirect_url);
    if (empty($idside)) {
        //echo "new page";exit;
        // Seite erstellen
        $sql = "INSERT INTO {$cms_db['side']} (idclient) VALUES ('{$client}')";
        $db->query($sql);
        // neue idside suchen
        $idside = mysql_insert_id();
        // Seite in alle Ordner einfügen
        foreach ($idcatnew as $value) {
            //sortindex suchen
            $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
            $db->query($sql);
            if ($db->next_record()) {
                $sortindex = $db->f('sortindex') + 1;
            } else {
                $sortindex = 1;
            }
            $sql = "SELECT * FROM {$cms_db['cat_side']} WHERE idcat='{$value}' AND is_start='1'";
            $db->query($sql);
            $is_start = $db->next_record() ? '0' : '1';
            $sql = "INSERT INTO {$cms_db['cat_side']} (idcat, idside, sortindex, is_start) VALUES ('{$value}', '{$idside}', '{$sortindex}', '{$is_start}')";
            $db->query($sql);
        }
        // idcatside suchen
        $sql = "SELECT idcatside FROM {$cms_db['cat_side']} WHERE idside='{$idside}'";
        $idcatside = array();
        getIdList($sql, $idcatside, '', 'idcatside');
        // für jede Sprache erstellen
        $a_languages = get_languages_by_client($client);
        foreach ($a_languages as $tmp_lang) {
            if ($tmp_lang == $lang) {
                $side_online = $online;
                $side_start = $start;
                $side_end = $end;
            } else {
                $side_online = 0;
                $side_start = time();
                $side_end = time();
            }
            //TODO Problems to update template in multilang pages
            $catobject =& sf_factoryGetObject('PAGE', 'Cat');
            $catobject->loadByIdcatIdlang($idcatnew['0'], $tmp_lang);
            $cat_is_protected = $catobject->getIsProtected();
            if ($cat_is_protected) {
                $side_online = $side_online | 0x4;
            }
            if ($tmp_lang == $lang) {
                $tmp_meta_description = $meta_description;
                $tmp_meta_keywords = $meta_keywords;
                $tmp_meta_robots = $meta_robots;
            } else {
                $cfg_lang = $val_ct->get_by_group('cfg_lang', $client, $tmp_lang);
                $tmp_meta_description = htmlentities($cfg_lang['meta_description'], ENT_COMPAT, 'UTF-8');
                $tmp_meta_keywords = htmlentities($cfg_lang['meta_keywords'], ENT_COMPAT, 'UTF-8');
                $tmp_meta_robots = htmlentities($cfg_lang['meta_robots'], ENT_COMPAT, 'UTF-8');
            }
            $sql = 'INSERT INTO ' . $cms_db['side_lang'];
            $sql .= ' (idside, idlang, title, meta_keywords, summary, created, lastmodified, author, meta_redirect, meta_redirect_url,';
            $sql .= ' user_protected, online, start, end, meta_author, meta_description, meta_robots, meta_redirect_time, rewrite_use_automatic, rewrite_url) ';
            $sql .= 'VALUES (';
            $sql .= " '{$idside}', '{$tmp_lang}', '{$title}', '{$tmp_meta_keywords}', '{$summary}', '{$created}', '{$lastmodified}', '{$author}', ";
            $sql .= " '{$meta_redirect}', '{$meta_redirect_url}', '{$user_protected}', '{$side_online}', '{$side_start}', '{$side_end}', ";
            $sql .= " '{$meta_author}', '{$tmp_meta_description}', '{$tmp_meta_robots}', '{$meta_redirect_time}', '{$rewrite_use_automatic}', '{$rewrite_url}')";
            $db->query($sql);
        }
        // idsidelang für die Templateerstellung raussuchen
        $sql = "SELECT idsidelang FROM " . $cms_db['side_lang'] . " WHERE idside='{$idside}'";
        $tmp_idsidelang = array();
        $affectedrows = getIdList($sql, $tmp_idsidelang, '', 'idsidelang');
        //print_r($tmp_idsidelang);exit;
        // Template erstellen
        if ($affectedrows) {
            foreach ($tmp_idsidelang as $value) {
                con_config_tpl_save($idtpl, $idlay, '', $value, $idtplconf);
            }
            //exit;
        }
        // Seite für Frontend erzeugen
        if ($cfg_client['publish'] == '1') {
            foreach ($a_languages as $tmp_lang) {
                $sql = 'INSERT INTO ' . $cms_db['code'] . "(idlang, idcatside, changed) VALUES ('{$tmp_lang}', '" . $idcatside['0'] . "', '1')";
                $db->query($sql);
            }
        }
        // Event
        fire_event('con_side_new', array('idside' => $idside, 'name' => $title));
        // Content aus Cache löschen
        sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content'));
        // Danach ins Frontend?
        // ermittle redirect-url
        if ($view) {
            $url_location = $sess->url($cfg_client['htmlpath'] . $cfg_client['contentfile'] . '?lang=' . $lang . '&idcatside=' . $idcatside['0'] . '&view=' . $view);
        } else {
            $url_location = $sess->url("main.php?area=con_editframe&idcatside=" . $idcatside['0']);
        }
        $idcatside = $idcatside['0'];
    } else {
        // handle $online-Angabe
        // 0 -> offline setzen
        // 1 -> online setzen
        // 2 -> zeitsteuerung setzen
        switch ((int) $online) {
            case 0:
                $change_online = 'online & 0xFC';
                break;
            case 1:
                $change_online = '((online & 0xFC) | 0x01)';
                break;
            case 2:
                $change_online = '((online & 0xFC) | 0x02)';
                break;
            default:
                $change_online = '0';
                break;
        }
        // update der 'side_lang' Tabelle
        $sql = 'UPDATE ' . $cms_db['side_lang'] . ' ';
        $sql .= 'SET';
        $sql .= " title='{$title}', meta_keywords='{$meta_keywords}', summary='{$summary}', meta_redirect='{$meta_redirect}', ";
        $sql .= " meta_redirect_url='{$meta_redirect_url}', user_protected = '{$user_protected}', online = {$change_online}, start='{$start}', ";
        $sql .= " end='{$end}', meta_author='{$meta_author}', meta_description='{$meta_description}', meta_robots='{$meta_robots}', ";
        $sql .= " meta_redirect_time = '{$meta_redirect_time}', rewrite_use_automatic = '{$rewrite_use_automatic}', rewrite_url = '{$rewrite_url}' ";
        $sql .= 'WHERE idsidelang = ' . $idsidelang;
        $db->query($sql);
        // in welchem Ordner existiert die Seite?
        $sql = 'SELECT idcat FROM ' . $cms_db['cat_side'] . ' WHERE idside = ' . $idside;
        $tmp_idcat = array();
        getIdList($sql, $tmp_idcat, 'idcat');
        if (is_array($tmp_idcat)) {
            // Seite in neue Ordner einfügen
            foreach ($idcatnew as $value) {
                if (!in_array($value, $tmp_idcat)) {
                    $sql = 'SELECT * FROM ' . $cms_db['cat_side'] . ' WHERE idcat = ' . $value . ' AND is_start = 1';
                    $db->query($sql);
                    $is_start = $db->next_record() ? '0' : '1';
                    //sortindex suchen
                    $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
                    $db->query($sql);
                    if ($db->next_record()) {
                        $sortindex = $db->f('sortindex') + 1;
                    } else {
                        $sortindex = 1;
                    }
                    if ($value == $idcatnew['0'] && !in_array($idcat, $idcatnew)) {
                        $sql = 'UPDATE ' . $cms_db['cat_side'] . ' ';
                        $sql .= 'SET';
                        $sql .= ' idcat    = ' . $value . ',';
                        $sql .= ' sortindex    = ' . $sortindex . ',';
                        $sql .= ' is_start = ' . $is_start . ' ';
                        $sql .= 'WHERE  idcat = ' . $idcat;
                        $sql .= ' AND  idside = ' . $idside;
                        $db->query($sql);
                        if (in_array($idcat, $idcatnew)) {
                            unset($tmp_idcat[$idcat]);
                        }
                        //alte kategorie neu sortieren
                        if (!function_exists('con_reindex_page_sort')) {
                            include_once 'inc/fnc.con.php';
                        }
                        con_reindex_page_sort($idcat);
                    } else {
                        //sortindex suchen
                        $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
                        $db->query($sql);
                        if ($db->next_record()) {
                            $sortindex = $db->f('sortindex') + 1;
                        } else {
                            $sortindex = 1;
                        }
                        $sql = 'INSERT INTO ' . $cms_db['cat_side'] . ' ';
                        $sql .= ' (idcat , idside , is_start, sortindex) ';
                        $sql .= 'VALUES';
                        $sql .= " ({$value}, {$idside}, {$is_start}, {$sortindex}) ";
                        $db->query($sql);
                    }
                }
            }
            // Seite aus nicht benutzen Ordnern löschen
            // jb_todo: rechte löschen??
            foreach ($tmp_idcat as $value) {
                if (!in_array($value, $idcatnew)) {
                    // suche alle idcatsides, die nicht mehr existieren
                    $sql = 'SELECT idcatside FROM ' . $cms_db['cat_side'] . " WHERE idcat='{$value}' AND idside='{$idside}'";
                    $db->query($sql);
                    $db->next_record();
                    // lösche alte 'code' Einträge
                    $sql = 'DELETE FROM ' . $cms_db['code'] . " WHERE idcatside='" . $db->f('idcatside') . "'";
                    $db->query($sql);
                    // lösche alte 'cat_side' Einträge
                    $sql = 'DELETE FROM ' . $cms_db['cat_side'] . " WHERE idside='{$idside}' AND idcat='{$value}'";
                    $db->query($sql);
                    // falls kein Startartikel mehr vorhanden neuen setzen
                    $sql = 'SELECT * FROM ' . $cms_db['cat_side'] . " WHERE idcat='{$value}' AND is_start='1'";
                    $db->query($sql);
                    if (!$db->affected_rows()) {
                        $sql = 'UPDATE ' . $cms_db['cat_side'] . " SET is_start = '1' WHERE idcat='{$value}' ORDER BY sortindex LIMIT 1";
                        $db->query($sql);
                    }
                    //sortindex neu sortieren
                    if (!function_exists('con_reindex_page_sort')) {
                        include_once 'inc/fnc.con.php';
                    }
                    con_reindex_page_sort($value);
                    // jb_todo:
                    // lösche alte 'tpl_conf' Einträge
                    // muß noch eingetragen werden
                    //Event
                    fire_event('get_unused_idcatside_by_save_side', array('idside' => $idside, 'idcat' => $value, 'idcatside' => $db->f('idcatside')));
                }
            }
        }
        // Template konfigurieren
        $have_perm_save_configdata = $perm->have_perm(27, 'side', $idcatside_for_rights, $idcat_for_rights);
        //		if ($idtplconf == '0' && $idtpl != '0') {
        //	 		$sql = 'SELECT idsidelang FROM ' . $cms_db['side_lang'] . " WHERE idside = $idside";
        //			$tmp_idsidelang = array();
        //			$affected_rows = getIdList($sql, $tmp_idsidelang, '', 'idsidelang');
        //			//print_r($tmp_idsidelang);exit;
        //
        //			// Template erstellen
        //			if ($affected_rows) {
        //				foreach ($tmp_idsidelang as $value) {
        //					con_config_tpl_save($idtpl, $idlay, '', $value, $idtplconf, $have_perm_save_configdata);
        //				}
        //			}
        //		}
        //		else {
        con_config_tpl_save($idtpl, $idlay, '', $idsidelang, $idtplconf, $have_perm_save_configdata);
        //		}
        // Rechte setzen
        if ($perm->have_perm(22, 'side', $idcatside_for_rights, $idcat_for_rights)) {
            global $backend_cms_gruppenids, $backend_cms_gruppenrechte, $backend_cms_gruppenrechtegeerbt, $backend_cms_gruppenrechteueberschreiben;
            $perm->set_group_rights('side', $idcatside_for_rights, $backend_cms_gruppenids, $backend_cms_gruppenrechte, $backend_cms_gruppenrechtegeerbt, $backend_cms_gruppenrechteueberschreiben, '', 0x7ffd0000, $idcat_for_rights, 0x7ffd0000);
        }
        if ($perm->have_perm(14, 'cat', $idcat_for_rights)) {
            global $frontend_cms_gruppenids, $frontend_cms_gruppenrechte, $frontend_cms_gruppenrechtegeerbt, $frontend_cms_gruppenrechteueberschreiben;
            $perm->set_group_rights('frontendpage', $idcatside_for_rights, $frontend_cms_gruppenids, $frontend_cms_gruppenrechte, $frontend_cms_gruppenrechtegeerbt, $frontend_cms_gruppenrechteueberschreiben, '', 68719476735.0, $idcat_for_rights, 4294967295.0);
        }
        // Codestatus ändern
        change_code_status($idcatside_for_rights, 1, 'idcatside');
        // Event
        fire_event('con_side_edit', array('idside' => $idside, 'name' => $title));
        // Content aus Cache löschen
        sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content'));
        // ermittle redirect-url
        if ($view) {
            $url_location = $sess->url($cfg_client['htmlpath'] . $cfg_client['contentfile'] . '?lang=' . $lang . '&idcatside=' . $idcatside . '&view=' . $view);
        } else {
            $url_location = $sess->url('main.php?area=con');
        }
    }
    // Cache-Group Frontend löschen
    sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend'));
    if ($use_redirect) {
        redirect_page($url_location);
    }
}
function rewriteGetCatRewriteAlias($idcat, $idlang)
{
    global $con_tree, $cms_db, $sf_lang_stack, $lang;
    $out = '';
    if (is_array($con_tree) && $lang == $idlang) {
        if ($con_tree[$idcat]['rewrite_alias'] == '') {
            $string = rewriteGenerateUrlString($con_tree[$idcat]['name']);
            $string = rewriteMakeUniqueStringForLang('idcat', $idcat, $string);
            rewriteSaveUrlString($idlang, 'idcat', $idcat, $string);
            $con_tree[$idcat]['rewrite_alias'] = $string;
        }
        $out = $con_tree[$idcat]['rewrite_alias'];
    } else {
        $ado =& sf_factoryGetObjectCache('DATABASE', 'Ado');
        $sql = "SELECT *\n\t\t\t\tFROM\n\t\t\t\t\t" . $cms_db['cat_lang'] . " CL LEFT JOIN\n\t\t\t\t\t" . $cms_db['cat'] . " C USING(idcat)\n\t\t\t\tWHERE \n\t\t\t\t\tCL.idcat = '" . $idcat . "'\n\t\t\t\t\tAND CL.idlang   = '" . $idlang . "'";
        $rs = $ado->Execute($sql);
        if ($rs === false) {
            return false;
        }
        if ($rs->EOF) {
            return false;
        }
        $out = $rs->fields['rewrite_alias'];
    }
    return $out;
}
Example #3
0
 /**
  * @return obj|boolen new cat object or false
  */
 function &copy($target_idcat, $title = '', $options = array())
 {
     global $cfg_cms, $perm;
     //option values are: default, yes, no
     //special: 'set_startflag': if_first
     //'set_online' (default|yes|no) default is copy flag from source
     //'set_copy' (default|yes|no) default is copy flag from source
     //'set_startflag' (default|from_source) default set the startflag if page in category haven't a valid startpage,
     //                                      from_source copys flag from source
     //'perms' bool (true|false)
     $options_default = array('set_online' => 'default', 'set_protected' => 'default', 'set_startflag' => 'from_source', 'perms' => true);
     $options = array_merge($options_default, $options);
     $target_idcat = (int) $target_idcat;
     $return = false;
     if ($target_idcat < 0) {
         return $return;
     }
     $catinfos = sf_factoryGetObjectCache('PAGE', 'Catinfos');
     //copy rootcat
     $cat_copy = sf_factoryGetObject('PAGE', 'Cat');
     $cat_copy->data = $this->data;
     $cat_copy->data['sql']['cat_lang']['idcatlang'] = false;
     $cat_copy->data['sql']['cat_lang']['idcat'] = false;
     $cat_copy->data['sql']['cat']['idcat'] = false;
     $cat_copy->data['sql']['cat']['parent'] = $target_idcat;
     $cat_copy->data['sql']['cat']['sortindex'] = false;
     //name
     if ($title != '') {
         $cat_copy->data['sql']['cat_lang']['name'] = $title;
     } else {
         $title = $cat_copy->data['sql']['cat_lang']['name'];
     }
     //online
     $visible = $cat_copy->data['sql']['cat_lang']['visible'];
     //print_r($options);
     //echo $visible.'<br>';
     if ($options['set_online'] == 'yes') {
         $visible = $visible | 0x1;
     } else {
         if ($options['set_online'] == 'no') {
             $visible = $visible & 0xfe;
         }
     }
     //echo $visible.'<br>';
     //protected
     if ($options['set_protected'] == 'yes') {
         $visible = $visible | 0x4;
     } else {
         if ($options['set_protected'] == 'no') {
             $visible = $visible & 0xfb;
         }
     }
     $cat_copy->data['sql']['cat_lang']['visible'] = $visible;
     //set langprefix on other langs then the default lang
     $cat_copy->_set_langprefix_on_save_if_new = true;
     $cat_copy->dirty = true;
     $cat_copy->save();
     //copy templates
     $copy_idtplconf = $this->_copyTemplateConfig($this->getIdcat(), $cat_copy->getIdcat());
     //echo "$target_idcat $title";exit;
     $cat_copy->data['sql']['cat_lang']['idtplconf'] = $copy_idtplconf;
     $cat_copy->dirty = true;
     //rewrite url
     include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . "inc/fnc.mod_rewrite.php";
     rewriteGenerateMapping();
     $rewrite_url = rewriteGenerateUrlString($title);
     $rewrite_url = rewriteMakeUniqueStringForLang('idcat', $cat_copy->getIdcat(), $rewrite_url, '', $cat_copy->getParent());
     $cat_copy->data['sql']['cat_lang']['rewrite_use_automatic'] = 1;
     $cat_copy->data['sql']['cat_lang']['rewrite_alias'] = $rewrite_url;
     $cat_copy->save();
     //copy rootcat perms
     if ($options['perms']) {
         $arr_langs = $this->_getLangInfoArray();
         foreach ($arr_langs['order'] as $current_lang) {
             $perm->xcopy_perm($this->getIdcat(), 'cat', $cat_copy->getIdcat(), 'cat', 4294967295.0, 0, $current_lang, false);
             $perm->xcopy_perm($this->getIdcat(), 'frontendcat', $cat_copy->getIdcat(), 'frontendcat', 4294967295.0, 0, $current_lang, false);
         }
     }
     //copy pages of rotcat
     include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . "inc/fnc.con.php";
     $arr_idcatsides = $this->_getIdcatsides($this->getIdcat());
     foreach ($arr_idcatsides as $v) {
         //echo '<br>---X'.$cat_copy->getIdcat();
         con_copy_page($this->_getIdclient(), $this->getIdlang(), $v, '', $cat_copy->getIdcat(), $options['perms'], $options);
     }
     //copy childcats
     $cattree = sf_factoryGetObjectCache('PAGE', 'Cattree');
     $cattree->setIdclient($this->_getIdclient());
     $cattree->generate();
     $this_idcat = $this->getIdcat();
     $new_parent = $cat_copy->getIdcat();
     $arr_childs = $cattree->getChilds($this_idcat);
     //print_r($arr_childs);
     foreach ($arr_childs as $v) {
         $cat_child = sf_factoryGetObject('PAGE', 'Cat');
         if ($cat_child->loadByIdcatIdlang($v, $this->getIdlang())) {
             $cat_child->copy($new_parent, '', $options);
         }
     }
     return $cat_copy;
 }
Example #4
0
function con_create_site_meta_from_idcatside($idclient, $idlang_current, $idcatside_from, $name = '', $lang_postfix = true, $target_idcat = -1, $options = array())
{
    global $db, $cms_db, $cfg_cms;
    //cast
    $idclient = (int) $idclient;
    $idlang_current = (int) $idlang_current;
    $idcatside_from = (int) $idcatside_from;
    if ($idclient < 1 || $idlang_current < 1 || $idcatside_from < 1) {
        return false;
    }
    set_magic_quotes_gpc($name);
    //init
    $db2 = new DB_cms();
    //get necessary values from source idcatside
    $sql = "SELECT * FROM " . $cms_db['cat_side'] . " WHERE idcatside='{$idcatside_from}'";
    $db->query($sql);
    if ($db->next_record()) {
        $idcat_from = $db->f('idcat');
        $idside_from = $db->f('idside');
        $sortindex_from = $db->f('sortindex');
        $is_start_from = $db->f('is_start');
    } else {
        return false;
    }
    //copy to same idcat or to an other category
    $idcat_to = $target_idcat < 1 ? $idcat_from : $target_idcat;
    //create idside
    $sql = "INSERT INTO " . $cms_db['side'] . " (idclient) VALUES ('{$idclient}')";
    $db->query($sql);
    $idside_to = mysql_insert_id();
    //create idcatside
    $sql = "INSERT INTO \n\t\t\t\t" . $cms_db['cat_side'] . " (idcat, idside, is_start) \n\t\t\tVALUES\n\t\t\t\t('{$idcat_to}', '{$idside_to}', '0')";
    $db->query($sql);
    $idcatside_to = mysql_insert_id();
    //sortindex
    $db->query("SELECT MAX(sortindex) AS max FROM " . $cms_db['cat_side'] . " WHERE idcat='{$idcat_to}'");
    $db->next_record();
    $lastindex = (int) $db->f('max');
    if ($lastindex < 1) {
        $lastindex = 1;
    } else {
        ++$lastindex;
    }
    $sql = "UPDATE " . $cms_db['cat_side'] . " SET sortindex='{$lastindex}' WHERE idcatside='{$idcatside_to}'";
    $db->query($sql);
    //check and set startpage
    if ($options['set_startflag'] == 'from_source') {
        $sql = "UPDATE " . $cms_db['cat_side'] . " SET is_start='{$is_start_from}' WHERE idcatside='{$idcatside_to}'";
        $db->query($sql);
    } else {
        $sql = "SELECT * FROM " . $cms_db['cat_side'] . " WHERE idcat='{$idcat_to}' AND is_start='1'";
        $db->query($sql);
        if (!$db->affected_rows()) {
            $sql = "UPDATE " . $cms_db['cat_side'] . " SET is_start='1' WHERE idcat='{$idcat_to}' AND sortindex='1'";
            $db->query($sql);
        }
    }
    //get lang infos
    include_once $cfg_cms['cms_path'] . "inc/fnc.clients.php";
    $arr_langs = clients_get_langs($idclient, true);
    //insert metadata foreach lang
    $db3 = new DB_cms();
    $sql = "SELECT * FROM " . $cms_db['side_lang'] . " WHERE idside='{$idside_from}'";
    $db3->query($sql);
    while ($db3->next_record()) {
        $idlang = $db3->f('idlang');
        if ($name == '') {
            $name = make_string_dump($db3->f('title'));
        }
        if ($lang_postfix && $idlang_current != $idlang) {
            $title = $name . ' (' . $arr_langs[$idlang]['name'] . ')';
        } else {
            $title = $name;
        }
        $summary = make_string_dump($db3->f('summary'));
        $meta_author = make_string_dump($db3->f('meta_author'));
        $meta_description = make_string_dump($db3->f('meta_description'));
        $meta_keywords = make_string_dump($db3->f('meta_keywords'));
        $meta_robots = make_string_dump($db3->f('meta_robots'));
        $meta_redirect_url = make_string_dump($db3->f('meta_redirect_url'));
        $rewrite_url = make_string_dump($db3->f('rewrite_url'));
        //get the stat
        $online = (int) $db3->f('online') & 0xff;
        //handle online/ offline, protection options
        //online
        if ($options['set_online'] == 'yes') {
            $online = $online | 0x1;
        } else {
            if ($options['set_online'] == 'no') {
                $online = $online & 0xfe;
            }
        }
        //protected
        if ($options['set_protected'] == 'yes') {
            $online = $online | 0x4;
        } else {
            if ($options['set_protected'] == 'no') {
                $online = $online & 0xfb;
            }
        }
        //make rewrite url
        if (!function_exists('rewriteGenerateUrlString')) {
            include_once $cfg_cms['cms_path'] . 'inc/fnc.mod_rewrite.php';
        }
        $rewrite_url = rewriteGenerateUrlString($title);
        $rewrite_url = rewriteMakeUniqueStringForLang('idcatside', $idcatside_to, $rewrite_url);
        //echo $online;exit;
        $sql2 = "INSERT INTO " . $cms_db['side_lang'] . " \n\t\t\t\t\t(idside, idlang, idtplconf, title, meta_keywords, summary, online, \n\t\t\t\t\t\tmeta_redirect, meta_redirect_url, author, \n\t\t\t\t\t\tcreated, lastmodified, user_protected, visited, edit_ttl, \n\t\t\t\t\t\tmeta_author, meta_description, meta_robots, meta_redirect_time,\n\t\t\t\t\t\trewrite_use_automatic, rewrite_url, start, end) \n\t\t\t\tVALUES ('" . $idside_to . "', '{$idlang}', '0', '{$title}', '{$meta_keywords}', '{$summary}', '{$online}',\n\t\t\t\t\t '" . $db3->f('meta_redirect') . "', '{$meta_redirect_url}', '" . $db3->f('author') . "', \r\n\t\t\t\t\t'" . time() . "', '" . time() . "', '" . $db3->f('user_protected') . "', '" . $db3->f('visited') . "', '" . $db3->f('edit_ttl') . "', \r\n\t\t\t\t\t'{$meta_author}', '{$meta_description}', '{$meta_robots}', '" . $db3->f('meta_redirect_time') . "',\r\n\t\t\t\t\t'1', '{$rewrite_url}', " . time() . ", " . time() . ")";
        $db2->query($sql2);
    }
    return $idcatside_to;
}