/** * Добавление контента * @param string $cat имя категории * @param int $id ID контента * @return null * @throws EngineException */ public function add($cat, $id = null) { lang::o()->get('content'); $id = (int) $id; if ($id) { $lj = $cols = ""; if ($this->tstate) { $cols = ", t.*"; $lj = " LEFT JOIN content_torrents AS t ON t.cid=c.id"; } $row = db::o()->p($id)->query('SELECT c.* ' . $cols . ' FROM content AS c ' . $lj . ' WHERE c.id=? LIMIT 1'); $row = db::o()->fetch_assoc($row); if ($row) { if ($this->tstate && $row["banned"] == 2) { throw new EngineException("content_torrent_cant_be_edited"); } $this->title .= ' "' . $row["title"] . '"'; $adder = $row['poster_id']; $cat = $row['category_id']; if (users::o()->v('id') == $adder) { users::o()->check_perms('edit_content'); } else { users::o()->check_perms('edit_content', '2'); } if ($this->tstate) { $row["screenshots"] = unserialize($row["screenshots"]); } tpl::o()->assign('nrow', $row); tpl::o()->assign('id', $id); } else { throw new EngineException('content_not_exists'); } } if ($this->tstate && !$row['screenshots']) { $row['screenshots'] = array(array(), array()); tpl::o()->assign('nrow', $row); } try { plugins::o()->pass_data(array('row' => &$row), true)->run_hook('content_add'); } catch (PReturn $e) { return $e->r(); } tpl::o()->assign('categories_selector', $this->cats->ajax_selector($cat)); tpl::o()->assign("num", 0); n('polls'); // для add_polls n('attachments'); // для add_attachments tpl::o()->display('content/add.tpl'); }