本文整理汇总了PHP中OC_JSON::success方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_JSON::success方法的具体用法?PHP OC_JSON::success怎么用?PHP OC_JSON::success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_JSON
的用法示例。
在下文中一共展示了OC_JSON::success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: sendTestMail
/**
* Send a mail to test the settings
*/
public static function sendTestMail()
{
\OC_Util::checkAdminUser();
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
$email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
if (!empty($email)) {
$defaults = new \OC_Defaults();
try {
\OC_Mail::send($email, \OC_User::getDisplayName(), $l->t('test email settings'), $l->t('If you received this email, the settings seem to be correct.'), \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
} catch (\Exception $e) {
$message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
\OC_JSON::error(array("data" => array("message" => $message)));
exit;
}
\OC_JSON::success(array("data" => array("message" => $l->t("Email sent"))));
} else {
$message = $l->t('You need to set your user email before being able to send test emails.');
\OC_JSON::error(array("data" => array("message" => $message)));
}
}
示例3: array
if (OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group)) {
$groups[] = $group;
}
}
if (count($groups) == 0) {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
}
} else {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
}
}
$username = $_POST["username"];
$password = $_POST["password"];
// Does the group exist?
if (in_array($username, OC_User::getUsers())) {
OC_JSON::error(array("data" => array("message" => "User already exists")));
exit;
}
// Return Success story
try {
OC_User::createUser($username, $password);
foreach ($groups as $i) {
if (!OC_Group::groupExists($i)) {
OC_Group::createGroup($i);
}
OC_Group::addToGroup($username, $i);
}
OC_JSON::success(array("data" => array("username" => $username, "groups" => implode(", ", OC_Group::getUserGroups($username)))));
} catch (Exception $exception) {
OC_JSON::error(array("data" => array("message" => $exception->getMessage())));
}
示例4: 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))));
}
示例5: 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."))));
}
示例6: isset
<?php
/**
* ownCloud - ajax frontend
*
* @author Jakob Sack
* @copyright 2011 Jakob Sack kde@jakobsack.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 Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
$app = isset($_POST["app"]) ? $_POST["app"] : "";
$app = OC_App::cleanAppId($app);
$l = OC_L10N::get($app);
OC_JSON::success(array('data' => $l->getTranslations(), 'plural_form' => $l->getPluralFormString()));
示例7: 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."))));
示例8: intval
* @author Victor Dubiniuk
* Copyright (c) 2012 Victor Dubiniuk <victor.dubiniuk@gmail.com>
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
$id = intval($_POST['id']);
$aid = intval($_POST['aid']);
$isaddressbook = isset($_POST['isaddressbook']) ? true : false;
// Ownership checking
try {
OCA\Contacts\Addressbook::find($id);
// is owner access check
} catch (Exception $e) {
OCP\JSON::error(array('data' => array('message' => $e->getMessage())));
exit;
}
try {
OCA\Contacts\VCard::moveToAddressBook($aid, $id, $isaddressbook);
} catch (Exception $e) {
$msg = $e->getMessage();
OCP\Util::writeLog('contacts', 'Error moving contacts "' . implode(',', $id) . '" to addressbook "' . $aid . '"' . $msg, OCP\Util::ERROR);
OC_JSON::error(array('data' => array('message' => $msg)));
exit;
}
OC_JSON::success(array('data' => array('ids' => $id)));
示例9: success
/**
* @brief Send json success msg
* @param array $data The data to use
*/
public static function success($data = array())
{
return \OC_JSON::success($data);
}
示例10: array
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS = true;
require_once '../../../lib/base.php';
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue("dbtype", "sqlite");
if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') {
$_ut = "strftime('%s','now')";
} else {
$_ut = "UNIX_TIMESTAMP()";
}
//FIXME: Detect when user adds a known URL
$query = OC_DB::prepare("\n\tINSERT INTO *PREFIX*bookmarks\n\t(url, title, user_id, public, added, lastmodified)\n\tVALUES (?, ?, ?, 0, {$_ut}, {$_ut})\n\t");
$params = array(htmlspecialchars_decode($_GET["url"]), htmlspecialchars_decode($_GET["title"]), OC_User::getUser());
$query->execute($params);
$b_id = OC_DB::insertid();
if ($b_id !== false) {
$query = OC_DB::prepare("\n\t\tINSERT INTO *PREFIX*bookmarks_tags\n\t\t(bookmark_id, tag)\n\t\tVALUES (?, ?)\n\t\t");
$tags = explode(' ', urldecode($_GET["tags"]));
foreach ($tags as $tag) {
if (empty($tag)) {
//avoid saving blankspaces
continue;
}
$params = array($b_id, trim($tag));
$query->execute($params);
}
OC_JSON::success(array('data' => $b_id));
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_bookmarks_ajax_addBookmark.php
示例11: isset
<?php
/**
* Copyright (c) 2012, Robin Appelman <icewind1991@gmail.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OC_JSON::checkAdminUser();
$count = isset($_GET['count']) ? $_GET['count'] : 50;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$entries = OC_Log_Owncloud::getEntries($count, $offset);
OC_JSON::success(array("data" => OC_Util::sanitizeHTML($entries), "remain" => count(OC_Log_Owncloud::getEntries(1, $offset + $offset)) != 0 ? true : false));
示例12: OC_L10N
<?php
// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkLoggedIn();
$l = new OC_L10N('core');
// Get data
if (isset($_POST['email'])) {
$email = trim($_POST['email']);
OC_Preferences::setValue(OC_User::getUser(), 'settings', 'email', $email);
OC_JSON::success(array("data" => array("message" => $l->t("email Changed"))));
} else {
OC_JSON::error(array("data" => array("message" => $l->t("Invalid request"))));
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:14,代码来源:owncloud_settings_ajax_lostpassword.php
示例13: isset
* @author Lukas Reschke <lukas@owncloud.com>
* @author Robin Appelman <icewind@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$groups = isset($_POST['groups']) ? (array) $_POST['groups'] : null;
try {
$app = OC_App::cleanAppId((string) $_POST['appid']);
OC_App::enable($app, $groups);
OC_JSON::success(['data' => ['update_required' => \OC_App::shouldUpgrade($app)]]);
} catch (Exception $e) {
\OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR);
OC_JSON::error(array("data" => array("message" => $e->getMessage())));
}
示例14: foreach
<?php
OC_JSON::callCheck();
OC_JSON::checkSubAdminUser();
$userCount = 0;
$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
if (!OC_User::isAdminUser($currentUser)) {
$groups = OC_SubAdmin::getSubAdminsGroups($currentUser);
foreach ($groups as $group) {
$userCount += count(OC_Group::usersInGroup($group));
}
} else {
$userCountArray = \OC::$server->getUserManager()->countUsers();
if (!empty($userCountArray)) {
foreach ($userCountArray as $classname => $usercount) {
$userCount += $usercount;
}
}
}
OC_JSON::success(array('count' => $userCount));
示例15: OC_L10N
*/
// Init owncloud
require_once '../../../lib/base.php';
$id = $_GET['id'];
$l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find($id);
if ($card === false) {
OC_JSON::error(array('data' => array('message' => $l10n->t('Contact could not be found.'))));
exit;
}
$addressbook = OC_Contacts_Addressbook::find($card['addressbookid']);
if ($addressbook === false || $addressbook['userid'] != OC_USER::getUser()) {
OC_JSON::error(array('data' => array('message' => $l10n->t('This is not your contact.'))));
exit;
}
$vcard = OC_Contacts_VCard::parse($card['carddata']);
// Check if the card is valid
if (is_null($vcard)) {
OC_JSON::error(array('data' => array('message' => $l10n->t('vCard could not be read.'))));
exit;
}
$details = OC_Contacts_VCard::structureContact($vcard);
$tmpl = new OC_Template('contacts', 'part.details');
$tmpl->assign('details', $details);
$tmpl->assign('id', $id);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array('id' => $id, 'page' => $page)));
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:30,代码来源:owncloud_apps_contacts_ajax_getdetails.php