Skip to content

Commit

Permalink
plugins: update indentation
Browse files Browse the repository at this point in the history
It's only cosmetic & indentation change of the code
  • Loading branch information
tenzap committed Oct 29, 2024
1 parent 26b9f0b commit 7ff153a
Show file tree
Hide file tree
Showing 21 changed files with 700 additions and 706 deletions.
8 changes: 4 additions & 4 deletions application/models/Plugins_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
* @author Justin Hyland www.justinhyland.com
* @link https://github.com/jhyland87/CI3_Plugin_System
*/
class Plugins_model extends MY_Model
{
class Plugins_model extends MY_Model {

/**
* @var CI_Controller|object Codeigniter instance (get_instance())
*/
Expand Down Expand Up @@ -86,7 +86,7 @@ public function get_plugins()

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

return FALSE;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public function update_plugin_info($plugin, array $settings)
*/
public function set_status($plugin, $status)
{
log_message("error","PLUGIN: $plugin; STATUS: $status");
log_message("error", "PLUGIN: $plugin; STATUS: $status");

if( ! static::$db
->where('system_name', $plugin)
Expand Down
20 changes: 8 additions & 12 deletions application/plugins/Plugin_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ function __construct($login = TRUE)
}
//$this->load->library('Plugins');
//$this->load->library('plugins', array('plugins_dir' => 'application/plugins/'));

// Check if plugin is active
$CI = &get_instance();
$this->load->library('Plugins_lib_kalkun');
if (!isset($this->plugins_lib_kalkun->get_enabled_plugins()[$this->plugin_name]))
if ( ! isset($this->plugins_lib_kalkun->get_enabled_plugins()[$this->plugin_name]))
{
$message = tr_raw('Plugin {0} is not installed.', NULL, $this->plugin_name);
$this->session->set_flashdata('notif', $message);
Expand All @@ -71,23 +70,23 @@ function __construct($login = TRUE)
}

// Temporarily add the plugin path to package path to load language, config...
$this->load->add_package_path(APPPATH.'plugins/'.$this->plugin_name, FALSE);
$this->load->add_package_path(APPPATH . 'plugins/' . $this->plugin_name, FALSE);

// Load translations
if (file_exists(APPPATH.'plugins/'.$this->plugin_name.'/language/english/'.$this->plugin_name.'_lang.php'))
if (file_exists(APPPATH . 'plugins/' . $this->plugin_name . '/language/english/' . $this->plugin_name . '_lang.php'))
{
$this->lang->load($this->plugin_name);
}

// Load plugin config
// Access config items with: $this->config->config[$plugin_name]->item('config_item');
if (file_exists(APPPATH.'plugins/'.$this->plugin_name.'/config/'.$this->plugin_name.'.php'))
if (file_exists(APPPATH . 'plugins/' . $this->plugin_name . '/config/' . $this->plugin_name . '.php'))
{
$this->load->config($this->plugin_name, TRUE);
}

// Remove plugin path from package path now that we finished loading language, config...
$this->load->remove_package_path(APPPATH.'plugins/'.$this->plugin_name);
$this->load->remove_package_path(APPPATH . 'plugins/' . $this->plugin_name);
}

// --------------------------------------------------------------------
Expand All @@ -114,20 +113,17 @@ function initialize($params = array())

// Check if all required value already set, otherwise thrown error
// ...

// Check if plugin already installed
// ..

// Check if plugin activated
// ..

// Set plugin view directory
$this->plugin_view_dir = 'plugin/'.$this->plugin_name.'/';
$this->plugin_view_dir = 'plugin/' . $this->plugin_name . '/';

// if models exist
if (file_exists(APPPATH.'models/plugin/'.$this->plugin_name.'_model.php'))
if (file_exists(APPPATH . 'models/plugin/' . $this->plugin_name . '_model.php'))
{
$this->load->model('plugin/'.$this->plugin_name.'_model', $this->plugin_name.'_model');
$this->load->model('plugin/' . $this->plugin_name . '_model', $this->plugin_name . '_model');
}
}
}
13 changes: 7 additions & 6 deletions application/plugins/Plugin_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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 All @@ -36,7 +37,7 @@ public static function autoloader()
$dirs = explode(DIRECTORY_SEPARATOR, $path);
$plugin_dir_path = implode(DIRECTORY_SEPARATOR, array_slice($dirs, 0, 2));

