Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked Models and Contollers and added service classes #1313

Closed
wants to merge 14 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/master_baikalservice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy PHP app to Azure Web App - baikalService

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v1
with:
files: 'composer.json'

- name: Run composer install if composer.json exists
if: steps.check_files.outputs.files_exists == 'true'
run: composer validate --no-check-publish && composer install --prefer-dist --no-progress

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: php-app
path: release.zip

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: php-app

- name: Unzip artifact for deployment
run: unzip release.zip

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_8E59B8ED0C9C4E2C84F5157B561281B2 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_C958CC7F865F478FA0C807248591BD7E }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_52A01645A16F4737911664E15B728186 }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'baikalService'
slot-name: 'Production'
package: .

70 changes: 70 additions & 0 deletions Core/Frameworks/Baikal/Core/Icons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

#################################################################
# Copyright notice
#
# (c) 2013 Jérôme Schneider <[email protected]>
# All rights reserved
#
# http://sabre.io/baikal
#
# This script is part of the Baïkal Server project. The Baïkal
# Server project is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
#
# This script 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 General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#################################################################

namespace Baikal\Core;

class Icons {

# User Icons
static function iconUser() {
return "icon-user";
}

static function mediumiconUser() {
return "glyph-user";
}

static function bigiconUser() {
return "glyph2x-user";
}

# Address Book Icons
static function iconBook() {
return "icon-book";
}

static function mediumiconBook() {
return "glyph-adress-book";
}

static function bigiconBook() {
return "glyph2x-adress-book";
}

# Calendar Icons
static function iconCalendar() {
return "icon-calendar";
}

static function mediumiconCalendar() {
return "glyph-calendar";
}

static function bigiconCalendar() {
return "glyph2x-calendar";
}
}
12 changes: 0 additions & 12 deletions Core/Frameworks/Baikal/Model/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ static function humanName() {
return "Address Book";
}

static function icon() {
return "icon-book";
}

static function mediumicon() {
return "glyph-adress-book";
}

static function bigicon() {
return "glyph2x-adress-book";
}

function getContactsBaseRequester() {
$oBaseRequester = \Baikal\Model\AddressBook\Contact::getBaseRequester();
$oBaseRequester->addClauseEquals(
Expand Down
66 changes: 30 additions & 36 deletions Core/Frameworks/Baikal/Model/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,43 @@
use Symfony\Component\Yaml\Yaml;

class Calendar extends \Flake\Core\Model\Db {
const DATATABLE = "calendarinstances";
const DATATABLE = "calendars";
const PRIMARYKEY = "id";
const LABELFIELD = "displayname";
const LABELFIELD = "components";

protected $aData = [
"principaluri" => "",
"displayname" => "",
"uri" => "",
"description" => "",
"calendarorder" => 0,
"calendarcolor" => "",
"timezone" => null,
"calendarid" => 0,
"access" => 1,
"share_invitestatus" => 2,
"components" => "",
];
protected $oCalendar; # Baikal\Model\Calendar\Calendar

function __construct($sPrimary = false) {
parent::__construct($sPrimary);
try {
$config = Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml");
$this->set("timezone", $config['system']["timezone"]);
} catch (\Exception $e) {
error_log('Error reading baikal.yaml file : ' . $e->getMessage());

public function getComponents() {
return $this->aData['components'];
}

public function setComponents($components) {
$this->aData['components'] = $components;
}

function hasInstances() {
$rSql = $GLOBALS["DB"]->exec_SELECTquery(
"count(*) as count",
"calendarinstances",
"calendarid='" . $this->aData["id"] . "'"
);

if (($aRs = $rSql->fetch()) === false) {
return false;
} else {
reset($aRs);

return $aRs["count"] > 1;
}
}

protected function initFloating() {
parent::initFloating();
$this->oCalendar = new Calendar\Calendar();
function destroy() {
if ($this->hasInstances()) {
throw new \Exception("Trying to destroy a calendar with instances");
}
parent::destroy();
}

protected function initByPrimary($sPrimary) {
Expand All @@ -74,18 +80,6 @@ function persist() {
parent::persist();
}

static function icon() {
return "icon-calendar";
}

static function mediumicon() {
return "glyph-calendar";
}

static function bigicon() {
return "glyph2x-calendar";
}

function getEventsBaseRequester() {
$oBaseRequester = \Baikal\Model\Calendar\Event::getBaseRequester();
$oBaseRequester->addClauseEquals(
Expand Down
24 changes: 24 additions & 0 deletions Core/Frameworks/Baikal/Model/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,28 @@ class Principal extends \Flake\Core\Model\Db {
"displayname" => "",
"email" => "",
];

public function getUri() {
return $this->aData['uri'];
}

public function setUri($uri) {
$this->aData['uri'] = $uri;
}

public function getDisplayName() {
return $this->aData['displayname'];
}

public function setDisplayName($displayname) {
$this->aData['displayname'] = $displayname;
}

public function getEmail() {
return $this->aData['email'];
}

public function setEmail($email) {
$this->aData['email'] = $email;
}
}
32 changes: 20 additions & 12 deletions Core/Frameworks/Baikal/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

namespace Baikal\Model;

<?php

namespace Baikal\Model;

use Symfony\Component\Yaml\Yaml;

class User extends \Flake\Core\Model\Db {
Expand All @@ -41,6 +45,22 @@ class User extends \Flake\Core\Model\Db {

protected $oIdentityPrincipal;

public function getUsername() {
return $this->aData['username'];
}

public function setUsername($username) {
$this->aData['username'] = $username;
}

public function getDigesta1() {
return $this->aData['digesta1'];
}

public function setDigesta1($digesta1) {
$this->aData['digesta1'] = $digesta1;
}

function initByPrimary($sPrimary) {
parent::initByPrimary($sPrimary);

Expand Down Expand Up @@ -266,18 +286,6 @@ function formMorphologyForThisModelInstance() {
return $oMorpho;
}

static function icon() {
return "icon-user";
}

static function mediumicon() {
return "glyph-user";
}

static function bigicon() {
return "glyph2x-user";
}

function getPasswordHashForPassword($sPassword) {
try {
$config = Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# This script 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 General Public License for more details.
# GNU General Public License for more details..
#
# This copyright notice MUST APPEAR in all copies of the script!
#################################################################
Expand Down
Loading
Loading