/** * Then user click on 'edit' in the schedule list - we need to load some of forms * Let's load form from created early scripts (create pages) * * @access public * * @param $social_post * * @return string * @internal param $category_id */ private function _get_edit_post_form($social_post) { $post = new Social_post($social_post->id); $isMedia = $post->isMediaPost(); $this->load->helper('MY_url_helper'); $this->load->helper('Image_designer_helper'); $this->load->config('timezones'); $block_data = Access_token::inst()->check_socials_access($this->c_user->id); $block_data['social_post'] = $social_post; $block_data['isMedia'] = $isMedia; $block_data['isSupportScheduledPosts'] = $this->isSupportScheduledPosts; $block_data['is_user_set_timezone'] = User_timezone::is_user_set_timezone($this->c_user->id); $socials = array('twitter' => 'twitter', 'facebook' => 'facebook', 'linkedin' => 'linkedin'); foreach ($socials as $social) { if (!Social_group::hasSocialAccountByType($this->profile->id, $social)) { unset($socials[$social]); } } $block_data['socials'] = $socials; $block_data['imageDesignerImages'] = Image_designer::getImages(); $html = $this->template->block('_edit_form', 'social/create/blocks/_post_update', $block_data); return $html; }
private function _validate_video($feeds) { $errors = array(); if (empty($feeds['image_name'])) { $errors['image_name'] = lang('video_error'); } if (isset($feeds['title'])) { if (empty($feeds['title'])) { $errors['title'] = lang('video_title_error'); } } else { $errors['title'] = lang('video_title_error'); } $youtube_token = Access_token::inst()->get_youtube_token($feeds['user_id']); foreach ($feeds['post_to_groups'] as $group_id) { if (Social_group::hasSocialAccountByType($group_id, 'twitter') || Social_group::hasSocialAccountByType($group_id, 'linkedin')) { if (!$youtube_token->exists()) { $errors['post_to_groups[]'] = lang('youtube_error'); break; } } } return $errors; }
/** * Used to get access url from Google (Youtube and Google have same OAUTH system) * Use Socializer Library * After - redirect to access url * * @access public * @return void */ public function google() { try { if (Social_group::hasSocialAccountByType($this->profile->id, 'google')) { $this->addFlash(lang('already_has_account_error', ['Google']), 'error'); redirect('settings/socialmedia'); } $this->load->library('Socializer/socializer'); /* @var Socializer_Google $google_socializer */ $google_socializer = Socializer::factory('Google', $this->c_user->id); $redirect_uri = $google_socializer->get_access_url(); redirect($redirect_uri); } catch (Exception $e) { $this->addFlash($e->getMessage()); redirect('settings/socialmedia'); } }