diff options
m--------- | 3rdparty | 0 | ||||
-rw-r--r-- | apps/files_encryption/lib/util.php | 92 | ||||
-rw-r--r-- | apps/user_ldap/templates/settings.php | 6 | ||||
-rw-r--r-- | core/templates/layout.base.php | 10 | ||||
-rw-r--r-- | core/templates/layout.guest.php | 11 | ||||
-rw-r--r-- | core/templates/layout.user.php | 10 | ||||
-rw-r--r-- | lib/private/archive/tar.php | 2 | ||||
-rw-r--r-- | lib/private/template.php | 27 | ||||
-rw-r--r-- | lib/private/user/session.php | 1 | ||||
-rw-r--r-- | lib/private/util.php | 6 | ||||
-rw-r--r-- | lib/public/util.php | 6 | ||||
-rw-r--r-- | settings/admin.php | 162 | ||||
-rw-r--r-- | settings/js/admin.js | 10 | ||||
-rw-r--r-- | settings/js/log.js | 62 | ||||
-rw-r--r-- | settings/templates/admin.php | 40 |
15 files changed, 255 insertions, 190 deletions
diff --git a/3rdparty b/3rdparty -Subproject 24a1c13088119fd070a3233b47457b60426418f +Subproject 7534a6a2b7549cc5db0a7f32749d962bfe9b2d3 diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 33c2f88b0fd..ce5e8c8b54c 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -385,55 +385,71 @@ class Util { && $this->isEncryptedPath($path) ) { - $offset = 0; - if ($this->containHeader($path)) { - $offset = Crypt::BLOCKSIZE; - } - - // get the size from filesystem if the file contains a encryption header we - // we substract it - $size = $this->view->filesize($path) - $offset; + $cipher = 'AES-128-CFB'; + $realSize = 0; - // fast path, else the calculation for $lastChunkNr is bogus - if ($size === 0) { - \OC_FileProxy::$enabled = $proxyStatus; - return 0; - } - - // calculate last chunk nr - // next highest is end of chunks, one subtracted is last one - // we have to read the last chunk, we can't just calculate it (because of padding etc) - $lastChunkNr = ceil($size/ Crypt::BLOCKSIZE) - 1; - $lastChunkSize = $size - ($lastChunkNr * Crypt::BLOCKSIZE); + // get the size from filesystem + $size = $this->view->filesize($path); // open stream - $stream = fopen('crypt://' . $path, "r"); + $stream = $this->view->fopen($path, "r"); if (is_resource($stream)) { - // calculate last chunk position - $lastChunckPos = ($lastChunkNr * Crypt::BLOCKSIZE); - // seek to end - if (@fseek($stream, $lastChunckPos) === -1) { - // storage doesn't support fseek, we need a local copy - fclose($stream); - $localFile = $this->view->getLocalFile($path); - Helper::addTmpFileToMapper($localFile, $path); - $stream = fopen('crypt://' . $localFile, "r"); - if (fseek($stream, $lastChunckPos) === -1) { - // if fseek also fails on the local storage, than - // there is nothing we can do - fclose($stream); - \OCP\Util::writeLog('Encryption library', 'couldn\'t determine size of "' . $path, \OCP\Util::ERROR); - return $result; - } + // if the file contains a encryption header we + // we set the cipher + // and we update the size + if ($this->containHeader($path)) { + $data = fread($stream,Crypt::BLOCKSIZE); + $header = Crypt::parseHeader($data); + $cipher = Crypt::getCipher($header); + $size -= Crypt::BLOCKSIZE; } + // fast path, else the calculation for $lastChunkNr is bogus + if ($size === 0) { + \OC_FileProxy::$enabled = $proxyStatus; + return 0; + } + + // calculate last chunk nr + // next highest is end of chunks, one subtracted is last one + // we have to read the last chunk, we can't just calculate it (because of padding etc) + $lastChunkNr = ceil($size/Crypt::BLOCKSIZE)-1; + + // calculate last chunk position + $lastChunkPos = ($lastChunkNr * Crypt::BLOCKSIZE); + // get the content of the last chunk - $lastChunkContent = fread($stream, $lastChunkSize); + if (@fseek($stream, $lastChunkPos, SEEK_CUR) === 0) { + $realSize+=$lastChunkNr*6126; + } + $lastChunkContentEncrypted=''; + $count=Crypt::BLOCKSIZE; + while ($count>0) { + $data=fread($stream,Crypt::BLOCKSIZE); + $count=strlen($data); + $lastChunkContentEncrypted.=$data; + if(strlen($lastChunkContentEncrypted)>Crypt::BLOCKSIZE) { + $realSize+=6126; + $lastChunkContentEncrypted=substr($lastChunkContentEncrypted,Crypt::BLOCKSIZE); + } + } + fclose($stream); + $relPath = \OCA\Encryption\Helper::stripUserFilesPath($path); + $shareKey = Keymanager::getShareKey($this->view, $this->keyId, $this, $relPath); + if($shareKey===false) { + \OC_FileProxy::$enabled = $proxyStatus; + return $result; + } + $session = new \OCA\Encryption\Session($this->view); + $privateKey = $session->getPrivateKey(); + $plainKeyfile = $this->decryptKeyfile($relPath, $privateKey); + $plainKey = Crypt::multiKeyDecrypt($plainKeyfile, $shareKey, $privateKey); + $lastChunkContent=Crypt::symmetricDecryptFileContent($lastChunkContentEncrypted, $plainKey, $cipher); // calc the real file size with the size of the last chunk - $realSize = (($lastChunkNr * 6126) + strlen($lastChunkContent)); + $realSize += strlen($lastChunkContent); // store file size $result = $realSize; diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 6a02b795258..811deada944 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -1,5 +1,7 @@ -<form id="ldap" action="#" method="post"> - <div id="ldapSettings" class="section"> +<form id="ldap" class="section" action="#" method="post"> + <h2><?php p($l->t('LDAP')); ?></h2> + + <div id="ldapSettings"> <ul> <?php foreach($_['toc'] as $id => $title) { ?> <li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li> diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index 3325bc9165e..2b496c23246 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -21,15 +21,7 @@ <?php foreach ($_['jsfiles'] as $jsfile): ?> <script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script> <?php endforeach; ?> - <?php foreach ($_['headers'] as $header): ?> - <?php - print_unescaped('<'.$header['tag'].' '); - foreach ($header['attributes'] as $name => $value) { - print_unescaped("$name='$value' "); - }; - print_unescaped('/>'); - ?> - <?php endforeach; ?> + <?php print_unescaped($_['headers']); ?> </head> <body id="body-public"> <noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 0ad2ea4d807..763af4dc1d2 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -22,16 +22,7 @@ <?php foreach($_['jsfiles'] as $jsfile): ?> <script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script> <?php endforeach; ?> - - <?php foreach($_['headers'] as $header): ?> - <?php - print_unescaped('<'.$header['tag'].' '); - foreach($header['attributes'] as $name=>$value) { - print_unescaped("$name='$value' "); - }; - print_unescaped('/>'); - ?> - <?php endforeach; ?> + <?php print_unescaped($_['headers']); ?> </head> <body id="<?php p($_['bodyid']);?>"> <noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 6164d16ac17..9f94344b21b 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -29,15 +29,7 @@ <?php foreach($_['jsfiles'] as $jsfile): ?> <script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script> <?php endforeach; ?> - <?php foreach($_['headers'] as $header): ?> - <?php - print_unescaped('<'.$header['tag'].' '); - foreach($header['attributes'] as $name=>$value) { - print_unescaped("$name='$value' "); - }; - print_unescaped('/>'); - ?> - <?php endforeach; ?> + <?php print_unescaped($_['headers']); ?> </head> <body id="<?php p($_['bodyid']);?>"> <noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript> diff --git a/lib/private/archive/tar.php b/lib/private/archive/tar.php index 31715c4778b..61b37c2542a 100644 --- a/lib/private/archive/tar.php +++ b/lib/private/archive/tar.php @@ -6,8 +6,6 @@ * See the COPYING-README file. */ -require_once OC::$THIRDPARTYROOT . '/3rdparty/Archive/Tar.php'; - class OC_Archive_TAR extends OC_Archive { const PLAIN = 0; const GZIP = 1; diff --git a/lib/private/template.php b/lib/private/template.php index fe0cde53ff1..9ad9d5466db 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -158,10 +158,15 @@ class OC_Template extends \OC\Template\Base { * Add a custom element to the header * @param string $tag tag name of the element * @param array $attributes array of attributes for the element - * @param string $text the text content for the element + * @param string $text the text content for the element. If $text is null then the + * element will be written as empty element. So use "" to get a closing tag. */ - public function addHeader( $tag, $attributes, $text='') { - $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes, 'text'=>$text); + public function addHeader($tag, $attributes, $text=null) { + $this->headers[]= array( + 'tag' => $tag, + 'attributes' => $attributes, + 'text' => $text + ); } /** @@ -178,12 +183,22 @@ class OC_Template extends \OC\Template\Base { $page = new OC_TemplateLayout($this->renderas, $this->app); // Add custom headers - $page->assign('headers', $this->headers, false); + $headers = ''; foreach(OC_Util::$headers as $header) { - $page->append('headers', $header); + $headers .= '<'.OC_Util::sanitizeHTML($header['tag']); + foreach($header['attributes'] as $name=>$value) { + $headers .= ' "'.OC_Util::sanitizeHTML($name).'"="'.OC_Util::sanitizeHTML($value).'"'; + } + if ($header['text'] !== null) { + $headers .= '>'.OC_Util::sanitizeHTML($header['text']).'</'.OC_Util::sanitizeHTML($header['tag']).'>'; + } else { + $headers .= '/>'; + } } - $page->assign( "content", $data, false ); + $page->assign('headers', $headers, false); + + $page->assign('content', $data, false ); return $page->fetchPage(); } else{ diff --git a/lib/private/user/session.php b/lib/private/user/session.php index b9c341b4ae9..ca0265dfb23 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -253,6 +253,7 @@ class Session implements IUserSession, Emitter { $this->setUser(null); $this->setLoginName(null); $this->unsetMagicInCookie(); + $this->session->clear(); } /** diff --git a/lib/private/util.php b/lib/private/util.php index 9b8a7a5bc40..de4bef4cb8a 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -388,13 +388,13 @@ class OC_Util { /** * Add a custom element to the header - * + * If $text is null then the element will be written as empty element. + * So use "" to get a closing tag. * @param string $tag tag name of the element * @param array $attributes array of attributes for the element * @param string $text the text content for the element - * @return void */ - public static function addHeader($tag, $attributes, $text = '') { + public static function addHeader($tag, $attributes, $text=null) { self::$headers[] = array( 'tag' => $tag, 'attributes' => $attributes, diff --git a/lib/public/util.php b/lib/public/util.php index 22ded1d0fc5..a87d26a4004 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -147,12 +147,14 @@ class Util { /** * Add a custom element to the header + * If $text is null then the element will be written as empty element. + * So use "" to get a closing tag. * @param string $tag tag name of the element * @param array $attributes array of attributes for the element * @param string $text the text content for the element */ - public static function addHeader( $tag, $attributes, $text='') { - \OC_Util::addHeader( $tag, $attributes, $text ); + public static function addHeader($tag, $attributes, $text=null) { + \OC_Util::addHeader($tag, $attributes, $text); } /** diff --git a/settings/admin.php b/settings/admin.php index f77145e0340..d58b9a597b9 100644 --- a/settings/admin.php +++ b/settings/admin.php @@ -6,89 +6,117 @@ */ OC_Util::checkAdminUser(); +OC_App::setActiveNavigationEntry("admin"); -OCP\Util::addStyle('settings', 'settings'); -OCP\Util::addScript('settings', 'settings'); -OCP\Util::addScript( "settings", "admin" ); -OCP\Util::addScript( "settings", "log" ); -OCP\Util::addScript( 'core', 'multiselect' ); -OCP\Util::addScript('core', 'select2/select2'); -OCP\Util::addStyle('core', 'select2/select2'); -OCP\Util::addScript('core', 'setupchecks'); -OC_App::setActiveNavigationEntry( "admin" ); - -$tmpl = new OC_Template( 'settings', 'admin', 'user'); -$forms=OC_App::getForms('admin'); -$htaccessworking=OC_Util::isHtaccessWorking(); - -$entries=OC_Log_Owncloud::getEntries(3); -$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3; +$template = new OC_Template('settings', 'admin', 'user'); +$htAccessWorking = OC_Util::isHtaccessWorking(); + +$entries = OC_Log_Owncloud::getEntries(3); +$entriesRemaining = count(OC_Log_Owncloud::getEntries(4)) > 3; $config = \OC::$server->getConfig(); +$appConfig = \OC::$server->getAppConfig(); // Should we display sendmail as an option? -$tmpl->assign('sendmail_is_available', (bool) findBinaryPath('sendmail')); - -$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 )); -$tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' )); -$tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' )); -$tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' )); -$tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' )); -$tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' )); -$tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' )); -$tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' )); -$tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false )); -$tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' )); -$tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' )); -$tmpl->assign('entries', $entries); -$tmpl->assign('entriesremain', $entriesremain); -$tmpl->assign('htaccessworking', $htaccessworking); -$tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking()); -$tmpl->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8()); -$tmpl->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking()); -$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded()); -$tmpl->assign('old_php', OC_Util::isPHPoutdated()); -$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax')); -$tmpl->assign('cron_log', OC_Config::getValue('cron_log', true)); -$tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false)); -$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes')); -$tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no')); -$tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7')); -$tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no')); -$excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; -$tmpl->assign('shareExcludeGroups', $excludeGroups); -$excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', ''); +$template->assign('sendmail_is_available', (bool)findBinaryPath('sendmail')); + +$template->assign('loglevel', $config->getSystemValue("loglevel", 2)); +$template->assign('mail_domain', $config->getSystemValue("mail_domain", '')); +$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", '')); +$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", '')); +$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", '')); +$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", '')); +$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", '')); +$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", '')); +$template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false)); +$template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", '')); +$template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", '')); +$template->assign('entries', $entries); +$template->assign('entriesremain', $entriesRemaining); +$template->assign('htaccessworking', $htAccessWorking); +$template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking()); +$template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8()); +$template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking()); +$template->assign('has_fileinfo', OC_Util::fileInfoLoaded()); +$template->assign('old_php', OC_Util::isPHPoutdated()); +$template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax')); +$template->assign('cron_log', $config->getSystemValue('cron_log', true)); +$template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false)); +$template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes')); +$template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no')); +$template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7')); +$template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no')); +$excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; +$template->assign('shareExcludeGroups', $excludeGroups); +$excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', ''); $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON! -$tmpl->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList)); +$template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList)); // Check if connected using HTTPS -$tmpl->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https'); -$tmpl->assign('enforceHTTPSEnabled', OC_Config::getValue( "forcessl", false)); +$template->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https'); +$template->assign('enforceHTTPSEnabled', $config->getSystemValue("forcessl", false)); -// If the current webroot is non-empty but the webroot from the config is, +// If the current web root is non-empty but the web root from the config is, // and system cron is used, the URL generator fails to build valid URLs. -$shouldSuggestOverwriteWebroot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' && +$shouldSuggestOverwriteWebRoot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' && \OC::$WEBROOT && \OC::$WEBROOT !== '/' && !$config->getSystemValue('overwritewebroot', ''); -$tmpl->assign('suggestedOverwriteWebroot', ($shouldSuggestOverwriteWebroot) ? \OC::$WEBROOT : ''); - -$tmpl->assign('allowLinks', OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes')); -$tmpl->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired()); -$tmpl->assign('allowPublicUpload', OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes')); -$tmpl->assign('allowResharing', OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes')); -$tmpl->assign('allowMailNotification', OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'no')); -$tmpl->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); -$tmpl->assign('forms', array()); -foreach($forms as $form) { - $tmpl->append('forms', $form); -} +$suggestedOverwriteWebRoot = ($shouldSuggestOverwriteWebRoot) ? \OC::$WEBROOT : ''; +$template->assign('suggestedOverwriteWebroot', $suggestedOverwriteWebRoot); +$template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes')); +$template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired()); +$template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes')); +$template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes')); +$template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no')); +$template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false); -$tmpl->assign('databaseOverload', $databaseOverload); +$template->assign('databaseOverload', $databaseOverload); + + +// add hardcoded forms from the template +$forms = OC_App::getForms('admin'); +$l = OC_L10N::get('settings'); +$formsAndMore = array(); +if (OC_Request::serverProtocol() !== 'https' || !$htAccessWorking || !OC_Util::isAnnotationsWorking() || + $suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() || + OC_Util::isPHPoutdated() || !OC_Util::fileInfoLoaded() || $databaseOverload +) { + $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings')); +} + +$formsMap = array_map(function ($form) { + if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) { + $sectionName = str_replace('<h2>', '', $regs[0]); + $sectionName = str_replace('</h2>', '', $sectionName); + $anchor = strtolower($sectionName); + $anchor = str_replace(' ', '-', $anchor); + + return array( + 'anchor' => $anchor, + 'section-name' => $sectionName, + 'form' => $form + ); + } + return array( + 'form' => $form + ); +}, $forms); + +$formsAndMore = array_merge($formsAndMore, $formsMap); + +// add bottom hardcoded forms from the template +$formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron')); +$formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing')); +$formsAndMore[] = array('anchor' => 'security', 'section-name' => $l->t('Security')); +$formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server')); +$formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log')); + +$template->assign('forms', $formsAndMore); -$tmpl->printPage(); +$template->printPage(); /** - * Try to find a programm + * Try to find a program * * @param string $program * @return null|string diff --git a/settings/js/admin.js b/settings/js/admin.js index 09e8a1d6916..e3a092f71b0 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -3,7 +3,8 @@ $(document).ready(function(){ // Hack to add a trusted domain if (params.trustDomain) { - OC.dialogs.confirm(t('core', 'Are you really sure you want add "{domain}" as trusted domain?', {domain: params.trustDomain}), + OC.dialogs.confirm(t('core', 'Are you really sure you want add "{domain}" as trusted domain?', + {domain: params.trustDomain}), t('core', 'Add trusted domain'), function(answer) { if(answer) { $.ajax({ @@ -52,14 +53,13 @@ $(document).ready(function(){ }); $('#shareAPI input:not(#excludedGroups)').change(function() { + var value = $(this).val(); if ($(this).attr('type') === 'checkbox') { if (this.checked) { - var value = 'yes'; + value = 'yes'; } else { - var value = 'no'; + value = 'no'; } - } else { - var value = $(this).val(); } OC.AppConfig.setValue('core', $(this).attr('name'), value); }); diff --git a/settings/js/log.js b/settings/js/log.js index 197fef907a0..46d1bfefd5f 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -5,75 +5,77 @@ * See the COPYING-README file. */ -OC.Log={ - reload:function(count){ - if(!count){ - count=OC.Log.loaded; +/* global formatDate */ + +OC.Log = { + reload: function (count) { + if (!count) { + count = OC.Log.loaded; } - OC.Log.loaded=0; + OC.Log.loaded = 0; $('#log tbody').empty(); OC.Log.getMore(count); }, - levels:['Debug','Info','Warning','Error','Fatal'], - loaded:3,//are initially loaded - getMore:function(count){ + levels: ['Debug', 'Info', 'Warning', 'Error', 'Fatal'], + loaded: 3,//are initially loaded + getMore: function (count) { count = count || 10; - $.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){ - if(result.status === 'success'){ + $.get(OC.filePath('settings', 'ajax', 'getlog.php'), {offset: OC.Log.loaded, count: count}, function (result) { + if (result.status === 'success') { OC.Log.addEntries(result.data); - if(!result.remain){ + if (!result.remain) { $('#moreLog').hide(); } $('#lessLog').show(); } }); }, - showLess:function(count){ + showLess: function (count) { count = count || 10; //calculate remaining items - at least 3 - OC.Log.loaded = Math.max(3,OC.Log.loaded-count); + OC.Log.loaded = Math.max(3, OC.Log.loaded - count); $('#moreLog').show(); // remove all non-remaining items $('#log tr').slice(OC.Log.loaded).remove(); - if(OC.Log.loaded <= 3) { + if (OC.Log.loaded <= 3) { $('#lessLog').hide(); } }, - addEntries:function(entries){ - for(var i=0;i<entries.length;i++){ - var entry=entries[i]; - var row=$('<tr/>'); - var levelTd=$('<td/>'); + addEntries: function (entries) { + for (var i = 0; i < entries.length; i++) { + var entry = entries[i]; + var row = $('<tr/>'); + var levelTd = $('<td/>'); levelTd.text(OC.Log.levels[entry.level]); row.append(levelTd); - var appTd=$('<td/>'); + var appTd = $('<td/>'); appTd.text(entry.app); row.append(appTd); - var messageTd=$('<td/>'); + var messageTd = $('<td/>'); messageTd.text(entry.message); row.append(messageTd); - var timeTd=$('<td/>'); + var timeTd = $('<td/>'); timeTd.addClass('date'); - if(isNaN(entry.time)){ + if (isNaN(entry.time)) { timeTd.text(entry.time); } else { - timeTd.text(formatDate(entry.time*1000)); + timeTd.text(formatDate(entry.time * 1000)); } row.append(timeTd); $('#log').append(row); } OC.Log.loaded += entries.length; } -} +}; -$(document).ready(function(){ - $('#moreLog').click(function(){ +$(document).ready(function () { + $('#moreLog').click(function () { OC.Log.getMore(); - }) - $('#lessLog').click(function(){ + }); + $('#lessLog').click(function () { OC.Log.showLess(); - }) + }); }); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 2ea5d824909..f02dedbbc80 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -8,6 +8,16 @@ * @var array $_ * @var \OCP\IL10N $l */ + +style('settings', 'settings'); +script('settings', 'settings'); +script( "settings", "admin" ); +script( "settings", "log" ); +script( 'core', 'multiselect' ); +script('core', 'select2/select2'); +style('core', 'select2/select2'); +script('core', 'setupchecks'); + $levels = array('Debug', 'Info', 'Warning', 'Error', 'Fatal'); $levelLabels = array( $l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ), @@ -40,9 +50,23 @@ if ($_['sendmail_is_available']) { if ($_['mail_smtpmode'] == 'qmail') { $mail_smtpmode[] = 'qmail'; } - ?> +<div id="app-navigation"> + <ul> + <?php foreach($_['forms'] as $form) { + if (isset($form['anchor'])) { + $anchor = '#' . $form['anchor']; + $sectionName = $form['section-name']; + print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", OC_Util::sanitizeHTML($anchor), OC_Util::sanitizeHTML($sectionName))); + } + }?> + </ul> +</div> + +<div id="app-content"> + +<div id="security-warning"> <?php // is ssl working ? @@ -72,7 +96,6 @@ if (!$_['htaccessworking']) { </div> <?php } - // Are doc blocks accessible? if (!$_['isAnnotationsWorking']) { ?> @@ -193,10 +216,12 @@ if ($_['suggestedOverwriteWebroot']) { ?></span> </div> </div> -<?php foreach ($_['forms'] as $form) { - print_unescaped($form); -} -;?> +</div> +<?php foreach($_['forms'] as $form) { + if (isset($form['form'])) {?> + <div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div> + <?php } +};?> <div class="section" id="backgroundjobs"> <h2 class="inlineblock"><?php p($l->t('Cron'));?></h2> @@ -419,7 +444,7 @@ if ($_['suggestedOverwriteWebroot']) { <span id="sendtestmail_msg" class="msg"></span> </div> -<div class="section"> +<div class="section" id="log-section"> <h2><?php p($l->t('Log'));?></h2> <?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'> <?php for ($i = 0; $i < 5; $i++): @@ -472,3 +497,4 @@ if ($_['suggestedOverwriteWebroot']) { <div class="section credits-footer"> <p><?php print_unescaped($theme->getShortFooter()); ?></p> </div> +</div> |