/**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function enableBackend()
 {
     $response = new JSONResponse();
     $params = $this->request->urlParams;
     $backend = $params['backend'];
     $enable = $params['enable'];
     return $response->setData(\OCP\Config::setAppValue('contacts', 'backend_' . $backend, $enable));
 }
示例#2
0
 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);
 }
示例#3
0
 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);
     }
 }
示例#4
0
 public function tearDown()
 {
     \OC_User::setUserId($this->user);
     $cache = $this->storage->getCache();
     $ids = $cache->getAll();
     $permissionsCache = $this->storage->getPermissionsCache();
     $permissionsCache->removeMultiple($ids, \OC_User::getUser());
     $cache->clear();
     if (!is_null($this->config['av_mode'])) {
         \OCP\Config::setAppValue('files_antivirus', 'av_mode', $this->config['av_mode']);
     }
     if (!is_null($this->config['av_path'])) {
         \OCP\Config::setAppValue('files_antivirus', 'av_path', $this->config['av_path']);
     }
 }
示例#5
0
 private static function webStep()
 {
     // Iterate over all users
     $lastid = \OCP\Config::getAppValue('news', 'backgroundjob_lastid', 0);
     $feedmapper = new FeedMapper();
     $feeds = $feedmapper->findAll();
     usort($feeds, array('OCA\\News\\Backgroundjob', 'sortFeeds'));
     $done = false;
     foreach ($feeds as $feed) {
         if ($feed['id'] > $lastid) {
             // set lastid BEFORE updating feed!
             \OCP\Config::setAppValue('news', 'backgroundjob_lastid', $feed['id']);
             $done = true;
             self::updateFeed($feedmapper, $feed);
         }
     }
     if (!$done) {
         \OCP\Config::setAppValue('news', 'backgroundjob_lastid', 0);
     }
 }
示例#6
0
 public static function updateGroups()
 {
     \OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', \OCP\Util::DEBUG);
     $lastUpdate = \OCP\Config::getAppValue('user_ldap', 'bgjUpdateGroupsLastRun', 0);
     if (time() - $lastUpdate < self::getRefreshInterval()) {
         \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – last run too fresh, aborting.', \OCP\Util::DEBUG);
         //komm runter Werner die Maurer geben ein aus
         return;
     }
     $knownGroups = array_keys(self::getKnownGroups());
     $actualGroups = self::getGroupBE()->getGroups();
     if (empty($actualGroups) && empty($knownGroups)) {
         \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.', \OCP\Util::INFO);
         \OCP\Config::setAppValue('user_ldap', 'bgjUpdateGroupsLastRun', time());
         return;
     }
     self::handleKnownGroups(array_intersect($actualGroups, $knownGroups));
     self::handleCreatedGroups(array_diff($actualGroups, $knownGroups));
     self::handleRemovedGroups(array_diff($knownGroups, $actualGroups));
     \OCP\Config::setAppValue('user_ldap', 'bgjUpdateGroupsLastRun', time());
     \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', \OCP\Util::DEBUG);
 }
示例#7
0
 /**
  * @param string $varName
  * @param string $value
  * @return bool
  */
 protected function saveValue($varName, $value)
 {
     return \OCP\Config::setAppValue('user_ldap', $this->configPrefix . $varName, $value);
 }
示例#8
0
 public static function setRecentBackupPath($path)
 {
     \OCP\Config::setAppValue(self::APP_ID, self::LAST_BACKUP_PATH, $path);
 }
示例#9
0
<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Documents;

