Skip to content

Commit

Permalink
3.36
Browse files Browse the repository at this point in the history
  • Loading branch information
bugfish\bugfishtm committed Jan 13, 2025
1 parent 6e837b9 commit 3f27070
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog


## [3.36] - 2025-01-13
### Changes
- x_class_mail_template: Now contains Database Key for Language (Reinstallation Required of Table)
- x_class_mail_template: name_exists($name) function now gives back ID instead of true.
- x_class_mail_template: Changes in different functions to use languages keys for templates. (Multi Language)
- x_class_user: Added Additional Table fields for SuitefishCMS (No Reinstallation required, fields are just optional for use with suitefish-cms)
- x_class_user: New User Table Fields: user_firstname, user_lastname, user_street, user_company, user_postcode, user_country, user_city, user_region, user_tel

## [3.35] - 2024-11-29
### Changes
- Changes on the Documentation
Expand Down
59 changes: 45 additions & 14 deletions _framework/classes/x_class_mail_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class x_class_mail_template {
private $mysql = false; // MySQL for Templates
private $table = false; // Table for Templates
private $section = false; // Section for Templates
private $lang = false; // Section for Templates

// Set Header
public $header = "";
Expand All @@ -49,7 +50,9 @@ public function set_template($name) {
$bind[0]["type"] = "s";
$bind[1]["value"] = $this->section;
$bind[1]["type"] = "s";
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ?", false, $bind);
$bind[2]["value"] = $this->lang;
$bind[2]["type"] = "s";
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ? AND lang = ?", false, $bind);
if(is_array($ar)) {
$this->subject = $ar["subject"];
$this->content = $ar["content"];
Expand All @@ -65,17 +68,19 @@ private function create_table() {
`subject` text NULL COMMENT 'Template Subject',
`description` text NULL COMMENT 'Template Description',
`content` text DEFAULT NULL COMMENT 'Template Content',
`lang` VARCHAR(32) DEFAULT '' COMMENT 'Language Key',
`section` VARCHAR(128) DEFAULT NULL COMMENT 'Related Section',
`creation` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation',
`modification` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modification | Auto - Set',
PRIMARY KEY (`id`),
UNIQUE KEY `x_class_mail_template` (`name`, `section`));");}
UNIQUE KEY `x_class_mail_template` (`name`, `lang`, `section`));");}

// Construct
function __construct($mysql, $table, $section = "") {
function __construct($mysql, $table, $section = "", $lang = "") {
$this->mysql = $mysql;
$this->table = @substr(trim($table ?? ''), 0, 256);
$this->section = @substr(trim($section ?? ''), 0, 127);
$this->lang = @substr(trim($lang ?? ''), 0, 127);
if(!$this->mysql->table_exists($table)) { $this->create_table(); $this->mysql->free_all(); }}

// Substitutions
Expand Down Expand Up @@ -114,12 +119,14 @@ public function get_subject($substitute = false) {
}

// Setup new Mail template
public function setup($name, $subject, $content, $description = "", $overwrite = false) {
public function setup($name, $subject, $content, $description = "", $overwrite = false, $lang = "") {
$bind[0]["value"] = $name;
$bind[0]["type"] = "s";
$bind[1]["value"] = $this->section;
$bind[1]["type"] = "s";
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ?", false, $bind);
$bind[2]["value"] = $this->lang;
$bind[2]["type"] = "s";
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ? AND lang = ?", false, $bind);
if(is_array($ar)) {
if($overwrite) {
$bind[0]["value"] = $name;
Expand All @@ -134,7 +141,9 @@ public function setup($name, $subject, $content, $description = "", $overwrite =
$bind[4]["type"] = "s";
$bind[5]["type"] = "s";
$bind[5]["value"] = $this->section;
$this->mysql->query("UPDATE `".$this->table."` SET name = ?, subject = ?, content = ?, description = ? WHERE name = ? AND section = ?", $bind);
$bind[6]["type"] = "s";
$bind[6]["value"] = $this->lang;
$this->mysql->query("UPDATE `".$this->table."` SET name = ?, subject = ?, content = ?, description = ? WHERE name = ? AND section = ? AND lang = ?", $bind);
}
} else {
$bind[0]["value"] = $name;
Expand All @@ -147,7 +156,9 @@ public function setup($name, $subject, $content, $description = "", $overwrite =
$bind[3]["type"] = "s";
$bind[4]["type"] = "s";
$bind[4]["value"] = $this->section;
$this->mysql->query("INSERT IGNORE INTO `".$this->table."` (name, subject, content, description, section) VALUES(?, ?, ?, ?, ?);", $bind);
$bind[5]["type"] = "s";
$bind[5]["value"] = $this->lang;
$this->mysql->query("INSERT IGNORE INTO `".$this->table."` (name, subject, content, description, section, lang) VALUES(?, ?, ?, ?, ?, ?);", $bind);
return $this->mysql->insert_id;
}
}
Expand All @@ -169,7 +180,9 @@ public function change($id, $name, $subject, $content, $description = "") {
$bind[3]["value"] = $name;
$bind[4]["type"] = "s";
$bind[4]["value"] = $this->section;
$this->mysql->query("UPDATE `".$this->table."` SET subject = ?, content = ?, description = ?, name = ? WHERE id = '".$id."' AND section = ?", $bind);
$bind[5]["type"] = "s";
$bind[5]["value"] = $this->lang;
$this->mysql->query("UPDATE `".$this->table."` SET subject = ?, content = ?, description = ?, name = ? WHERE id = '".$id."' AND section = ? AND lang = ?", $bind);
}
}

Expand All @@ -178,9 +191,11 @@ public function name_exists($name) {
$bind[0]["type"] = "s";
$bind[1]["type"] = "s";
$bind[1]["value"] = $this->section;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ?", false, $bind);
$bind[2]["type"] = "s";
$bind[2]["value"] = $this->lang;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE name = ? AND section = ? AND lang = ?", false, $bind);
if(is_array($ar)) {
return true;
return $ar["id"];
} else {
return false;
}
Expand All @@ -190,7 +205,9 @@ public function get_name_by_id($id) {
if(!is_numeric($id)) { return false; }
$b[0]["type"] = "s";
$b[0]["value"] = $this->section;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ?", false, $b);
$b[1]["type"] = "s";
$b[1]["value"] = $this->lang;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ? AND lang = ?", false, $b);
if(is_array($ar)) {
return $ar["name"];
} else {
Expand All @@ -202,7 +219,9 @@ public function id_exists($id) {
if(!is_numeric($id)) { return false; }
$b[0]["type"] = "s";
$b[0]["value"] = $this->section;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ?", false, $b);
$b[1]["type"] = "s";
$b[1]["value"] = $this->lang;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ? AND lang = ?", false, $b);
if(is_array($ar)) {
return true;
} else {
Expand All @@ -214,14 +233,26 @@ public function id_delete($id) {
if(!is_numeric($id)) { return false; }
$b[0]["type"] = "s";
$b[0]["value"] = $this->section;
return $this->mysql->query("DELETE FROM `".$this->table."` WHERE id = '".$id."' AND section = ?", $b);
$b[1]["type"] = "s";
$b[1]["value"] = $this->lang;
return $this->mysql->query("DELETE FROM `".$this->table."` WHERE id = '".$id."' AND section = ? AND lang = ?", $b);
}

public function name_delete($name) {
$b[0]["type"] = "s";
$b[0]["value"] = $name;
$b[1]["type"] = "s";
$b[1]["value"] = $this->section;
return $this->mysql->query("DELETE FROM `".$this->table."` WHERE name = ? AND id = '".$id."' AND section = ?", $b);
}

public function get_full($id) {
if(!is_numeric($id)) { return false; }
$b[0]["type"] = "s";
$b[0]["value"] = $this->section;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ?", false, $b);
$b[1]["type"] = "s";
$b[1]["value"] = $this->lang;
$ar = $this->mysql->select("SELECT * FROM `".$this->table."` WHERE id = '".$id."' AND section = ? AND lang = ?", false, $b);
if(is_array($ar)) {
return $ar;
} else {
Expand Down
11 changes: 10 additions & 1 deletion _framework/classes/x_class_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ private function create_table($initial = false, $initialpass = "changeme", $init
`user_shadow` varchar(512) DEFAULT NULL COMMENT 'Users Store for Mail if Renew',
`user_rank` int(9) NULL DEFAULT NULL COMMENT 'Users Rank',
`user_confirmed` tinyint(1) DEFAULT '0' COMMENT 'User Activation Status',
`user_firstname` TEXT NULL COMMENT 'Users First Name',
`user_lastname` TEXT NULL COMMENT 'Users Last Name',
`user_street` TEXT NULL COMMENT 'Users Street',
`user_company` TEXT NULL COMMENT 'Users Company Name',
`user_postcode` TEXT NULL COMMENT 'Users Postcode',
`user_country` TEXT NULL COMMENT 'Users Country',
`user_city` TEXT NULL COMMENT 'Users City',
`user_region` TEXT NULL COMMENT 'Users Region',
`user_tel` TEXT NULL COMMENT 'Users Mobile',
`req_activation` datetime DEFAULT NULL COMMENT 'Activation Date Counter for new Requests',
`last_activation` datetime DEFAULT NULL COMMENT 'Activation Date Counter for new Requests',
`user_disabled` int(1) DEFAULT 0 COMMENT '1 - User is Disabled',
Expand Down Expand Up @@ -518,7 +527,7 @@ private function create_table($initial = false, $initialpass = "changeme", $init
$bind[2]["value"] = $this->password_crypt($initialpass);
$this->mysql->query("INSERT INTO `".$this->dt_users."` (user_name, user_mail, user_confirmed, user_pass, user_rank, user_initial)
VALUES(?, ?, 1, ?, '".$initialrank."', 1);", $bind);}}

######################################################################################################################################################
/* . ____ .__
| | ____ ____ |__| ____
Expand Down
2 changes: 1 addition & 1 deletion _framework/classes/x_class_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class x_class_version {
public $contact = "[email protected]";
public $website = "https://www.bugfish.eu";
public $github = "https://github.com/bugfishtm";
public $version = "3.35";
public $version = "3.36";
public $beta = false;
}
Binary file added _releases/3.36.zip
Binary file not shown.

0 comments on commit 3f27070

Please sign in to comment.