/** * Authorizes the user. */ public function authAction() { $onedrive = $this->getModel(); if (!isset($_GET['onedrive'])) { return $this->getView()->getContent('onedrive.auth', array('url' => $onedrive->getAuthorizationUrl())); } if (!$onedrive->isAuthenticated()) { if (!$onedrive->authorize($_GET['onedrive'])) { return $this->getView()->getContent('onedrive.authError', array('errors' => $onedrive->getErrors())); } $request = reqBup::get('get'); $uri = null; if (is_array($request)) { $uri = array(); foreach ($request as $key => $value) { if ($key != 'onedrive') { $uri[] = $key . '=' . $value; } } $uri = 'admin.php?' . join('&', $uri); } $redirectURI = !empty($uri) ? $uri : 'admin.php?page=' . BUP_PLUGIN_PAGE_URL_SUFFIX; redirectBup(admin_url($redirectURI)); } }
public function ajaxExec($forceAjax = false) { $reqType = reqBup::getVar('reqType'); $redirect = reqBup::getVar('redirect'); if (count($this->errors) > 0) { $this->error = true; } if ($reqType == 'ajax' || $forceAjax) { exit(json_encode($this)); } if ($redirect) { redirectBup($redirect); } return $this; }
public function getRootObjects() { if ($this->isAuthenticated() === false) { return false; } $client = $this->getClient(); $service = new Google_DriveService($client); $token = null; $list = array(); $cDomain = $this->_getCurrentDomain(); $config = array('q' => 'mimeType = "application/vnd.google-apps.folder" or title = "' . $this->_folderName . '" or title = "' . $cDomain . '"'); do { if (!empty($token)) { $config['pageToken'] = $token; } try { $files = $service->files->listFiles($config); } catch (Exception $e) { $this->resetCredentials(); redirectBup($this->authenticate()); } $list = array_merge($list, $files['items']); $token = null; if (isset($files['nextPageToken'])) { $token = $files['nextPageToken']; } } while ($token); return $list; }
/** * Authenticate Action * * @since 1.0 */ public function authenticateAction($errors = array()) { $request = reqBup::get('get'); if (BUP_PLUGIN_PAGE_URL_SUFFIX !== $request['page']) { return; } if (!isset($request['dropboxToken'])) { $url = 'http://supsystic.com/authenticator/index.php/authenticator/dropbox'; $slug = frameBup::_()->getModule('adminmenu')->getView()->getFile(); $queryString = !empty($_SERVER['QUERY_STRING']) ? 'admin.php?' . $_SERVER['QUERY_STRING'] : ''; $redirectURI = !empty($queryString) ? $queryString : 'admin.php?page=' . $slug; if (!empty($errors) && !is_array($errors)) { $errors = array($errors); } return $this->render('auth', array('authUrl' => $url . '?ref=' . base64_encode(admin_url($redirectURI)), 'errors' => $errors)); } else { $authResult = $this->model->authenticate($request['dropboxToken']); if ($authResult === false) { return $this->model->getErrors(); } else { $uri = null; if (is_array($request)) { $uri = array(); foreach ($request as $key => $value) { if ($key != 'dropboxToken') { $uri[] = $key . '=' . $value; } } $uri = 'admin.php?' . join('&', $uri); } $redirectURI = !empty($uri) ? $uri : 'admin.php?page=' . BUP_PLUGIN_PAGE_URL_SUFFIX; redirectBup(admin_url($redirectURI)); } } }