Plugin Directory

Changeset 2678354


Ignore:
Timestamp:
02/14/2022 10:05:58 AM (4 years ago)
Author:
blacker92
Message:

fix old contact form

Location:
nobita-connect/trunk/admin
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • nobita-connect/trunk/admin/lead-model.php

    r2659142 r2678354  
    33class NobitaLead
    44{
    5    private $data = array();
     5    private $data = array();
    66
    7    function __construct($default) {
     7    public function __construct($default)
     8    {
    89        $this->data = $default;
    9    }
     10    }
    1011
    11    public function __set($name, $value)
    12    {
    13        $this->data[$name] = $value;
    14    }
     12    public function __set($name, $value)
     13    {
     14        $this->data[$name] = $value;
     15    }
    1516
    16    public function __get($name)
    17    {
    18        if (array_key_exists($name, $this->data)) {
    19            return $this->data[$name];
    20        }
     17    public function __get($name)
     18    {
     19        if (array_key_exists($name, $this->data)) {
     20            return $this->data[$name];
     21        }
    2122
    22        return null;
    23    }
     23        return null;
     24    }
    2425
    25    public function to_json(){
    26        $modelKeys = array("fullName","phone","address","email","birthdate","firstName"
    27        ,"lastName","name","Email","Name","Birthdate","FullName","Phone","Address");
     26    public function to_json()
     27    {
     28        $modelKeys = array("fullName", "phone", "address", "email", "birthdate", "firstName"
     29            , "lastName", "name", "Email", "Name", "Birthdate", "FullName", "Phone", "Address");
    2830
    29         $model = array_filter($this->data,function($value,$key) use ($modelKeys){
    30             return isset($value) && $value != "" && in_array($key,$modelKeys);
    31         },ARRAY_FILTER_USE_BOTH );
     31        if (!isset($this->data["fullName"]) && isset($this->data["your-name"])) {
     32            $this->data["fullName"] = $this->data["your-name"];
     33            unset($this->data["your-name"]);
     34        }
    3235
    33         $extra = array_filter($this->data,function($value,$key) use ($modelKeys){
    34             return isset($value) && $value != "" && !in_array($key,$modelKeys);
    35         },ARRAY_FILTER_USE_BOTH );
     36        if (!isset($this->data["email"]) && isset($this->data["your-email"])) {
     37            $this->data["email"] = $this->data["your-email"];
     38            unset($this->data["your-email"]);
     39        }
     40
     41        $model = array_filter($this->data, function ($value, $key) use ($modelKeys) {
     42            return isset($value) && $value != "" && in_array($key, $modelKeys);
     43        }, ARRAY_FILTER_USE_BOTH);
     44
     45        $extra = array_filter($this->data, function ($value, $key) use ($modelKeys) {
     46            return isset($value) && $value != "" && !in_array($key, $modelKeys);
     47        }, ARRAY_FILTER_USE_BOTH);
    3648
    3749        $data = array(
    38             "model" => $model,
     50            "model" => $model,
    3951        );
    40         if(count($extra)>0){
    41             $data["queryString"] = $extra;
     52        if (count($extra) > 0) {
     53            $data["queryString"] = $extra;
    4254        }
    43        return json_encode($data);
    44    }
     55        return json_encode($data);
     56    }
    4557}
    46 
    47  
Note: See TracChangeset for help on using the changeset viewer.