Ejemplo n.º 1
0
	public function makeStaticPfifNote() {

		// make the note unless we are explicitly asked not to...
		if(!$this->makePfifNote) {
			return;
		}

		global $global;
		require_once($global['approot']."inc/lib_uuid.inc");
		require_once($global['approot']."mod/pfif/pfif.inc");
		require_once($global['approot']."mod/pfif/util.inc");

		$p = new Pfif();

		$n = new Pfif_Note();
		$n->note_record_id          = shn_create_uuid('pfif_note');
		$n->person_record_id        = $this->p_uuid;
		$n->linked_person_record_id = null;
		$n->source_date             = $this->last_updated; // since we are now creating the note,
		$n->entry_date              = $this->last_updated; // we use the last_updated for both values
		$n->author_phone            = null;
		$n->email_of_found_person   = null;
		$n->phone_of_found_person   = null;
		$n->last_known_location     = $this->last_seen;
		$n->text                    = $this->other_comments;
		$n->found                   = null; // we have no way to know if the reporter had direct contact (hence we leave this null)

		// figure out the person's pfif status
		$n->status = shn_map_status_to_pfif($this->opt_status);

		// find author name and email...
		$q = "
			SELECT *
			FROM contact c, person_uuid p
			WHERE p.p_uuid = c.p_uuid
			AND c.opt_contact_type = 'email'
			AND p.p_uuid = '".$this->rep_uuid."';
		";
		$result = $this->db->Execute($q);
		if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get contact for pfif note ((".$q."))"); }

		if($result != NULL && !$result->EOF) {
			$n->author_name  = $result->fields['full_name'];
			$n->author_email = $result->fields['contact_value'];
		} elseif($this->author_name != null) {
			$n->author_name  = $this->author_name;
			$n->author_email = $this->author_email;
		} else {
			$n->author_name  = null;
			$n->author_email = null;
		}

		$p->setNote($n);
		$p->setIncidentId($this->incident_id);
		$p->storeNotesInDatabase();
	}
Ejemplo n.º 2
0
try {
    $repos->start_harvest($mode, 'in');
    print "\nImport started from {$pfif_uri} at " . $repos->get_log()->start_time . "\n";
    if ($is_person) {
        $loaded = $p->loadPersonsFromXML($pfif_uri);
    } else {
        $loaded = $p->loadNotesFromXML($pfif_uri);
    }
    if ($loaded > 0) {
        print "Loaded {$loaded} XML records. ";
        if ($is_scheduled) {
            // Output to database for production
            if ($is_person) {
                $stored = $p->storePersonsInDatabase();
            } else {
                $stored = $p->storeNotesInDatabase();
            }
            print "Stored {$stored} records.\n";
        } else {
            // Output to file for test/debug. (This leverages export functionality.)
            $xml = $p->storeInXML(false);
            // non-embedded format
            //print $xml;
            $logfile_name = 'crontest_' . $service_name . '.xml';
            $fh = fopen($logfile_name, 'a+');
            $charstowrite = strlen($xml);
            $written = fwrite($fh, $xml, $charstowrite);
            fclose($fh);
            print "wrote {$written} of {$charstowrite} characters to {$logfile_name}\n";
        }
        // Note: For tests, only last_entry_date is saved. (No skip, etc.)