本文整理汇总了PHP中OC_JSON类的典型用法代码示例。如果您正苦于以下问题:PHP OC_JSON类的具体用法?PHP OC_JSON怎么用?PHP OC_JSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_JSON类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleUnexpectedShutdown
function handleUnexpectedShutdown()
{
if (!my_temporary_cron_class::$sent) {
if (OC::$CLI) {
echo 'Unexpected error!' . PHP_EOL;
} else {
OC_JSON::error(array('data' => array('message' => 'Unexpected error!')));
}
}
}
示例2: handleUnexpectedShutdown
function handleUnexpectedShutdown()
{
// Delete lockfile
if (!TemporaryCronClass::$keeplock && file_exists(TemporaryCronClass::$lockfile)) {
unlink(TemporaryCronClass::$lockfile);
}
// Say goodbye if the app did not shutdown properly
if (!TemporaryCronClass::$sent) {
if (OC::$CLI) {
echo 'Unexpected error!' . PHP_EOL;
} else {
OC_JSON::error(array('data' => array('message' => 'Unexpected error!')));
}
}
}
示例3: index
function index()
{
if (isset($_GET['fileid'])) {
$fileIds = array($_GET['fileid']);
} else {
$fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
}
$eventSource = new OC_EventSource();
$eventSource->send('count', count($fileIds));
$skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
foreach ($fileIds as $id) {
$skipped = false;
$fileStatus = OCA\Search_Lucene\Status::fromFileId($id);
try {
//before we start mark the file as error so we know there was a problem when the php execution dies
$fileStatus->markError();
$path = OC\Files\Filesystem::getPath($id);
$eventSource->send('indexing', $path);
foreach ($skippedDirs as $skippedDir) {
if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
$result = $fileStatus->markSkipped();
$skipped = true;
break;
}
}
if (!$skipped) {
if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
$result = $fileStatus->markIndexed();
}
}
if (!$result) {
OC_JSON::error(array('message' => 'Could not index file.'));
$eventSource->send('error', $path);
}
} catch (Exception $e) {
//sqlite might report database locked errors when stock filescan is in progress
//this also catches db locked exception that might come up when using sqlite
\OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
OC_JSON::error(array('message' => 'Could not index file.'));
$eventSource->send('error', $e->getMessage());
//try to mark the file as new to let it reindex
$fileStatus->markNew();
// Add UI to trigger rescan of files with status 'E'rror?
}
}
$eventSource->send('done', '');
$eventSource->close();
}
示例4: index
function index()
{
$fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
$eventSource = new OC_EventSource();
$eventSource->send('count', count($fileIds));
$skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
$query = OC_DB::prepare('INSERT INTO `*PREFIX*lucene_status` VALUES (?,?)');
foreach ($fileIds as $id) {
$skipped = false;
try {
//before we start mark the file as error so we know there was a problem when the php execution dies
$result = $query->execute(array($id, 'E'));
$path = OC\Files\Filesystem::getPath($id);
$eventSource->send('indexing', $path);
//clean jobs for indexed file
$param = json_encode(array('path' => $path, 'user' => OCP\User::getUser()));
$cleanjobquery = OC_DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=? AND `parameters`=?');
$cleanjobquery->execute(array('search_lucene', $param));
foreach ($skippedDirs as $skippedDir) {
if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
$result = $query->execute(array($id, 'S'));
$skipped = true;
break;
}
}
if (!$skipped) {
if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
$result = $query->execute(array($id, 'I'));
}
}
if (!$result) {
OC_JSON::error(array('message' => 'Could not index file.'));
$eventSource->send('error', $path);
}
} catch (PDOException $e) {
//sqlite might report database locked errors when stock filescan is in progress
//this also catches db locked exception that might come up when using sqlite
\OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
OC_JSON::error(array('message' => 'Could not index file.'));
$eventSource->send('error', $e->getMessage());
//try to mark the file as new to let it reindex
$query->execute(array($id, 'N'));
// Add UI to trigger rescan of files with status 'E'rror?
}
}
$eventSource->send('done', '');
$eventSource->close();
}
示例5: getDisplayNames
public static function getDisplayNames($args)
{
\OC_JSON::checkLoggedIn();
\OC_JSON::callCheck();
$users = $_GET['users'];
$result = array();
$userManager = \OC::$server->getUserManager();
foreach ($users as $user) {
$userObject = $userManager->get($user);
if (is_object($userObject)) {
$result[$user] = $userObject->getDisplayName();
} else {
$result[$user] = $user;
}
}
\OC_JSON::success(array('users' => $result));
}
示例6: foreach
}
}
}
$count = 0;
// enable l10n support
$l = \OC::$server->getL10N('core');
foreach ($groups as $group) {
if ($count < 15) {
if (!isset($_GET['itemShares']) || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) || !is_array((string) $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) || !in_array($group, (string) $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) {
$shareWith[] = array('label' => $group, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_GROUP, 'shareWith' => $group));
$count++;
}
} else {
break;
}
}
// allow user to add unknown remote addresses for server-to-server share
$backend = \OCP\Share::getBackend((string) $_GET['itemType']);
if ($backend->isShareTypeAllowed(\OCP\Share::SHARE_TYPE_REMOTE)) {
if (substr_count((string) $_GET['search'], '@') === 1) {
$shareWith[] = array('label' => (string) $_GET['search'], 'value' => array('shareType' => \OCP\Share::SHARE_TYPE_REMOTE, 'shareWith' => (string) $_GET['search']));
}
}
$sorter = new \OC\Share\SearchResultSorter((string) $_GET['search'], 'label', new \OC\Log());
usort($shareWith, array($sorter, 'sort'));
OC_JSON::success(array('data' => $shareWith));
}
break;
}
}
}
示例7: isset
OCP\JSON::callCheck();
OC_JSON::checkLoggedIn();
$l = \OC::$server->getL10N('settings');
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
$displayName = (string) $_POST["displayName"];
$userstatus = null;
if (OC_User::isAdminUser(OC_User::getUser())) {
$userstatus = 'admin';
}
$isUserAccessible = false;
$subadminUserObject = \OC::$server->getUserManager()->get(\OC_User::getUser());
$targetUserObject = \OC::$server->getUserManager()->get($username);
if ($subadminUserObject !== null && $targetUserObject !== null) {
$isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($subadminUserObject, $targetUserObject);
}
if ($isUserAccessible) {
$userstatus = 'subadmin';
}
if ($username === OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) {
$userstatus = 'changeOwnDisplayName';
}
if (is_null($userstatus)) {
OC_JSON::error(array("data" => array("message" => $l->t("Authentication error"))));
exit;
}
// Return Success story
if (OC_User::setDisplayName($username, $displayName)) {
OC_JSON::success(array("data" => array("message" => $l->t('Your full name has been changed.'), "username" => $username, 'displayName' => $displayName)));
} else {
OC_JSON::error(array("data" => array("message" => $l->t("Unable to change full name"), 'displayName' => OC_User::getDisplayName($username))));
}
示例8: catch
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();
if (!array_key_exists('appid', $_POST)) {
OCP\JSON::error(array('message' => 'No AppId given!'));
return;
}
$appId = (string) $_POST['appid'];
if (!is_numeric($appId)) {
$appId = \OC::$server->getAppConfig()->getValue($appId, 'ocsid', null);
if ($appId === null) {
OCP\JSON::error(array('message' => 'No OCS-ID found for app!'));
exit;
}
}
$appId = OC_App::cleanAppId($appId);
$config = \OC::$server->getConfig();
$config->setSystemValue('maintenance', true);
try {
$result = OC_Installer::updateAppByOCSId($appId);
$config->setSystemValue('maintenance', false);
} catch (Exception $ex) {
$config->setSystemValue('maintenance', false);
OC_JSON::error(array("data" => array("message" => $ex->getMessage())));
return;
}
if ($result !== false) {
OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
$l = \OC::$server->getL10N('settings');
OC_JSON::error(array("data" => array("message" => $l->t("Couldn't update app."))));
}
示例9: renderResult
/**
* @param string $format
* @return string
*/
public static function renderResult($format, $meta, $data)
{
$response = array('ocs' => array('meta' => $meta, 'data' => $data));
if ($format == 'json') {
return OC_JSON::encode($response);
}
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->startDocument();
self::toXML($response, $writer);
$writer->endDocument();
return $writer->outputMemory(true);
}
示例10: array
}
}
} else {
if ($param === 'removeHeaderNav') {
OCP\Config::setAppValue('roundcube', 'removeHeaderNav', false);
}
if ($param === 'removeControlNav') {
OCP\Config::setAppValue('roundcube', 'removeControlNav', false);
}
if ($param === 'autoLogin') {
OCP\Config::setAppValue('roundcube', 'autoLogin', false);
}
if ($param === 'enableDebug') {
OCP\Config::setAppValue('roundcube', 'enableDebug', false);
}
if ($param === 'rcNoCronRefresh') {
OCP\Config::setAppValue('roundcube', 'rcNoCronRefresh', false);
}
}
}
// update login status
$username = OCP\User::getUser();
$params = array("uid" => $username);
$loginHelper = new OC_RoundCube_AuthHelper();
$loginHelper->login($params);
} else {
OC_JSON::error(array("data" => array("message" => $l->t("Not submitted for us."))));
return false;
}
OCP\JSON::success(array('data' => array('message' => $l->t('Application settings successfully stored.'))));
return true;
示例11:
<?php
// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkAdminUser();
OC_JSON::setContentTypeHeader();
OC_App::disable($_POST['appid']);
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:7,代码来源:owncloud_settings_ajax_disableapp.php
示例12:
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS = true;
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
$id = $_POST['id'];
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)) {
OC_JSON::error();
exit;
}
OCP\JSON::success();
示例13: array
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OCP\JSON::checkAppEnabled('external');
OCP\User::checkAdminUser();
OCP\JSON::callCheck();
$sites = array();
for ($i = 0; $i < sizeof($_POST['site_name']); $i++) {
if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) {
array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i])));
}
}
$l = OC_L10N::get('external');
foreach ($sites as $site) {
if (strpos($site[1], 'https://') === 0) {
continue;
}
if (strpos($site[1], 'http://') === 0) {
continue;
}
OC_JSON::error(array("data" => array("message" => $l->t('Please enter valid urls - they have to start with either http:// or https://'))));
return;
}
if (sizeof($sites) == 0) {
$appConfig = \OC::$server->getAppConfig();
$appConfig->deleteKey('external', 'sites');
} else {
OCP\Config::setAppValue('external', 'sites', json_encode($sites));
}
OC_JSON::success(array("data" => array("message" => $l->t("External sites saved."))));
示例14: changeUserPassword
public static function changeUserPassword($args)
{
// Check if we are an user
\OC_JSON::callCheck();
\OC_JSON::checkLoggedIn();
$l = new \OC_L10n('settings');
if (isset($_POST['username'])) {
$username = $_POST['username'];
} else {
\OC_JSON::error(array('data' => array('message' => $l->t('No user supplied'))));
exit;
}
$password = isset($_POST['password']) ? $_POST['password'] : null;
$recoveryPassword = isset($_POST['recoveryPassword']) ? $_POST['recoveryPassword'] : null;
$isUserAccessible = false;
$currentUserObject = \OC::$server->getUserSession()->getUser();
$targetUserObject = \OC::$server->getUserManager()->get($username);
if ($currentUserObject !== null && $targetUserObject !== null) {
$isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject);
}
if (\OC_User::isAdminUser(\OC_User::getUser())) {
$userstatus = 'admin';
} elseif ($isUserAccessible) {
$userstatus = 'subadmin';
} else {
\OC_JSON::error(array('data' => array('message' => $l->t('Authentication error'))));
exit;
}
if (\OC_App::isEnabled('encryption')) {
//handle the recovery case
$crypt = new \OCA\Encryption\Crypto\Crypt(\OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig(), \OC::$server->getL10N('encryption'));
$keyStorage = \OC::$server->getEncryptionKeyStorage();
$util = new \OCA\Encryption\Util(new \OC\Files\View(), $crypt, \OC::$server->getLogger(), \OC::$server->getUserSession(), \OC::$server->getConfig(), \OC::$server->getUserManager());
$keyManager = new \OCA\Encryption\KeyManager($keyStorage, $crypt, \OC::$server->getConfig(), \OC::$server->getUserSession(), new \OCA\Encryption\Session(\OC::$server->getSession()), \OC::$server->getLogger(), $util);
$recovery = new \OCA\Encryption\Recovery(\OC::$server->getUserSession(), $crypt, \OC::$server->getSecureRandom(), $keyManager, \OC::$server->getConfig(), $keyStorage, \OC::$server->getEncryptionFilesHelper(), new \OC\Files\View());
$recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled();
$validRecoveryPassword = false;
$recoveryEnabledForUser = false;
if ($recoveryAdminEnabled) {
$validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword);
$recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username);
}
if ($recoveryEnabledForUser && $recoveryPassword === '') {
\OC_JSON::error(array('data' => array('message' => $l->t('Please provide an admin recovery password, otherwise all user data will be lost'))));
} elseif ($recoveryEnabledForUser && !$validRecoveryPassword) {
\OC_JSON::error(array('data' => array('message' => $l->t('Wrong admin recovery password. Please check the password and try again.'))));
} else {
// now we know that everything is fine regarding the recovery password, let's try to change the password
$result = \OC_User::setPassword($username, $password, $recoveryPassword);
if (!$result && $recoveryEnabledForUser) {
\OC_JSON::error(array("data" => array("message" => $l->t("Backend doesn't support password change, but the user's encryption key was successfully updated."))));
} elseif (!$result && !$recoveryEnabledForUser) {
\OC_JSON::error(array("data" => array("message" => $l->t("Unable to change password"))));
} else {
\OC_JSON::success(array("data" => array("username" => $username)));
}
}
} else {
// if encryption is disabled, proceed
if (!is_null($password) && \OC_User::setPassword($username, $password)) {
\OC_JSON::success(array('data' => array('username' => $username)));
} else {
\OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password'))));
}
}
}
示例15: isset
<?php
/**
* ownCloud
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Check if we are a user
OC_JSON::checkLoggedIn();
$query = isset($_GET['query']) ? $_GET['query'] : '';
if ($query) {
$result = \OC::$server->getSearch()->search($query);
OC_JSON::encodedPrint($result);
} else {
echo 'false';
}