本文整理汇总了PHP中OCP\App::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP App::isEnabled方法的具体用法?PHP App::isEnabled怎么用?PHP App::isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\App
的用法示例。
在下文中一共展示了App::isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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');
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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;
}
示例8: run
public static function run()
{
if (!\OCP\App::isEnabled('files_antivirus')) {
return;
}
$application = new Application();
$container = $application->getContainer();
$container->query('BackgroundScanner')->run();
}
示例9: 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);
}
}
}
示例10: 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);
}
}
}
示例11: 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;
}
}
示例12: 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);
}
示例13: search
/**
* Search for query in tasks
*
* @param string $query
* @return array list of \OCA\Tasks\Controller\Task
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OC::$server->getUserSession()->getUser()->getUID(), true);
$user_timezone = \OC_Calendar_App::getTimezone();
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
// $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
$objects = \OC_Calendar_Object::all($calendar['id']);
// $date = strtotime($query);
// // search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-todos
if ($object['objecttype'] != 'VTODO') {
continue;
}
if (!($vtodo = Helper::parseVTODO($object))) {
continue;
}
$id = $object['id'];
$calendarId = $object['calendarid'];
// check these properties
$properties = array('SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES');
foreach ($properties as $property) {
$string = $vtodo->{$property};
if (stripos($string, $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
$comments = $vtodo->COMMENT;
if ($comments) {
foreach ($comments as $com) {
if (stripos($com->getValue(), $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
}
}
}
usort($results, array($this, 'sort_completed'));
return $results;
}
示例14: 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);
}
}
}
}
示例15: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* Shows the albums and pictures at the root folder or a message if
* there are no pictures.
*
* This is the entry page for logged-in users accessing the app from
* within ownCloud.
* A TemplateResponse response uses a template from the templates folder
* and parameters provided here to build the page users will see
*
* @return TemplateResponse
*/
public function index()
{
$appName = $this->appName;
if (\OCP\App::isEnabled('gallery')) {
$url = $this->urlGenerator->linkToRoute($appName . '.page.error_page', ['message' => "You need to disable the Pictures app before being able to use the Gallery+ app", 'code' => Http::STATUS_INTERNAL_SERVER_ERROR]);
return new RedirectResponse($url);
} else {
// Parameters sent to the template
$params = ['appName' => $appName];
// Will render the page using the template found in templates/index.php
$response = new TemplateResponse($appName, 'index', $params);
$this->addContentSecurityToResponse($response);
return $response;
}
}