/** * @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; }
/** * @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); }
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; }
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; }
/** * {@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; }
public function __construct($Table = 'admin') { if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) { $this->DbType = 1; } $this->Table = $Table; }
/** * @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); } }
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; }
/** * 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); }
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(); }
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; }
public static function getSites() { if (($sites = json_decode(\OCP\Config::getAppValue("external", "sites", ''))) != null) { return $sites; } return array(); }
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(''); }
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); }
/** * 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='******', path='" . $path . "' matched to '" . $pat . "', excluding!", \OCP\Util::INFO); $excluded = true; break; } } unset($pat); } if ($excluded) { return; } if ($path != '') { Storage::store($path); } } }
private static function Load() { if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) { self::$DbType = 1; } self::$CurrentUID = \OC::$server->getUserSession()->getUser(); self::$CurrentUID = self::$CurrentUID ? self::$CurrentUID->getUID() : ''; self::$L10N = \OC::$server->getL10N('ocdownloader'); $Settings = new Settings(); $Settings->SetKey('ProxyAddress'); self::$ProxyAddress = $Settings->GetValue(); $Settings->SetKey('ProxyPort'); self::$ProxyPort = intval($Settings->GetValue()); $Settings->SetKey('ProxyUser'); self::$ProxyUser = $Settings->GetValue(); $Settings->SetKey('ProxyPasswd'); self::$ProxyPasswd = $Settings->GetValue(); $Settings->SetTable('personal'); $Settings->SetUID(self::$CurrentUID); $Settings->SetKey('DownloadsFolder'); self::$DownloadsFolder = $Settings->GetValue(); self::$DownloadsFolder = '/' . (is_null(self::$DownloadsFolder) ? 'Downloads' : self::$DownloadsFolder); self::$AbsoluteDownloadsFolder = \OC\Files\Filesystem::getLocalFolder(self::$DownloadsFolder); $Settings->SetKey('YTDLBinary'); $YTDLBinary = $Settings->GetValue(); self::$YTDLBinary = '/usr/local/bin/youtube-dl'; // default path if (!is_null($YTDLBinary)) { self::$YTDLBinary = $YTDLBinary; } }
protected function run($argument) { // Remove activities that are older then one year $expireDays = \OCP\Config::getSystemValue('activity_expire_days', 365); $data = new \OCA\Activity\Data(\OC::$server->getActivityManager()); $data->expire($expireDays); }
public static function scan($id, $path, $storage) { $file = $storage->getLocalFile($path); $result = OC_Files_Antivirus::clamav_scan($file); switch ($result) { case CLAMAV_SCANRESULT_UNCHECKED: \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR); break; case CLAMAV_SCANRESULT_INFECTED: $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log'); if ($infected_action == 'delete') { \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR); unlink($file); } else { \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR); } break; case CLAMAV_SCANRESULT_CLEAN: $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)'); try { $result = $stmt->execute(array($id, time())); if (\OC_DB::isError($result)) { \OC_Log::write('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); } break; } }
/** * test set and get share folder */ function testSetGetShareFolder() { $this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder()); \OCA\Files_Sharing\Helper::setShareFolder('/Shared'); $this->assertSame('/Shared', \OCA\Files_Sharing\Helper::getShareFolder()); // cleanup \OCP\Config::deleteSystemValue('share_folder'); }
public function testSetAppValueIfSetToNull() { $key = $this->getUniqueID('key-'); $result = \OCP\Config::setAppValue('unit-test', $key, null); $this->assertTrue($result); $result = \OCP\Config::setAppValue('unit-test', $key, '12'); $this->assertTrue($result); }
/** * @NoAdminRequired * @NoCSRFRequired */ public function backendStatus() { $response = new JSONResponse(); $params = $this->request->urlParams; $backend = $params['backend']; $enabled = \OCP\Config::getAppValue('contacts', 'backend_' . $backend, "false"); return $response->setData($enabled); }
/** * * @param string $sender user id */ public function __construct($sender) { $this->l = \OC::$server->getL10N('lib'); $this->senderId = $sender; $this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply'); $this->replyTo = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from); $this->senderDisplayName = \OCP\User::getDisplayName($this->senderId); }
public function __construct($AppName, IRequest $Request, IL10N $L10N) { parent::__construct($AppName, $Request); if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) { $this->DbType = 1; } $this->L10N = $L10N; $this->Settings = new Settings(); }
public function disableBackend($backend) { $backends = $this->getBackends(); if (array_key_exists($backend, $backends)) { \OCP\Config::setAppValue('chat', 'backend_' . $backend . '_enabled', false); return true; } else { throw new BackendNotFoundException('Backend not found', 404); } }
public function __construct($user = null, $addressBooksTableName = '*PREFIX*addressbook', $backendsTableName = '*PREFIX*addressbooks_backend', $dbBackend = null) { $this->user = $user ? $user : \OC::$server->getUserSession()->getUser()->getUId(); $this->addressBooksTableName = $addressBooksTableName; $this->backendsTableName = $backendsTableName; $this->dbBackend = $dbBackend ? $dbBackend : new Backend\Database($user); if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") { self::$backendClasses['ldap'] = 'OCA\\Contacts\\Backend\\Ldap'; } }
function thumb($path) { $thumb_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/reader'; if (file_exists($thumb_path . $path)) { return new \OC_Image($thumb_path . $path); } if (!\OC\Files\Filesystem::file_exists($path)) { return false; } }
/** * test set and get share folder */ function testSetGetShareFolder() { $this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder()); \OCA\Files_Sharing\Helper::setShareFolder('/Shared/Folder'); $sharedFolder = \OCA\Files_Sharing\Helper::getShareFolder(); $this->assertSame('/Shared/Folder', \OCA\Files_Sharing\Helper::getShareFolder()); $this->assertTrue(\OC\Files\Filesystem::is_dir($sharedFolder)); // cleanup \OCP\Config::deleteSystemValue('share_folder'); }
/** * Returns the list of allowed "versions" * @return array */ public static function getVersions() { $versions = array(); $result = json_decode(\OCP\Config::getAppValue('user_files_restore', 'versions', '')); if (is_array($result)) { foreach ($result as $item) { array_push($versions, $item); } } return $versions; }
private function hostKeysPath() { try { $storage_view = \OCP\Files::getStorage('files_external'); if ($storage_view) { return \OCP\Config::getSystemValue('datadirectory') . $storage_view->getAbsolutePath('') . 'ssh_hostKeys'; } } catch (\Exception $e) { } return false; }
public function __construct() { parent::__construct(); // get the path to the executable $avPath = \OCP\Config::getAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan'); // check that the executable is available if (!file_exists($avPath)) { throw new \RuntimeException('The antivirus executable could not be found at ' . $avPath); } $this->avPath = $avPath; }