当前位置: 首页>>代码示例>>PHP>>正文


PHP JSON::error方法代码示例

本文整理汇总了PHP中OCP\JSON::error方法的典型用法代码示例。如果您正苦于以下问题:PHP JSON::error方法的具体用法?PHP JSON::error怎么用?PHP JSON::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\JSON的用法示例。


在下文中一共展示了JSON::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Returns the rendered json
  * @return the rendered json
  */
 public function render()
 {
     parent::render();
     ob_start();
     if ($this->error) {
         \OCP\JSON::error($this->data);
     } else {
         \OCP\JSON::success($this->data);
     }
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
开发者ID:nanowish,项目名称:apps,代码行数:17,代码来源:json.response.php

示例2: rename

 public static function rename($args)
 {
     self::preDispatch();
     $fileId = intval(Helper::getArrayValueByKey($args, 'file_id', 0));
     $name = Helper::getArrayValueByKey($_POST, 'name');
     $view = \OC\Files\Filesystem::getView();
     $path = $view->getPath($fileId);
     if (isset($name) && $view->is_file($path) && $view->isUpdatable($path)) {
         $newPath = dirname($path) . '/' . $name;
         if ($view->rename($path, $newPath)) {
             \OCP\JSON::success();
             return;
         }
     }
     \OCP\JSON::error(array('message' => Config::getL10n()->t('You don\'t have permission to rename this document')));
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:16,代码来源:documentController.php

示例3: postlogin_hook

 /**
  * Send JSON response on successful login
  * @param String $uid
  */
 public static function postlogin_hook($uid)
 {
     if (!self::$_isPersona) {
         return;
     }
     \OCP\Util::writeLog(App::APP_ID, 'Check ambigous ', \OCP\Util::DEBUG);
     if (self::$_isAmbigous) {
         //Reply with error and logout
         \OCP\User::logout();
         \OCP\JSON::error(array('msg' => 'More than one user found'));
         exit;
     } else {
         \OCP\JSON::success(array('msg' => 'Access granted'));
         exit;
     }
 }
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:20,代码来源:validator.php

示例4: setupFromToken

 /**
  * Sets up the filesystem and user for public sharing
  * @param string $token string share token
  * @param string $relativePath optional path relative to the share
  * @param string $password optional password
  */
 public static function setupFromToken($token, $relativePath = null, $password = null)
 {
     \OC_User::setIncognitoMode(true);
     $linkItem = \OCP\Share::getShareByToken($token, !$password);
     if ($linkItem === false || $linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder') {
         \OC_Response::setStatus(404);
         \OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
         exit;
     }
     if (!isset($linkItem['uid_owner']) || !isset($linkItem['file_source'])) {
         \OC_Response::setStatus(500);
         \OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
         exit;
     }
     $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
     $path = null;
     if (isset($rootLinkItem['uid_owner'])) {
         \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
         $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
     }
     if ($path === null) {
         \OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (!isset($linkItem['item_type'])) {
         \OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (isset($linkItem['share_with'])) {
         if (!self::authenticate($linkItem, $password)) {
             \OC_Response::setStatus(403);
             \OCP\JSON::error(array('success' => false));
             exit;
         }
     }
     $basePath = $path;
     if ($relativePath !== null && \OC\Files\Filesystem::isReadable($basePath . $relativePath)) {
         $path .= \OC\Files\Filesystem::normalizePath($relativePath);
     }
     return array('linkItem' => $linkItem, 'basePath' => $basePath, 'realPath' => $path);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:53,代码来源:helper.php

示例5: av_scan

 public static function av_scan($path)
 {
     $path = $path[\OC\Files\Filesystem::signal_param_path];
     if ($path != '') {
         if (isset($_POST['dirToken'])) {
             //Public upload case
             $filesView = \OC\Files\Filesystem::getView();
         } else {
             $filesView = \OCP\Files::getStorage("files");
         }
         if (!is_object($filesView)) {
             \OCP\Util::writeLog('files_antivirus', 'Can\'t init filesystem view', \OCP\Util::WARN);
             return;
         }
         // check if path is a directory
         if ($filesView->is_dir($path)) {
             return;
         }
         // we should have a file to work with, and the file shouldn't
         // be empty
         $fileExists = $filesView->file_exists($path);
         if ($fileExists && $filesView->filesize($path) > 0) {
             $fileStatus = self::scanFile($filesView, $path);
             $result = $fileStatus->getNumericStatus();
             switch ($result) {
                 case Status::SCANRESULT_UNCHECKED:
                     //TODO: Show warning to the user: The file can not be checked
                     break;
                 case Status::SCANRESULT_INFECTED:
                     //remove file
                     $filesView->unlink($path);
                     Notification::sendMail($path);
                     $message = \OCP\Util::getL10N('files_antivirus')->t("Virus detected! Can't upload the file %s", array(basename($path)));
                     \OCP\JSON::error(array("data" => array("message" => $message)));
                     exit;
                     break;
                 case Status::SCANRESULT_CLEAN:
                     //do nothing
                     break;
             }
         }
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:43,代码来源:scanner.php

示例6: __construct

 public function __construct($AppName, IRequest $request, $UserId)
 {
     parent::__construct($AppName, $request);
     $this->userId = $UserId;
     $path = self::PROJECTKIT_PREFIX . DIRECTORY_SEPARATOR;
     if (isset($_GET['containerId'])) {
         $path .= self::PROJECT_PREFIX . (string) $_GET['containerId'] . DIRECTORY_SEPARATOR;
         if (isset($_GET['targetType']) && isset($_GET['targetId'])) {
             switch ($_GET['targetType']) {
                 case TargetType::TASK:
                     $path .= self::TASK_PREFIX;
                     break;
                 case TargetType::ISSUE:
                     $path .= self::ISSUE_PREFIX;
                     break;
                 default:
                     break;
             }
             $path .= (string) $_GET['targetId'] . DIRECTORY_SEPARATOR;
             $_SESSION['targetType'] = $_GET['targetType'];
         } elseif (!isset($_GET['targetType']) && !isset($_GET['targetId'])) {
             $_SESSION['targetType'] = TargetType::PROJECT;
         }
         //use session to save targetType
         $path = Filesystem::normalizePath($path);
         //Create folder for path
         if (!Filesystem::file_exists($path)) {
             try {
                 Filesystem::mkdir($path);
             } catch (\Exception $e) {
                 $result = ['success' => false, 'data' => ['message' => $e->getMessage()]];
                 \OCP\JSON::error($result);
                 exit;
             }
         }
         if (!isset($_GET['dir'])) {
             $params = array_merge($_GET, ["dir" => $path]);
             $url = $_SERVER['PHP_SELF'] . '?' . http_build_query($params);
             header('Location: ' . $url, true, 302);
             exit;
         }
     }
 }
开发者ID:fproject,项目名称:apps,代码行数:43,代码来源:pagecontroller.php

示例7: joinAsUser

 public static function joinAsUser($args)
 {
     $uid = self::preDispatch();
     $fileId = Helper::getArrayValueByKey($args, 'file_id');
     try {
         $view = \OC\Files\Filesystem::getView();
         $path = $view->getPath($fileId);
         if ($view->isUpdatable($path)) {
             $file = new File($fileId);
             $session = Db\Session::start($uid, $file);
             \OCP\JSON::success($session);
         } else {
             $info = $view->getFileInfo($path);
             \OCP\JSON::success(array('permissions' => $info['permissions'], 'id' => $fileId));
         }
         exit;
     } catch (\Exception $e) {
         Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
         \OCP\JSON::error();
         exit;
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:22,代码来源:sessionController.php

示例8: array

 * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('files_encryption');
if (isset($_POST['userEnableRecovery']) && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])) {
    $userId = \OCP\USER::getUser();
    $view = new \OC\Files\View('/');
    $util = new \OCA\Encryption\Util($view, $userId);
    // Save recovery preference to DB
    $return = $util->setRecoveryForUser($_POST['userEnableRecovery']);
    if ($_POST['userEnableRecovery'] === '1') {
        $util->addRecoveryKeys();
    } else {
        $util->removeRecoveryKeys();
    }
} else {
    $return = false;
}
// Return success or failure
if ($return) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('File recovery settings updated'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update file recovery'))));
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:31,代码来源:userrecovery.php

示例9: elseif

<?php

/**
 * ownCloud - gsync plugin
 * 
 * @author Victor Dubiniuk
 * @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 * 
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA_Gsync;

App::initAjaxController();
// Get data
if (isset($_POST[App::GOOGLE_CLIENT_ID])) {
    App::setClientId($_POST[App::GOOGLE_CLIENT_ID]);
} elseif (isset($_POST[App::GOOGLE_SECRET])) {
    App::setSecret($_POST[App::GOOGLE_SECRET]);
} elseif (isset($_POST[App::GOOGLE_REFRESH_TOKEN])) {
    $token = App::getRefreshToken();
    Request::revokeRefreshToken($token);
    App::setRefreshToken('');
} else {
    \OCP\JSON::error(array("data" => array("message" => App::$l10n->t("Invalid request"))));
}
\OCP\JSON::success(array("data" => array("message" => App::$l10n->t("Saved"))));
开发者ID:seanbradley28,项目名称:gsync,代码行数:27,代码来源:settings.php

示例10: array

<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser());
$result = $util->restoreBackup('decryptAll');
if ($result) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('Backups restored successfully'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t restore your encryption keys, please check your owncloud.log or ask your administrator'))));
}
开发者ID:samj1912,项目名称:repo,代码行数:12,代码来源:restorekeys.php

示例11: isset

    $password = $_POST['password'];
}
$relativePath = null;
if (isset($_GET['dir'])) {
    $relativePath = $_GET['dir'];
}
$sortAttribute = isset($_GET['sort']) ? $_GET['sort'] : 'name';
$sortDirection = isset($_GET['sortdirection']) ? $_GET['sortdirection'] === 'desc' : false;
$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
$linkItem = $data['linkItem'];
// Load the files
$dir = $data['realPath'];
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\JSON::error(array('success' => false));
    exit;
}
$data = array();
// make filelist
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
$formattedFiles = array();
foreach ($files as $file) {
    $entry = \OCA\Files\Helper::formatFileInfo($file);
    unset($entry['directory']);
    // for now
    $entry['permissions'] = \OCP\PERMISSION_READ;
    $formattedFiles[] = $entry;
}
$data['directory'] = $relativePath;
$data['files'] = $formattedFiles;
开发者ID:olucao,项目名称:owncloud-core,代码行数:31,代码来源:list.php

示例12: array

 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkAdminUser();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = OC_L10N::get('files_encryption');
$return = false;
// Enable recoveryAdmin
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
    $return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
    // Return success or failure
    if ($return) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully enabled'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Could not enable recovery key. Please check your recovery key password!'))));
    }
    // Disable recoveryAdmin
} elseif (isset($_POST['adminEnableRecovery']) && '0' === $_POST['adminEnableRecovery']) {
    $return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
    // Return success or failure
    if ($return) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully disabled'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Could not disable recovery key. Please check your recovery key password!'))));
    }
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:31,代码来源:adminrecovery.php

示例13: catch

        } catch (\Exception $e) {
            \OCP\JSON::error(array('message' => $e->getMessage()));
            exit;
        }
        \OCP\JSON::error();
        exit;
        break;
    case 'save':
        $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false;
        $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null;
        if ($key === false || is_null($val)) {
            \OCP\JSON::error(array('message' => $l->t('No data specified')));
            exit;
        }
        $cfg = array($key => $val);
        $setParameters = array();
        $configuration->setConfiguration($cfg, $setParameters);
        if (!in_array($key, $setParameters)) {
            \OCP\JSON::error(array('message' => $l->t($key . ' Could not set configuration %s', $setParameters[0])));
            exit;
        }
        $configuration->saveConfiguration();
        //clear the cache on save
        $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix);
        $connection->clearCache();
        OCP\JSON::success();
        break;
    default:
        //TODO: return 4xx error
        break;
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:31,代码来源:wizard.php

示例14: array

<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
//encryption app needs to be loaded
OC_App::loadApp('files_encryption');
// init encryption app
$params = array('uid' => \OCP\User::getUser(), 'password' => $_POST['password']);
$view = new OC\Files\View('/');
$util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
$l = \OC_L10N::get('settings');
$result = $util->initEncryption($params);
if ($result !== false) {
    try {
        $successful = $util->decryptAll();
    } catch (\Exception $ex) {
        \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR);
        $successful = false;
    }
    $util->closeEncryptionSession();
    if ($successful === true) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator'))));
    }
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again'))));
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:28,代码来源:decryptall.php

示例15: Chart

 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
use Arnovr\Statistics\Api\ApiConnection;
use GuzzleHttp\Exception\RequestException;
use OCA\ocUsageCharts\AppInfo\Chart;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('ocusagecharts');
\OCP\JSON::callCheck();
$l = \OCP\Util::getL10N('ocusagecharts');
$app = new Chart();
$container = $app->getContainer();
/** @var ApiConnection $apiConnection */
$apiConnection = $container->query('ContentStatisticsClientApiConnection');
$data = array('data' => array('status' => 'success'));
try {
    if ($apiConnection->testConnection()) {
        \OCP\JSON::success($data);
        exit;
    }
} catch (RequestException $exception) {
}
$data = array('data' => array('status' => 'error'));
\OCP\JSON::error($data);
开发者ID:xn--nding-jua,项目名称:ocusagecharts,代码行数:30,代码来源:checkconnection.php


注:本文中的OCP\JSON::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。