Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/templateeditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-12-15 15:37:38 +0300
committerGitHub <noreply@github.com>2016-12-15 15:37:38 +0300
commit5124fd1f5cfdb769732eb2f3ca896f0ae12e4d0b (patch)
treef8baa300902a619fffb51ef1eb4530ac38e75772
parentefa3adc5d7c2e94c42ed33b200c5209841e7d156 (diff)
parent67ed313c4930e3ba732b163ce58f98499e8ece27 (diff)
Merge pull request #9 from nextcloud/no-more-php-5.4-and-5.5
Remove 5.4 and 5.5 support
-rw-r--r--.travis.yml52
-rw-r--r--controller/adminsettingscontroller.php2
-rw-r--r--lib/mailtemplate.php46
-rw-r--r--settings-admin.php2
4 files changed, 56 insertions, 46 deletions
diff --git a/.travis.yml b/.travis.yml
index 0429523..9693ff6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,12 @@
language: php
php:
- - 5.4
- - 5.5
- 5.6
- 7
env:
global:
- CORE_BRANCH=master
+ - APP_NAME=templateeditor
matrix:
- DB=sqlite
@@ -18,29 +17,48 @@ branches:
before_install:
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- - bash ./before_install.sh templateeditor $CORE_BRANCH $DB
+ - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB
+
+ # Add some output debugging information
+ - cd ../server
+ - ./occ check
+ - ./occ status
+ - ./occ app:list
+ - ./occ app:enable $APP_NAME
+ - ./occ app:list
script:
- # Test lint
- - cd ../server/apps/templateeditor
- - sh -c "if [ '$DB' = 'sqlite' ]; then ant test; fi"
+ - cd apps/$APP_NAME/
+
+ # Test the app
+ - sh -c "if [ '$CODECHECK' = '1' ]; then find . -name \*.php -exec php -l \"{}\" \;; fi"
+ - cd ../../
+ - sh -c "if [ '$CODECHECK' = '1' ]; then ./occ app:check-code $APP_NAME -c private -c strong-comparison; fi"
+ - sh -c "if [ '$CODECHECK' = '2' ]; then ./occ app:check-code $APP_NAME -c deprecation; fi"
+ - cd apps/$APP_NAME/
# Run phpunit tests
- # - cd tests
- # - phpunit --configuration phpunit.xml
+# - cd tests
+# - sh -c "if [ '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then phpunit --configuration phpunit.xml; fi"
+# - cd ..
# Create coverage report
- # - wget https://scrutinizer-ci.com/ocular.phar
- # - php ocular.phar code-coverage:upload --format=php-clover clover.xml
+# - cd tests
+# - sh -c "if [ '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then wget https://scrutinizer-ci.com/ocular.phar; fi"
+# - sh -c "if [ '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then php ocular.phar code-coverage:upload --format=php-clover clover.xml; fi"
+# - cd ..
matrix:
include:
-# - php: 5.4
-# env: DB=mysql
-# - php: 5.4
-# env: DB=pgsql
-# - php: 5.4
-# env: DB=oracle
+ - php: 5.6
+ env: DB=mysql
+ - php: 5.6
+ env: DB=pgsql
+ - php: 5.6
+ env: DB=mysql;CODECHECK=1
+ - php: 5.6
+ env: DB=mysql;CODECHECK=2
allow_failures:
- - php: hhvm
+ - env: DB=mysql;CODECHECK=2
fast_finish: true
+
diff --git a/controller/adminsettingscontroller.php b/controller/adminsettingscontroller.php
index 0e08123..0987557 100644
--- a/controller/adminsettingscontroller.php
+++ b/controller/adminsettingscontroller.php
@@ -38,7 +38,7 @@ class AdminSettingsController extends ApiController {
/**
* @param string $theme
* @param string $template
- * @return \OCA\TemplateEditor\Http\MailTemplateResponse
+ * @return \OCA\TemplateEditor\Http\MailTemplateResponse|JSONResponse
*/
public function renderTemplate( $theme, $template ) {
try {
diff --git a/lib/mailtemplate.php b/lib/mailtemplate.php
index 285aa83..8afac72 100644
--- a/lib/mailtemplate.php
+++ b/lib/mailtemplate.php
@@ -23,11 +23,11 @@
namespace OCA\TemplateEditor;
-use OCP\Files\NotPermittedException;
-use OC\AppFramework\Middleware\Security\SecurityException;
use OCA\TemplateEditor\Http\MailTemplateResponse;
+use OCP\App\AppPathNotFoundException;
+use OCP\Template;
-class MailTemplate extends \OC_Template {
+class MailTemplate extends Template {
/** @var string */
private $path;
@@ -42,8 +42,8 @@ class MailTemplate extends \OC_Template {
private $editableTemplates;
/**
- * @param string string $theme
- * @param string string $path
+ * @param string $theme
+ * @param string $path
*/
public function __construct($theme, $path) {
$this->theme = $theme;
@@ -57,7 +57,7 @@ class MailTemplate extends \OC_Template {
/**
* @return \OCA\TemplateEditor\Http\MailTemplateResponse
- * @throws \OC\AppFramework\Middleware\Security\SecurityException
+ * @throws \Exception
*/
public function getResponse() {
if($this->isEditable()) {
@@ -66,21 +66,10 @@ class MailTemplate extends \OC_Template {
list(, $template) = $this->findTemplate($this->theme, $app, $name);
return new MailTemplateResponse($template);
}
- throw new SecurityException('Template not editable.', 403);
+ throw new \Exception('Template not editable.', 403);
}
- public function renderContent() {
- if($this->isEditable()) {
- list($app, $filename) = explode('/templates/', $this->path, 2);
- $name = substr($filename, 0, -4);
- list(, $template) = $this->findTemplate($this->theme, $app, $name);
- \OC_Response::sendFile($template);
- } else {
- throw new SecurityException('Template not editable.', 403);
- }
- }
-
- public function isEditable() {
+ protected function isEditable() {
if (isset($this->editableThemes[$this->theme])
&& isset($this->editableTemplates[$this->path])
) {
@@ -107,10 +96,10 @@ class MailTemplate extends \OC_Template {
//overwrite theme templates? use versions?
return file_put_contents($absolutePath, $data);
}
- throw new SecurityException('Template not editable.', 403);
+ throw new \Exception('Template not editable.', 403);
}
- public function reset(){
+ public function reset() {
if($this->isEditable()) {
$absolutePath = \OC::$SERVERROOT.'/themes/'.$this->theme.'/'.$this->path;
if ($this->theme === 'default') {
@@ -132,7 +121,7 @@ class MailTemplate extends \OC_Template {
}
return !file_exists($absolutePath);
}
- throw new NotPermittedException('Template not editable.', 403);
+ throw new \Exception('Template not editable.', 403);
}
/**
@@ -177,10 +166,15 @@ class MailTemplate extends \OC_Template {
'settings/templates/email.new_user_plain_text.php' => $l10n->t('New user email (plain text fallback)'),
);
- if (\OCP\App::isEnabled('activity')) {
- $tmplPath = \OC_App::getAppPath('activity') . '/templates/email.notification.php';
- $path = substr($tmplPath, strlen(\OC::$SERVERROOT) + 1);
- $templates[$path] = $l10n->t('Activity notification mail');
+ $appManager = \OC::$server->getAppManager();
+ if ($appManager->isEnabledForUser('activity')) {
+ try {
+ $tmplPath = $appManager->getAppPath('activity') . '/templates/email.notification.php';
+ $path = substr($tmplPath, strlen(\OC::$SERVERROOT) + 1);
+ $templates[$path] = $l10n->t('Activity notification mail');
+ } catch (AppPathNotFoundException $e) {
+ // App not found, ignore and go on
+ }
}
return $templates;
diff --git a/settings-admin.php b/settings-admin.php
index a86d5d8..67f3f36 100644
--- a/settings-admin.php
+++ b/settings-admin.php
@@ -21,8 +21,6 @@
*
*/
-\OC_Util::checkAdminUser();
-
\OCP\Util::addStyle('templateeditor', 'settings-admin');
\OCP\Util::addScript('templateeditor', 'settings-admin');