Location: PHPKode > projects > OpenBizMap > openbizmap/mydata/script/run_new.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
Action execution

IN $id - current record id
*/

$group=get('group');

// Adding new
if($group)
{
  $variable_array2=load_config($group);

  $variable_array=array();
  reset($variable_array2);
  while(list($variable_name,$tmp)=each($variable_array2))
  {
    if(substr($variable_name,0,3)!='sys')
    {
      $val=get(purename($variable_name));
      if(!$val) // reading properly changes from old manual mascs
        $val=get(str_replace(' ','_',$variable_name));
      if($variable_array2[$variable_name]['template']=='check' and $val==1 and !get(purename($variable_name).'check')) //checkbox
        $val=' ';
      if(!strlen($val))
      {
        if(isset($session_array['FileUpload'.purename($variable_name)]))
        {
          $val=$session_array['FileUpload'.purename($variable_name)];
          $session_array['FileUpload'.purename($variable_name)]='';
        }
      }

      if(strlen($val))
      {
        $template=$variable_array2[$variable_name]['template'];

        $show_value=$val;
        $show_mode=CFG_SAVE;
        if(file_exists(cfg_data_path.'/config/script/fld_'.$template.'.txt'))
        {
          include(cfg_data_path.'/config/script/fld_'.$template.'.txt');
        }
        else
        {
          if(!file_exists(cfg_data_path.'/script/fld_'.$template.'.txt'))
            $template='';

          include(cfg_data_path.'/script/fld_'.$template.'.txt');
        }
        $val=$show_value;

        $variable_array[$variable_name]=$val;

        //echo 'DICT'.$variable_name.'='.$variable_array[$variable_name];
        addpath(cfg_data_path.'/config/dict');
        $fp=fopen(cfg_data_path.'/config/dict/dict_'.purename($variable_name).'.txt','ab');
          fwrite($fp,$variable_array[$variable_name].CRLF);
        fclose($fp);
      }
    }
  }


  $get_array=$_POST;
  reset($get_array);
  while(list($variable_name,$val)=each($get_array))
  {
    $variable_name=str_replace('_',' ',str_replace('odb_','',$variable_name));
    if(
      !isset($variable_array[$variable_name])
      and substr($variable_name,0,3)!='sys'
      and $variable_name!='run'
      and $variable_name!='script'
      and $variable_name!='group'
      and $variable_name!='trans'
      and $variable_name!='search'
      and $variable_name!='save'
    )
    {
      if(strlen($val))
      {
        $variable_array[$variable_name]=$val;

        //echo 'DICT'.$variable_name.'='.$variable_array[$variable_name];
        addpath(cfg_data_path.'/config/dict');
        $fp=fopen(cfg_data_path.'/config/dict/dict_'.purename($variable_name).'.txt','ab');
          fwrite($fp,$variable_array[$variable_name].CRLF);
        fclose($fp);
      }
    }
  }

  $variable_array['sysId']=$sysId;
  $variable_array['sysGroupBy']=$group;
  $variable_array['sysValidFrom']=date('Ymd');
  $variable_array['sysValidTo']=99991231;
  $variable_array['sysValid']=1;
  $variable_array['sysComment']='New record added';

  //USEREXIT OnSave
  $userexit='onsave';
  if(file_exists(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt'))
  {
    include(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt');
  }
  else
  {
    include(cfg_data_path.'/script/userexit/exit_'.$userexit.'.txt');
  }

  if($variable_array['MyBag']=='')
    $variable_array['MyBag']=$bag;

  if($variable_array['sysGroupBy']=='user')
  	$variable_array['MyBag']='access';

  $variable_array['MyBag']=purename($variable_array['MyBag']);

  $id=save($variable_array);
  $message='New data added';
  //$search=$group.' sysId='.$id;
  if(!$script)
    $search='sysId='.$id;

}

?>
Return current item: OpenBizMap