Example #1
0
function createHistory($o, $h)
{
    if ($o instanceof Ticket) {
        $history = new TicketHistory();
        $history->setTicket($o);
    } else {
        $history = new IssueHistory();
        $history->setIssue($o);
    }
    if (!empty($h['enteredDate'])) {
        $d = DateTime::createFromFormat('U', $h['enteredDate']->sec);
        if ($d) {
            $history->setEnteredDate($d->format('Y-m-d H:i:s'));
        }
    }
    if (!empty($h['actionDate'])) {
        $d = DateTime::createFromFormat('U', $h['actionDate']->sec);
        if ($d) {
            $history->setActionDate($d->format('Y-m-d H:i:s'));
        }
    }
    if (!empty($h['enteredByPerson'])) {
        $id = getPersonIdFromCrosswalk($h['enteredByPerson']['_id']);
        if ($id) {
            $history->setEnteredByPerson_id($id);
        }
    }
    if (!empty($h['actionPerson'])) {
        $id = getPersonIdFromCrosswalk($h['actionPerson']['_id']);
        if ($id) {
            $history->setActionPerson_id($id);
        }
    }
    if (!empty($h['action'])) {
        try {
            $action = new Action($h['action']);
        } catch (Exception $e) {
            $action = new Action();
            $action->setName($h['action']);
            $action->setDescription($h['action']);
            $action->setType('system');
        }
        $history->setAction($action);
    }
    if (!empty($h['notes'])) {
        $history->setNotes($h['notes']);
    }
    $history->save();
}
    $c->setCategoryGroup($g);
    $d = new Department($r['department']['name']);
    $c->setDepartment($d);
    if (!empty($r['customFields'])) {
        $c->setCustomFields(json_encode($r['customFields']));
    }
    $c->save();
    echo "Category: {$c->getName()}\n";
}
// Now that we've got People and Categories in the database,
// Link the Departments with their Categories and Default Person
$result = $mongo->departments->find();
foreach ($result as $r) {
    $d = new Department($r['name']);
    if (!empty($r['defaultPerson']['_id'])) {
        $id = getPersonIdFromCrosswalk($r['defaultPerson']['_id']);
        $d->setDefaultPerson_id($id);
    }
    if (!empty($r['categories'])) {
        $ids = array();
        foreach ($r['categories'] as $c) {
            try {
                $category = new Category($c['name']);
                $ids[] = $category->getId();
            } catch (Exception $e) {
                // Departments may have old categories we have deleted
                // Just ignore them
            }
        }
        $d->setCategories($ids);
    }
Example #3
0
<?php

/**
 * @copyright 2012 City of Bloomington, Indiana
 * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
 * @author Cliff Ingham <*****@*****.**>
 */
require_once './config.inc';
// Clients
$result = $mongo->clients->find();
foreach ($result as $r) {
    $id = getPersonIdFromCrosswalk($r['contactPerson']['_id']);
    $zend_db->insert('clients', array('name' => $r['name'], 'url' => $r['url'], 'api_key' => (string) $r['_id'], 'contactPerson_id' => $id));
    echo "Client: {$r['name']}\n";
}