\OCP\JSON::callCheck();
$unstable = isset($_POST['unstable']) ? $_POST['unstable'] : null;
if (!is_null($unstable)) {
    \OCP\JSON::checkAdminUser();
    \OCP\Config::setAppValue('documents', 'unstable', $unstable);
    \OCP\JSON::success();
    exit;
}
if (isset($_GET['unstable'])) {
    \OCP\JSON::success(array('value' => \OCP\Config::getAppValue('documents', 'unstable', 'false')));
}
exit;
示例#10
0
<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
$installedVersion = \OCP\Config::getAppValue('documents', 'installed_version');
$cleanup = \OC_DB::prepare('DELETE FROM `*PREFIX*documents_member` WHERE `last_activity`=0 or `last_activity` is NULL');
$cleanup->execute();
if (version_compare($installedVersion, '0.7', '<=')) {
    \OCP\Config::setAppValue('documents', 'unstable', 'false');
    $session = new \OCA\Documents\Db_Session();
    $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?');
    foreach ($session->getCollection() as $sessionData) {
        $sessionData['genesis_url'] = \OCA\Documents\Genesis::DOCUMENTS_DIRNAME . $sessionData['genesis_url'];
        $query->execute(array($sessionData['genesis_url'], $sessionData['es_id']));
    }
}
if (version_compare($installedVersion, '0.8', '<')) {
    $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_member` SET `is_guest`=1 WHERE `uid` LIKE \'%(guest)\' ');
    $query->execute(array());
}
示例#11
0
	/**
	 * Writes a new app wide value
	 *
	 * @param string $appName the appName that we want to store the value under
	 * @param string $key the key of the value, under which will be saved
	 * @param string $value the value that should be stored
	 */
	public function setAppValue($appName, $key, $value) {
		\OCP\Config::setAppValue($appName, $key, $value);
	}
示例#12
0
 /**
  * @brief Sets auto create account flag
  *
  * If true Mozilla Sync accounts are auto created for ownCloud users, i.e. no registration required
  *
  * @param boolean $autocreate
  */
 public static function setAutoCreateUser($autocreate)
 {
     \OCP\Config::setAppValue('mozilla_sync', 'auto_create_user', $autocreate);
 }
示例#13
0
 /**
  * @medium
  */
 function testUpdateShareExpireDate()
 {
     $fileInfo = $this->view->getFileInfo($this->folder);
     // enforce expire date, by default 7 days after the file was shared
     \OCP\Config::setAppValue('core', 'shareapi_default_expire_date', 'yes');
     \OCP\Config::setAppValue('core', 'shareapi_enforce_expire_date', 'yes');
     $dateWithinRange = new \DateTime();
     $dateWithinRange->add(new \DateInterval('P5D'));
     $dateOutOfRange = new \DateTime();
     $dateOutOfRange->add(new \DateInterval('P8D'));
     $result = \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
     // share was successful?
     $this->assertTrue(is_string($result));
     $items = \OCP\Share::getItemShared('file', null);
     // make sure that we found a link share
     $this->assertEquals(1, count($items));
     $linkShare = reset($items);
     // update expire date to a valid value
     $params = array();
     $params['id'] = $linkShare['id'];
     $params['_put'] = array();
     $params['_put']['expireDate'] = $dateWithinRange->format('Y-m-d');
     $result = Share\Api::updateShare($params);
     $this->assertTrue($result->succeeded());
     $items = \OCP\Share::getItemShared('file', $linkShare['file_source']);
     $updatedLinkShare = reset($items);
     // date should be changed
     $this->assertTrue(is_array($updatedLinkShare));
     $this->assertEquals($dateWithinRange->format('Y-m-d') . ' 00:00:00', $updatedLinkShare['expiration']);
     // update expire date to a value out of range
     $params = array();
     $params['id'] = $linkShare['id'];
     $params['_put'] = array();
     $params['_put']['expireDate'] = $dateOutOfRange->format('Y-m-d');
     $result = Share\Api::updateShare($params);
     $this->assertFalse($result->succeeded());
     $items = \OCP\Share::getItemShared('file', $linkShare['file_source']);
     $updatedLinkShare = reset($items);
     // date shouldn't be changed
     $this->assertTrue(is_array($updatedLinkShare));
     $this->assertEquals($dateWithinRange->format('Y-m-d') . ' 00:00:00', $updatedLinkShare['expiration']);
     // cleanup
     \OCP\Config::setAppValue('core', 'shareapi_default_expire_date', 'no');
     \OCP\Config::setAppValue('core', 'shareapi_enforce_expire_date', 'no');
     \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);
 }
示例#14
0
//detect if we can switch on naming guidelines. We won't do it on conflicts.
//it's a bit spaghetti, but hey.
$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'unset');
if ($state === 'unset') {
    OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
}
$installedVersion = OCP\Config::getAppValue('user_ldap', 'installed_version');
$enableRawMode = version_compare($installedVersion, '0.4.1', '<');
$configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
$ldap = new OCA\user_ldap\lib\LDAP();
foreach ($configPrefixes as $config) {
    $connection = new OCA\user_ldap\lib\Connection($ldap, $config);
    $state = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_uuid_user_attribute', 'not existing');
    if ($state === 'non existing') {
        $value = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_uuid_attribute', '');
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_uuid_user_attribute', $value);
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_uuid_group_attribute', $value);
    }
    $state = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_expert_uuid_user_attr', 'not existing');
    if ($state === 'non existing') {
        $value = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_expert_uuid_attr', '');
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_expert_uuid_user_attr', $value);
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_expert_uuid_group_attr', $value);
    }
    if ($enableRawMode) {
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_user_filter_mode', 1);
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_login_filter_mode', 1);
        \OCP\Config::setAppValue('user_ldap', $config . 'ldap_group_filter_mode', 1);
    }
}
示例#15
0
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\App::registerAdmin('files_antivirus', 'settings');
OCP\Util::connectHook('OC_Filesystem', 'post_write', '\\OCA\\Files_Antivirus\\Scanner', 'av_scan');
OCP\BackgroundJob::AddRegularTask('OCA\\Files_Antivirus\\BackgroundScanner', 'check');
$avBinary = \OCP\Config::getAppValue('files_antivirus', 'av_path', '');
if (empty($avBinary)) {
    try {
        $query = \OCP\DB::prepare('SELECT count(`id`) AS `totalRules` FROM `*PREFIX*files_antivirus_status`');
        $result = $query->execute();
        $result = $result->fetchRow();
        if ($result['totalRules'] == 0) {
            \OCA\Files_Antivirus\Status::init();
        }
        \OCP\Config::setAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan');
    } catch (\Exception $e) {
    }
}
示例#16
0
文件: api.php 项目: hjimmy/owncloud
 /**
  * Writes a new appwide value
  * @param string $key the key of the value, under which will be saved
  * @param string $value the value that should be stored
  */
 public function setAppValue($key, $value, $appName = null)
 {
     if ($appName === null) {
         $appName = $this->appName;
     }
     return \OCP\Config::setAppValue($appName, $key, $value);
 }
示例#17
0
<?php

//detect if we can switch on naming guidelines. We won't do it on conflicts.
//it's a bit spaghetti, but hey.
$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'unset');
if ($state === 'unset') {
    OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
}
$configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
$ldap = new OCA\user_ldap\lib\LDAP();
foreach ($configPrefixes as $config) {
    $connection = new OCA\user_ldap\lib\Connection($ldap, $config);
    $value = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_uuid_attribute', 'auto');
    \OCP\Config::setAppValue('user_ldap', $config . 'ldap_uuid_user_attribute', $value);
    \OCP\Config::setAppValue('user_ldap', $config . 'ldap_uuid_group_attribute', $value);
    $value = \OCP\Config::getAppValue('user_ldap', $config . 'ldap_expert_uuid_attr', 'auto');
    \OCP\Config::setAppValue('user_ldap', $config . 'ldap_expert_uuid_user_attr', $value);
    \OCP\Config::setAppValue('user_ldap', $config . 'ldap_expert_uuid_group_attr', $value);
}
示例#18
0
 protected static function setAppValue($key, $value)
 {
     return \OCP\Config::setAppValue(self::APP_NAME, $key, $value);
 }
示例#19
0
 /**
  * @brief set app config value
  *
  * @param string $key key for value to change
  * @param string $value value to use
  * @return bool success
  */
 public static function setApp($key, $value)
 {
     return \OCP\Config::setAppValue('files_opds', $key, $value);
 }
示例#20
0
 /**
  * @brief Validates the user specified configuration
  * @returns true if configuration seems OK, false otherwise
  */
 private function validateConfiguration()
 {
     //first step: "soft" checks: settings that are not really necessary, but advisable. If left empty, give an info message
     if (empty($this->config['ldapBaseUsers'])) {
         \OCP\Util::writeLog('user_ldap', 'Base tree for Users is empty, using Base DN', \OCP\Util::INFO);
         $this->config['ldapBaseUsers'] = $this->config['ldapBase'];
     }
     if (empty($this->config['ldapBaseGroups'])) {
         \OCP\Util::writeLog('user_ldap', 'Base tree for Groups is empty, using Base DN', \OCP\Util::INFO);
         $this->config['ldapBaseGroups'] = $this->config['ldapBase'];
     }
     if (empty($this->config['ldapGroupFilter']) && empty($this->config['ldapGroupMemberAssocAttr'])) {
         \OCP\Util::writeLog('user_ldap', 'No group filter is specified, LDAP group feature will not be used.', \OCP\Util::INFO);
     }
     if (!in_array($this->config['ldapUuidAttribute'], array('auto', 'entryuuid', 'nsuniqueid', 'objectguid')) && !is_null($this->configID)) {
         \OCP\Config::setAppValue($this->configID, 'ldap_uuid_attribute', 'auto');
         \OCP\Util::writeLog('user_ldap', 'Illegal value for the UUID Attribute, reset to autodetect.', \OCP\Util::INFO);
     }
     //second step: critical checks. If left empty or filled wrong, set as unconfigured and give a warning.
     $configurationOK = true;
     if (empty($this->config['ldapHost'])) {
         \OCP\Util::writeLog('user_ldap', 'No LDAP host given, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (empty($this->config['ldapPort'])) {
         \OCP\Util::writeLog('user_ldap', 'No LDAP Port given, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (empty($this->config['ldapAgentName']) && !empty($this->config['ldapAgentPassword']) || !empty($this->config['ldapAgentName']) && empty($this->config['ldapAgentPassword'])) {
         \OCP\Util::writeLog('user_ldap', 'Either no password given for the user agent or a password is given, but no LDAP agent; won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     //TODO: check if ldapAgentName is in DN form
     if (empty($this->config['ldapBase']) && (empty($this->config['ldapBaseUsers']) && empty($this->config['ldapBaseGroups']))) {
         \OCP\Util::writeLog('user_ldap', 'No Base DN given, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (empty($this->config['ldapUserDisplayName'])) {
         \OCP\Util::writeLog('user_ldap', 'No user display name attribute specified, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (empty($this->config['ldapGroupDisplayName'])) {
         \OCP\Util::writeLog('user_ldap', 'No group display name attribute specified, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (empty($this->config['ldapLoginFilter'])) {
         \OCP\Util::writeLog('user_ldap', 'No login filter specified, won`t connect.', \OCP\Util::WARN);
         $configurationOK = false;
     }
     if (mb_strpos($this->config['ldapLoginFilter'], '%uid', 0, 'UTF-8') === false) {
         \OCP\Util::writeLog('user_ldap', 'Login filter does not contain %uid place holder, won`t connect.', \OCP\Util::WARN);
         \OCP\Util::writeLog('user_ldap', 'Login filter was ' . $this->config['ldapLoginFilter'], \OCP\Util::DEBUG);
         $configurationOK = false;
     }
     return $configurationOK;
 }
示例#21
0
 /**
  * Set system settings
  * @param int $policy 
  */
 public static function setSystemPolicy($policy)
 {
     $policy = self::_validatePolicy($policy);
     \OCP\Config::setAppValue(App::APP_ID, self::CONFIG_KEY, $policy);
 }
示例#22
0
 public function setAdminVal($option, $value)
 {
     \OCP\Config::setAppValue('ownnote', $option, $value);
 }