本文整理汇总了PHP中OCP\App类的典型用法代码示例。如果您正苦于以下问题:PHP App类的具体用法?PHP App怎么用?PHP App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了App类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: registerSettings
/**
* Register settings templates
*/
public function registerSettings()
{
$container = $this->getContainer();
$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
\OCP\App::registerAdmin('files_external', 'settings');
\OCP\App::registerPersonal('files_external', 'personal');
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:10,代码来源:application.php
示例2: deleteUser_hook
/**
* @brief clean up user specific settings if user gets deleted
* @param array with uid
*
* This function is connected to the pre_deleteUser signal of OC_Users
* to remove the used space for the trash bin stored in the database
*/
public static function deleteUser_hook($params)
{
if (\OCP\App::isEnabled('files_trashbin')) {
$uid = $params['uid'];
Trashbin::deleteUser($uid);
}
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:hooks.php
示例3: getCalendarsForUser
/**
* Returns a list of calendars for a principal.
*
* Every project is an array with the following keys:
* * id, a unique id that will be used by other functions to modify the
* calendar. This can be the same as the uri or a database key.
* * uri, which the basename of the uri with which the calendar is
* accessed.
* * principalUri. The owner of the calendar. Almost always the same as
* principalUri passed to this method.
*
* Furthermore it can contain webdav properties in clark notation. A very
* common one is '{DAV:}displayname'.
*
* @param string $principalUri
* @return array
*/
public function getCalendarsForUser($principalUri)
{
$raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
$calendars = array();
foreach ($raw as $row) {
$components = explode(',', $row['components']);
if ($row['userid'] != OCP\USER::getUser()) {
$row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
}
$calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet($components));
foreach ($this->propertyMap as $xmlName => $dbName) {
$calendar[$xmlName] = isset($row[$dbName]) ? $row[$dbName] : '';
}
$calendars[] = $calendar;
}
if (\OCP\App::isEnabled('contacts')) {
$ctag = 0;
$app = new \OCA\Contacts\App();
$addressBooks = $app->getAddressBooksForUser();
foreach ($addressBooks as $addressBook) {
$tmp = $addressBook->lastModified();
if (!is_null($tmp)) {
$ctag = max($ctag, $tmp);
}
}
$ctag++;
$calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/contact_birthdays', '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $ctag, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{http://apple.com/ns/ical/}calendar-color' => '#CCCCCC');
}
return $calendars;
}
开发者ID:AlfredoCubitos,项目名称:calendar,代码行数:47,代码来源:backend.php
示例4: registerPersonal
/**
* Tells ownCloud to include a template in the personal overview
* @param string $mainPath the path to the main php file without the php
* suffix, relative to your apps directory! not the template directory
* @param string $appName the name of the app, defaults to the current one
*/
public function registerPersonal($mainPath, $appName = null)
{
if ($appName === null) {
$appName = $this->appName;
}
\OCP\App::registerPersonal($appName, $mainPath);
}
开发者ID:hjimmy,项目名称:owncloud,代码行数:13,代码来源:api.php
示例5: run
/**
* @param array $arguments
*/
public function run($arguments)
{
if (!App::isEnabled('search_lucene')) {
return;
}
$app = new Application();
$container = $app->getContainer();
/** @var Logger $logger */
$logger = $container->query('Logger');
if (empty($arguments['user'])) {
$logger->debug('indexer job did not receive user in arguments: ' . json_encode($arguments));
return;
}
$userId = $arguments['user'];
$logger->debug('background job optimizing index for ' . $userId);
$container->query('FileUtility')->setUpIndexFolder($userId);
/** @var Index $index */
$index = $container->query('Index');
/** @var StatusMapper $mapper */
$mapper = $container->query('StatusMapper');
$deletedIds = $mapper->getDeleted();
$count = 0;
foreach ($deletedIds as $fileId) {
$logger->debug('deleting status for (' . $fileId . ') ');
//delete status
$status = new Status($fileId);
$mapper->delete($status);
//delete from lucene
$count += $index->deleteFile($fileId);
}
$logger->debug('removed ' . $count . ' files from index');
}
开发者ID:ntvis,项目名称:search_lucene,代码行数:35,代码来源:deletejob.php
示例6: fopen
/**
* Asynchronously scan data that are written to the file
* @param string $path
* @param string $mode
* @return resource | bool
*/
public function fopen($path, $mode)
{
$stream = $this->storage->fopen($path, $mode);
if (is_resource($stream) && $this->isWritingMode($mode)) {
try {
$scanner = $this->scannerFactory->getScanner();
$scanner->initAsyncScan();
return CallBackWrapper::wrap($stream, null, function ($data) use($scanner) {
$scanner->onAsyncData($data);
}, function () use($scanner, $path) {
$status = $scanner->completeAsyncScan();
if (intval($status->getNumericStatus()) === \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED) {
//prevent from going to trashbin
if (App::isEnabled('files_trashbin')) {
\OCA\Files_Trashbin\Storage::preRenameHook([]);
}
$owner = $this->getOwner($path);
$this->unlink($path);
if (App::isEnabled('files_trashbin')) {
\OCA\Files_Trashbin\Storage::postRenameHook([]);
}
\OC::$server->getActivityManager()->publishActivity('files_antivirus', Activity::SUBJECT_VIRUS_DETECTED, [$path, $status->getDetails()], Activity::MESSAGE_FILE_DELETED, [], $path, '', $owner, Activity::TYPE_VIRUS_DETECTED, Activity::PRIORITY_HIGH);
throw new InvalidContentException($this->l10n->t('Virus %s is detected in the file. Upload cannot be completed.', $status->getDetails()));
}
});
} catch (\Exception $e) {
$message = implode(' ', [__CLASS__, __METHOD__, $e->getMessage()]);
$this->logger->warning($message);
}
}
return $stream;
}
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:38,代码来源:avirwrapper.php
示例7: getAccessList
/**
* get list of users with access to the file
*
* @param string $path to the file
* @return array
*/
public function getAccessList($path)
{
// Make sure that a share key is generated for the owner too
list($owner, $ownerPath) = $this->util->getUidAndFilename($path);
// always add owner to the list of users with access to the file
$userIds = array($owner);
if (!$this->util->isFile($ownerPath)) {
return array('users' => $userIds, 'public' => false);
}
$ownerPath = substr($ownerPath, strlen('/files'));
$ownerPath = $this->util->stripPartialFileExtension($ownerPath);
// Find out who, if anyone, is sharing the file
$result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
$userIds = \array_merge($userIds, $result['users']);
$public = $result['public'] || $result['remote'];
// check if it is a group mount
if (\OCP\App::isEnabled("files_external")) {
$mounts = \OC_Mount_Config::getSystemMountPoints();
foreach ($mounts as $mount) {
if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
$mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
$userIds = array_merge($userIds, $mountedFor);
}
}
}
// Remove duplicate UIDs
$uniqueUserIds = array_unique($userIds);
return array('users' => $uniqueUserIds, 'public' => $public);
}
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:35,代码来源:file.php
示例8: search
/**
* Search for query in calendar events
*
* @param string $query
* @return array list of \OCA\Calendar\Search\Event
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('calendar')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
$objects = \OC_Calendar_Object::all($calendar['id']);
$date = strtotime($query);
// search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-events
if ($object['objecttype'] != 'VEVENT') {
continue;
}
// check the event summary string
if (stripos($object['summary'], $query) !== false) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
// check if the event is happening on a queried date
$range = $this->getDateRange($object);
if ($date && $this->fallsWithin($date, $range)) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
}
}
return $results;
}
开发者ID:yheric455042,项目名称:owncloud82,代码行数:38,代码来源:provider.php
示例9: __construct
public function __construct(array $urlParams = [])
{
parent::__construct('updater', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('UpdateController', function ($c) {
return new UpdateController($c->query('AppName'), $c->query('Request'), $c->query('L10N'));
});
$container->registerService('BackupController', function ($c) {
return new BackupController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
});
$container->registerService('AdminController', function ($c) {
return new AdminController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
});
$container->registerService('L10N', function ($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$container->registerService('Config', function ($c) {
return new Config($c->query('ServerContainer')->getConfig());
});
$container->registerService('Channel', function ($c) {
return new Channel($c->query('L10N'));
});
//Startup
if (\OC_Util::getEditionString() === '') {
\OCP\App::registerAdmin('updater', 'admin');
$appPath = $container->query('Config')->getBackupBase();
if (!@file_exists($appPath)) {
Helper::mkdir($appPath);
}
}
}
开发者ID:amin-hedayati,项目名称:updater,代码行数:34,代码来源:application.php
示例10: deleteUser_hook
/**
* @brief clean up user specific settings if user gets deleted
* @param array with uid
*
* This function is connected to the pre_deleteUser signal of OC_Users
* to remove the used space for versions stored in the database
*/
public static function deleteUser_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
$uid = $params['uid'];
Storage::deleteUser($uid);
}
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:hooks.php
示例11: registerAll
/**
* Registers all config options
*/
public function registerAll()
{
$this->registerNavigation();
$this->registerHooks();
// Fuck it lets just do this quick and dirty until core supports this
Backgroundjob::addRegularTask($this->config['cron']['job'], 'run');
App::registerAdmin($this->config['id'], $this->config['admin']);
}
开发者ID:rafalwojciechowski,项目名称:news,代码行数:11,代码来源:appconfig.php
示例12: run
public static function run()
{
if (!\OCP\App::isEnabled('files_antivirus')) {
return;
}
$application = new Application();
$container = $application->getContainer();
$container->query('BackgroundScanner')->run();
}
开发者ID:amin-hedayati,项目名称:files_antivirus,代码行数:9,代码来源:task.php
示例13: rename_hook
/**
* rename/move versions of renamed/moved files
* @param array $params array with oldpath and newpath
*
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
* of the stored versions along the actual file
*/
public static function rename_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
$oldpath = $params['oldpath'];
$newpath = $params['newpath'];
if ($oldpath != '' && $newpath != '') {
Storage::rename($oldpath, $newpath);
}
}
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:17,代码来源:hooks.php
示例14: getAppInfo
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function getAppInfo($parameters)
{
$app = $parameters['appid'];
$info = \OCP\App::getAppInfo($app);
if (!is_null($info)) {
return new OC_OCS_Result(OC_App::getAppInfo($app));
} else {
return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The request app was not found');
}
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:14,代码来源:apps.php
示例15: getlayer
/**
* Get an layer
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getlayer()
{
$layer = $this->params('layer') ? $this->params('layer') : null;
if ($layer === "contacts") {
if (\OCP\App::isEnabled('contacts')) {
} else {
OCP\Util::writeLog('maps', "App contacts missing for Maps", \OCP\Util::WARN);
}
}
}
开发者ID:evaluation-alex,项目名称:maps,代码行数:15,代码来源:pagecontroller.php
示例16: run
/**
* @param array $arguments
*/
public function run($arguments)
{
if ((\OCP\App::isEnabled('contacts') || \OCP\App::isEnabled('contactsplus')) && \OCP\App::isEnabled('fbsync')) {
$cache = \OC::$server->getCache();
$cache->set("test", "test");
} else {
\OCP\Util::writeLog('fbsync', "App not enabled", \OCP\Util::INFO);
return;
}
}
开发者ID:skjnldsv,项目名称:Owncloud-FBSync,代码行数:13,代码来源:jobs.php
示例17: setup
public function setup()
{
App::checkAppEnabled('files_locking');
OC_User::clearBackends();
OC_User::useBackend(new OC_User_Dummy());
// Login
OC_User::createUser('test', 'test');
$this->user = OC_User::getUser();
OC_User::setUserId('test');
$this->storage = $this->getTestStorage();
}
开发者ID:AdamWill,项目名称:apps,代码行数:11,代码来源:LockingWrapperTest.php
示例18: getUidAndFilename
private static function getUidAndFilename($filename)
{
if (\OCP\App::isEnabled('files_sharing') && substr($filename, 0, 7) == '/Shared' && ($source = \OCP\Share::getItemSharedWith('file', substr($filename, 7), \OC_Share_Backend_File::FORMAT_SHARED_STORAGE))) {
$filename = $source['path'];
$pos = strpos($filename, '/files', 1);
$uid = substr($filename, 1, $pos - 1);
$filename = substr($filename, $pos + 6);
} else {
$uid = \OCP\User::getUser();
}
return array($uid, $filename);
}
开发者ID:ryanshoover,项目名称:core,代码行数:12,代码来源:versions.php
示例19: init
public static function init()
{
self::$l10n = \OCP\Util::getL10N(self::APP_ID);
\OC::$CLASSPATH['OCA\\Updater\\Backup'] = self::APP_ID . '/lib/backup.php';
\OC::$CLASSPATH['OCA\\Updater\\Downloader'] = self::APP_ID . '/lib/downloader.php';
\OC::$CLASSPATH['OCA\\Updater\\Updater'] = self::APP_ID . '/lib/updater.php';
\OC::$CLASSPATH['OCA\\Updater\\Helper'] = self::APP_ID . '/lib/helper.php';
\OC::$CLASSPATH['OCA\\Updater\\Location'] = self::APP_ID . '/lib/location.php';
\OC::$CLASSPATH['OCA\\Updater\\Location_3rdparty'] = self::APP_ID . '/lib/location/3rdparty.php';
\OC::$CLASSPATH['OCA\\Updater\\Location_Apps'] = self::APP_ID . '/lib/location/apps.php';
\OC::$CLASSPATH['OCA\\Updater\\Location_Core'] = self::APP_ID . '/lib/location/core.php';
//Allow config page
\OCP\App::registerAdmin(self::APP_ID, 'admin');
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:14,代码来源:app.php
示例20: check
public static function check()
{
if (!\OCP\App::isEnabled('files_antivirus')) {
return;
}
// get mimetype code for directory
$query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
$result = $query->execute(array('httpd/unix-directory'));
if ($row = $result->fetchRow()) {
$dir_mimetype = $row['id'];
} else {
$dir_mimetype = 0;
}
// locate files that are not checked yet
$sql = 'SELECT `*PREFIX*filecache`.`fileid`, `path`, `*PREFIX*storages`.`id`' . ' FROM `*PREFIX*filecache`' . ' LEFT JOIN `*PREFIX*files_antivirus` ON `*PREFIX*files_antivirus`.`fileid` = `*PREFIX*filecache`.`fileid`' . ' JOIN `*PREFIX*storages` ON `*PREFIX*storages`.`numeric_id` = `*PREFIX*filecache`.`storage`' . ' WHERE `mimetype` != ?' . ' AND (`*PREFIX*storages`.`id` LIKE ? OR `*PREFIX*storages`.`id` LIKE ?)' . ' AND (`*PREFIX*files_antivirus`.`fileid` IS NULL OR `mtime` > `check_time`)' . ' AND `path` LIKE ?';
$stmt = \OCP\DB::prepare($sql, 5);
try {
$result = $stmt->execute(array($dir_mimetype, 'local::%', 'home::%', 'files/%'));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('files_antivirus', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return;
}
} catch (\Exception $e) {
\OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return;
}
$serverContainer = \OC::$server;
/** @var $serverContainer \OCP\IServerContainer */
$root = $serverContainer->getRootFolder();
// scan the found files
while ($row = $result->fetchRow()) {
$file = $root->getById($row['fileid']);
// this should always work ...
if (!empty($file)) {
$file = $file[0];
$storage = $file->getStorage();
$path = $file->getInternalPath();
self::scan($file->getId(), $path, $storage);
} else {
// ... but sometimes it doesn't, try to get the storage
$storage = self::getStorage($serverContainer, $row['id']);
if ($storage !== null && $storage->is_dir('')) {
self::scan($row['fileid'], $row['path'], $storage);
} else {
\OCP\Util::writeLog('files_antivirus', 'Can\'t get \\OCP\\Files\\File for id "' . $row['fileid'] . '"', \OCP\Util::ERROR);
}
}
}
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:49,代码来源:backgroundscanner.php
注:本文中的OCP\App类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论