";
$out .= "".datetime2dmy($this->lastUpdate)." | ";
if($this->visible){
$out .= "";
}
else{
$out .= " | ";
}
if ($_SESSION['userid'] == $this->ownerId || $_SESSION['userlevel'] == USER_ADMIN) {
$out .= "printPath()."');\" target=\"_self\">".$this->toString()." ";
$out .= "id.");\" target=\"_self\">(löschen)";
}
else {
$out .= $this->toString();
}
$out .= " | ";
$out .= "
";
return $out;
}
/** @see CmsObject::doPublish()
*/
//----------------------------------------------
function doPublish(){
//----------------------------------------------
$this->visible = 1;
$this->save();
}
/** @see DBElement::canBePublished()
*/
//----------------------------------------------
function canBePublished(){
//----------------------------------------------
$ok = true;
if(empty($this->name)){
$this->addError("Bitte vergeben Sie einen Titel für die Veranstaltung!");
$ok = false;
}
if(empty($this->startDate) || ereg("^0000-00-00$", $this->startDate)){
$this->addError("Bitte vergeben Sie ein Datum/Zeitraum!");
$ok = false;
}
if($this->category1 == 0){
if($this->category2 == 0 && $this->category3 == 0){
$this->addError("Bitte wählen Sie zumindest eine Kategorie, unter der die Veranstaltung eingeordnet werden soll!");
$ok = false;
}
else{
if($this->category2 != 0) $this->category1 = $this->category2;
else $this->category1 = $this->category3;
}
}
foreach($this->dates as $i=>$date){#
$date = clone($date);
if(!$date->isValid()){
$this->addError("Der Termin ".$date->toString()." ist fehlerhaft!");
$ok = false;
}
}
return $ok;
}
/** @see CmsObject::handleAction()
*/
//-----------------------------------------------
function handleAction($action, $position, $type){
//-----------------------------------------------
switch($action){
case "insertDate":
$this->doInsertDate($position);
break;
case "deleteDate":
$this->doDeleteDate($position);
break;
}
}
/** @see CmsObject::show()
*/
//---------------------------------------------
function show(){
//---------------------------------------------
$this->childObjects[0]->load();
return $this->childObjects[0]->show();
}
/** @see Element::getCssClass()
*/
//------------------------------------------------
function getCssClass(){
//------------------------------------------------
return "itemTicketEvent";
}
// === ADDITIONAL METHODS =============================================================== //
/** changes the reservation type and deletes all previous dates
* @param type new reservation type
*/
//-----------------------------------------------
function changeReservationType($type){
//-----------------------------------------------
if($this->reservationType == RESERVATION_SEAT && $_SESSION['userlevel'] != USER_ADMIN){
$this->addError("Der Reservierungstyp kann nicht mehr geändert werden!");
return;
}
$this->reservationType = $type;
foreach($this->dates as $i=>$date){
$this->dates[$i]->delete();
}
$this->dates = array();
}
/** uploads a preview image file
* @param file $_FILES file date
*/
//------------------------------------------------
function uploadPreviewImage($file){
//------------------------------------------------
//remove old image
if(!empty($this->thumb) && file_exists(TICKET_THUMB_DIR.$this->thumb)){
@unlink(TICKET_THUMB_DIR.$this->thumb);
}
//create target path
$imgSize = getImageSize($file['tmp_name']);
switch($imgSize[2]){
case 1: //gif
$path = $this->id.".gif";
break;
case 2: //jpg
$path = $this->id.".jpg";
break;
case 3: //png
$path = $this->id.".png";
break;
default:
logError(3, "Unsupported mime type: $file[name] ($imgSize[2])", __FILE__, __LINE__);
$this->addError("Das Bild verwendet ein nicht unterstütztes Dateiformat oder es ist beschädigt!");
return "";
}
//resize image
if($imgSize[0] > $this->thumbWidth || $imgSize[1] > $this->thumbHeight){
switch($imgSize[2]){
case 1: //gif
$original = imageCreateFromGif($file['tmp_name']);
break;
case 2: //jpg
$original = imageCreateFromJpeg($file['tmp_name']);
break;
case 3: //png
$original = imageCreateFromPng($file['tmp_name']);
break;
}
$origWidth = $imgSize[0];
$origHeight = $imgSize[1];
$width = $this->thumbWidth;
$height = $this->thumbHeight;
$origX = 0;
$origY = 0;
//clip image
if(!$this->thumbStretch){
if($origWidth > $origHeight){
$origX = ($origWidth - $origHeight)/2;
$origWidth = $origHeight;
}
else{
$origY = ($origHeight - $origWidth)/2;
$origHeight = $origWidth;
}
}
$small = imageCreateTrueColor($width, $height);
imageCopyResampled($small, $original, 0, 0, $origX, $origY, $width, $height, $origWidth, $origHeight);
switch($imgSize[2]){
case 1:
if(!@imageGif($small, TICKET_THUMB_DIR.$path)){
logError(4, "Could not create gif image: $path", __FILE__, __LINE__);
$this->addError("Das Bild konnte nicht erzeugt werden!");
return "";
}
break;
case 2:
if(!@imageJpeg($small, TICKET_THUMB_DIR.$path, 100)){
logError(4, "Could not create jpg image: $path", __FILE__, __LINE__);
$this->addError("Das Bild konnte nicht erzeugt werden!");
return "";
}
break;
case 3:
if(!@imagePng($small, TICKET_THUMB_DIR.$path)){
logError(4, "Could not create png image: $path", __FILE__, __LINE__);
$this->addError("Das Bild konnte nicht erzeugt werden!");
return "";
}
break;
}
imageDestroy($small);
imageDestroy($original);
@chmod(TICKET_THUMB_DIR.$path, 0777);
}
//copy image in original size
else{
if(@move_uploaded_file($file['tmp_name'], TICKET_THUMB_DIR.$path)){
@chmod(TICKET_THUMB_DIR.$path, 0777);
}
else{
logError(4, "Could not copy image: $file[tmp_name] => $path)", __FILE__, __LINE__);
$this->addError("Das Bild konnte nicht erzeugt werden!");
return "";
}
}
return $path;
}
/** inserts a date
* @param index position
*/
//-----------------------------------------------
function doInsertDate($index){
//-----------------------------------------------
$d = new TicketDate(0, $this);
$d->setDate($this->startDate." 19:30:00");
$d->setEntries($this->entries);
$d->setReductions($this->reductions);
$this->dates = array_insert($this->dates, $index, $d);
$this->save();
}
/** deletes a date
* @param index position
*/
//-----------------------------------------------
function doDeleteDate($index){
//-----------------------------------------------
$this->dates[$index]->delete();
$this->dates = array_remove($this->dates, $index);
$this->save();
}
/** prints a bar with buttons for inserting new dates
* @return string
*/
//-----------------------------------------------
function doPrintDateInsertBar($index){
//-----------------------------------------------
$t = new Template(CMS_TEMPLATE_DIR."insertbar.html");
$button = "