$fullpath = APPPATH.$plugin_dir_path.'/libraries/'.$class.'.php';
$fullpath = APPPATH . $plugin_dir_path . '/libraries/' . $class . '.php';
if (file_exists($fullpath))
{
require_once $fullpath;
Expand All @@ -48,19 +49,19 @@ public static function autoloader()
public static function get_plugin_config($plugin_name)
{
$CI = &get_instance();
$CI->load->add_package_path(APPPATH.'plugins/'.$plugin_name, FALSE);
$CI->load->add_package_path(APPPATH . 'plugins/' . $plugin_name, FALSE);
$CI->load->config($plugin_name, TRUE);
$CI->load->remove_package_path(APPPATH.'plugins/'.$plugin_name, FALSE);
$CI->load->remove_package_path(APPPATH . 'plugins/' . $plugin_name, FALSE);

return $CI->config->config[$plugin_name];
}

public static function load_lang($plugin_name, $idiom = NULL)
{
$CI = &get_instance();
$CI->load->add_package_path(APPPATH.'plugins/'.$plugin_name, FALSE);
$CI->load->add_package_path(APPPATH . 'plugins/' . $plugin_name, FALSE);
$CI->lang->load($plugin_name, $idiom);
$CI->load->remove_package_path(APPPATH.'plugins/'.$plugin_name, FALSE);
$CI->load->remove_package_path(APPPATH . 'plugins/' . $plugin_name, FALSE);

return $CI->config->config[$plugin_name];
}
Expand Down
114 changes: 57 additions & 57 deletions application/plugins/blacklist_number/blacklist_number.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,86 +10,86 @@

class Blacklist_number_plugin extends CI3_plugin_system {

use plugin_trait;
use plugin_trait;

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

// Add hook for incoming message
add_action('message.incoming.before', array($this, 'blacklist_number_incoming'), 10);

// Add hook for outgoing message
add_action('message.outgoing', array($this, 'blacklist_number_outgoing'), 10);
}
}

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

/**
* Install Plugin
*
* Anything that needs to happen when this plugin gets installed
*
* @access public
* @since 0.1.0
* @return bool TRUE by default
*/
public static function install($data = NULL)
{
$CI = &get_instance();
$CI->load->helper('kalkun');
// check if table already exist
if ( ! $CI->db->table_exists('plugin_blacklist_number'))
/**
* Install Plugin
*
* Anything that needs to happen when this plugin gets installed
*
* @access public
* @since 0.1.0
* @return bool TRUE by default
*/
public static function install($data = NULL)
{
$db_driver = $CI->db->platform();
$db_prop = get_database_property($db_driver);
execute_sql(APPPATH.'plugins/blacklist_number/media/'.$db_prop['file'].'_blacklist_number.sql');
}
return TRUE;
$CI = &get_instance();
$CI->load->helper('kalkun');
// check if table already exist
if ( ! $CI->db->table_exists('plugin_blacklist_number'))
{
$db_driver = $CI->db->platform();
$db_prop = get_database_property($db_driver);
execute_sql(APPPATH . 'plugins/blacklist_number/media/' . $db_prop['file'] . '_blacklist_number.sql');
}
return TRUE;
}

function blacklist_number_incoming($sms)
{
$CI = &get_instance();
$CI->load->model('blacklist_number/blacklist_number_model', 'blacklist_number_model');
$evil = array();
$CI = &get_instance();
$CI->load->model('blacklist_number/blacklist_number_model', 'blacklist_number_model');
$evil = array();

// Get blacklist number
$lists = $CI->blacklist_number_model->get('all')->result_array();
foreach ($lists as $tmp)
{
$evil[] = $tmp['phone_number'];
}
// Get blacklist number
$lists = $CI->blacklist_number_model->get('all')->result_array();
foreach ($lists as $tmp)
{
$evil[] = $tmp['phone_number'];
}

// Delete message if it's on blacklist number
if (in_array($sms->SenderNumber, $evil))
{
$CI->db->where('ID', $sms->ID)->delete('inbox');
return 'break';
}
// Delete message if it's on blacklist number
if (in_array($sms->SenderNumber, $evil))
{
$CI->db->where('ID', $sms->ID)->delete('inbox');
return 'break';
}
}

function blacklist_number_outgoing($numbers = array())
{
$CI = &get_instance();
$CI->load->model('blacklist_number/blacklist_number_model', 'blacklist_number_model');
$evil = array();
$CI = &get_instance();
$CI->load->model('blacklist_number/blacklist_number_model', 'blacklist_number_model');
$evil = array();

// Get blacklist number
$lists = $CI->blacklist_number_model->get('all')->result_array();
foreach ($lists as $tmp)
{
$evil[] = $tmp['phone_number'];
}
// Get blacklist number
$lists = $CI->blacklist_number_model->get('all')->result_array();
foreach ($lists as $tmp)
{
$evil[] = $tmp['phone_number'];
}

// Delete number if it's on blacklist number
foreach ($numbers as $key => $number)
{
if (in_array($number, $evil))
// Delete number if it's on blacklist number
foreach ($numbers as $key => $number)
{
unset($numbers[$key]);
if (in_array($number, $evil))
{
unset($numbers[$key]);
}
}
}
return $numbers;
return $numbers;
}
}
Loading

0 comments on commit 7ff153a

Please sign in to comment.