Skip to content
Snippets Groups Projects
check_user_entities.php 1.16 KiB
Newer Older
  • Learn to ignore specific revisions
  • SNA's avatar
    SNA committed
    <?php
    
    $error = '';
    
    function get_values_in_array($val)
    {
    
        $val = str_replace("&#039;", "'", $val);
    
    SNA's avatar
    SNA committed
        $tab = explode('$$',$val);
        $values = array();
        for($i=0; $i<count($tab);$i++)
        {
            $tmp = explode('#', $tab[$i]);
            if(isset($tmp[1]))
            {
                array_push($values, array('ID' => $tmp[0], 'VALUE' => trim($tmp[1])));
            }
        }
        return $values;
    
    SNA's avatar
    SNA committed
    }
    
    function get_value_fields($values, $field)
    {
    
    SNA's avatar
    SNA committed
        for($i=0; $i<count($values);$i++)
        {
            if($values[$i]['ID'] == $field)
            {
                return  $values[$i]['VALUE'];
            }
        }
        return false;
    
    SNA's avatar
    SNA committed
    }
    
    if(!isset($_REQUEST['form_values']) || empty($_REQUEST['form_values']))
    {
    
    SNA's avatar
    SNA committed
        $error = _ERROR_FORM_VALUES." check<br/>";
        echo "{status : 2, error_txt : '".$error."'}";
        exit();
    
    SNA's avatar
    SNA committed
    }
    
    $values = get_values_in_array($_REQUEST['form_values']);
    $entity_id = get_value_fields($values, 'entity_id');
    $role = get_value_fields($values, 'role');
    
    if(!isset($entity_id ) || $entity_id  == '')
    {
    
    SNA's avatar
    SNA committed
        $error = _NO_ENTITY_SELECTED."!";
    
    SNA's avatar
    SNA committed
    }
    
    if(!empty($error))
    {
    
    SNA's avatar
    SNA committed
        echo "{status : 1, error_txt : '".$error."'}";
    
    SNA's avatar
    SNA committed
    }
    else
    {
    
    SNA's avatar
    SNA committed
        echo "{status : 0, error_txt : '".$error."'}";
    
    SNA's avatar
    SNA committed
    }
     exit();