コード例 #1
0
ファイル: person.php プロジェクト: Jonathan-Law/fhd
 protected function update($user)
 {
     if ($user === null) {
         $user = User::current_user();
     }
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         $fields = self::$db_fields;
         // $this->submitter = (int)$user->id;
         if (isset($user) && !isset($user->rights) || !($user->rights === 'super' || $user->rights === 'admin')) {
             $this->status = 'I';
             $tempPerson = Person::getById($this->id);
             if ($tempPerson->status === 'A') {
                 $message = "An old Individual has been updated and will require aproval to the changes:<br><br>";
                 $message .= "<a href='http://dev.familyhistorydatabase.org/#/individual?individual=" . $this->id . "&tab=default'>" . $this->displayName() . "</a><br><br>";
                 $message .= "by " . $user->username . " " . $user->email;
                 $message .= "<br><br>Changes Include:<br>";
                 $message .= print_r(recursive_array_diff((array) $this, (array) $tempPerson), true);
                 $subject = "Old Individual for approval";
                 sendOwnerUpdate($message, $subject);
             }
         } else {
             if (is_null($user)) {
                 return false;
             }
         }
         foreach ($fields as $key) {
             $flag = $database->SQLUpdate("person", $key, $this->{$key}, "id", $this->id);
             if ($flag == "fail") {
                 break;
             }
         }
         if ($flag == "fail") {
             return 'we failed on check2';
             return false;
         } else {
             return $this->id;
         }
     }
     return 'this happened';
 }
コード例 #2
0
ファイル: functions.php プロジェクト: Jonathan-Law/fhd
function recursive_array_diff($a1, $a2)
{
    $r = array();
    foreach ($a1 as $k => $v) {
        if (array_key_exists($k, $a2)) {
            if (is_array($v)) {
                $rad = recursive_array_diff($v, $a2[$k]);
                if (count($rad)) {
                    $r[$k] = $rad;
                }
            } else {
                if ($v != $a2[$k]) {
                    $r[$k] = $v;
                }
            }
        } else {
            $r[$k] = $v;
        }
    }
    return $r;
}