public function addmedia($parameter) { $media_type = $parameter[0]; $this->data['media_type'] = $media_type; $this->data['album_categories'] = $this->category_model->get(array('category_slug' => 'album')); $category = $this->category_model->getColRow('category_title', $media_type); $this->data['title'] = 'Add ' . ucfirst($media_type); if (isset($_POST['title']) && !empty($_POST['title'])) { $title = $_POST['title']; $artist = $_POST['artist']; $description = $_POST['description']; $youtubelink = $_POST['youtubelink']; $category_id = $_POST['category']; // $status_id = $status->status_id; $slug = \helpers\url::generateSafeSlug($title); if (isset($youtubelink) && $youtubelink != '') { $exp = explode('=', $youtubelink); if (count($exp) > 1) { $youtubelink = $exp[1]; } } $insert_array = array('album_item_album_id' => \helpers\session::get('user')->user_album_id, 'album_item_category_id' => $category->category_id, 'album_item_user_id' => \helpers\session::get('user')->user_id, 'album_item_title' => $title, 'album_item_artist' => $artist, 'album_item_description' => $description, 'album_item_youtubelink' => $youtubelink, 'album_item_created' => time(), 'album_item_alias' => $slug); $insert_array = \helpers\gump::xss_clean($insert_array); $insert_array = \helpers\gump::sanitize($insert_array); $insert_id = $this->albumitem_model->create($insert_array); if ($insert_id > 0) { $message = 'ok'; } else { $message = 'no'; } //check if item is a video // $category_type = $this->category_model->find($_POST['category']); if ($media_type == 'video' && isset($youtubelink) && $youtubelink != '') { $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/maxresdefault.jpg"; if (!file_exists($youtube_url)) { $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/hqdefault.jpg"; } //resize youtube image into uploads folder \helpers\upload::setName(time()); \helpers\upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px'); $image_name = \helpers\upload::getFileName('images'); $update_data = array('album_item_file' => $image_name); $where_array = array('album_item_id' => $insert_id); $this->albumitem_model->update($update_data, $where_array); } //UPLOAD ATTACHMENT if ($_FILES["image"]["tmp_name"] != '') { //upload image into uploads folder \helpers\upload::setName(uniqid()); \helpers\upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px'); $image_name = \helpers\upload::getFileName('images'); $update_data = array('album_item_file' => $image_name); $where_array = array('album_item_id' => $insert_id); $this->albumitem_model->update($update_data, $where_array); } } if ($message == 'ok') { \helpers\session::set('success', 'record edited'); $url = 'user/' . $media_type; \helpers\url::redirect($url); } else { if ($message == 'no') { $this->data['error'] = 'Operation Fails!'; } } View::rendertemplate('header', $this->data); View::rendertemplate('mobile-menu', $this->data); View::render('user/user.media', $this->data); View::rendertemplate('footer', $this->data); }
public function edit($param) { $edit_id = $param[0]; $this->data['title'] = 'Edit Settings'; if (isset($_POST) && !empty($_POST)) { $title = $_POST['title']; $value = $_POST['value']; $slug = \helpers\url::generateSafeSlug($title); $update_array = array('site_preference' => $title, 'site_value' => $value); // $update_id = $settings->update($update_array,array('id'=>$edit_id)); $update_id = $this->site_model->updateId($update_array, $edit_id); if ($update_id > 0) { $this->data['success'] = 'Record Updated!'; } else { ${$this}->data['error'] = 'Operation Fails!'; } if ($_FILES["image"]["tmp_name"] != '') { //upload image into uploads folder \helpers\upload::setName(time()); \helpers\upload::upload_file($_FILES["image"], UPLOAD_PATH); $image_name = \helpers\upload::getFileName('images'); $update_data = array('site_file' => $image_name); $update_id = $this->site_model->updateId($update_data, $edit_id); if ($update_id > 0) { $this->data['success'] = 'Record Updated!'; } else { ${$this}->data['error'] = 'Operation Fails!'; } } } $this->data['site_data'] = $this->site_model->find($edit_id); $this->data['settings'] = $this->site_model->all(); View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('settings/settings.index', $this->data); View::rendertemplate('footer', $this->data); }