Skip to content

Commit

Permalink
comment updated and phpunit tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 committed Nov 22, 2023
1 parent 9d7e69b commit 23ef7cd
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 62 deletions.
3 changes: 0 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
error_reporting(E_ALL | E_STRICT);
}

/* config file location */
define('CONFIG_FILE', APP_PATH.'hm3.rc');

/* don't let anything output content until we are ready */
ob_start();

Expand Down
2 changes: 1 addition & 1 deletion lib/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Hm_Dispatch {
*/
public function __construct($config) {

/* get the site config defined in the hm3.rc file */
/* get the site config defined in the config/app.php file */
$this->site_config = $config;

/* check for the site module set override */
Expand Down
23 changes: 0 additions & 23 deletions lib/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,6 @@ protected function get_environment_variables() {
}
}

if (!function_exists('config_env_file')) {
/**
* Get / set the specified configuration value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array|string|null $key
* @param mixed $default
* @return mixed
*/
function config_env_file($key = null, $default = null) {
if (is_null($key)) {
// TO DO
}

if (is_array($key)) {
// TO DO
}
// TO DO
// return ConfigClass->get($key, $default);
}
}

if (!function_exists('env')) {
/**
* Gets the value of an environment variable.
Expand Down
2 changes: 1 addition & 1 deletion modules/2fa/2fa.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for 2 factor authentication with Google Authenticator
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
7 changes: 4 additions & 3 deletions modules/api_login/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
define('APP_PATH', dirname(dirname(dirname(__FILE__))).'/');
define('VENDOR_PATH', APP_PATH.'vendor/');
define('WEB_ROOT', '');
define('CONFIG_FILE', APP_PATH.'hm3.rc');

/* Init the framework */
require_once APP_PATH.'lib/framework.php';
Expand All @@ -29,7 +28,8 @@ function cypht_login($user, $pass, $url, $lifetime=0) {
$session->check($request, $user, $pass, false);
if ($session->is_active()) {
list($domain, $path, $secure) = url_parse($url);
$config = new Hm_Site_Config_File(CONFIG_FILE);
$all_configs = merge_config_files(APP_PATH.'config');
$config = new Hm_Site_Config_File($all_configs);
$user_config = load_user_config_object($config);
$user_config->load($user, $pass);
module_init_functions($user_config, $session, $request, $config, $user, $pass);
Expand Down Expand Up @@ -93,7 +93,8 @@ function url_parse($url) {
* @return array
*/
function session_init() {
$config = new Hm_Site_Config_File(APP_PATH.'hm3.rc');
$all_configs = merge_config_files(APP_PATH.'config');
$config = new Hm_Site_Config_File($all_configs);
$module_exec = new Hm_Module_Exec($config);
$module_exec->load_module_sets('functional_api');
$request = new Hm_Request($module_exec->filters, $config);
Expand Down
2 changes: 1 addition & 1 deletion modules/carddav_contacts/carddav.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for CardDav communication
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Hm_Output_contacts_list extends Hm_Output_Module {
protected function output() {
if (count($this->get('contact_sources', array())) == 0) {
return '<div class="no_contact_sources">'.$this->trans('No contact backends are enabled!').
'<br />'.$this->trans('At least one backend must be enabled in the hm3.ini file to use contacts.').'</div>';
'<br />'.$this->trans('At least one backend must be enabled in the config/app.php file to use contacts.').'</div>';
}
$per_page = 25;
$current_page = $this->get('contact_page', 1);
Expand Down
2 changes: 1 addition & 1 deletion modules/dynamic_login/dynamic_login.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for dynamic login configuration
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/github/github.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for oauth2 communication with github.com
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/hello_world/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This module set is intented to give developers an overview of
* the module system. Most of what it does is silly and consists of printing "Hello
* World" in different ways. You can enable this module by adding it to the modules
* value in the hm3.ini file, and rebuilding the site config.
* value in the config/app.php file.
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/hello_world/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This module set is intented to give developers an overview of
* the module system. Most of what it does is silly and consists of printing "Hello
* World" in different ways. You can enable this module by adding it to the modules
* value in the hm3.ini file, and rebuilding the site config.
* value in the config/app.php file.
*/

/**
Expand All @@ -20,7 +20,7 @@
* These set the default sources for modules assigned in this file. It can be overridden
* by the module assignment itself. The module system uses the source to know which PHP
* files to include when servicing a given request. It should match the name of the module
* set as used in the hm3.ini file, as well as the current directory name.
* set as used in the config/app.php file, as well as the current directory name.
*/
handler_source('hello_world');
output_source('hello_world');
Expand Down
2 changes: 1 addition & 1 deletion modules/hello_world/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* way to delay actions until page onload if you need to. Built in data sources like
* hm_page_name() are defined before this is run so they are also available. When the
* site build process is run this code will be combined with JS from other module sets,
* and optionally minified based on the hm3.ini file settings.
* and optionally minified based on the config/app.php file settings.
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/oauth2.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for oauth2 authentication over IMAP
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/ldap_contacts/ldap.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for LDAP communication
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/recaptcha/recaptcha.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; https://developers.google.com/recaptcha/
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
7 changes: 3 additions & 4 deletions modules/site/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

/**
* To use these overrides, you must first enable the "site" module in your
* hm3.ini file, then rebuild your configuration with the config_gen.php script
* to activate the module.
* config/app.php file to activate the module.
*/

/**
* Override the session class. These are the methods that must be overriden to
* create a new session backend. The "session_type" value in your hm3.ini must
* create a new session backend. The "session_type" value in your config/app.php must
* be set to "custom" to activate this class. There are several other
* properties and methods that can be modified to create custom sessions:
*
Expand Down Expand Up @@ -103,7 +102,7 @@ public function destroy($request) {
/**
* Override the authentication class. This method needs to be overriden to
* create a custom authentication backend. You must set the "auth_type" setting
* in your hm3.ini file to "custom" to activate this class. More information
* in your config/app.php file to "custom" to activate this class. More information
* about the base class for authentication is located here:
*
* https://cypht.org/docs/code_docs/class-Hm_Auth.html
Expand Down
2 changes: 1 addition & 1 deletion modules/themes/themes.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Custom themes available in Cypht
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. You will also need to re-run the
; config_gen.php script.
;
; SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER !
Expand Down
2 changes: 1 addition & 1 deletion modules/wordpress/wordpress.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Constants used for oauth2 communication with WordPress.com
;
; Once you edit this file, you must move it to the directory defined by
; app_data_dir in your hm3.ini file. You will also need to re-run the
; app_data_dir in your config/app.php file. No need to re-run the
; config_gen.php script.
;
;
Expand Down
3 changes: 0 additions & 3 deletions scripts/config_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ function build_config() {
/* combine and compress page content */
$hashes = combine_includes($js, $js_compress, $css, $css_compress, $settings);

/* write out the hm3.rc file */
write_config_file($settings, $filters);

/* create the production version */
create_production_site($assets, $settings, $hashes);
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/create_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
/* get the framework */
require APP_PATH.'lib/framework.php';

$all_configs = merge_config_files(APP_PATH.'config');
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH.'hm3.rc');
$config = new Hm_Site_Config_File($all_configs);

/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
Expand Down
5 changes: 3 additions & 2 deletions scripts/delete_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

/* get the framework */
require APP_PATH.'lib/framework.php';

//get all config array merged
$all_configs = merge_config_files(APP_PATH.'config');
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH.'hm3.rc');
$config = new Hm_Site_Config_File($all_configs);

/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
Expand Down
3 changes: 1 addition & 2 deletions scripts/update_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

/* get the framework */
require APP_PATH.'lib/framework.php';

/* get config object */
$config = new Hm_Site_Config_File(APP_PATH.'hm3.rc');
$config = new Hm_Site_Config_File(merge_config_files(APP_PATH.'config'));

/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function setUp(): void {
* @runInSeparateProcess
*/
public function test_get_modules() {
$config = new Hm_Site_Config_File('./data/siteconfig.rc');
$config = new Hm_Site_Config_File(merge_config_files(APP_PATH.'tests/phpunit/data'));
$this->assertFalse($config->get_modules());
$config->set('modules', 'asdf');
$this->assertEquals(array('asdf'), $config->get_modules());
Expand All @@ -181,15 +181,15 @@ public function test_get_modules() {
* @runInSeparateProcess
*/
public function test_site_load() {
$config = new Hm_Site_Config_File(APP_PATH.'tests/phpunit/data/siteconfig.rc');
$config = new Hm_Site_Config_File(merge_config_files(APP_PATH.'tests/phpunit/data'));
$this->assertEquals(array('version' => VERSION, 'foo' => 'bar', 'default_setting_foo' => 'bar'), $config->dump());
}
/**
* @preserveGlobalState disabled
* @runInSeparateProcess
*/
public function test_get_user_defaults() {
$config = new Hm_Site_Config_File(APP_PATH.'tests/phpunit/data/siteconfig.rc');
$config = new Hm_Site_Config_File(merge_config_files(APP_PATH.'tests/phpunit/data'));
$this->assertEquals(array('version' => VERSION, 'foo' => 'bar', 'default_setting_foo' => 'bar'), $config->dump());
}
public function tearDown(): void {
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/data/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return array('foo' => 'bar','default_setting_foo' => 'bar',);
4 changes: 2 additions & 2 deletions tests/phpunit/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Hm_Test_Dispatch extends TestCase {
public function setUp(): void {
require 'bootstrap.php';
require 'helpers.php';
define('CONFIG_FILE', APP_PATH.'hm3.rc');
define('CONFIG_FILE', merge_config_files(APP_PATH.'config'));
$this->config = new Hm_Mock_Config();
}
/**
Expand Down Expand Up @@ -142,7 +142,7 @@ class Hm_Test_Debug_Page_Redirect extends TestCase {
public function setUp(): void {
define('DEBUG_MODE', true);
require 'bootstrap.php';
define('CONFIG_FILE', APP_PATH.'hm3.rc');
define('CONFIG_FILE', merge_config_files(APP_PATH.'config'));
}
/**
* @preserveGlobalState disabled
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Hm_Test_Request extends TestCase {

public function setUp(): void {
require 'bootstrap.php';
define('CONFIG_FILE', APP_PATH.'hm3.rc');
define('CONFIG_FILE', merge_config_files(APP_PATH.'config'));
$this->config = new Hm_Mock_Config();
}
/**
Expand Down

0 comments on commit 23ef7cd

Please sign in to comment.