本文整理汇总了PHP中OCP\App类的典型用法代码示例。如果您正苦于以下问题:PHP App类的具体用法?PHP App怎么用?PHP App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了App类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例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);
}
}
示例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;
}
示例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);
}
示例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');
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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']);
}
示例12: run
public static function run()
{
if (!\OCP\App::isEnabled('files_antivirus')) {
return;
}
$application = new Application();
$container = $application->getContainer();
$container->query('BackgroundScanner')->run();
}
示例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);
}
}
}
示例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');
}
}
示例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);
}
}
}