本文整理汇总了PHP中OC_Defaults::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Defaults::getName方法的具体用法?PHP OC_Defaults::getName怎么用?PHP OC_Defaults::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Defaults
的用法示例。
在下文中一共展示了OC_Defaults::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendEmail
public static function sendEmail($args)
{
$isEncrypted = \OC_App::isEnabled('files_encryption');
if (!$isEncrypted || isset($_POST['continue'])) {
$continue = true;
} else {
$continue = false;
}
if (\OC_User::userExists($_POST['user']) && $continue) {
$token = hash('sha256', \OC_Util::generateRandomBytes(30) . \OC_Config::getValue('passwordsalt', ''));
\OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
// Hash the token again to prevent timing attacks
$email = \OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {
$link = \OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
$link = \OC_Helper::makeURLAbsolute($link);
$tmpl = new \OC_Template('core/lostpassword', 'email');
$tmpl->assign('link', $link, false);
$msg = $tmpl->fetchPage();
$l = \OC_L10N::get('core');
$from = \OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
try {
$defaults = new \OC_Defaults();
\OC_Mail::send($email, $_POST['user'], $l->t('%s password reset', array($defaults->getName())), $msg, $from, $defaults->getName());
} catch (Exception $e) {
\OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
}
self::displayLostPasswordPage(false, true);
} else {
self::displayLostPasswordPage(true, false);
}
} else {
self::displayLostPasswordPage(true, false);
}
}
示例2: getSystemInfo
/**
* Gathers system information like database type and does
* a few system checks.
*
* @return array of system info, including an "errors" value
* in case of errors/warnings
*/
public function getSystemInfo($allowAllDatabases = false)
{
$databases = $this->getSupportedDatabases($allowAllDatabases);
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$errors = array();
// Create data directory to test whether the .htaccess works
// Notice that this is not necessarily the same data directory as the one
// that will effectively be used.
@mkdir($dataDir);
$htAccessWorking = true;
if (is_dir($dataDir) && is_writable($dataDir)) {
// Protect data directory here, so we can test if the protection is working
\OC\Setup::protectDataDirectory();
try {
$util = new \OC_Util();
$htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig());
} catch (\OC\HintException $e) {
$errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
$htAccessWorking = false;
}
}
if (\OC_Util::runningOnMac()) {
$errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
}
if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
$errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4 GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.'));
}
return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'errors' => $errors);
}
示例3: create
/**
* @NoAdminRequired
*
* @param string $username
* @param string $password
* @param array $groups
* @param string $email
* @return DataResponse
*/
public function create($username, $password, array $groups = array(), $email = '')
{
if ($email !== '' && !$this->mail->validateAddress($email)) {
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mail address')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$this->isAdmin) {
$userId = $this->userSession->getUser()->getUID();
if (!empty($groups)) {
foreach ($groups as $key => $group) {
if (!$this->subAdminFactory->isGroupAccessible($userId, $group)) {
unset($groups[$key]);
}
}
}
if (empty($groups)) {
$groups = $this->subAdminFactory->getSubAdminsOfGroups($userId);
}
}
if ($this->userManager->userExists($username)) {
return new DataResponse(array('message' => (string) $this->l10n->t('A user with that name already exists.')), Http::STATUS_CONFLICT);
}
try {
$user = $this->userManager->createUser($username, $password);
} catch (\Exception $exception) {
return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
}
if ($user instanceof User) {
if ($groups !== null) {
foreach ($groups as $groupName) {
$group = $this->groupManager->get($groupName);
if (empty($group)) {
$group = $this->groupManager->createGroup($groupName);
}
$group->addUser($user);
}
}
/**
* Send new user mail only if a mail is set
*/
if ($email !== '') {
$this->config->setUserValue($username, 'settings', 'email', $email);
// data for the mail template
$mailData = array('username' => $username, 'url' => $this->urlGenerator->getAbsoluteURL('/'));
$mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
$mailContent = $mail->render();
$mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
$plainTextMailContent = $mail->render();
$subject = $this->l10n->t('Your %s account was created', [$this->defaults->getName()]);
try {
$this->mail->send($email, $username, $subject, $mailContent, $this->fromMailAddress, $this->defaults->getName(), 1, $plainTextMailContent);
} catch (\Exception $e) {
$this->log->error("Can't send new user mail to {$email}: " . $e->getMessage(), array('app' => 'settings'));
}
}
// fetch users groups
$userGroups = $this->groupManager->getUserGroupIds($user);
return new DataResponse($this->formatUserForIndex($user, $userGroups), Http::STATUS_CREATED);
}
return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
}
示例4: sendEmail
protected function sendEmail($user, $proceed)
{
if ($this->isDataEncrypted && !$proceed) {
throw new EncryptedDataException();
}
if (!$this->userManager->userExists($user)) {
throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure ' . 'your username is correct.'));
}
$token = hash('sha256', \OC_Util::generateRandomBytes(30));
// Hash the token again to prevent timing attacks
$this->config->setUserValue($user, 'owncloud', 'lostpassword', hash('sha256', $token));
$email = $this->config->getUserValue($user, 'settings', 'email');
if (empty($email)) {
throw new \Exception($this->l10n->t('Couldn\'t send reset email because there is no ' . 'email address for this username. Please ' . 'contact your administrator.'));
}
$link = $this->getLink('core.lost.resetform', $user, $token);
$tmpl = new \OC_Template('core/lostpassword', 'email');
$tmpl->assign('link', $link, false);
$msg = $tmpl->fetchPage();
try {
// FIXME: should be added to the container and injected in here
\OC_Mail::send($email, $user, $this->l10n->t('%s password reset', array($this->defaults->getName())), $msg, $this->from, $this->defaults->getName());
} catch (\Exception $e) {
throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
}
}
示例5: __construct
/**
* FedAuth constructor.
*
* @param DbHandler $db
*/
public function __construct(DbHandler $db)
{
$this->db = $db;
$this->principalPrefix = 'principals/system/';
// setup realm
$defaults = new \OC_Defaults();
$this->realm = $defaults->getName();
}
示例6: __construct
/**
* @param IRequest $request
* @param IManager $shareManager
* @param ISession $session
*/
public function __construct(IRequest $request, IManager $shareManager, ISession $session)
{
$this->request = $request;
$this->shareManager = $shareManager;
$this->session = $session;
// setup realm
$defaults = new \OC_Defaults();
$this->realm = $defaults->getName();
}
示例7: __construct
/**
* @param ISession $session
* @param Session $userSession
* @param IRequest $request
* @param Manager $twoFactorManager
* @param string $principalPrefix
*/
public function __construct(ISession $session, Session $userSession, IRequest $request, Manager $twoFactorManager, $principalPrefix = 'principals/users/')
{
$this->session = $session;
$this->userSession = $userSession;
$this->twoFactorManager = $twoFactorManager;
$this->request = $request;
$this->principalPrefix = $principalPrefix;
// setup realm
$defaults = new \OC_Defaults();
$this->realm = $defaults->getName();
}
示例8: sendTestMail
/**
* Send a mail to test the settings
* @return array
*/
public function sendTestMail()
{
$email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
if (!empty($email)) {
try {
$this->mail->send($email, $this->userSession->getUser()->getDisplayName(), $this->l10n->t('test email settings'), $this->l10n->t('If you received this email, the settings seem to be correct.'), $this->defaultMailAddress, $this->defaults->getName());
} catch (\Exception $e) {
return array('data' => array('message' => (string) $this->l10n->t('A problem occurred while sending the email. Please revise your settings.')), 'status' => 'error');
}
return array('data' => array('message' => (string) $this->l10n->t('Email sent')), 'status' => 'success');
}
return array('data' => array('message' => (string) $this->l10n->t('You need to set your user email before being able to send test emails.')), 'status' => 'error');
}
示例9: send
/**
* Send the specified message. Also sets the from address to the value defined in config.php
* if no-one has been passed.
*
* @param Message $message Message to send
* @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
* therefore should be considered
* @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
* has been supplied.)
*/
public function send(Message $message)
{
$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
if (sizeof($message->getFrom()) === 0) {
$message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName())]);
}
$failedRecipients = [];
$mailer = $this->getInstance();
// Enable logger if debug mode is enabled
if ($debugMode) {
$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
}
$mailer->send($message->getSwiftMessage(), $failedRecipients);
// Debugging logging
$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
$this->logger->debug($logMessage, ['app' => 'core']);
if ($debugMode && isset($mailLogger)) {
$this->logger->debug($mailLogger->dump(), ['app' => 'core']);
}
return $failedRecipients;
}
示例10: authenticateUser
/**
* @brief Authenticate user by HTTP Basic Authentication
* with user name and password
*/
public static function authenticateUser()
{
if (!isset($_SERVER['PHP_AUTH_USER'])) {
$defaults = new \OC_Defaults();
$realm = $defaults->getName();
header("HTTP/1.0 401 Unauthorized");
header('WWW-Authenticate: Basic realm="' . $realm . '"');
exit;
}
$userName = $_SERVER['PHP_AUTH_USER'];
// Check the password in the ownCloud database
return self::checkPassword($userName, $_SERVER['PHP_AUTH_PW']);
}
示例11: createServer
/**
* @param string $baseUri
* @param string $requestUri
* @param BackendInterface $authBackend
* @param callable $viewCallBack callback that should return the view for the dav endpoint
* @return Server
*/
public function createServer($baseUri, $requestUri, BackendInterface $authBackend, callable $viewCallBack)
{
// Fire up server
$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
// Set URL explicitly due to reverse-proxy situations
$server->httpRequest->setUrl($requestUri);
$server->setBaseUri($baseUri);
// Load plugins
$defaults = new \OC_Defaults();
$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
$server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
$server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin($objectTree));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\ListenerPlugin($this->dispatcher));
// wait with registering these until auth is handled and the filesystem is setup
$server->on('beforeMethod', function () use($server, $objectTree, $viewCallBack) {
// ensure the skeleton is copied
\OC::$server->getUserFolder();
/** @var \OC\Files\View $view */
$view = $viewCallBack();
$rootInfo = $view->getFileInfo('');
// Create ownCloud Dir
if ($rootInfo->getType() === 'dir') {
$root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo);
} else {
$root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
}
$objectTree->init($root, $view, $this->mountManager);
$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
if ($this->userSession->isLoggedIn()) {
$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
// custom properties plugin must be the last one
$server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend($objectTree, $this->databaseConnection, $this->userSession->getUser())));
}
$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
}, 30);
// priority 30: after auth (10) and acl(20), before lock(50) and handling the request
return $server;
}
示例12: sendNewUserNotifEmail
/**
* Sends new user notification email to admin
* @param array $to
* @param string $username the new user
* @return null
* @throws \Exception
*/
private function sendNewUserNotifEmail(array $to, string $username)
{
$template_var = ['user' => $username, 'sitename' => $this->defaults->getName()];
$html_template = new TemplateResponse('registration', 'email.newuser_html', $template_var, 'blank');
$html_part = $html_template->render();
$plaintext_template = new TemplateResponse('registration', 'email.newuser_plaintext', $template_var, 'blank');
$plaintext_part = $plaintext_template->render();
$subject = $this->l10n->t('A new user "%s" had created an account on %s', [$username, $this->defaults->getName()]);
$from = Util::getDefaultEmailAddress('register');
$message = $this->mailer->createMessage();
$message->setFrom([$from => $this->defaults->getName()]);
$message->setTo($to);
$message->setSubject($subject);
$message->setPlainBody($plaintext_part);
$message->setHtmlBody($html_part);
$failed_recipients = $this->mailer->send($message);
if (!empty($failed_recipients)) {
throw new \Exception('Failed recipients: ' . print_r($failed_recipients, true));
}
}
示例13: sendTestMail
/**
* Send a mail to test the settings
*/
public static function sendTestMail()
{
\OC_Util::checkAdminUser();
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
$email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
if (!empty($email)) {
$defaults = new \OC_Defaults();
try {
\OC_Mail::send($email, \OC_User::getDisplayName(), $l->t('test email settings'), $l->t('If you received this email, the settings seem to be correct.'), \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
} catch (\Exception $e) {
$message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
\OC_JSON::error(array("data" => array("message" => $message)));
exit;
}
\OC_JSON::success(array("data" => array("message" => $l->t("Email sent"))));
} else {
$message = $l->t('You need to set your user email before being able to send test emails.');
\OC_JSON::error(array("data" => array("message" => $message)));
}
}
示例14: serveFeed
/**
* @brief serve opds feed for given directory
*
* @param string $dir full path to directory
* @param int $id requested id
*/
public static function serveFeed($dir, $id)
{
if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
header('Content-Type: application/atom+xml');
} else {
header('Content-Type: text/xml; charset=UTF-8');
}
$sortAttribute = 'name';
$sortDirection = false;
$defaults = new \OC_Defaults();
$tmpl = new \OCP\Template('files_opds', 'feed');
$tmpl->assign('files', Files::formatFileInfos(Files::getFiles($dir, $sortAttribute, $sortDirection)));
$tmpl->assign('bookshelf', Files::formatFileInfos(Bookshelf::get()));
$tmpl->assign('bookshelf-count', Bookshelf::count());
$tmpl->assign('feed_id', self::getFeedId());
$tmpl->assign('id', $id);
$tmpl->assign('dir', $dir);
$tmpl->assign('user', \OCP\User::getDisplayName());
$tmpl->assign('feed_title', Config::get('feed_title', \OCP\User::getDisplayName() . "'s Library"));
$tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
$tmpl->assign('feed_updated', time());
$tmpl->printPage();
}
示例15: getSystemInfo
/**
* Gathers system information like database type and does
* a few system checks.
*
* @return array of system info, including an "errors" value
* in case of errors/warnings
*/
public function getSystemInfo()
{
$setup = new \OC_Setup($this->config);
$databases = $setup->getSupportedDatabases();
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$vulnerableToNullByte = false;
if (@file_exists(__FILE__ . "Nullbyte")) {
// Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
$vulnerableToNullByte = true;
}
$errors = array();
// Create data directory to test whether the .htaccess works
// Notice that this is not necessarily the same data directory as the one
// that will effectively be used.
@mkdir($dataDir);
$htAccessWorking = true;
if (is_dir($dataDir) && is_writable($dataDir)) {
// Protect data directory here, so we can test if the protection is working
\OC_Setup::protectDataDirectory();
try {
$htAccessWorking = \OC_Util::isHtaccessWorking();
} catch (\OC\HintException $e) {
$errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
$htAccessWorking = false;
}
}
if (\OC_Util::runningOnMac()) {
$errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
}
if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
$errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64bit PHP.'));
}
if (!function_exists('curl_init') && PHP_INT_SIZE === 4) {
$errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and cURL is not installed. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.'));
}
return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'hasMSSQL' => isset($databases['mssql']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors);
}