Initial commit

This commit is contained in:
Joey Kimsey
2024-08-04 21:15:59 -04:00
parent c9d1fb983f
commit 0d469501ee
695 changed files with 70184 additions and 71 deletions

View File

@ -0,0 +1,54 @@
<?php
/**
* app/plugins/dashboards/models/dashboards.php
*
* This class is used for the manipulation of the dashboards database table.
*
* @todo make this send a confirmation email
*
* @package TP Dashboards
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Dashboards as Plugin;
class Dashboards extends DatabaseModel {
public $tableName = 'dashboards';
public $databaseMatrix = [
[ 'name', 'varchar', '128' ],
];
public $plugin;
/**
* The model constructor.
*/
public function __construct() {
parent::__construct();
$this->plugin = new Plugin;
}
public function create( $name, $email, $dashboard ) {
if ( !$this->plugin->checkEnabled() ) {
Debug::info( 'Dashboards are disabled in the config.' );
return false;
}
$fields = [
'name' => $name,
'email' => $email,
'time' => time(),
'ip' => $_SERVER['REMOTE_ADDR'],
];
if ( !self::$db->insert( $this->tableName, $fields ) ) {
Debug::info( 'Dashboards::create - failed to insert to db' );
return false;
}
return self::$db->lastId();
}
}