Initial commit
This commit is contained in:
75
app/plugins/polls/models/vote.php
Normal file
75
app/plugins/polls/models/vote.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/feedback/models/feedback.php
|
||||
*
|
||||
* This class is used for the manipulation of the feedback database table.
|
||||
*
|
||||
* @todo make this send a confirmation email
|
||||
*
|
||||
* @package TP Feedback
|
||||
* @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\Feedback as Plugin;
|
||||
|
||||
class Feedback extends DatabaseModel {
|
||||
public $tableName = 'feedback';
|
||||
public $databaseMatrix = [
|
||||
|
||||
// userID
|
||||
// review_category_id
|
||||
// rating
|
||||
// review
|
||||
// createdAt
|
||||
// approvedAt
|
||||
[ 'name', 'varchar', '128' ],
|
||||
[ 'time', 'int', '10' ],
|
||||
[ 'email', 'varchar', '128' ],
|
||||
[ 'ip', 'varchar', '64' ],
|
||||
[ 'feedback', 'text', '' ],
|
||||
];
|
||||
public $plugin;
|
||||
|
||||
/**
|
||||
* The model constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->plugin = new Plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a feedback form to the db.
|
||||
*
|
||||
* @param string $name -the name on the form
|
||||
* @param string $email -the email provided
|
||||
* @param string $feedback -contents of the feedback form.
|
||||
* @return bool
|
||||
*/
|
||||
public function create( $name, $email, $feedback ) {
|
||||
if ( !$this->plugin->checkEnabled() ) {
|
||||
Debug::info( 'Feedback is disabled in the config.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'feedback' => $feedback,
|
||||
'time' => time(),
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
];
|
||||
if ( !self::$db->insert( $this->tableName, $fields ) ) {
|
||||
Debug::info( 'Feedback::create - failed to insert to db' );
|
||||
return false;
|
||||
}
|
||||
return self::$db->lastId();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user