class MessageDB extends DB {
function __construct() {
parent::__construct();
global $g_user_object;
$options = $this->get_usernames();
$this->has(array(
subject => array(isa => 'Str32',
name => "Subject",
row => 1,
col => 1,
required => 1,
control => function($args){
$args["size"] = "40";
$args["maxlength"] = "32";
render_input($args);}),
message => array(isa => 'Text',
name => "Message",
row => 3,
col => 1,
required => 1,
control => function($args) {
$args["rows"] = "10";
$args["cols"] = "60";
render_textarea($args, $args['value']);}),
from_user_id => array(isa => 'int',
required => 1,
init => $g_user_object->get_user_id()),
to_user_id => array(name => 'To',
isa => 'int',
row => 2,
col => 1,
required => 1,
control => function($args) use ($options) {
render_multiselect("to_user_id[]", $_POST['to_user_id'], $options, "5");
})));
}
function get_usernames() {
$options = array();
$sql = "SELECT user_id, username FROM lms_user ORDER BY username";
if ($stmt = $this->db_prepare($sql, null)) {
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_row()) {
array_push($options, array('value' => $row[0], 'label' => $row[1]));
}
$stmt->close();
}
return($options);
}
}
Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer