Ejemplo n.º 1
0
 /**
  * Edit Role
  */
 public function edit($id)
 {
     $data['js'] = array(Url::assetPath('js') . 'plugins/forms/selects/select2.min.js', Url::assetPath('js') . 'plugins/forms/validation/validate.min.js', Url::assetPath('js') . 'plugins/notifications/bootbox.min.js', Url::assetPath('js') . 'pages/roles_add.js');
     $data['role'] = $this->role->getRole($id);
     $data['rolesL18n'] = $this->role->getRoleL18n($id);
     if (isset($_POST['update'])) {
         $name = $_POST['name'];
         $name = strtoupper(Url::generateSafeSlug($name, ''));
         $display_name = $_POST['display_name'];
         $description = $_POST['description'];
         $unique = $this->role->isNameUnique($name, $id);
         if ($name == '') {
             $error[] = $this->language->get('required');
         }
         if ($display_name == '') {
             $error[] = $this->language->get('required');
         }
         if (!empty($unique)) {
             $error[] = $this->language->get('unique_name_required');
         }
         if (!$error) {
             $data = array('name' => $name);
             $where = array('id' => $id);
             $this->role->updateRole($data, $where);
             $data_l18n = array('role_id' => $id, 'language_id' => Session::get('language_id'), 'display_name' => $display_name, 'description' => $description);
             $this->role->updateRoleL18n($data_l18n);
             $languageL18n = L18n::getLanguagesForL18n();
             if (!empty($languageL18n)) {
                 foreach ($languageL18n as $language) {
                     $display_name_l18n = $_POST['display_name_' . $language->code];
                     $description_l18n = $_POST['description_' . $language->code];
                     $data_l18n = array('role_id' => $id, 'language_id' => $language->id, 'display_name' => $display_name_l18n, 'description' => $description_l18n);
                     $this->role->updateRoleL18n($data_l18n);
                 }
             }
             Session::set('success', $this->language->get('msg_role_edit'));
             Log::notice('log_role_edit', 'id: ' . $id . ', name: ' . $name . ', display_name: ' . $display_name);
             Url::redirect('roles');
         }
     }
     if (isset($_POST['cancel'])) {
         Url::redirect('roles');
     }
     if (isset($_POST['delete'])) {
         Url::redirect('roles/delete/' . $id . '');
     }
     View::renderTemplate('header', $data);
     View::render('roles/edit', $data, $error);
     View::renderTemplate('footer', $data);
 }
Ejemplo n.º 2
0
 public function edit($param)
 {
     $song_id = $param[0];
     $songModel = new \Models\Song();
     $this->data['title'] = 'Edit Song';
     $this->data['albums'] = $this->albumModel->all();
     $this->data['artist'] = User::artist();
     $this->data['genre'] = $this->categoryModel->get(array('category_slug' => 'genre'));
     $this->data['tags'] = $this->categoryModel->get(array('category_slug' => 'tag'));
     $this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
     if (isset($_POST) && !empty($_POST)) {
         $songArray = array('song_album_id' => $_POST['album_id'], 'song_user_id' => Session::get('user_id'), 'song_artist_id' => $_POST['artist_id'], 'song_genre_id' => $_POST['genre_id'], 'song_status_id' => $_POST['status_id'], 'song_title' => $_POST['title'], 'song_description' => $_POST['description'], 'song_modified' => time(), 'song_slug' => Url::generateSafeSlug($_POST['title']));
         $songArray = Gump::xss_clean($songArray);
         $songArray = Gump::sanitize($songArray);
         $update = $songModel->updateId($songArray, $song_id);
         if ($update > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
         if ($_FILES["mp3"]["tmp_name"] != '') {
             //resize youtube image into uploads folder
             Upload::setName(time());
             Upload::upload_file($_FILES["mp3"], UPLOAD_PATH);
             $filepath = UPLOAD_PATH . Upload::getName();
             $outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName();
             //check bitrate
             $bitRate = Audio::bitRateSampleRate($filepath, 'bitrate');
             $duration = Audio::duration($filepath);
             if ($bitRate > 128) {
                 $convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3);
             }
             if (is_file($outputMp3)) {
                 $updateArray = array('song_file' => 'images/encoded_' . Upload::getName(), 'song_duration' => $duration);
                 unlink($filepath);
             } else {
                 $updateArray = array('song_file' => Upload::getFileName('images'), 'song_duration' => $duration);
             }
             $saveMp3 = $songModel->updateId($updateArray, $song_id);
         }
         //UPLOAD SONG COVER
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload file into uploads folder
             Upload::setName(time());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('song_image' => Upload::getFileName('images'));
             $songModel->updateId($update_data, $song_id);
         }
     }
     if ($message == 'ok') {
         Session::set('success', 'record edited');
         Url::redirect('song/item/' . $_POST['album_id']);
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['song'] = \Models\Song::item($song_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('song/song.edit', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 3
0
 public function add()
 {
     $user_model = new User();
     $album_model = new Album();
     $role_model = new Role();
     $status_model = new Status();
     $this->data['title'] = 'Add Artist';
     if (isset($_POST) && !empty($_POST)) {
         $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_status_id' => Status::id('active'), 'user_role_id' => Role::id('artist'), 'user_created' => time());
         $artistArray = Gump::xss_clean($artistArray);
         $artistArray = Gump::sanitize($artistArray);
         $artist_id = $user_model->create($artistArray);
         if ($artist_id > 0) {
             $this->data['success'] = 'Artist Added!';
             $slug = Url::generateSafeSlug($_POST['stagename'] . $artist_id);
             $user_model->updateId(array('user_slug' => $slug), $artist_id);
         } else {
             $this->data['error'] = 'Operation Fails!';
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             Upload::setName($slug . uniqid());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('user_image' => Upload::getFileName('images'));
             $this->user_model->updateId($update_data, $artist_id);
         }
         //GET INSERTED ID
         $this->data['user_data'] = $user_model->find($insert_id);
         Url::redirect('artist');
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('artist/artist.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 4
0
 public function edit($param)
 {
     $edit_id = $param[0];
     $action = $_GET['action'];
     $this->data['album_group'] = $this->albumModel->all();
     $this->data['title'] = 'Edit Page';
     if (isset($_POST) && !empty($_POST)) {
         $pagename = $_POST['pagename'];
         $category = $_POST['category'];
         $sort_order = $_POST['sort_order'];
         $slug = Url::generateSafeSlug($pagename);
         $update_array = array('page_name' => $pagename, 'page_category_id' => $category, 'page_sort_order' => $sort_order, 'page_alias' => $slug);
         $where_array = array('page_id' => $edit_id);
         $update_id = $this->pageModel->update($update_array, $where_array);
         if ($update_id > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
     }
     if ($message == 'ok') {
         $this->data['success'] = 'Operation Successful!';
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['pages'] = $this->pageModel->allPages();
     $this->data['page_data'] = $this->pageModel->detail($edit_id);
     $this->data['page_categories'] = $this->categoryModel->page();
     $this->data['parent_page'] = $this->pageModel->parent_page();
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('pages/page.edit', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 5
0
 public function editprofile()
 {
     $this->data['title'] = 'Edit Profile';
     $user_model = new \Models\User();
     $this->data['user'] = Session::get('user');
     $this->data['user'] = $user_model->find(Session::get('user')->user_id);
     if (isset($_POST['user_firstname']) && !empty($_POST['user_firstname'])) {
         if (count($_POST['dance_category']) > 3) {
             $this->data['error'] = 'Dance category cannot exceed 3, Please correct';
         } else {
             $user_firstname = $_POST['user_firstname'];
             $user_lastname = $_POST['user_lastname'];
             $user_email = $_POST['user_email'];
             $user_phone = $_POST['user_phone'];
             $user_gender = $_POST['user_gender'];
             $user_bio = $_POST['user_bio'];
             $dance_category = $_POST['dance_category'];
             $user_slug = Url::generateSafeSlug($user_firstname . $this->data['user']->user_id . $user_lastname);
             //delete all user's dancer's category first
             $delete = $userdance_model->delete(array('user_dance_user_id' => $this->data['user']->user_id), 5);
             //insert dance category
             if (count($_POST['dance_category']) > 0) {
                 foreach ($dance_category as $value) {
                     $dance_category_count = 0;
                     $insert_dance_category = $userdance_model->create(array('user_dance_user_id' => $this->data['user']->user_id, 'user_dance_category_id' => $value));
                     $dance_category_count++;
                 }
             }
             //update user db
             $update_array = array('user_firstname' => $user_firstname, 'user_lastname' => $user_lastname, 'user_email' => $user_email, 'user_bio' => $user_bio, 'user_gender' => $user_gender, 'user_slug' => $user_slug, 'user_phone' => $user_phone);
             $update_array = Gump::xss_clean($update_array);
             $update_array = Gump::sanitize($update_array);
             $update_id = $user_model->updateId($update_array, $this->data['user']->user_id);
             //UPLOAD ATTACHMENT
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload image into uploads folder
                 Upload::setName($slug . uniqid());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
                 $image_name = Upload::getFileName('images');
                 $update_data = array('user_image' => $image_name);
                 $update_img = $this->user_model->updateId($update_data, $this->data['user']->user_id);
                 if ($update_img > 0) {
                     Session::set('success', 'Profile Updated!');
                     Url::redirect('user');
                 } else {
                     $this->data['error'] = 'Operation Fails!';
                 }
             }
             if ($update_id > 0) {
                 Session::set('success', 'Profile Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
             if (isset($dance_category_count) && $dance_category_count > 0) {
                 Session::set('success', 'Dance Category Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
         }
     }
     $this->data['dance_category'] = \models\category::section('dance');
     $user_dance_category = \models\userdance::category($this->data['user']->user_id);
     foreach ($user_dance_category as $item) {
         $this->data['user_dance_category'][] = $item->category_id;
     }
     View::rendertemplate('header', $this->data);
     View::render('workspace/workspace.editprofile', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 6
0
 public function edit($parameter)
 {
     $item_id = $parameter[0];
     $this->data['title'] = 'Edit Post';
     $category_model = new \Models\Category();
     $post_model = new \Models\Post();
     $album_model = new \models\album();
     $this->data['post'] = $post_model->getItem($item_id);
     $this->data['album_group'] = $album_model->all();
     $this->data['post_category_groups'] = $category_model->groupByCol('category_slug');
     if (isset($_POST) && !empty($_POST)) {
         $post_category_id = $_POST['post_category_id'];
         $post_album_id = $_POST['post_album_id'];
         $post_title = $_POST['post_title'];
         $post_body = $_POST['post_body'];
         $post_link = $_POST['post_link'];
         $post_excerpt = $_POST['post_excerpt'];
         $post_slug = Url::generateSafeSlug($post_title);
         $post_modified = time();
         $update_array = array('post_category_id' => $post_category_id, 'post_album_id' => $post_album_id, 'post_title' => $post_title, 'post_body' => $post_body, 'post_link' => $post_link, 'post_excerpt' => $post_excerpt, 'post_slug' => $post_slug, 'post_modified' => $post_modified);
         $update_array = Gump::xss_clean($update_array);
         $update_array = Gump::sanitize($update_array);
         $update_id = $post_model->updateId($update_array, $item_id);
         //UPLOAD IMAGE
         if ($_FILES["image"]["tmp_name"] != '') {
             Upload::setName(uniqid());
             Upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $image_name = Upload::getFileName('images');
             $update_data = array('post_image' => $image_name);
             $update = $post_model->updateId($update_data, $update_id);
         }
         if ($update_id > 0) {
             Session::set('success', 'post edited');
             Url::redirect('post');
         }
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('post/post.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 7
0
 public function edit($param)
 {
     $media_id = $param[0];
     //get album detail
     $albumitem_detail = $this->mediaModel->find($media_id);
     $this->data['title'] = 'Edit Item';
     $this->data['album_categories'] = $this->categoryModel->get(array('category_slug' => 'album'));
     $this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
     if (isset($_POST) && !empty($_POST)) {
         $slug = Url::generateSafeSlug($_POST['title']);
         $mediaArray = array('media_category_id' => $_POST['category'], 'media_user_id' => Session::get('user_id'), 'media_title' => $_POST['title'], 'media_description' => $_POST['description'], 'media_youtubelink' => $_POST['youtubelink'], 'media_slug' => $slug, 'media_modified' => time());
         $update = $this->mediaModel->updateId($mediaArray, $media_id);
         if ($update > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
         //check if item is a video
         $category_type = $this->categoryModel->find($_POST['category']);
         if ($category_type->category_title == 'video' && isset($_POST['youtubelink']) && $_POST['youtubelink'] != '') {
             //item is a video
             $youtube_url = "https://i.ytimg.com/vi/" . $_POST['youtubelink'] . "/maxresdefault.jpg";
             if (!file_exists($youtube_url)) {
                 $youtube_url = "https://i.ytimg.com/vi/" . $_POST['youtubelink'] . "/hqdefault.jpg";
             }
             //resize youtube image into uploads folder
             Upload::setName(time());
             Upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px');
             $update_data = array('media_file' => Upload::getFileName('images'));
             $this->mediaModel->updateId($update_data, $media_id);
         }
         if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'audio') {
             //resize youtube image into uploads folder
             Upload::setName(time());
             Upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $filepath = UPLOAD_PATH . Upload::getName();
             $outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName();
             //check bitrate
             $bitRate = Audio::bitRateSampleRate($filepath, 'bitrate');
             if ($bitRate > 128) {
                 $convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3);
             }
             if (is_file($outputMp3)) {
                 $updateArray = array('media_file' => 'images/encoded_' . Upload::getName());
                 unlink($filepath);
             } else {
                 $updateArray = array('media_file' => Upload::getFileName('images'));
             }
             $saveMp3 = $this->mediaModel->updateId($updateArray, $media_id);
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'image') {
             //upload image into uploads folder
             Upload::setName(time());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
             $update_data = array('media_file' => Upload::getFileName('images'));
             $update_img = $this->mediaModel->updateId($update_data, $media_id);
             if ($update_img > 0) {
                 Session::set('success', 'record edited');
                 Url::redirect('album/media/' . $albumitem_detail->media_album_id);
             } else {
                 if ($message == 'no') {
                     $this->data['error'] = 'Operation Fails!';
                 }
             }
         }
     }
     if ($message == 'ok') {
         Session::set('success', 'record edited');
         Url::redirect('album/media/' . $albumitem_detail->media_album_id);
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['media'] = Media::row('media_id', $media_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('album/album.edit_item', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 8
0
 public function signup($slug = null)
 {
     $this->data['title'] = 'Join Us';
     $statusModel = new Status();
     $roleModel = new Role();
     $userModel = new User();
     if (isset($_POST['email']) && !empty($_POST['email'])) {
         $firstname = $_POST['firstname'];
         $email = $_POST['email'];
         if ($_POST['password'] == $_POST['password2']) {
             $encrypted = md5($_POST['password']);
             $row_count = $userModel->getColRow('user_email', $email);
             if (!is_bool($row_count)) {
                 Session::set('error', 'Email exists in our records, please use a different email');
             } else {
                 $userArray = array('user_firstname' => $firstname, 'user_email' => $email, 'user_password' => $encrypted, 'user_role_id' => Role::id('user'), 'user_status_id' => Status::id('active'));
                 $userArray = Gump::xss_clean($userArray);
                 $userArray = Gump::sanitize($userArray);
                 $is_valid = Gump::is_valid($userArray, array('user_firstname' => 'required|max_len,200|min_len,1', 'user_email' => 'required|max_len,200|min_len,1', 'user_password' => 'required|max_len,200|min_len,1'));
                 if ($is_valid === true) {
                     $user_id = $userModel->create($userArray);
                     if ($user_id > 0) {
                         $slug = Url::generateSafeSlug($firstname . $user_id);
                         //send email
                         $subject = 'Welcome to GbeduMobile';
                         $content .= "You just opened a new account with us, Get login details below<br><br>";
                         $content .= "Username: "******"<br>";
                         $content .= "Password: "******"<br>";
                         if (ENVIRONMENT == 'production') {
                             $mail = new Mail();
                             $mail->general($email, $subject, $firstname, $content);
                         }
                         Session::set('success', 'Login details has been sent to your email, Congrats!');
                         Url::redirect('home');
                     } else {
                         Session::set('error', 'Operation Fails, Please contact admin');
                     }
                 } else {
                     Session::set('error', $is_valid);
                 }
             }
         } else {
             Session::set('error', 'Password does not match!');
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('account/signup', $this->data);
     View::rendertemplate('footer', $this->data);
 }