コード例 #1
0
ファイル: api.php プロジェクト: Kevin-ZK/vaneDisk
 /**
  * handles an api call
  * @param array $parameters
  */
 public static function call($parameters)
 {
     $request = \OC::$server->getRequest();
     $method = $request->getMethod();
     // Prepare the request variables
     if ($method === 'PUT') {
         $parameters['_put'] = $request->getParams();
     } else {
         if ($method === 'DELETE') {
             $parameters['_delete'] = $request->getParams();
         }
     }
     $name = $parameters['_route'];
     // Foreach registered action
     $responses = array();
     foreach (self::$actions[$name] as $action) {
         // Check authentication and availability
         if (!self::isAuthorised($action)) {
             $responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised'), 'shipped' => OC_App::isShipped($action['app']));
             continue;
         }
         if (!is_callable($action['action'])) {
             $responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'Api method not found'), 'shipped' => OC_App::isShipped($action['app']));
             continue;
         }
         // Run the action
         $responses[] = array('app' => $action['app'], 'response' => call_user_func($action['action'], $parameters), 'shipped' => OC_App::isShipped($action['app']));
     }
     $response = self::mergeResponses($responses);
     $format = self::requestedFormat();
     if (self::$logoutRequired) {
         OC_User::logout();
     }
     self::respond($response, $format);
 }
コード例 #2
0
ファイル: listapps.php プロジェクト: evanjt/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
         $shouldFilterShipped = true;
         $shippedFilter = $input->getOption('shipped') === 'true';
     } else {
         $shouldFilterShipped = false;
     }
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter) {
             continue;
         }
         if (\OC_App::isEnabled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
コード例 #3
0
ファイル: apps.php プロジェクト: CDN-Sparks/owncloud
 public function collect($dryRun = false)
 {
     foreach (\OC_App::getAllApps() as $appId) {
         if (\OC_App::isShipped($appId)) {
             if ($dryRun || @file_exists($this->newBase . '/' . $appId)) {
                 $this->appsToUpdate[$appId] = $appId;
             } else {
                 $this->appsToDisable[$appId] = $appId;
             }
         }
     }
 }
コード例 #4
0
ファイル: Updater.php プロジェクト: stweil/owncloud-core
 /**
  * @param string $version the oc version to check app compatibility with
  */
 protected function checkAppUpgrade($version)
 {
     $apps = \OC_App::getEnabledApps();
     $this->emit('\\OC\\Updater', 'appUpgradeCheckBefore');
     foreach ($apps as $appId) {
         $info = \OC_App::getAppInfo($appId);
         $compatible = \OC_App::isAppCompatible($version, $info);
         $isShipped = \OC_App::isShipped($appId);
         if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) {
             /**
              * FIXME: The preupdate check is performed before the database migration, otherwise database changes
              * are not possible anymore within it. - Consider this when touching the code.
              * @link https://github.com/owncloud/core/issues/10980
              * @see \OC_App::updateApp
              */
             if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
                 $this->includePreUpdate($appId);
             }
             if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
                 $this->emit('\\OC\\Updater', 'appSimulateUpdate', array($appId));
                 \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
             }
         }
     }
     $this->emit('\\OC\\Updater', 'appUpgradeCheck');
 }
コード例 #5
0
ファイル: app.php プロジェクト: hjimmy/owncloud
 /**
  * @brief disables an app
  * @param string $app app
  * @return bool
  *
  * This function set an app as disabled in appconfig.
  */
 public static function disable($app)
 {
     self::$enabledAppsCache = array();
     // flush
     // check if app is a shipped app or not. if not delete
     \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
     OC_Appconfig::setValue($app, 'enabled', 'no');
     // check if app is a shipped app or not. if not delete
     if (!OC_App::isShipped($app)) {
         OC_Installer::removeApp($app);
     }
 }
