Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copied from CakePHP, adjusted for PSR-12
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.php]
indent_size = 4
max_line_length = 80

[*.bat]
end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2
46 changes: 46 additions & 0 deletions .github/workflows/dockerpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Docker

on:
push:
branches:
- master
pull_request:

env:
IMAGE_NAME: wannabe-app

jobs:
push:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Calculate tags and other docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}

- name: Set up builder
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: --debug

- name: Login to Github packages
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
# TODO: Remove once GITHUB_TOKEN support is relased for GHCR
password: ${{ secrets.GHCR_PAT }}

- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.docker_meta.outputs.tags }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
22 changes: 7 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ ARG PHP_VERSION

### Builder
FROM composer as Builder
ARG GIT_BRANCH
RUN echo "Building app from ${GIT_BRANCH:-prod} branch"
RUN echo "Building app from local folder, with PHP version ${PHP_VERSION:-7}"

RUN apk add git
RUN git clone --single-branch --branch ${GIT_BRANCH:-prod} https://github.com/gathering/wannabe.git ./
COPY . .

# Remove lock file since it's currently configured only for PHP 5
RUN rm -f ./composer.lock
Expand All @@ -18,19 +16,16 @@ RUN chmod +x build/prepare.sh && build/prepare.sh

### Production
FROM php:${PHP_VERSION:-5}-fpm-alpine as production
RUN apk add --no-cache libpng libpng-dev libjpeg-turbo-dev libmcrypt-dev gettext gettext-dev
RUN docker-php-ext-configure gd \
--with-gd \
--with-jpeg-dir \
--with-png-dir
RUN docker-php-ext-install pdo pdo_mysql gd exif mcrypt gettext
RUN apk add --no-cache libpng libpng-dev libjpeg-turbo-dev gettext gettext-dev php-pear
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install pdo pdo_mysql gd exif gettext
COPY --from=builder /app/app /var/www/html/wannabe/app
COPY --from=builder /app/lib /var/www/html/wannabe/lib
COPY --from=builder /app/index.php /var/www/html/wannabe/index.php


