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


PHP JSON::success方法代码示例

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


在下文中一共展示了JSON::success方法的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: invite

 /**
  * Invite users to the editing session
  */
 public static function invite()
 {
     self::preDispatch();
     $invitees = @$_POST['users'];
     if (is_array($invitees)) {
         $invitees = array_unique($invitees);
         $esId = @$_POST['esId'];
         foreach ($invitees as $userId) {
             try {
                 Invite::add($esId, $userId);
             } catch (\Exception $e) {
             }
         }
     }
     \OCP\JSON::success();
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:19,代码来源:userController.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: rename

 public static function rename($args)
 {
     self::preDispatchGuest();
     $memberId = Helper::getArrayValueByKey($args, 'member_id');
     $name = Helper::getArrayValueByKey($_POST, 'name');
     $member = new Db\Member();
     $member->load($memberId);
     if ($member->getEsId() && $member->getStatus() == Db\Member::MEMBER_STATUS_ACTIVE && $member->getIsGuest()) {
         $guestMark = Db\Member::getGuestPostfix();
         if (substr($name, -strlen($guestMark)) !== $guestMark) {
             $name = $name . ' ' . $guestMark;
         }
         $op = new Db\Op();
         $op->changeNick($member->getEsId(), $memberId, $name);
     }
     \OCP\JSON::success();
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:17,代码来源:userController.php

示例5: apply

 /**
  * Check if we have a user to login
  * @param String $email 
  * @param String $uid 
  * @return String 
  */
 public static function apply($email, $uid = '')
 {
     //Get list of matching users
     $list = array();
     $query = \OCP\DB::prepare('SELECT userid FROM *PREFIX*preferences WHERE appid = ? AND configkey = ? AND configvalue  = ?');
     $result = $query->execute(array('settings', 'email', $email));
     while ($userid = $result->fetchOne()) {
         $list[] = $userid;
     }
     $qtyUser = count($list);
     //No users found
     if (!$qtyUser) {
         \OCP\Util::writeLog(App::APP_ID, 'No users found. Deny login.', \OCP\Util::DEBUG);
         return false;
     }
     //One user found
     if ($qtyUser == 1) {
         \OCP\Util::writeLog(App::APP_ID, 'Single user found. Entering the open space.', \OCP\Util::DEBUG);
         return $list[0];
     }
     //Multiple users found
     $currentPolicy = self::getSystemPolicy();
     $isValidUid = in_array($uid, $list);
     if ($currentPolicy == self::MULTIPLE_USERS_LIST) {
         //Do we have correct uid?
         if ($isValidUid) {
             \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Entering the open space.', \OCP\Util::DEBUG);
             return $uid;
         } else {
             \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. List them all.', \OCP\Util::DEBUG);
             \OCP\JSON::success(array('list' => $list));
             exit;
         }
     } elseif ($currentPolicy == self::MULTIPLE_USERS_FIRST) {
         \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Use first.', \OCP\Util::DEBUG);
         //not first but the best matching ;)
         $userid = $isValidUid ? $uid : $list[0];
         return $userid;
     }
     \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Deny login.', \OCP\Util::DEBUG);
     return Validator::setAmbigous();
 }
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:48,代码来源:policy.php

示例6: listAll

 /**
  * lists the documents the user has access to (including shared files, once the code in core has been fixed)
  * also adds session and member info for these files
  */
 public static function listAll()
 {
     self::preDispatch();
     $documents = Storage::getDocuments();
     $fileIds = array();
     //$previewAvailable = \OCP\Preview::show($file);
     foreach ($documents as $key => $document) {
         //\OCP\Preview::show($document['path']);
         $documents[$key]['icon'] = preg_replace('/\\.png$/', '.svg', \OC_Helper::mimetypeIcon($document['mimetype']));
         $fileIds[] = $document['fileid'];
     }
     usort($documents, function ($a, $b) {
         return @$b['mtime'] - @$a['mtime'];
     });
     $session = new Db_Session();
     $sessions = $session->getCollectionBy('file_id', $fileIds);
     $members = array();
     $member = new Db_Member();
     foreach ($sessions as $session) {
         $members[$session['es_id']] = $member->getActiveCollection($session['es_id']);
     }
     \OCP\JSON::success(array('documents' => $documents, 'sessions' => $sessions, 'members' => $members));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:27,代码来源:documentController.php

示例7: DateTime

            $link = (string) $_POST['link'];
            $file = (string) $_POST['file'];
            $to_address = (string) $_POST['toaddress'];
            $mailNotification = new \OC\Share\MailNotifications();
            $expiration = null;
            if (isset($_POST['expiration']) && $_POST['expiration'] !== '') {
                try {
                    $date = new DateTime((string) $_POST['expiration']);
                    $expiration = $date->getTimestamp();
                } catch (Exception $e) {
                    \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
                }
            }
            $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration);
            if (empty($result)) {
                \OCP\JSON::success();
            } else {
                $l = \OC::$server->getL10N('core');
                OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't send mail to following users: %s ", implode(', ', $result)))));
            }
            break;
    }
} else {
    if (isset($_GET['fetch'])) {
        switch ($_GET['fetch']) {
            case 'getItemsSharedStatuses':
                if (isset($_GET['itemType'])) {
                    $return = OCP\Share::getItemsShared((string) $_GET['itemType'], OCP\Share::FORMAT_STATUSES);
                    is_array($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
                }
                break;
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:31,代码来源:share.php

示例8:

 */
namespace OCA_Updater;

\OCP\JSON::checkAdminUser();
// Url to download package e.g. http://download.owncloud.org/releases/owncloud-4.0.5.tar.bz2
$packageUrl = 'http://owncloud.org/releases/owncloud-latest.zip';
//Package version e.g. 4.0.4
$packageVersion = '';
$updateData = \OC_Updater::check();
if (isset($updateData['version'])) {
    $packageVersion = $updateData['version'];
}
if (isset($updateData['url']) && extension_loaded('bz2')) {
    $packageUrl = $updateData['url'];
}
if (!$packageVersion) {
    \OCP\JSON::error(array('msg' => 'Version not found'));
    exit;
}
$sourcePath = Downloader::getPackage($packageUrl, $packageVersion);
if (!$sourcePath) {
    \OCP\JSON::error(array('msg' => 'Unable to fetch package'));
    exit;
}
$backupPath = Backup::createBackup();
if ($backupPath) {
    Updater::update($sourcePath, $backupPath);
    \OCP\JSON::success(array());
} else {
    \OCP\JSON::error(array('msg' => 'Failed to create backup'));
}
开发者ID:blablubli,项目名称:owncloudapps,代码行数:31,代码来源:admin.php

示例9: array

    $errorMessage = $l->t('Please repeat the new recovery password');
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
    exit;
}
if ($_POST['newPassword'] !== $_POST['confirmPassword']) {
    $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password');
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
    exit;
}
$view = new \OC\Files\View('/');
$util = new \OCA\Files_Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$keyId = $util->getRecoveryKeyId();
$encryptedRecoveryKey = \OCA\Files_Encryption\Keymanager::getPrivateSystemKey($keyId);
$decryptedRecoveryKey = $encryptedRecoveryKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedRecoveryKey, $oldPassword) : false;
if ($decryptedRecoveryKey) {
    $cipher = \OCA\Files_Encryption\Helper::getCipher();
    $encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword, $cipher);
    if ($encryptedKey) {
        \OCA\Files_Encryption\Keymanager::setPrivateSystemKey($encryptedKey, $keyId);
        $return = true;
    }
}
\OC_FileProxy::$enabled = $proxyStatus;
// success or failure
if ($return) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('Password successfully changed.'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Could not change the password. Maybe the old password was not correct.'))));
}
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:31,代码来源:changeRecoveryPassword.php

示例10: array

<?php

/**
 * ownCloud - Files_Opds App
 *
 * @author Frank de Lange
 * @copyright 2014 Frank de Lange
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Files_Opds;

$l = new \OC_L10N('files_opds');
\OCP\JSON::checkLoggedIn();
\OCP\JSON::callCheck();
Bookshelf::clear();
\OCP\JSON::success(array("data" => array("message" => $l->t("Bookshelf cleared"))));
开发者ID:RavenB,项目名称:owncloud-apps,代码行数:18,代码来源:clear_bookshelf.php

示例11: Dispatcher

    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'deleteGroup');
});
$this->create('contacts_categories_rename', 'groups/rename')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'renameGroup');
});
$this->create('contacts_categories_addto', 'groups/addto/{categoryId}')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'addToGroup');
});
$this->create('contacts_categories_removefrom', 'groups/removefrom/{categoryId}')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'removeFromGroup');
})->requirements(array('categoryId'));
$this->create('contacts_setpreference', 'preference/set')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('SettingsController', 'set');
});
$this->create('contacts_index_properties', 'indexproperties/{user}/')->post()->action(function ($params) {
    \OC::$session->close();
    // TODO: Add BackgroundJob for this.
    \OCP\Util::emitHook('OCA\\Contacts', 'indexProperties', array());
    \OCP\Config::setUserValue($params['user'], 'contacts', 'contacts_properties_indexed', 'yes');
    \OCP\JSON::success(array('isIndexed' => true));
})->requirements(array('user'))->defaults(array('user' => \OCP\User::getUser()));
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:31,代码来源:routes.php

示例12: isset

<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Documents;

\OCP\JSON::callCheck();
$unstable = isset($_POST['unstable']) ? $_POST['unstable'] : null;
if (!is_null($unstable)) {
    \OCP\JSON::checkAdminUser();
    \OCP\Config::setAppValue('documents', 'unstable', $unstable);
    \OCP\JSON::success();
    exit;
}
if (isset($_GET['unstable'])) {
    \OCP\JSON::success(array('value' => \OCP\Config::getAppValue('documents', 'unstable', 'false')));
}
exit;
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:settings.php

示例13:

<?php

/**
 * 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.
 *
 * @brief Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
if (isset($_POST['userEnableRecovery']) && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])) {
    $userId = \OCP\USER::getUser();
    $view = new \OC_FilesystemView('/');
    $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
$return ? \OCP\JSON::success() : \OCP\JSON::error();
开发者ID:omusico,项目名称:isle-web-framework,代码行数:29,代码来源:userrecovery.php

示例14: filter_var

<?php

/**
* ownCloud
*
* @author Oliver Gasser
* @copyright 2013 Oliver Gasser
*
*/
// Check if this file is called by admin user, otherwise send JSON error
\OCP\JSON::checkAdminUser();
// Check if valid requesttoken was sent
\OCP\JSON::callCheck();
// Load translations
$l = OC_L10N::get('mozilla_sync');
// Get inputs and set correct settings
$quota = filter_var($_POST['quota'], FILTER_VALIDATE_INT);
if ($quota === false) {
    // Send error message
    \OCP\JSON::error(array("data" => array("message" => $l->t("Invalid input"))));
} else {
    // Update settings values
    \OCA\mozilla_sync\User::setQuota($quota);
    // Send success message
    \OCP\JSON::success(array("data" => array("message" => $l->t("Quota saved"))));
}
/* vim: set ts=4 sw=4 tw=80 noet : */
开发者ID:mach-o,项目名称:mozilla_sync,代码行数:27,代码来源:setquota.php

示例15: stream_get_meta_data

<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('files_irods');
$source = $_GET['source'];
$f = \OC\Files\Filesystem::fopen($source, 'r');
$meta = stream_get_meta_data($f)['wrapper_data']->metadata;
$html = "<table id='metadata'>\n           <thead>\n             <tr>\n               <th>Key</th>\n               <th>Value</th>\n               <th>Units</th>\n               <th>Actions</th>\n             </tr>\n           </thead>\n           <tbody>";
foreach ($meta as $m) {
    $html .= sprintf("<tr><td class='editable' data-name='name' data-pk={$m->id}>%s</td>\n                    <td class='editable' data-name='value' data-pk={$m->id}>%s</td>\n                    <td class='editable' data-name='units' data-pk={$m->id}>%s</td>\n                    <td><button class='btn btn-danger remove-metadata' data-pk={$m->id}><i class='glyphicon glyphicon-remove'></i> Remove</button></td>\n                    </tr>", $m->name, $m->value, $m->units);
}
$html .= "</tbody></table>";
\OCP\JSON::success(array('data' => $html));
开发者ID:nesi,项目名称:files_irods,代码行数:14,代码来源:getMeta.php


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