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;
     }
 }