function run($max_time) {
        global $cfg;

        $i18n = new Internationalization($cfg->get('system_language', 'en_US'));
        $sequences = $i18n->getTemplate('sequence.yaml')->getData();
        foreach ($sequences as $s) {
            Sequence::create($s)->save();
        }
        db_query('UPDATE '.SEQUENCE_TABLE.' SET `next`= '
            .'(SELECT MAX(ticket_id)+1 FROM '.TICKET_TABLE.') '
            .'WHERE `id`=1');

        require_once(INCLUDE_DIR . 'class.list.php');

        $lists = $i18n->getTemplate('list.yaml')->getData();
        foreach ($lists as $l) {
            DynamicList::create($l);
        }

        $statuses = $i18n->getTemplate('ticket_status.yaml')->getData();
        foreach ($statuses as $s) {
            TicketStatus::__create($s);
        }

        // Initialize MYSQL search backend
        MysqlSearchBackend::__init();
    }
Esempio n. 2
0
 static function __load()
 {
     require_once INCLUDE_DIR . 'class.i18n.php';
     $i18n = new Internationalization();
     $tpl = $i18n->getTemplate('list.yaml');
     foreach ($tpl->getData() as $f) {
         if ($f['type'] == 'ticket-status') {
             $list = DynamicList::create($f);
             $list->save();
             break;
         }
     }
     if (!$list || !($o = DynamicForm::objects()->filter(array('type' => 'L' . $list->getId())))) {
         return false;
     }
     // Create default statuses
     if ($statuses = $i18n->getTemplate('ticket_status.yaml')->getData()) {
         foreach ($statuses as $status) {
             TicketStatus::__create($status);
         }
     }
     return $o[0];
 }
Esempio n. 3
0
             $field->save();
         } else {
             # notrans (not shown)
             $errors["field-{$id}"] = 'Field has validation errors';
         }
         // Keep track of the last sort number
         $max_sort = max($max_sort, $field->get('sort'));
     }
     break;
 case 'add':
     foreach ($fields as $f) {
         if (in_array($f, $required) && !$_POST[$f]) {
             $errors[$f] = sprintf('%s is required', mb_convert_case($f, MB_CASE_TITLE));
         }
     }
     $list = DynamicList::create(array('name' => $_POST['name'], 'name_plural' => $_POST['name_plural'], 'sort_mode' => $_POST['sort_mode'], 'notes' => $_POST['notes']));
     $form = DynamicForm::create(array('title' => $_POST['name'] . ' Properties'));
     if ($errors) {
         $errors['err'] = 'Unable to create custom list. Correct any error(s) below and try again.';
     } elseif (!$list->save(true)) {
         $errors['err'] = 'Unable to create custom list: Unknown internal error';
     }
     $form->set('type', 'L' . $list->get('id'));
     if (!$errors && !$form->save(true)) {
         $errors['err'] = 'Unable to create properties for custom list: Unknown internal error';
     } else {
         $msg = 'Custom list added successfully';
     }
     break;
 case 'mass_process':
     if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {