/** * allows user to add a channel through a form */ public function channel($id = null) { $this->_force_admin(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['newchannel']) { unset($_POST['id']); unset($id); } else { $postdata = $_POST; if (get_magic_quotes_gpc()) { foreach ($postdata as $k => $v) { $postdata[$k] = stripslashes($v); } } $postdata['slug'] = str_replace(' ', '-', strtolower($postdata['name'])); $postdata['create_date'] = date('Y-m-d H:i:s'); $channel = new MyChannel($postdata); $id = $channel->id; if ($_POST['targets'] != null) { $channel->_save(); MyPortalObject::save_targets($_POST['targets'], $channel->id, 'MyChannel'); echo 'Your channel has been saved.'; } else { echo 'You have selected no targets and your channel has not been saved. Did you mean to select public targeting?'; } } } if ($channel->id == null && $id == null) { $channel = new ChannelForm(); } else { if ($channel->id != null) { $id = $channel->id; } $channel = MyChannel::fetch($id); $this->tpl->assign('custom_authz', ChannelAuthZ::_has_authz($channel->slug)); $channel = MyPortalObject::fetchRow($channel->id, 'MyChannel'); $channel = array_map('stripslashes', $channel); $channel = new ChannelForm($channel); } $this->tpl->assign('channel', $channel); $this->display('admin-channel.tpl'); }