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


PHP OCP\Util类代码示例

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


在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTasks

 /**
  * @NoAdminRequired
  */
 public function getTasks()
 {
     $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
     $user_timezone = \OC_Calendar_App::getTimezone();
     $tasks = array();
     foreach ($calendars as $calendar) {
         $calendar_tasks = \OC_Calendar_Object::all($calendar['id']);
         foreach ($calendar_tasks as $task) {
             if ($task['objecttype'] != 'VTODO') {
                 continue;
             }
             if (is_null($task['summary'])) {
                 continue;
             }
             $vtodo = Helper::parseVTODO($task['calendardata']);
             try {
                 $task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone);
                 $task_data['calendarid'] = $calendar['id'];
                 $task_data['calendarcolor'] = $calendar['calendarcolor'];
                 $tasks[] = $task_data;
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
             }
         }
     }
     $result = array('data' => array('tasks' => $tasks));
     $response = new JSONResponse();
     $response->setData($result);
     return $response;
 }
开发者ID:msbt,项目名称:tasks,代码行数:33,代码来源:taskscontroller.php

示例2: getCalenderSources

 public static function getCalenderSources($parameters)
 {
     $base_url = \OCP\Util::linkTo('calendar', 'ajax/events.php') . '?calendar_id=';
     foreach (Addressbook::all(\OCP\USER::getUser()) as $addressbook) {
         $parameters['sources'][] = array('url' => $base_url . 'birthday_' . $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', 'textColor' => 'black', 'cache' => true, 'editable' => false);
     }
 }
开发者ID:netcon-source,项目名称:apps,代码行数:7,代码来源:hooks.php

示例3: setup

 public function setup()
 {
     Util::connectHook('OC_User', 'post_createUser', $this, 'postCreateUser');
     Util::connectHook('OC_User', 'pre_deleteUser', $this, 'preDeleteUser');
     Util::connectHook('OC_User', 'post_deleteUser', $this, 'postDeleteUser');
     Util::connectHook('OC_User', 'changeUser', $this, 'changeUser');
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:7,代码来源:hookmanager.php

示例4: __construct

 public function __construct(IL10N $l, ISession $session, ICrypto $crypto)
 {
     $this->session = $session;
     $this->crypto = $crypto;
     $this->setIdentifier('password::sessioncredentials')->setScheme(self::SCHEME_PASSWORD)->setText($l->t('Session credentials'))->addParameters([]);
     \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
 }
开发者ID:kenwi,项目名称:core,代码行数:7,代码来源:sessioncredentials.php

示例5: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // enable resharing
     \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create users
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:28,代码来源:share.php

示例6: get_realm

 public static function get_realm()
 {
     $appConfig = \OC::$server->getAppConfig();
     $result = $appConfig->getValue('privacyIDEA', 'realm', '');
     \OCP\Util::writeLog('user_privacyidea', "Getting result for realm: {$result}", \OCP\Util::DEBUG);
     return $result;
 }
开发者ID:vDorst,项目名称:privacyidea,代码行数:7,代码来源:helper.php

示例7: __construct

 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = \OCP\Util::getVersion();
     $this->defaultEntity = 'ownCloud';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = 'ownCloud';
     /* short name, used when referring to the software */
     $this->defaultTitle = 'ownCloud';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = 'https://owncloud.org';
     $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
     $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
     $this->defaultiTunesAppId = '543672169';
     $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
     $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.' . $version[1];
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('web services under your control');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
     if (file_exists($themePath)) {
         // prevent defaults.php from printing output
         ob_start();
         require_once $themePath;
         ob_end_clean();
         if (class_exists('OC_Theme')) {
             $this->theme = new OC_Theme();
         }
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:33,代码来源:defaults.php

示例8: __construct

 /**
  * @param array $urlParams
  */
 public function __construct(array $urlParams = array())
 {
     parent::__construct('settings', $urlParams);
     $container = $this->getContainer();
     /**
      * Controllers
      */
     $container->registerService('MailSettingsController', function (SimpleContainer $c) {
         return new MailSettingsController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('Config'), $c->query('UserSession'), $c->query('Defaults'), $c->query('Mail'), $c->query('DefaultMailAddress'));
     });
     /**
      * Core class wrappers
      */
     $container->registerService('Config', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getConfig();
     });
     $container->registerService('L10N', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getL10N('settings');
     });
     $container->registerService('UserSession', function (SimpleContainer $c) {
         return $c->query('ServerContainer')->getUserSession();
     });
     $container->registerService('Mail', function (SimpleContainer $c) {
         return new \OC_Mail();
     });
     $container->registerService('Defaults', function (SimpleContainer $c) {
         return new \OC_Defaults();
     });
     $container->registerService('DefaultMailAddress', function (SimpleContainer $c) {
         return Util::getDefaultEmailAddress('no-reply');
     });
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:35,代码来源:application.php

示例9: sendMail

 public static function sendMail($path)
 {
     if (!\OCP\User::isLoggedIn()) {
         return;
     }
     $config = \OC::$server->getConfig();
     $user = \OC::$server->getUserSession()->getUser();
     $email = $user->getEMailAddress();
     $displayName = $user->getDisplayName();
     if (strval($displayName) === '') {
         $displayName = $user->getUID();
     }
     \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
     if (!empty($email)) {
         try {
             $tmpl = new \OCP\Template('files_antivirus', 'notification');
             $tmpl->assign('file', $path);
             $tmpl->assign('host', \OC::$server->getRequest()->getServerHost());
             $tmpl->assign('user', $displayName);
             $msg = $tmpl->fetchPage();
             $from = \OCP\Util::getDefaultEmailAddress('security-noreply');
             $mailer = \OC::$server->getMailer();
             $message = $mailer->createMessage();
             $message->setSubject(\OCP\Util::getL10N('files_antivirus')->t('Malware detected'));
             $message->setFrom([$from => 'ownCloud Notifier']);
             $message->setTo([$email => $displayName]);
             $message->setPlainBody($msg);
             $message->setHtmlBody($msg);
             $mailer->send($message);
         } catch (\Exception $e) {
             \OC::$server->getLogger()->error(__METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']);
         }
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:34,代码来源:notification.php

示例10: index

	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 */
	public function index() {
		\OC::$server->getNavigationManager()->setActiveEntry($this->appName);

		$importManager = new ImportManager();
		$imppTypes = Properties::getTypesForProperty('IMPP');
		$adrTypes = Properties::getTypesForProperty('ADR');
		$phoneTypes = Properties::getTypesForProperty('TEL');
		$emailTypes = Properties::getTypesForProperty('EMAIL');
		$ims = Properties::getIMOptions();
		$imProtocols = array();
		foreach($ims as $name => $values) {
			$imProtocols[$name] = $values['displayname'];
		}

		$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');

		$response = new TemplateResponse($this->appName, 'contacts');
		$response->setParams(array(
			'uploadMaxFilesize' => $maxUploadFilesize,
			'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
			'phoneTypes' => $phoneTypes,
			'emailTypes' => $emailTypes,
			'adrTypes' => $adrTypes,
			'imppTypes' => $imppTypes,
			'imProtocols' => $imProtocols,
			'importManager' => $importManager,
		));

		return $response;
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:34,代码来源:pagecontroller.php

示例11: logException

 /**
  * Log exception
  *
  * @internal param Exception $e exception
  */
 public function logException($e)
 {
     $exceptionClass = get_class($e);
     if ($exceptionClass !== 'Sabre_DAV_Exception_NotAuthenticated') {
         \OCP\Util::logException($this->appName, $e);
     }
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:12,代码来源:exceptionloggerplugin.php

示例12: testGetTypeIcon

 /**
  * @dataProvider getTypeIconData
  */
 public function testGetTypeIcon($type, $expected)
 {
     $manager = $this->getMock('\\OCP\\Activity\\IManager');
     $manager->expects($this->any())->method('getTypeIcon')->willReturn('');
     $dataHelper = new DataHelper($manager, new ParameterHelper($manager, new View(''), $this->getMockBuilder('OCP\\IConfig')->disableOriginalConstructor()->getMock(), Util::getL10N('activity')), Util::getL10N('activity'));
     $this->assertEquals($expected, $dataHelper->getTypeIcon($type));
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:10,代码来源:datahelpertest.php

示例13: register

 public function register()
 {
     $loginRecord = function ($user) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:login success", Util::INFO);
     };
     $logoutRecord = function () {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $this->UserRole . " action:logout success", Util::INFO);
     };
     $createRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
     };
     $deleteRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
     };
     $renameRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
     };
     $touchRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
     };
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
     $this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
     $this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
 }
开发者ID:inwinstack,项目名称:owncloud-activity_logging,代码行数:33,代码来源:userhooks.php

示例14: format

 /**
  * @param IEvent $event
  * @param string $parameter The parameter to be formatted
  * @return string The formatted parameter
  */
 public function format(IEvent $event, $parameter)
 {
     $param = $this->fixLegacyFilename($parameter);
     // If the activity is about the very same file, we use the current path
     // for the link generation instead of the one that was saved.
     $fileId = '';
     if (is_array($param)) {
         $fileId = key($param);
         $param = $param[$fileId];
         $info = $this->infoCache->getInfoById($this->user, $fileId, $param);
     } elseif ($event->getObjectType() === 'files' && $event->getObjectName() === $param) {
         $fileId = $event->getObjectId();
         $info = $this->infoCache->getInfoById($this->user, $fileId, $param);
     } else {
         $info = $this->infoCache->getInfoByPath($this->user, $param);
     }
     if ($info['is_dir']) {
         $linkData = ['dir' => $info['path']];
     } else {
         $parentDir = substr_count($info['path'], '/') === 1 ? '/' : dirname($info['path']);
         $fileName = basename($info['path']);
         $linkData = ['dir' => $parentDir, 'scrollto' => $fileName];
     }
     if ($info['view'] !== '') {
         $linkData['view'] = $info['view'];
     }
     $param = trim($param, '/');
     $fileLink = $this->urlGenerator->linkToRouteAbsolute('files.view.index', $linkData);
     return '<file link="' . $fileLink . '" id="' . Util::sanitizeHTML($fileId) . '">' . Util::sanitizeHTML($param) . '</file>';
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:35,代码来源:FileFormatter.php

示例15: testTranslation

 /**
  * @dataProvider translationData
  */
 public function testTranslation($text, $params, $stripPath, $highlightParams, $expected)
 {
     $config = $this->getMockBuilder('OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getSystemValue')->with('enable_avatars', true)->willReturn(true);
     $dataHelper = new \OCA\Activity\DataHelper($this->getMock('\\OCP\\Activity\\IManager'), new \OCA\Activity\ParameterHelper(new \OC\Files\View(''), $config, \OCP\Util::getL10N('activity')), \OCP\Util::getL10N('activity'));
     $this->assertEquals($expected, (string) $dataHelper->translation('files', $text, $params, $stripPath, $highlightParams));
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:10,代码来源:datahelpertest.php


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