### Development
FROM php:${PHP_VERSION:-5}-fpm as Development
FROM php:${PHP_VERSION:-7}-fpm as Development
RUN apt-get update && apt-get install -y \
mariadb-client \
python-dev \
Expand All @@ -43,10 +38,7 @@ RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
unzip
RUN docker-php-ext-configure gd \
--with-gd \
--with-jpeg-dir \
--with-png-dir
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install pdo pdo_mysql gd exif
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=builder /app /var/www/html/wannabe
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@ COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml
```

When in development mode `app` container is using a minimal `php-fpm` docker
image which only contains a few source code and lib folders. This is built by
cloning the `prod` branch from git, installing composer dependencies and doing
some basic preparation steps in `build/prepare.sh`.
image which only contains a few source code and lib folders. This is built from
you local context, so make sure you working directory is clean, or modified as
expected in the final image. Some basic preparation steps are run via
`build/prepare.sh`.

To build production image from another branch:
To semi-cleanly build production image locally from another branch:

```
docker-compose build --build-arg GIT_BRANCH=branch-name app
git stash
git checkout brand-name
docker-compose build app
git stash pop
```

When using in a custom production environment we recommend that you use a
Expand Down
2 changes: 1 addition & 1 deletion app/Config/SqlTemplate/EnrollMailSqlTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EnrollMailSqlTemplate {
array(
'name' => 'E-postlister',
'name_as_header' => 1,
'content' => "<? \nif(preg_match('/:/', \$crews[\$crew_id])) {\nlist(\$supercrewname, \$crewname) = split('[:]', strtolower(\$crews[\$crew_id]));\n} else {\n\$supercrewname = false;\n\$crewname = \$crews[\$crew_id];\n}\n?>\nNår du nå har blitt tatt opp i crew, blir du automatisk påmeldt følgende e-postlister som blir brukt til å spre informasjon og diskutere ting innad i crew.\n\n • <?=WB::\$event->reference?>crew-announce@gathering.org\n Obligatorisk medlemsskap, her kommer ALL viktig info.\n Denne listen er moderert.\n\n • <?=WB::\$event->reference?>crew@gathering.org\n Frivillig diskusjonsliste for crew. Denne listen kan du melde deg av\n i wannabe under «ditt nick» -> E-poslister, hvis du ikke ønsker \n å delta i diskusjonene.\n Denne listen er ikke moderert.\n\n<? if(!\$supercrewname) { ?>\n • <?=WB::\$event->reference?><?=strtolower(\$crewname)?>@gathering.org\n Diskusjonsliste innad i ditt eget crew.\n<? } else { ?>\n • <?=WB::\$event->reference?><?=\$supercrewname?>@gathering.org\n Diskusjonsliste for din hovedseksjon på <?=WB::\$event->name?>.\n\n • <?=WB::\$event->reference?><?=\$supercrewname?>-<?=\$crewname?>@gathering.org\n Diskusjonsliste innad i ditt eget crew.\n<? } ?>\n\nEnkelte av listene genererer en del trafikk. Vi anbefaler at du benytter deg av filtreringsfunksjonen i din e-postklient, så du ikke blir oversvømt. For å unngå filtreringsproblemer som oppstår når enkelte sender e-post til flere lister samtidig, anbefaler vi at du sorterer TG-e-post etter e-posthodet «List-id».\n\nE-postlistene har opptil 300 brukere. Vi har enkle regler du må følge når du skriver til listene:\nhttp://antibiomatika.net/usenet/quoting.html\n\nKort oppsummert: \n• svar under det du svarer på, fjern alt du ikke svarer på\n• bruk > som indenteringstegn på det du svarer på \n\nAlle e-postlesere har muligheten til et slikt oppsett. Hvis du har problemer anbefaler vi Mozilla Thunderbird som e-postklient. Den kan du hente gratis fra http://www.mozilla.com/thunderbird/\n\nVi vil også nevne at e-postlistene skal brukes til samarbeid og intern kommunikasjon. Det er derfor viktig å holde en god tone på e-postlistene :-)",
'content' => "<? \nif(preg_match('/:/', \$crews[\$crew_id])) {\nlist(\$supercrewname, \$crewname) = explode(':', strtolower(\$crews[\$crew_id]));\n} else {\n\$supercrewname = false;\n\$crewname = \$crews[\$crew_id];\n}\n?>\nNår du nå har blitt tatt opp i crew, blir du automatisk påmeldt følgende e-postlister som blir brukt til å spre informasjon og diskutere ting innad i crew.\n\n • <?=WB::\$event->reference?>crew-announce@gathering.org\n Obligatorisk medlemsskap, her kommer ALL viktig info.\n Denne listen er moderert.\n\n • <?=WB::\$event->reference?>crew@gathering.org\n Frivillig diskusjonsliste for crew. Denne listen kan du melde deg av\n i wannabe under «ditt nick» -> E-poslister, hvis du ikke ønsker \n å delta i diskusjonene.\n Denne listen er ikke moderert.\n\n<? if(!\$supercrewname) { ?>\n • <?=WB::\$event->reference?><?=strtolower(\$crewname)?>@gathering.org\n Diskusjonsliste innad i ditt eget crew.\n<? } else { ?>\n • <?=WB::\$event->reference?><?=\$supercrewname?>@gathering.org\n Diskusjonsliste for din hovedseksjon på <?=WB::\$event->name?>.\n\n • <?=WB::\$event->reference?><?=\$supercrewname?>-<?=\$crewname?>@gathering.org\n Diskusjonsliste innad i ditt eget crew.\n<? } ?>\n\nEnkelte av listene genererer en del trafikk. Vi anbefaler at du benytter deg av filtreringsfunksjonen i din e-postklient, så du ikke blir oversvømt. For å unngå filtreringsproblemer som oppstår når enkelte sender e-post til flere lister samtidig, anbefaler vi at du sorterer TG-e-post etter e-posthodet «List-id».\n\nE-postlistene har opptil 300 brukere. Vi har enkle regler du må følge når du skriver til listene:\nhttp://antibiomatika.net/usenet/quoting.html\n\nKort oppsummert: \n• svar under det du svarer på, fjern alt du ikke svarer på\n• bruk > som indenteringstegn på det du svarer på \n\nAlle e-postlesere har muligheten til et slikt oppsett. Hvis du har problemer anbefaler vi Mozilla Thunderbird som e-postklient. Den kan du hente gratis fra http://www.mozilla.com/thunderbird/\n\nVi vil også nevne at e-postlistene skal brukes til samarbeid og intern kommunikasjon. Det er derfor viktig å holde en god tone på e-postlistene :-)",
'position' => 5
),
array(
Expand Down
9 changes: 6 additions & 3 deletions app/Config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php

require APP . 'Vendor/autoload.php';

spl_autoload_unregister(array('App', 'load'));
spl_autoload_register(array('App', 'load'), true, true);

/**
* This file is loaded automatically by the app/webroot/index.php file after core.php
*
Expand Down Expand Up @@ -106,8 +112,5 @@
//Load the Wannabe Class
App::import('Lib', 'Wannabe');

//Load Composer
App::import('Vendor', ['file' => 'autoload']);

// Auth cookie key (change to invalidate all existing re-login/remember cookies), unset to disable functionality
Configure::write('AuthCookieKey', env('AUTH_COOKIE_KEY'));
2 changes: 1 addition & 1 deletion app/Controller/Component/AclComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AclComponent extends Component {
* Init ACL function, makes sure that we got some data in cache, or else it will put
* ACL data there.
*/
public function initialize(&$controller) {
public function initialize(Controller $controller) {

$this->Aclobject = ClassRegistry::init('Aclobject');
$this->controller = $controller;
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Component/LanguageComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LanguageComponent extends Component {
'eng' => 'en'
);

public function initialize(&$controller) {
public function initialize(Controller $controller) {
if(isset($controller->request->query['hl']) && $this->valid($controller->request->query['hl'])) {
$this->lang = $controller->request->query['hl'];
} else if(isset($controller->Wannabe->user['User'])) {
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Component/MenuComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MenuComponent extends Component {

var $controller;

public function initialize(&$controller) {
public function initialize(Controller $controller) {
if(!isset($controller->Wannabe->user['User']['id'])) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Component/TaskHandlerComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TaskHandlerComponent extends Component {
var $task = array();
var $task_button = false;

public function initialize(&$controller) {
public function initialize(Controller $controller) {
if(!isset($controller->Wannabe->user['User']) ||
!$controller->Wannabe->event->reference ||
$controller->Wannabe->user['User']['registered'] != 'done' ||
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Component/TermHandlerComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TermHandlerComponent extends Component {

var $terms = array();

public function initialize(&$controller) {
public function initialize(Controller $controller) {
if(!isset($controller->Wannabe->user['User']) ||
!$controller->Wannabe->event->reference ||
!in_array($controller->Wannabe->user['User']['registered'], ['done', 'edit']) ||
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Component/WannabeComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WannabeComponent extends Component {
var $lang;
var $searchAccess = false;

public function initialize(&$controller) {
public function initialize(Controller $controller) {
if(isset($controller->request->params['eventPrefix'])) {
if($controller->request->params['eventPrefix'] != CakeSession::read('last_event_reference')) {
$controller->changedEvent = true;
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/CrewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public function viewAllTaskStatuses() {
public function description($name=null) {
preg_match('/\/(\w+)\/(\w+)\/(\w+)\/(.*)/', $this->here, $matches);
array_splice($matches, 0, 4);
if(!empty($matches)) list($name) = split('[/]', $matches[0]);
if(!empty($matches)) list($name) = explode('/', $matches[0]);

if ($name !== null) {
$crews = & $this->Crew->find('all', array(
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/WikiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class WikiController extends AppController {
public function index() {
preg_match('/\/(\w+)\/(\w+)\/(.*)/', $this->here, $matches);
array_splice($matches, 0, 3);
$args = split('[/]', $matches[0]);
$args = explode('/', $matches[0]);
$num_args = sizeof($args);
// Make sure the title is camelized.
if ( $num_args > 0 && ($camelizedtitle = Inflector::camelize($args[0])) != $args[0] ) {
Expand Down
4 changes: 2 additions & 2 deletions app/Model/Crew.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Crew extends AppModel {
)
);

public function beforeValidate() {
public function beforeValidate($options = []) {
$this->validate = array(
'name' => array(
'special-characters' => array(
Expand All @@ -38,7 +38,7 @@ public function beforeValidate() {
}


public function beforeSave($options) {
public function beforeSave($options = []) {
/*if($this->data['Crew']['crew_id'] == NULL) {
$this->data['Crew']['crew_id'] = 0;
}*/
Expand Down
2 changes: 1 addition & 1 deletion app/Model/EnrollSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EnrollSetting extends AppModel {
)
);

public function afterSave($created) {
public function afterSave($created, $options = []) {
if(!$created)
$this->clearEnrollCache();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Model/IrcChannelKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IrcChannelKey extends AppModel {
*
* @var array
*/
public function beforeValidate() {
public function beforeValidate($options = []) {
$this->validate = array(
'event_id' => array(
'notempty' => array(
Expand Down
2 changes: 1 addition & 1 deletion app/Model/Mailinglist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Mailinglist extends AppModel {
*
* @var array
*/
public function beforeValidate() {
public function beforeValidate($options = []) {
$this->validate = array(
'event_id' => array(
'notempty' => array(
Expand Down
15 changes: 6 additions & 9 deletions app/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class User extends AppModel {
)
);

public function beforeValidate() {
public function beforeValidate($options = []) {
$this->validate = array(
'username' => array(
'username-rule-1' => array(
Expand Down Expand Up @@ -86,14 +86,14 @@ public function beforeValidate() {
);
}

public function beforeFind() {
public function beforeFind($query) {
if(isset(WB::$event->id)) {
$this->hasAndBelongsToMany['Crew']['conditions'] = ' Crew.event_id='.(int)WB::$event->id;
}
return true;
}

public function afterFind($res) {
public function afterFind($res, $primary = false) {
$loadExtras = $this->loadExtras;
foreach ( $res as & $result ) {
// Calculate the age for the user.
Expand All @@ -110,9 +110,6 @@ public function afterFind($res) {
}
return $res;
}
public function afterSave() {

}

public function updateLatestActivity($user_id) {
$db = $this->getDataSource();
Expand Down Expand Up @@ -326,9 +323,9 @@ public function clearMemberCache($crew_id) {
public function calculateAge($date) {
list($year, $month, $day) = explode('-', $date);

$year_diff = date('Y') - $year;
$month_diff = date('m') - $month;
$day_diff = date('d') - $day;
$year_diff = intval(date('Y')) - intval($year);
$month_diff = intval(date('m')) - intval($month);
$day_diff = intval(date('d')) - intval($day);

if ( $month_diff < 0 || (($month_diff == 0) and ($day_diff < 0)) )
$year_diff --;
Expand Down
2 changes: 1 addition & 1 deletion app/Model/Wikipage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Wikipage extends AppModel {
'order' => ''
)
);
public function save($data) {
public function save($data = [], $validate = true, $fieldList = []) {
$title = addslashes($data['Wikipage']['title']);
$user_id = (int)$data['Wikipage']['user_id'];
$comment = addslashes($data['Wikipage']['comment']);
Expand Down
6 changes: 3 additions & 3 deletions app/View/Helper/WbHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function lastActive($user) {

private function getExtendedFormTag($fieldName)
{
return split('[.]', $fieldName);
return explode('.', $fieldName);
}

private function tagExtendedValue($fieldName)
Expand Down Expand Up @@ -93,7 +93,7 @@ public function useBootstrapForms() {

public function textarea($fieldName, $htmlAttributes=array(), $return=false, $value=false)
{
$fields = split('[.]', $fieldName);
$fields = explode('.', $fieldName);
if (count($fields) <= 2)
return $this->Form->textarea($fieldName, $htmlAttributes, $return);

Expand All @@ -105,7 +105,7 @@ public function textarea($fieldName, $htmlAttributes=array(), $return=false, $va

public function hidden($fieldName, $htmlAttributes=array(), $return=false, $value=false)
{
$fields = split('[.]', $fieldName);
$fields = explode('.', $fieldName);
if (count($fields) <= 2)
return $this->Form($fieldName, $htmlAttributes, $return);

Expand Down
5 changes: 4 additions & 1 deletion app/webroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
*
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
*/
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
define(
'CAKE_CORE_INCLUDE_PATH',
ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib',
);

/**
* Editing below this line should NOT be necessary.
Expand Down
Loading