コード例 #6
0
ファイル: updateapp.php プロジェクト: WYSAC/oregon-owncloud
/**
 * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();
if (!array_key_exists('appid', $_POST)) {
    OCP\JSON::error(array('message' => 'No AppId given!'));
    exit;
}
$appId = $_POST['appid'];
if (!is_numeric($appId)) {
    $appId = OC_Appconfig::getValue($appId, 'ocsid', null);
    $isShipped = OC_App::isShipped($appId);
    if ($appId === null) {
        OCP\JSON::error(array('message' => 'No OCS-ID found for app!'));
        exit;
    }
} else {
    $isShipped = false;
}
$appId = OC_App::cleanAppId($appId);
\OC_Config::setValue('maintenance', true);
$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
\OC_Config::setValue('maintenance', false);
if ($result !== false) {
    OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
    $l = OC_L10N::get('settings');
コード例 #7
0
ファイル: api.php プロジェクト: CDN-Sparks/owncloud
 /**
  * merge the returned result objects into one response
  * @param array $responses
  */
 private static function mergeResponses($responses)
 {
     $response = array();
     // Sort into shipped and thirdparty
     $shipped = array('succeeded' => array(), 'failed' => array());
     $thirdparty = array('succeeded' => array(), 'failed' => array());
     foreach ($responses as $response) {
         if (OC_App::isShipped($response['app']) || $response['app'] === 'core') {
             if ($response['response']->succeeded()) {
                 $shipped['succeeded'][$response['app']] = $response['response'];
             } else {
                 $shipped['failed'][$response['app']] = $response['response'];
             }
         } else {
             if ($response['response']->succeeded()) {
                 $thirdparty['succeeded'][$response['app']] = $response['response'];
             } else {
                 $thirdparty['failed'][$response['app']] = $response['response'];
             }
         }
     }
     // Remove any error responses if there is one shipped response that succeeded
     if (!empty($shipped['succeeded'])) {
         $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
     } else {
         if (!empty($shipped['failed'])) {
             // Which shipped response do we use if they all failed?
             // They may have failed for different reasons (different status codes)
             // Which reponse code should we return?
             // Maybe any that are not OC_API::RESPOND_SERVER_ERROR
             $response = reset($shipped['failed']);
             return $response;
         } elseif (!empty($thirdparty['failed'])) {
             // Return the third party failure result
             $response = reset($thirdparty['failed']);
             return $response;
         } else {
             $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
         }
     }
     // Merge the successful responses
     $meta = array();
     $data = array();
     foreach ($responses as $app => $response) {
         if (OC_App::isShipped($app)) {
             $data = array_merge_recursive($response->getData(), $data);
         } else {
             $data = array_merge_recursive($data, $response->getData());
         }
     }
     $result = new OC_OCS_Result($data, 100);
     return $result;
 }
コード例 #8
0
ファイル: api.php プロジェクト: omusico/isle-web-framework
 /**
  * handles an api call
  * @param array $parameters
  */
 public static function call($parameters)
 {
     // Prepare the request variables
     if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         parse_str(file_get_contents("php://input"), $parameters['_put']);
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
             parse_str(file_get_contents("php://input"), $parameters['_delete']);
         }
     }
     $name = $parameters['_route'];
     // Foreach registered action
     $responses = array();
     foreach (self::$actions[$name] as $action) {
         // Check authentication and availability
         if (!self::isAuthorised($action)) {
             $responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, OC_API::RESPOND_UNAUTHORISED, 'Unauthorised'), 'shipped' => OC_App::isShipped($action['app']));
             continue;
         }
         if (!is_callable($action['action'])) {
             $responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, OC_API::RESPOND_NOT_FOUND, 'Api method not found'), 'shipped' => OC_App::isShipped($action['app']));
             continue;
         }
         // Run the action
         $responses[] = array('app' => $action['app'], 'response' => call_user_func($action['action'], $parameters), 'shipped' => OC_App::isShipped($action['app']));
     }
     $response = self::mergeResponses($responses);
     $formats = array('json', 'xml');
     $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml';
     if (self::$logoutRequired) {
         OC_User::logout();
     }
     self::respond($response, $format);
 }