Exemplo n.º 1
0
 public function indexAction()
 {
     if (!WM_Users::allow('edit', 'modules')) {
         JO_Session::set('error_permision', $this->translate('You do not have permission to this action'));
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth/');
     }
     $request = $this->getRequest();
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if ($request->isPost()) {
         //validate app id
         $validate = new Helper_Modules_Instagram($request->getPost('instagram[instagram_oauth_key]'), $request->getPost('instagram[instagram_oauth_secret]'));
         if ($validate->checkValidAppId()) {
             Model_Settings::updateAll(array('instagram' => $request->getPost('instagram')));
             JO_Session::set('successfu_edite', true);
             $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_instagram/');
         } else {
             $this->view->error = $this->translate('Invalid appID');
         }
     }
     $this->view->modules_url = $this->getRequest()->getModule() . '/modules';
     $this->view->modules_oauth_url = $this->getRequest()->getModule() . '/modules_oauth';
     $methods = $this->getClassResources();
     $this->view->methods = array();
     $ignore = array('index', 'error404', 'install', 'uninstall');
     foreach ($methods as $type => $mods) {
         foreach ($mods as $key => $value) {
             if (in_array($value, $ignore)) {
                 continue;
             }
             if ($type == 'actions') {
                 $this->view->methods[$type][] = array('title' => $this->translate($value), 'edit' => $this->getRequest()->getModule() . '/modules_oauth_instagram/' . strtolower($value));
             } elseif ($type == 'radio') {
                 $this->view->methods[$type][] = array('title' => $this->translate(str_replace('_', ' ', $value)), 'key' => 'instagram_' . strtolower($value));
             }
         }
     }
     $store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'instagram'));
     foreach ($store_config as $key => $data) {
         $this->view->{$key} = $data;
     }
 }
Exemplo n.º 2
0
 private function initInstagram(&$instagramoauth)
 {
     if ($this->user_data) {
         return true;
     }
     $instagramoauth = new Helper_Modules_Instagram();
     $InstagramAccessToken = $instagramoauth->getAccessToken();
     $user_data = JO_Json::decode($instagramoauth->getUser(), true);
     if (isset($user_data['meta']['code']) && $user_data['meta']['code'] == 200) {
         JO_Session::set('InstagramAccessToken', $InstagramAccessToken);
         $this->user_data = $user_data['data'];
     } elseif ($InstagramAccessToken) {
         JO_Session::set('InstagramAccessToken', $InstagramAccessToken);
         $instagramoauth->setAccessToken($InstagramAccessToken);
     } elseif (JO_Session::get('InstagramAccessToken')) {
         $instagramoauth->setAccessToken(JO_Session::get('InstagramAccessToken'));
     }
     if (!$this->user_data) {
         $user_data = JO_Json::decode($instagramoauth->getUser(), true);
         if (isset($user_data['meta']['code']) && $user_data['meta']['code'] == 200) {
             $this->user_data = $user_data['data'];
         }
     }
     return $this->user_data ? true : false;
 }