예제 #1
0
        }
        $sql = 'INSERT INTO `' . TABLE_PREFIX . 'ticket__cdata` SET ' . $fields . ', `ticket_id`=' . db_input($answer->getEntry()->get('object_id')) . ' ON DUPLICATE KEY UPDATE ' . $fields;
        if (!db_query($sql) || !db_affected_rows()) {
            return self::dropDynamicDataView();
        }
    }
}
// Add fields from the standard ticket form to the ticket filterable fields
Filter::addSupportedMatches('Ticket Data', function () {
    $matches = array();
    foreach (TicketForm::getInstance()->getFields() as $f) {
        if (!$f->hasData()) {
            continue;
        }
        $matches['field.' . $f->get('id')] = 'Ticket / ' . $f->getLabel();
        if (($fi = $f->getImpl()) instanceof SelectionField) {
            foreach ($fi->getList()->getProperties() as $p) {
                $matches['field.' . $f->get('id') . '.' . $p->get('id')] = 'Ticket / ' . $f->getLabel() . ' / ' . $p->getLabel();
            }
        }
    }
    return $matches;
}, 30);
// Manage materialized view on custom data updates
Signal::connect('model.created', array('TicketForm', 'updateDynamicDataView'), 'DynamicFormEntryAnswer');
Signal::connect('model.updated', array('TicketForm', 'updateDynamicDataView'), 'DynamicFormEntryAnswer');
// Recreate the dynamic view after new or removed fields to the ticket
// details form
Signal::connect('model.created', array('TicketForm', 'dropDynamicDataView'), 'DynamicFormField', function ($o) {
    return $o->getForm()->get('type') == 'T';
});
    return $o->getForm()->get('type') == 'T';
});
// If the `name` column is in the dirty list, we would be renaming a
// column. Delete the view instead.
Signal::connect('model.updated', array('TicketForm', 'dropDynamicDataView'), 'DynamicFormField', function ($o, $d) {
    return isset($d['dirty']) && (isset($d['dirty']['name']) || isset($d['dirty']['type']));
});
Filter::addSupportedMatches('Custom Forms', function () {
    $matches = array();
    foreach (DynamicForm::objects()->filter(array('type' => 'G')) as $form) {
        foreach ($form->getFields() as $f) {
            if (!$f->hasData()) {
                continue;
            }
            $matches['field.' . $f->get('id')] = $form->getTitle() . ' / ' . $f->getLabel();
            if (($fi = $f->getImpl()) && $fi->hasSubFields()) {
                foreach ($fi->getSubFields() as $p) {
                    $matches['field.' . $f->get('id') . '.' . $p->get('id')] = $form->getTitle() . ' / ' . $f->getLabel() . ' / ' . $p->getLabel();
                }
            }
        }
    }
    return $matches;
}, 9900);
require_once INCLUDE_DIR . "class.json.php";
class DynamicFormField extends VerySimpleModel
{
    static $meta = array('table' => FORM_FIELD_TABLE, 'ordering' => array('sort'), 'pk' => array('id'), 'joins' => array('form' => array('null' => true, 'constraint' => array('form_id' => 'DynamicForm.id'))));
    var $_field;
    const REQUIRE_NOBODY = 0;
    const REQUIRE_EVERYONE = 1;
예제 #3
0
        }
        if (!$cfg || $cfg->getTopicSortMode() == 'a') {
            static::updateSortOrder();
        }
        return $rv;
    }
    static function updateSortOrder()
    {
        // Fetch (un)sorted names
        if (!($names = static::getHelpTopics(false, true))) {
            return;
        }
        uasort($names, function ($a, $b) {
            return strcmp($a, $b);
        });
        $update = array_keys($names);
        foreach ($update as $idx => &$id) {
            $id = sprintf("(%s,%s)", db_input($id), db_input($idx + 1));
        }
        if (!count($update)) {
            return;
        }
        // Thanks, http://stackoverflow.com/a/3466
        $sql = sprintf('INSERT INTO `%s` (topic_id,`sort`) VALUES %s
            ON DUPLICATE KEY UPDATE `sort`=VALUES(`sort`)', TOPIC_TABLE, implode(',', $update));
        db_query($sql);
    }
}
// Add fields from the standard ticket form to the ticket filterable fields
Filter::addSupportedMatches('Help Topic', array('topicId' => 'Topic ID'), 100);
예제 #4
0
                break;
            }
        }
        if (!$form || !($o = static::objects())) {
            return false;
        }
        // Create sample organization.
        if ($orgs = $i18n->getTemplate('organization.yaml')->getData()) {
            foreach ($orgs as $org) {
                Organization::__create($org);
            }
        }
        return $o[0];
    }
}
Filter::addSupportedMatches('Organization Data', function () {
    $matches = array();
    foreach (OrganizationForm::getInstance()->getFields() as $f) {
        if (!$f->hasData()) {
            continue;
        }
        $matches['field.' . $f->get('id')] = __('Organization') . ' / ' . $f->getLabel();
        if (($fi = $f->getImpl()) && $fi->hasSubFields()) {
            foreach ($fi->getSubFields() as $p) {
                $matches['field.' . $f->get('id') . '.' . $p->get('id')] = __('Organization') . ' / ' . $f->getLabel() . ' / ' . $p->getLabel();
            }
        }
    }
    return $matches;
}, 40);
Organization::_inspect();