Exemplo n.º 1
0
    /**
     * 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;
    }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
    /**
     * 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;
    }