本文整理汇总了PHP中OCP\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* @NoAdminRequired
*/
public function set()
{
\OCP\Config::setUserValue($this->api->getUserId(), 'tasks_enhanced', $this->params('type') . '_' . $this->params('setting'), $this->params('value'));
$response = new JSONResponse();
$response->setData();
return $response;
}
示例2: getGroups
/**
* @NoAdminRequired
*/
public function getGroups() {
$tags = $this->tags->getTags();
foreach ($tags as &$tag) {
try {
$ids = $this->tags->getIdsForTag($tag['id']);
$tag['contacts'] = $ids;
$tag['displayname'] = $this->displayName($tag);
} catch(\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $e->getMessage(), \OCP\Util::ERROR);
}
}
$favorites = $this->tags->getFavorites();
$shares = \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
$addressbookShare = new \OCA\Contacts\Share\Addressbook();
foreach ($shares as $key => $share) {
$children = $addressbookShare->getChildren($share['id']); // FIXME: This should be cheaper!
$shares[$key]['length'] = count($children);
}
$groups = array(
'categories' => $tags,
'favorites' => $favorites,
'shared' => $shares,
'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'),
'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''),
);
return new JSONResponse($groups);
}
示例3: getShortFooter
public function getShortFooter()
{
$baseUrl = "<a href=\"" . $this->getBaseUrl() . "\" target=\"_blank\">" . $this->getEntity() . "</a>";
$slogan = $this->getSlogan();
// === GTU
$cguUrl = '';
if (OC_APP::isEnabled('gtu')) {
$cguUrl = \OCP\Config::getAppvalue('gtu', 'url', '');
}
if (empty($cguUrl)) {
$cguUrl = \OCP\Config::getSystemvalue('custom_termsofserviceurl', '');
}
$cgu = '';
if (!empty($cguUrl)) {
$cgu = '<a href="' . $cguUrl . '" target="_blank">CGU</a>';
}
// === Help
$helpUrl = '';
if (empty($helpUrl)) {
$helpUrl = $this->getHelpUrl();
}
$help = '';
if (!empty($helpUrl)) {
$help = '<a href="' . $helpUrl . '" target="_blank">Aide</a>';
}
// === contact
$contact = ' – ' . '<a href="http://ods.cnrs.fr/contacts.html" target="_blank">Contacts</a>';
// =========================
$footer = $baseUrl . ' – ' . $slogan . ' – ' . $cgu . ' – ' . $help . $contact;
return $footer;
}
示例4: __construct
public function __construct($AppName, IRequest $Request, $CurrentUID, IL10N $L10N)
{
parent::__construct($AppName, $Request);
if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
$this->DbType = 1;
}
$this->CurrentUID = $CurrentUID;
$Settings = new Settings();
$Settings->SetKey('ProxyAddress');
$this->ProxyAddress = $Settings->GetValue();
$Settings->SetKey('ProxyPort');
$this->ProxyPort = intval($Settings->GetValue());
$Settings->SetKey('ProxyUser');
$this->ProxyUser = $Settings->GetValue();
$Settings->SetKey('ProxyPasswd');
$this->ProxyPasswd = $Settings->GetValue();
$Settings->SetKey('ProxyOnlyWithYTDL');
$this->ProxyOnlyWithYTDL = $Settings->GetValue();
$this->ProxyOnlyWithYTDL = is_null($this->ProxyOnlyWithYTDL) ? false : strcmp($this->ProxyOnlyWithYTDL, 'Y') == 0;
$Settings->SetKey('WhichDownloader');
$this->WhichDownloader = $Settings->GetValue();
$this->WhichDownloader = is_null($this->WhichDownloader) ? 0 : (strcmp($this->WhichDownloader, 'ARIA2') == 0 ? 0 : 1);
// 0 means ARIA2, 1 means CURL
$Settings->SetTable('personal');
$Settings->SetUID($this->CurrentUID);
$Settings->SetKey('DownloadsFolder');
$this->DownloadsFolder = $Settings->GetValue();
$this->DownloadsFolder = '/' . (is_null($this->DownloadsFolder) ? 'Downloads' : $this->DownloadsFolder);
$this->AbsoluteDownloadsFolder = \OC\Files\Filesystem::getLocalFolder($this->DownloadsFolder);
$this->L10N = $L10N;
}
示例5: getThumbnail
/**
* {@inheritDoc}
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
$defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
$clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
$exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
shell_exec($exec);
//create imagick object from pdf
$pdfPreview = null;
try {
list($dirname, , , $filename) = array_values(pathinfo($absPath));
$pdfPreview = $dirname . '/' . $filename . '.pdf';
$pdf = new \imagick($pdfPreview . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($pdfPreview);
\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($pdfPreview);
if ($image->valid()) {
$image->scaleDownToFit($maxX, $maxY);
return $image;
}
return false;
}
示例6: __construct
public function __construct($Table = 'admin')
{
if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
$this->DbType = 1;
}
$this->Table = $Table;
}
示例7: 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\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
$uid = $params['uid'];
Storage::deleteUser($uid);
}
}
示例8: getThumbnail
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = get_temp_dir();
$defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ';
$clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
$exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
$export = 'export HOME=/' . $tmpDir;
shell_exec($export . "\n" . $exec);
//create imagick object from pdf
try {
$pdf = new \imagick($absPath . '.pdf' . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($absPath . '.pdf');
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($absPath . '.pdf');
return $image->valid() ? $image : false;
}
示例9: runStep
/**
* Send an email to {$limit} users
*
* @param int $limit Number of users we want to send an email to
* @return int Number of users we sent an email to
*/
protected function runStep($limit)
{
// Get all users which should receive an email
$affectedUsers = $this->mqHandler->getAffectedUsers($limit);
if (empty($affectedUsers)) {
// No users found to notify, mission abort
return 0;
}
$preferences = new \OC\Preferences(\OC_DB::getConnection());
$userLanguages = $preferences->getValueForUsers('core', 'lang', $affectedUsers);
$userEmails = $preferences->getValueForUsers('settings', 'email', $affectedUsers);
// Get all items for these users
// We don't use time() but "time() - 1" here, so we don't run into
// runtime issues and delete emails later, which were created in the
// same second, but were not collected for the emails.
$sendTime = time() - 1;
$mailData = $this->mqHandler->getItemsForUsers($affectedUsers, $sendTime);
// Send Email
$default_lang = \OCP\Config::getSystemValue('default_language', 'en');
foreach ($mailData as $user => $data) {
if (!isset($userEmails[$user])) {
// The user did not setup an email address
// So we will not send an email :(
continue;
}
$language = isset($userLanguages[$user]) ? $userLanguages[$user] : $default_lang;
$this->mqHandler->sendEmailToUser($user, $userEmails[$user], $language, $data);
}
// Delete all entries we dealt with
$this->mqHandler->deleteSentItems($affectedUsers, $sendTime);
return sizeof($affectedUsers);
}
示例10: scan
protected function scan($fileView, $filepath)
{
$this->status = new Status();
if ($this->useSocket) {
$av_socket = \OCP\Config::getAppValue('files_antivirus', 'av_socket', '');
$shandler = stream_socket_client('unix://' . $av_socket, $errno, $errstr, 5);
if (!$shandler) {
throw new \RuntimeException('Cannot connect to "' . $av_socket . '": ' . $errstr . ' (code ' . $errno . ')');
}
} else {
$av_host = \OCP\Config::getAppValue('files_antivirus', 'av_host', '');
$av_port = \OCP\Config::getAppValue('files_antivirus', 'av_port', '');
$shandler = $av_host && $av_port ? @fsockopen($av_host, $av_port) : false;
if (!$shandler) {
throw new \RuntimeException('The clamav module is not configured for daemon mode.');
}
}
$fhandler = $this->getFileHandle($fileView, $filepath);
\OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
// request scan from the daemon
fwrite($shandler, "nINSTREAM\n");
while (!feof($fhandler)) {
$chunk = fread($fhandler, $this->chunkSize);
$chunk_len = pack('N', strlen($chunk));
fwrite($shandler, $chunk_len . $chunk);
}
fwrite($shandler, pack('N', 0));
$response = fgets($shandler);
\OCP\Util::writeLog('files_antivirus', 'Response :: ' . $response, \OCP\Util::DEBUG);
fclose($shandler);
fclose($fhandler);
$this->status->parseResponse($response);
return $this->status->getNumericStatus();
}
示例11: __construct
public function __construct($AppName, IRequest $Request, $CurrentUID, IL10N $L10N)
{
parent::__construct($AppName, $Request);
$this->CurrentUID = $CurrentUID;
$this->L10N = $L10N;
if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
$this->DbType = 1;
}
$this->CanCheckForUpdate = Tools::CanCheckForUpdate();
$this->Settings = new Settings();
$this->Settings->SetKey('WhichDownloader');
$this->WhichDownloader = $this->Settings->GetValue();
$this->WhichDownloader = is_null($this->WhichDownloader) ? 'ARIA2' : $this->WhichDownloader;
$this->Settings->SetKey('AllowProtocolHTTP');
$this->AllowProtocolHTTP = $this->Settings->GetValue();
$this->AllowProtocolHTTP = is_null($this->AllowProtocolHTTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolHTTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolFTP');
$this->AllowProtocolFTP = $this->Settings->GetValue();
$this->AllowProtocolFTP = is_null($this->AllowProtocolFTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolFTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolYT');
$this->AllowProtocolYT = $this->Settings->GetValue();
$this->AllowProtocolYT = is_null($this->AllowProtocolYT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolYT, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolBT');
$this->AllowProtocolBT = $this->Settings->GetValue();
$this->AllowProtocolBT = is_null($this->AllowProtocolBT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolBT, 'Y') == 0;
}
示例12: getSites
public static function getSites()
{
if (($sites = json_decode(\OCP\Config::getAppValue("external", "sites", ''))) != null) {
return $sites;
}
return array();
}
示例13: __construct
public function __construct($params)
{
$host = $params['host'];
//remove leading http[s], will be generated in createBaseUri()
if (substr($host, 0, 8) == "https://") {
$host = substr($host, 8);
} else {
if (substr($host, 0, 7) == "http://") {
$host = substr($host, 7);
}
}
$this->host = $host;
$this->user = $params['user'];
$this->password = $params['password'];
$this->secure = isset($params['secure']) && $params['secure'] == 'true' ? true : false;
$this->root = isset($params['root']) ? $params['root'] : '/';
if (!$this->root || $this->root[0] != '/') {
$this->root = '/' . $this->root;
}
if (substr($this->root, -1, 1) != '/') {
$this->root .= '/';
}
$settings = array('baseUri' => $this->createBaseUri(), 'userName' => $this->user, 'password' => $this->password);
$this->client = new OC_Connector_Sabre_Client($settings);
if ($caview = \OCP\Files::getStorage('files_external')) {
$certPath = \OCP\Config::getSystemValue('datadirectory') . $caview->getAbsolutePath("") . 'rootcerts.crt';
if (file_exists($certPath)) {
$this->client->addTrustedCertificates($certPath);
}
}
//create the root folder if necesary
$this->mkdir('');
}
示例14: __construct
public function __construct(\OC\Files\Storage\Storage $storage)
{
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false);
}
示例15: write_hook
/**
* listen to write event.
*/
public static function write_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
$path = $params[\OC\Files\Filesystem::signal_param_path];
$user = \OCP\User::getUser();
$excluded = false;
$excludes = \OCP\Config::getSystemValue('files_versions_excludes', NULL);
if (isset($excludes) && array_key_exists($user, $excludes)) {
$user_excludes = $excludes[$user];
foreach ($user_excludes as &$pat) {
if (fnmatch($pat, $path)) {
// TODO: Not certain if logging of the files names and patters is allowed.
\OCP\Util::writeLog('files_versions', "write_hook: user='" . $user . "', path='" . $path . "' matched to '" . $pat . "', excluding!", \OCP\Util::INFO);
$excluded = true;
break;
}
}
unset($pat);
}
if ($excluded) {
return;
}
if ($path != '') {
Storage::store($path);
}
}
}