/** * Load all available techniques. * * @return \self */ public static function loadList() { $sql = ' SELECT `techniqueId` FROM techniques WHERE !deleted ORDER BY `name` '; $techniqueIds = query($sql, true); $obj = new self(); if (empty($techniqueIds)) { return $obj; } $list = array(); foreach ($techniqueIds as $technique) { $list[$technique['techniqueId']] = \Model\Technique::loadById($technique['techniqueId']); } $obj->setList($list); return $obj; }
/** * Create or edit an item type. * * @param integer|string $id The id of the item type entry. May be a string * if a new item type is created. Otherwise it's * an integer. * @param array $data The data for the item type. * * @return void */ protected function editItem($id, $data) { if ($id == 'new') { $response = array('ok' => \Model\Technique::create($data)); } else { $technique = \Model\Technique::loadById($id); $response = array('ok' => $technique->update($data), 'data' => $technique->getAsArray()); } $this->echoAjaxResponse($response); }
/** * Load the techniques for the blueprint. * * @return void */ public function loadTechniques() { $sql = ' SELECT `techniqueId` FROM techniquesToBlueprints WHERE `blueprintId` = ' . \sqlval($this->blueprintId) . ' AND !deleted '; $techniqueIds = query($sql, true); $list = array(); if (!empty($techniqueIds)) { foreach ($techniqueIds as $technique) { $list[$technique['techniqueId']] = \Model\Technique::loadById($technique['techniqueId']); } } $this->techniqueList = $list; }