Skip to content

Commit

Permalink
fix code style that wasn't autofixed previously
Browse files Browse the repository at this point in the history
Because of previous commit (php-cs-fixer wasn't run anymore)
  • Loading branch information
tenzap committed Dec 16, 2024
1 parent 799b8d4 commit 5d5babb
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 94 deletions.
4 changes: 2 additions & 2 deletions application/config/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
// Plugins_lib.php of upstream. Using 'plugin_dir' is actually a bug in upstream.
$config['plugin_path'] = APPPATH . 'plugins/';

require_once( APPPATH . 'libraries/abstract.plugins.php' );
require_once( APPPATH . 'libraries/trait.plugins.php' );
require_once(APPPATH . 'libraries/abstract.plugins.php');
require_once(APPPATH . 'libraries/trait.plugins.php');
5 changes: 2 additions & 3 deletions application/controllers/Pluginss.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ function __construct()

$this->load->library('Plugins_lib_kalkun');
$this->load->model('Plugins_kalkun_model');

$this->plugins_lib_kalkun->restore_orphaned_plugins();
$this->plugins_lib_kalkun->update_all_plugin_headers();

}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -86,7 +85,7 @@ function index($type = 'installed')
{
continue;
}
if (! ($plugin->status & $plugins_lib::P_STATUS_ENABLED))
if ( ! ($plugin->status & $plugins_lib::P_STATUS_ENABLED))
{
$data['plugins'][$key] = $plugin;
}
Expand Down
15 changes: 9 additions & 6 deletions application/controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@ function add_user_process()
'msg' => tr_raw('Modification of username of "kalkun" user forbidden in demo mode. Username was restored.'),
];
}
else if ($this->input->post('level') !== 'admin')
else
{
$return_msg = [
'type' => 'error',
'msg' => tr_raw('Changing role of "kalkun" user forbidden in demo mode. Role was restored.'),
];
if ($this->input->post('level') !== 'admin')
{
$return_msg = [
'type' => 'error',
'msg' => tr_raw('Changing role of "kalkun" user forbidden in demo mode. Role was restored.'),
];
}
}
}
if (! isset($return_msg))
if ( ! isset($return_msg))
{
$return_msg = [
'type' => 'info',
Expand Down
38 changes: 19 additions & 19 deletions application/helpers/plugin_kalkun_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
* @link https://kalkun.sourceforge.io/
*/

# This file includes/requires the original upstream file at the end of the document
# which permits us to override some methods before they are defined by upstream
// This file includes/requires the original upstream file at the end of the document
// which permits us to override some methods before they are defined by upstream

if( ! function_exists('do_action_kalkun'))
if ( ! function_exists('do_action_kalkun'))
{
/**
* Shortcut to Plugins_lib::do_action_kalkun()
*
* Execute all plugin functions tied to a specific tag
*
* @param string $tag Tag to execute
* @param mixed $args Arguments to hand to plugin (Can be anything)
*
* @since 0.1.0
* @return mixed
*/
function do_action_kalkun( $tag, $args = NULL )
{
//log_message('error',"Doing $tag " . ($args ? "With args: " . serialize($args) : "With no args"));
return Plugins_lib::$instance->do_action_kalkun( $tag, $args );
}
/**
* Shortcut to Plugins_lib::do_action_kalkun()
*
* Execute all plugin functions tied to a specific tag
*
* @param string $tag Tag to execute
* @param mixed $args Arguments to hand to plugin (Can be anything)
*
* @since 0.1.0
* @return mixed
*/
function do_action_kalkun($tag, $args = NULL)
{
//log_message('error',"Doing $tag " . ($args ? "With args: " . serialize($args) : "With no args"));
return Plugins_lib::$instance->do_action_kalkun($tag, $args);
}
}

require_once('plugin_helper.php');
103 changes: 51 additions & 52 deletions application/models/Plugins_kalkun_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,64 @@
*/
class Plugins_kalkun_model extends Plugins_model {

function __construct()
{
parent::__construct();
}
function __construct()
{
parent::__construct();
}

/**
* Insert Plugin
*
* Insert the plugin information in the database.
*
* @param str $plugin The system_name of the plugin
* @param array $settings New settings for plugin
* @access public
* @since 0.1.0
* @return bool
*/
public function insert_plugin($plugin, array $settings)
{
return static::$db->where('system_name', $plugin)->insert('plugins', $settings);
}
/**
* Insert Plugin
*
* Insert the plugin information in the database.
*
* @param str $plugin The system_name of the plugin
* @param array $settings New settings for plugin
* @access public
* @since 0.1.0
* @return bool
*/
public function insert_plugin($plugin, array $settings)
{
return static::$db->where('system_name', $plugin)->insert('plugins', $settings);
}

// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

/**
* Get Plugins
*
* Get all plugins, return an array of the plugins from the database, with the system_name
* as the keys
* The override here is so that it returns FALSE only if the result is not an array.
* ie. if the resultset is emtpy (ie. an empty array), it will not return FALSE but the empty array.
*
* @access public
* @since 0.1.0
* @return array|bool
*/
public function get_plugins()
{
$query = static::$db->get('plugins');
/**
* Get Plugins
*
* Get all plugins, return an array of the plugins from the database, with the system_name
* as the keys
* The override here is so that it returns FALSE only if the result is not an array.
* ie. if the resultset is emtpy (ie. an empty array), it will not return FALSE but the empty array.
*
* @access public
* @since 0.1.0
* @return array|bool
*/
public function get_plugins()
{
$query = static::$db->get('plugins');

if( ! is_array($result = $query->result()))
{
log_message('error', 'Error retrieving plugins from database');
if ( ! is_array($result = $query->result()))
{
log_message('error', 'Error retrieving plugins from database');

return FALSE;
}
return FALSE;
}

$return = array();
$return = array();

foreach($result as $r)
{
if( ! empty($r->data))
{
$r->data = unserialize($r->data);
}
foreach ($result as $r)
{
if ( ! empty($r->data))
{
$r->data = unserialize($r->data);
}

$return[$r->system_name] = $r;
}

return $return;
}
$return[$r->system_name] = $r;
}

return $return;
}
}
9 changes: 6 additions & 3 deletions application/models/User_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ function addUser()
// Restore username to 'kalkun'
$this->db->set('username', 'kalkun');
}
else if ($this->input->post('level') !== 'admin')
else
{
// Restore level to 'admin'
$this->db->set('level', 'admin');
if ($this->input->post('level') !== 'admin')
{
// Restore level to 'admin'
$this->db->set('level', 'admin');
}
}
}
$this->db->where('id_user', $this->input->post('id_user'));
Expand Down
3 changes: 1 addition & 2 deletions application/plugins/Plugin_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class Plugin_helper {

public static function autoloader()
{
spl_autoload_register(function ($class_name)
{
spl_autoload_register(function ($class_name) {
if (strpos($class_name, 'Kalkun\\Plugins') === 0)
{
$class = array_slice(explode('\\', $class_name), -1)[0];
Expand Down
4 changes: 2 additions & 2 deletions application/plugins/phonebook_ldap/phonebook_ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function phonebook_ldap($number)
//Create result set
$entries = ldap_get_entries($conn, $result);
$z = 0;
for ($i = 0; $i < $entries['count']; $i ++ )
for ($i = 0; $i < $entries['count']; $i++)
{
// phone number or name not found, continue iteration
if ( ! array_key_exists('telephonenumber', $entries[$i]) OR ! array_key_exists('givenname', $entries[$i]))
Expand All @@ -87,7 +87,7 @@ function phonebook_ldap($number)
{
$users[$z]['name'] .= $entries[$i]['sn'][0];
}
$z ++;
$z++;
}
ldap_close($conn);
return $users;
Expand Down
2 changes: 1 addition & 1 deletion application/plugins/server_alert/server_alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Server_alert_plugin extends CI3_plugin_system {

use plugin_trait;

// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

/**
* Install Plugin
Expand Down
4 changes: 2 additions & 2 deletions application/plugins/sms_to_wordpress/sms_to_wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

require_once (APPPATH . 'plugins/Plugin_helper.php');

class Sms_to_wordpress_plugin extends CI3_plugin_system {

class Sms_to_wordpress_plugin extends CI3_plugin_system
{
use plugin_trait;

public function __construct()
Expand Down
2 changes: 1 addition & 1 deletion application/plugins/soap/soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Soap_plugin extends CI3_plugin_system {

use plugin_trait;

// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

/**
* Install Plugin
Expand Down
2 changes: 1 addition & 1 deletion application/views/main/dock.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
IntlDateFormatter::FULL,
IntlDateFormatter::SHORT
);
echo $fmt->format(time()) . " " . IntlTimeZone::createDefault()->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, $this->lang->locale);
echo $fmt->format(time()) . ' ' . IntlTimeZone::createDefault()->getDisplayName(FALSE, IntlTimeZone::DISPLAY_SHORT, $this->lang->locale);
?>
</div>

Expand Down
1 change: 1 addition & 0 deletions utils/php-cs-fixer-configs/finder.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
->notPath('config/smileys.php')
->notPath('config/user_agents.php')
->notPath('models/Plugins_model.php')
->notPath('helpers/plugin_helper.php')
->in('application')
//->in(__DIR__)
;

0 comments on commit 5d5babb

Please sign in to comment.