function execute(JitFilter $data)
 {
     $object_id = $data->object_id->int();
     $field = $data->field->word();
     $value = $data->value->text();
     $trklib = TikiLib::lib('trk');
     $info = $trklib->get_item_info($object_id);
     $definition = Tracker_Definition::get($info['trackerId']);
     $utilities = new Services_Tracker_Utilities();
     $utilities->updateItem($definition, array('itemId' => $object_id, 'status' => $info['status'], 'fields' => array($field => $value)));
     return true;
 }
Exemple #2
0
 function action_update_item_status($input)
 {
     if ($input->status->word() == 'DONE') {
         return array('status' => 'DONE', 'redirect' => $input->redirect->word());
     }
     $trackerId = $input->trackerId->int();
     $definition = Tracker_Definition::get($trackerId);
     if (!$definition) {
         throw new Services_Exception_NotFound();
     }
     if (!($itemId = $input->itemId->int())) {
         throw new Services_Exception_MissingValue('itemId');
     }
     $itemInfo = TikiLib::lib('trk')->get_tracker_item($itemId);
     if (!$itemInfo || $itemInfo['trackerId'] != $trackerId) {
         throw new Services_Exception_NotFound();
     }
     if (empty($input->item_label->text())) {
         $item_label = "item";
     } else {
         $item_label = $input->item_label->text();
     }
     if (empty($input->title->text())) {
         $title = "Change item status";
     } else {
         $title = $input->title->text();
     }
     if (empty($input->button_label->text())) {
         $button_label = "Update " . $item_label;
     } else {
         $button_label = $input->button_label->text();
     }
     $itemObject = Tracker_Item::fromInfo($itemInfo);
     if (!$itemObject->canModify()) {
         throw new Services_Exception_Denied();
     }
     if ($input->confirm->int()) {
         $result = $this->utilities->updateItem($definition, array('itemId' => $itemId, 'trackerId' => $trackerId, 'status' => $input->status->text()));
         return array('FORWARD' => array('controller' => 'tracker', 'action' => 'update_item_status', 'status' => 'DONE', 'redirect' => $input->redirect->text()));
     } else {
         return array('trackerId' => $trackerId, 'itemId' => $itemId, 'item_label' => $item_label, 'status' => $input->status->text(), 'redirect' => $input->redirect->text(), 'confirmation_message' => $input->confirmation_message->text(), 'title' => $title, 'button_label' => $button_label);
     }
     if (false === $result) {
         throw new Services_Exception(tr('Validation error'), 406);
     }
 }
Exemple #3
0
 function write(\Tracker\Tabular\Source\SourceInterface $source)
 {
     $schema = $source->getSchema();
     $definition = $schema->getDefinition();
     $columns = $schema->getColumns();
     $utilities = new \Services_Tracker_Utilities();
     $tx = \TikiDb::get()->begin();
     $lookup = $this->getItemIdLookup($schema);
     foreach ($source->getEntries() as $entry) {
         $info = ['itemId' => false, 'status' => '', 'fields' => []];
         foreach ($columns as $column) {
             $entry->parseInto($info, $column);
         }
         $info['itemId'] = $lookup($info);
         if ($info['itemId']) {
             $utilities->updateItem($definition, $info);
         } else {
             $utilities->insertItem($definition, $info);
         }
     }
     $tx->commit();
 }
Exemple #4
0
 private function updateItem($itemId, $metadata, $additional)
 {
     $definition = $this->getScormTracker();
     $fields = $this->buildFields($definition, $metadata, $additional);
     $utilities = new Services_Tracker_Utilities();
     $utilities->updateItem($definition, array('itemId' => (int) $itemId, 'status' => 'o', 'fields' => $fields));
 }