<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.8.0
 *	LISENSE: FL4HLD2A8696 - https://www.flynax.com/flynax-software-eula.html
 *	PRODUCT: Real Estate Script
 *	DOMAIN : immofil.com
 *	FILE   : ANDROID_SETTINGS.INC.PHP
 *
 *	This script is a commercial software and any kind of using it must be
 *	coordinate with Flynax Owners Team and be agree to Flynax License Agreement
 *
 *	This block may not be removed from this file or any other files with out
 *	permission of Flynax respective owners.
 *
 *	Copyrights Flynax Classifieds Software | 2020
 *	https://www.flynax.com
 *
 ******************************************************************************/

if ($_POST['submit']) {
    $post_config = isset($_POST['post_config']) ? $_POST['post_config'] : $_POST['config'];

    $update = array();

    foreach ($post_config as $key => $value) {
        if ($value['d_type'] == 'int') {
            $value['value'] = (int) $value['value'];
        }

        $rlValid->sql($value['value']);

        $row['where']['Key'] = $key;
        $row['fields']['Default'] = $value['value'];
        if ($key == 'android_inapp_key') {
            $row['fields']['Values'] = $value['value'];
        }
        array_push($update, $row);
        unset($row);
    }

    if ($rlDb->update($update, 'config')) {
        $reefless->loadClass('Notice');

        $aUrl = array('controller' => $controller);

        $rlNotice->saveNotice($lang['config_saved']);
        $reefless->redirect($aUrl);
    }
}

$group_id = $rlDb->getOne('ID', "`Key` = 'androidConnect'", 'config_groups');

/* get all configs */
$configsLsit = $rlDb->fetch('*', array('Group_ID' => $group_id), "ORDER BY `Position`", null, 'config');
$configsLsit = $rlLang->replaceLangKeys($configsLsit, 'config', array('name', 'des'), RL_LANG_CODE, 'admin');
$rlAdmin->mixSpecialConfigs($configsLsit);

$rlSmarty->assign_by_ref('configs', $configsLsit);
