Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -1,44 +1,53 @@
|
|||
<?php
|
||||
|
||||
define("CONFIG_PATH", dirname(dirname( __DIR__)) . "/application/configs/");
|
||||
define("DEFAULT_STOR_DIR", "/srv/airtime/stor/");
|
||||
define('CONFIG_PATH', dirname(dirname(__DIR__)) . '/application/configs/');
|
||||
define('DEFAULT_STOR_DIR', '/srv/airtime/stor/');
|
||||
|
||||
require_once(dirname(dirname( __DIR__)) . "/vendor/propel/propel1/runtime/lib/Propel.php");
|
||||
require_once(CONFIG_PATH . 'conf.php');
|
||||
require_once dirname(dirname(__DIR__)) . '/vendor/propel/propel1/runtime/lib/Propel.php';
|
||||
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/map/CcMusicDirsTableMap.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/om/BaseCcMusicDirsQuery.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcMusicDirsQuery.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/om/BaseCcMusicDirs.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcMusicDirs.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/om/BaseCcMusicDirsPeer.php");
|
||||
require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcMusicDirsPeer.php");
|
||||
require_once CONFIG_PATH . 'conf.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/map/CcMusicDirsTableMap.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/om/BaseCcMusicDirsQuery.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/CcMusicDirsQuery.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/om/BaseCcMusicDirs.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/CcMusicDirs.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/om/BaseCcMusicDirsPeer.php';
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . '/application/models/airtime/CcMusicDirsPeer.php';
|
||||
|
||||
/**
|
||||
* Author: sourcefabric
|
||||
* Date: 08/12/14
|
||||
* Date: 08/12/14.
|
||||
*
|
||||
* Class MediaSetup
|
||||
*
|
||||
* Wrapper class for validating and setting up media folder during the installation process
|
||||
*/
|
||||
class MediaSetup extends Setup {
|
||||
class MediaSetup extends Setup
|
||||
{
|
||||
public const MEDIA_FOLDER = 'mediaFolder';
|
||||
public const LIBRETIME_CONF_FILE_NAME = 'airtime.conf';
|
||||
|
||||
const MEDIA_FOLDER = "mediaFolder";
|
||||
const LIBRETIME_CONF_FILE_NAME = "airtime.conf";
|
||||
public static $path;
|
||||
public static $message;
|
||||
public static $errors = [];
|
||||
|
||||
static $path;
|
||||
static $message = null;
|
||||
static $errors = array();
|
||||
|
||||
function __construct($settings) {
|
||||
public function __construct($settings)
|
||||
{
|
||||
self::$path = $settings[self::MEDIA_FOLDER];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array associative array containing a display message and fields with errors
|
||||
*/
|
||||
function runSetup() {
|
||||
public function runSetup()
|
||||
{
|
||||
// If the path passed in is empty, set it to the default
|
||||
if (strlen(self::$path) == 0) {
|
||||
self::$path = DEFAULT_STOR_DIR;
|
||||
|
@ -48,26 +57,26 @@ class MediaSetup extends Setup {
|
|||
}
|
||||
|
||||
// Append a trailing / if they didn't
|
||||
if (!(substr(self::$path, -1) == "/")) {
|
||||
self::$path .= "/";
|
||||
if (!(substr(self::$path, -1) == '/')) {
|
||||
self::$path .= '/';
|
||||
}
|
||||
|
||||
if (file_exists(self::$path)) {
|
||||
$this->setupMusicDirectory();
|
||||
} else {
|
||||
self::$message = "Invalid path!";
|
||||
self::$message = 'Invalid path!';
|
||||
self::$errors[] = self::MEDIA_FOLDER;
|
||||
}
|
||||
|
||||
|
||||
// Finalize and move airtime.conf.temp
|
||||
if (file_exists("/etc/airtime/")) {
|
||||
if (file_exists('/etc/airtime/')) {
|
||||
if (!$this->moveAirtimeConfig()) {
|
||||
self::$message = "Error moving airtime.conf or deleting /tmp/airtime.conf.temp!";
|
||||
self::$errors[] = "ERR";
|
||||
self::$message = 'Error moving airtime.conf or deleting /tmp/airtime.conf.temp!';
|
||||
self::$errors[] = 'ERR';
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're upgrading from an old Airtime instance (pre-2.5.2) we rename their old
|
||||
/*
|
||||
* If we're upgrading from an old Airtime instance (pre-2.5.2) we rename their old
|
||||
* airtime.conf to airtime.conf.tmp during the setup process. Now that we're done,
|
||||
* we can rename it to airtime.conf.bak to avoid confusion.
|
||||
*/
|
||||
|
@ -79,20 +88,22 @@ class MediaSetup extends Setup {
|
|||
}
|
||||
} else {
|
||||
self::$message = "Failed to move airtime.conf; /etc/airtime doesn't exist!";
|
||||
self::$errors[] = "ERR";
|
||||
self::$errors[] = 'ERR';
|
||||
}
|
||||
|
||||
return array(
|
||||
"message" => self::$message,
|
||||
"errors" => self::$errors
|
||||
);
|
||||
|
||||
return [
|
||||
'message' => self::$message,
|
||||
'errors' => self::$errors,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves /tmp/airtime.conf.temp to /etc/airtime.conf and then removes it to complete setup
|
||||
* @return boolean false if either of the copy or removal operations fail
|
||||
* Moves /tmp/airtime.conf.temp to /etc/airtime.conf and then removes it to complete setup.
|
||||
*
|
||||
* @return bool false if either of the copy or removal operations fail
|
||||
*/
|
||||
function moveAirtimeConfig() {
|
||||
public function moveAirtimeConfig()
|
||||
{
|
||||
return copy(AIRTIME_CONF_TEMP_PATH, LIBRETIME_CONF_DIR . '/' . self::LIBRETIME_CONF_FILE_NAME)
|
||||
&& unlink(AIRTIME_CONF_TEMP_PATH);
|
||||
}
|
||||
|
@ -101,21 +112,24 @@ class MediaSetup extends Setup {
|
|||
* Add the given directory to cc_music_dirs
|
||||
* TODO Should we check for an existing entry in cc_music_dirs?
|
||||
*/
|
||||
function setupMusicDirectory() {
|
||||
public function setupMusicDirectory()
|
||||
{
|
||||
try {
|
||||
$_SERVER['AIRTIME_CONF'] = AIRTIME_CONF_TEMP_PATH;
|
||||
Propel::init(CONFIG_PATH . "airtime-conf-production.php");
|
||||
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
||||
$con = Propel::getConnection();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
self::$message = "Failed to insert media folder; database isn't configured properly!";
|
||||
self::$errors[] = self::MEDIA_FOLDER;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runMusicDirsQuery($con);
|
||||
}
|
||||
|
||||
function runMusicDirsQuery($con) {
|
||||
public function runMusicDirsQuery($con)
|
||||
{
|
||||
try {
|
||||
if ($this->checkMusicDirectoryExists($con)) {
|
||||
$dir = CcMusicDirsQuery::create()->findPk(1, $con);
|
||||
|
@ -124,21 +138,22 @@ class MediaSetup extends Setup {
|
|||
}
|
||||
|
||||
$dir->setDirectory(self::$path)
|
||||
->setType("stor")
|
||||
->save();
|
||||
self::$message = "Successfully set up media folder!";
|
||||
->setType('stor')
|
||||
->save()
|
||||
;
|
||||
self::$message = 'Successfully set up media folder!';
|
||||
Propel::close();
|
||||
unset($_SERVER['AIRTIME_CONF']);
|
||||
} catch (Exception $e) {
|
||||
self::$message = "Failed to insert " . self::$path . " into cc_music_dirs";
|
||||
self::$message = 'Failed to insert ' . self::$path . ' into cc_music_dirs';
|
||||
self::$errors[] = self::MEDIA_FOLDER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkMusicDirectoryExists($con) {
|
||||
public function checkMusicDirectoryExists($con)
|
||||
{
|
||||
$entry = CcMusicDirsQuery::create()->findPk(1, $con);
|
||||
|
||||
return isset($entry) && $entry;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue