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


PHP OC_JSON::error方法代码示例

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


在下文中一共展示了OC_JSON::error方法的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!')));
        }
    }
}
开发者ID:noci2012,项目名称:owncloud,代码行数:10,代码来源:cron.php

示例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!')));
        }
    }
}
开发者ID:Romua1d,项目名称:core,代码行数:15,代码来源:cron.php

示例3: 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();
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:48,代码来源:lucene.php

示例4: 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();
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:48,代码来源:lucene.php

示例5:

/**
* 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();
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:delBookmark.php

示例6: 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'))));
         }
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:66,代码来源:Controller.php

示例7: array

 * 2012 Frank Karlitschek frank@owncloud.org
 * 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."))));
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:setsites.php

示例8: 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))));
}
开发者ID:rajeshpillai,项目名称:core,代码行数:31,代码来源:changedisplayname.php

示例9: error

 /**
  * @brief Send json error msg
  * @param array $data The data to use
  */
 public static function error($data = array())
 {
     return \OC_JSON::error($data);
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:8,代码来源:json.php

示例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;
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:adminSettings.php

示例11: 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."))));
}
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:31,代码来源:updateapp.php

示例12: array

    $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $username);
    $recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');
    $validRecoveryPassword = false;
    $recoveryPasswordSupported = false;
    if ($recoveryAdminEnabled) {
        $validRecoveryPassword = $util->checkRecoveryPassword($recoveryPassword);
        $recoveryEnabledForUser = $util->recoveryEnabledForUser();
    }
    if ($recoveryEnabledForUser && $recoveryPassword === '') {
        OC_JSON::error(array('data' => array('message' => 'Please provide a admin recovery password, otherwise all user data will be lost')));
    } elseif ($recoveryEnabledForUser && !$validRecoveryPassword) {
        OC_JSON::error(array('data' => array('message' => '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 && $recoveryPasswordSupported) {
            OC_JSON::error(array("data" => array("message" => "Back-end doesn't support password change, but the users encryption key was successfully updated.")));
        } elseif (!$result && !$recoveryPasswordSupported) {
            OC_JSON::error(array("data" => array("message" => "Unable to change password")));
        } else {
            OC_JSON::success(array("data" => array("username" => $username)));
        }
    }
} else {
    // if user changes his own password or 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' => 'Unable to change password')));
    }
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:changepassword.php

示例13: md5

/**
 * ownCloud - RainLoop mail plugin
 *
 * @author RainLoop Team
 * @copyright 2015 RainLoop Team
 *
 * https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('rainloop');
OCP\JSON::callCheck();
$sEmail = '';
$sLogin = '';
if (isset($_POST['appname'], $_POST['rainloop-password'], $_POST['rainloop-email']) && 'rainloop' === $_POST['appname']) {
    $sUser = OCP\User::getUser();
    $sPostEmail = $_POST['rainloop-email'];
    OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-email', $sPostEmail);
    $sPass = $_POST['rainloop-password'];
    if ('******' !== $sPass && '' !== $sPass) {
        include_once OC_App::getAppPath('rainloop') . '/lib/RainLoopHelper.php';
        OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', OC_RainLoop_Helper::encodePassword($sPass, md5($sPostEmail)));
    }
    $sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
} else {
    sleep(1);
    OC_JSON::error(array('Message' => 'Invalid argument(s)', 'Email' => $sEmail));
    return false;
}
sleep(1);
OCP\JSON::success(array('Message' => 'Saved successfully', 'Email' => $sEmail));
return true;
开发者ID:helsaba,项目名称:rainloop-webmail,代码行数:31,代码来源:personal.php

示例14: unFavorite

 public static function unFavorite($args)
 {
     $tagger = self::getTagger($args['type']);
     if (!$tagger->removeFromFavorites($args['id'])) {
         $l = new \OC_L10n('core');
         \OC_JSON::error(array('message' => $l->t('Error unfavoriting')));
     } else {
         \OC_JSON::success();
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:10,代码来源:controller.php

示例15: array

<?php

OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
OC_JSON::setContentTypeHeader();
$appid = OC_App::enable($_POST['appid']);
if ($appid !== false) {
    OC_JSON::success(array('data' => array('appid' => $appid)));
} else {
    $l = OC_L10N::get('settings');
    OC_JSON::error(array("data" => array("message" => $l->t("Could not enable app. "))));
}
开发者ID:ryanshoover,项目名称:core,代码行数:12,代码来源:enableapp.php


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