Files
bm/public_html/public/cms/modules/attendanceblock.class.php
2025-09-24 13:26:28 +02:00

154 lines
4.3 KiB
PHP

<?php
/** Attendance Block
*
* @version 1.0.0
* @since 2012-01-11
* @author martin lenzelbauer
*/
class AttendanceBlock extends BuildingBlock{
var $event; //event name
var $url = "http://www.bruckmuehle.at/index.php?id=1977&usr={USER_ID}&evt={EVENT_ID}&hash={USER_HASH}";
//var $url = "http://localhost/bruckmuehle/index.php?id=1808&usr={USER_ID}&evt={EVENT_ID}&hash={USER_HASH}";
/** C'tor
*/
//------------------------------------------------
function AttendanceBlock($id=0){
//------------------------------------------------
parent::BuildingBlock($id);
$this->event = "";
}
/** @see BuildingBlock::install()
*/
//-----------------------------------------------
function install(){
//-----------------------------------------------
$query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_attendanceblock (
id INT not null AUTO_INCREMENT,
event VARCHAR(128) not null,
PRIMARY KEY(id)
)");
dbQuery($query);
}
/** @see BuildingBlock::load()
*/
//-------------------------------------------------
function load(){
//-------------------------------------------------
$query = sprintf("SELECT * FROM bruckm_attendanceblock WHERE id = %d", $this->id);
$result = dbQuery($query);
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
$this->event = $line['event'];
}
/** @see BuildingBlock::doSave()
*/
//-----------------------------------------------
function doSave(){
//-----------------------------------------------
$query = sprintf("UPDATE bruckm_attendanceblock SET event = %s WHERE id = %d",
sqlstring($this->event),
$this->id);
dbQuery($query);
}
/** @see BuildingBlock::doCreate()
*/
//-----------------------------------------------
function doCreate(){
//-----------------------------------------------
$query = sprintf("INSERT INTO bruckm_attendanceblock (event) VALUES (%s)",
sqlstring($this->event));
dbQuery($query);
return mysql_insert_id();
}
/** @see BuildingBlock::delete()
*/
//-------------------------------------------------
function delete(){
//-------------------------------------------------
$query = sprintf("DELETE FROM bruckm_attendanceblock WHERE id = %d", $this->id);
dbQuery($query);
@unlink($this->fileDir.$this->file);
}
/** @see BuildingBlock::update()
*/
//-----------------------------------------------
function update(){
//-----------------------------------------------
$this->event = trim($_POST["attendanceblock_event".$this->id]);
}
/** @see BuildingBlock::printContent()
*/
//-----------------------------------------------
function printContent($position){
//-----------------------------------------------
$t = new Template(CMS_TEMPLATE_DIR."attendanceblock.html");
$t->setVar("ID", $this->id);
$t->setVar("POSITION", $position);
$t->setVar("EVENT", htmlspecialchars($this->event));
return $t->toString();
}
/** @see BuildingBlock::publish()
*/
//----------------------------------------------
function publish(){
//----------------------------------------------
$p = new Template();
$p->setString('<p><a href="' . $this->url . '&attendance=1" target="_blank">Ja, ich nehme teil</a><br />' .
'<a href="' . $this->url . '&attendance=0" target="_blank">Nein, ich nehme nicht teil</a></p>');
$p->setVar("EVENT_ID", $this->id);
return $p->toString();
}
/** @see BuildingBlock::publishAsPlainText()
*/
//----------------------------------------------
function publishAsPlainText(){
//----------------------------------------------
$p = new Template();
$p->setString("Ja, ich nehme teil: " . $this->url . "&attendance=1\n" .
"Nein, ich nehme nicht teil: " . $this->url . "&attendance=0\n\n");
$p->setVar("EVENT_ID", $this->id);
return $p->toString();
}
/** @see BuildingBlock::publishForNewsletter()
*/
//----------------------------------------------
function publishForNewsletter(){
//----------------------------------------------
$p = new Template(NEWSLETTER_DIR . "subparts/attendance.html");
$p->setVar("URL", $this->url);
$p->setVar("EVENT_ID", $this->id);
return $p->toString();
}
// === ADDITIONAL METHODS ========================================================== //
};
?>