if ($param === 'rcHost') { if ($_POST[$param] == '' || strlen($_POST[$param]) > 3) { OCP\Config::setAppValue('roundcube', $param, $_POST[$param]); } } else { if ($param === 'maildir') { $maildir = $_POST[$param]; if (substr($maildir, -1) != '/') { $maildir .= '/'; } OCP\Config::setAppValue('roundcube', $param, $maildir); } else { if ($param == 'rcRefreshInterval') { $refresh = trim($_POST[$param]); if ($refresh == '') { OC_Appconfig::deleteKey('roundcube', $param); } else { if (!is_numeric($refresh)) { OC_JSON::error(array("data" => array("message" => $l->t("Refresh interval '%s' is not a number.", array($refresh))))); return false; } else { OCP\Config::setAppValue('roundcube', $param, $refresh); } } } else { OCP\Config::setAppValue('roundcube', $param, $_POST[$param]); } } } } } else {
<?php /** * Copyright (c) 2011, Frank Karlitschek <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */ OCP\User::checkAdminUser(); OCP\JSON::callCheck(); $sites = array(); for ($i = 0; $i < sizeof($_POST['site_name']); $i++) { if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) { array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i]))); } } if (sizeof($sites) == 0) { OC_Appconfig::deleteKey('external', 'sites'); } else { OCP\Config::setAppValue('external', 'sites', json_encode($sites)); } echo 'true';
// This change is due the fact that an admin may not be expected // to execute arbitrary code in every environment. if ($app === 'core' && isset($_POST['key']) && (substr($_POST['key'], 0, 7) === 'remote_' || substr($_POST['key'], 0, 7) === 'public_')) { OC_JSON::error(array('data' => array('message' => 'Unexpected error!'))); return; } $result = false; switch ($action) { case 'getValue': $result = OC_Appconfig::getValue($app, $_GET['key'], $_GET['defaultValue']); break; case 'setValue': $result = OC_Appconfig::setValue($app, $_POST['key'], $_POST['value']); break; case 'getApps': $result = OC_Appconfig::getApps(); break; case 'getKeys': $result = OC_Appconfig::getKeys($app); break; case 'hasKey': $result = OC_Appconfig::hasKey($app, $_GET['key']); break; case 'deleteKey': $result = OC_Appconfig::deleteKey($app, $_POST['key']); break; case 'deleteApp': $result = OC_Appconfig::deleteApp($app); break; } OC_JSON::success(array('data' => $result));
/** * Removes information about association identified by $handle * * @param string $handle assiciation handle * @return bool */ public function delAssociation($handle) { $name = 'assoc_' . md5($handle); OC_Appconfig::deleteKey('user_openid_provider', $name); return true; }
public function testDeleteKey() { \OC_Appconfig::deleteKey('testapp', 'deletethis'); $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'); $query->execute(array('testapp', 'deletethis')); $result = (bool) $query->fetchRow(); $this->assertFalse($result); }
/** * update the database for the app and call the update script * * @param string $appId * @return bool */ public static function updateApp($appId) { if (file_exists(self::getAppPath($appId) . '/appinfo/database.xml')) { OC_DB::updateDbFromStructure(self::getAppPath($appId) . '/appinfo/database.xml'); } unset(self::$appVersion[$appId]); // run upgrade code if (file_exists(self::getAppPath($appId) . '/appinfo/update.php')) { self::loadApp($appId, false); include self::getAppPath($appId) . '/appinfo/update.php'; } //set remote/public handlers $appData = self::getAppInfo($appId); if (array_key_exists('ocsid', $appData)) { OC_Appconfig::setValue($appId, 'ocsid', $appData['ocsid']); } elseif (OC_Appconfig::getValue($appId, 'ocsid', null) !== null) { OC_Appconfig::deleteKey($appId, 'ocsid'); } foreach ($appData['remote'] as $name => $path) { OCP\CONFIG::setAppValue('core', 'remote_' . $name, $appId . '/' . $path); } foreach ($appData['public'] as $name => $path) { OCP\CONFIG::setAppValue('core', 'public_' . $name, $appId . '/' . $path); } self::setAppTypes($appId); $version = \OC_App::getAppVersion($appId); \OC_Appconfig::setValue($appId, 'installed_version', $version); return true; }
<?php //from version 0.1 to 0.2 //ATTENTION //Upgrade from ownCloud 3 (LDAP backend 0.1) to ownCloud 4.5 (LDAP backend 0.3) is not supported!! //You must do upgrade to ownCloud 4.0 first! //The upgrade stuff in the section from 0.1 to 0.2 is just to minimize the bad efffects. //settings $pw = OCP\Config::getAppValue('user_ldap', 'ldap_password'); if (!is_null($pw)) { $pwEnc = base64_encode($pw); OCP\Config::setAppValue('user_ldap', 'ldap_agent_password', $pwEnc); OC_Appconfig::deleteKey('user_ldap', 'ldap_password'); } //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); } // ### SUPPORTED upgrade path starts here ### //from version 0.2 to 0.3 (0.2.0.x dev version) $objects = array('user', 'group'); $connector = new \OCA\user_ldap\lib\Connection('user_ldap'); $userBE = new \OCA\user_ldap\USER_LDAP(); $userBE->setConnector($connector); $groupBE = new \OCA\user_ldap\GROUP_LDAP(); $groupBE->setConnector($connector); foreach ($objects as $object) { $fetchDNSql = 'SELECT `ldap_dn`, `owncloud_name` FROM `*PREFIX*ldap_' . $object . '_mapping` WHERE `directory_uuid` = ""'; $updateSql = 'UPDATE `*PREFIX*ldap_' . $object . '_mapping` SET `ldap_DN` = ?, `directory_uuid` = ? WHERE `ldap_dn` = ?';
public function testShareItemWithLinkAndDefaultExpireDate() { OC_User::setUserId($this->user1); \OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes'); \OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2'); $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertInternalType('string', $token, 'Failed asserting that user 1 successfully shared text.txt as link with token.'); // share should have default expire date $row = $this->getShareByValidToken($token); $this->assertNotEmpty($row['expiration'], 'Failed asserting that the returned row has an default expiration date.'); \OC_Appconfig::deleteKey('core', 'shareapi_default_expire_date'); \OC_Appconfig::deleteKey('core', 'shareapi_expire_after_n_days'); }
/** * Delete an app wide defined value * * @param string $appName the appName that we stored the value under * @param string $key the key of the value, under which it was saved */ public function deleteAppValue($appName, $key) { \OC_Appconfig::deleteKey($appName, $key); }
/** * Ensure that we do not allow removing a an expiration date from a link share if this * is enforced by the settings. */ public function testClearExpireDateWhileEnforced() { OC_User::setUserId($this->user1); \OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes'); \OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2'); \OC_Appconfig::setValue('core', 'shareapi_enforce_expire_date', 'yes'); $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertInternalType('string', $token, 'Failed asserting that user 1 successfully shared text.txt as link with token.'); $setExpireDateFailed = false; try { $this->assertTrue(OCP\Share::setExpirationDate('test', 'test.txt', '', ''), 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'); } catch (\Exception $e) { $setExpireDateFailed = true; } $this->assertTrue($setExpireDateFailed); \OC_Appconfig::deleteKey('core', 'shareapi_default_expire_date'); \OC_Appconfig::deleteKey('core', 'shareapi_expire_after_n_days'); \OC_Appconfig::deleteKey('core', 'shareapi_enforce_expire_date'); }