Example #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();
	}
Example #2
0
        //var_dump("exporting to repository",$r);
    }
}
unset($r);
unset($repositories);
$export_queue = $pfif_conf['services'];
foreach ($export_queue as $service_name => $service) {
    $repos = $service['repository'];
    $req_params = $repos->get_request_params();
    $min_entry_date = $req_params['min_entry_date'];
    $skip = $req_params['skip'];
    $subdomain = empty($service['subdomain']) ? '' : '?subdomain=' . $service['subdomain'];
    $auth_key = empty($service['auth_key']) ? '' : '?key=' . $service['auth_key'];
    $pfif_uri = $service['post_url'] . $auth_key;
    $at_subdomain = " at subdomain {$subdomain} ";
    $p = new Pfif();
    $p->setService($service_name, $service);
    $repos->start_harvest('scheduled', 'out');
    print "\n\nExport started to " . $service['post_url'] . " at " . date("Y-m-d H:i:s") . "\n";
    $local_date = local_date($min_entry_date);
    $loaded = $p->loadFromDatabase($local_date, null, 0, $skip);
    print "Exporting original records after {$local_date}.\n";
    if ($loaded > 0) {
        // Export records
        $xml = $p->storeInXML(false, true);
        if ($xml != null) {
            $fh = fopen('cronpfif.xml', 'w');
            $charstowrite = strlen($xml);
            $written = fwrite($fh, $xml, $charstowrite);
            fclose($fh);
            $post_status = $p->postToService($xml);
Example #3
0
foreach ($repositories as $r) {
    if ($r->is_ready_for_harvest($sched_time)) {
        add_pfif_service($r);
        //initialize pfif_conf
    }
}
unset($r);
unset($repositories);
$import_queue = $pfif_conf['services'];
//print "Queued imports:\n".print_r($import_queue,true)."\n";
foreach ($import_queue as $service_name => $service) {
    $repos = $service['repository'];
    //var_dump("repository", $repos);
    $req_params = $repos->get_request_params();
    $pfif_uri = $service['feed_url'] . '?min_entry_date=' . $req_params['min_entry_date'] . '&max_results=' . $service['max_results'] . '&key=' . $service['auth_key'] . '&skip=' . $req_params['skip'] . '&version=' . $service['version'];
    $p = new Pfif();
    $p->setService($service_name, $service);
    //print_r($pfif_conf);
    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) {