development/coursemanagement-bundle/src/Resources/contao/dca/tl_calendar_events.php line 125

Open in your IDE?
  1. <?php
  2. use CityMountain\ToolBundle\Utils\OperationTool;
  3. use CityMountain\CourseManagementBundle\Utils\OperationCM;
  4. use CityMountain\CourseManagementBundle\Utils\ReplaceInsertTagsListener;
  5. //$this->import('BackendUser', 'User');
  6. /**
  7.  * add config
  8.  */
  9. $GLOBALS['TL_DCA']['tl_calendar_events']['config']['switchToEdit'] = false;
  10. $GLOBALS['TL_DCA']['tl_calendar_events']['config']['onsubmit_callback'][] = array('tl_calendar_eventsCM''generateIndex');
  11. $GLOBALS['TL_DCA']['tl_calendar_events']['config']['onload_callback'][] = array('tl_calendar_eventsCM''permissionEdit');
  12. /**
  13.  * add list
  14.  */
  15. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['sorting']['child_record_callback'] = array('tl_calendar_eventsCM''listEvents');
  16. //FILTER!!
  17. /**
  18.  * add operations
  19.  */
  20. $GLOBALS['TL_DCA']['tl_calendar_events']['edit']['buttons_callback'] = array(array('tl_calendar_eventsCM''editButtonAtEdit'));
  21. unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['edit']);
  22. unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['cut']);
  23. unset($GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['feature']);
  24. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['global_operations']['all']['button_callback'] = array('tl_calendar_eventsCM''buttonGlobal');
  25. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['editheader']['icon'] = 'edit.svg';
  26. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['delete']['button_callback'] = array('tl_calendar_eventsCM''buttonDelete');
  27. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['cmActEveBookingImport'] = array(
  28.     'label'               => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmActEveBookingImport'],
  29.     'href'                => 'key=importBooking',
  30.     'icon'                => 'bundles/citymountaincoursemanagement/icons/iconUpload.svg',
  31.     //'button_callback'     => array('tl_calendar_eventsCM', 'buttonBooking')
  32. );
  33. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['cmActEveBooking'] = array(
  34.     'label'               => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmActEveBooking'],
  35.     'href'                => 'table=tl_zEventBooking',
  36.     'icon'                => 'bundles/citymountaincoursemanagement/icons/booking.png',
  37.     'button_callback'     => array('tl_calendar_eventsCM''buttonBooking')
  38. );
  39. $GLOBALS['TL_DCA']['tl_calendar_events']['list']['operations']['cmActEveExport'] = array(
  40.     'label'               => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmActEveExport'],
  41.     'href'                   => 'act=show&key=eventExport',
  42.     'icon'                => 'bundles/citymountaincoursemanagement/icons/exportEve.png',
  43. );
  44. /**
  45.  * add palettes
  46.  */
  47. $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'cmMoreDate';
  48. $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'cmRegistrationVariant';
  49. $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'cmEventHybrid';
  50. $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default'] = '
  51.         {title_legend},fkUnit,fkEventType,fkEventSector1,fkEventSector2,title,author;
  52.         {date_legend},startDate,addTime,cmMoreDate;
  53.         
  54.         {legendCMGeneral},cmLocation,cmCost,cmClosingDate,cmMaxTn,cmEventHybrid,cmCoursLeader,fkUnitConfirmationMail,cmContact,cmRegistrationVariant;
  55.         {legendCMSpecialSetting:hide},fkUnitRightEvent,cmEventCanceled,cmMoreConfirmationMail,cmEventRequestType,cmTarget;
  56.         
  57.         {details_legend},cmTeaserShort,teaser;
  58.         {enclosure_legend:hide},addEnclosure;
  59.         
  60.         {publish_legend},published,start,stop';
  61. /**
  62.  * add subpalettes
  63.  */
  64. array_insert($GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes'], 2, array
  65.     (
  66.          'cmRegistrationVariant_url' => 'urlExtern',
  67.          'cmMoreDate'                 => 'cmMoreDateTime',
  68.          'cmEventHybrid'             => 'cmEventHybridTool',
  69.     )
  70. );
  71. $GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['addTime'] =  'startTime,endTime';
  72. /**
  73.  * Standartfelder beeinflussen
  74.  */
  75. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['author']['filter']            = false;
  76. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['featured']['filter']        = false;
  77. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['recurring']['filter']        = false;
  78. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['address']['search']            = false;
  79. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['alt']['search']                = false;
  80. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['author']['search']            = false;
  81. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['imageUrl']['search']        = false;
  82. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['imageTitle']['search']        = false;
  83. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['caption']['search']            = false;
  84. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['alias']['search']            = false;
  85. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['url']['search']                = false;
  86. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['location']['search']        = false;
  87. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['robots']['search']            = false;
  88. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['pageTitle']['search']        = false;
  89. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['description']['search']        = false;
  90. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['author']['sorting']            = false;
  91. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['title']['eval']['maxlength']= 82;
  92. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['featured']['eval']['tl_class']= 'clr w50 m12';
  93. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['addTime']['eval']['tl_class']= 'clr w50 m12';
  94. if(isset($GLOBALS['TL_LANG']['tl_calendar_events']['cmTeaser']))$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['teaser']['label'] = $GLOBALS['TL_LANG']['tl_calendar_events']['cmTeaser'];
  95. /**
  96.  * add fields
  97.  */
  98. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkUnit'] = array
  99. (
  100.     'default'                  => OperationCM::getDefaultUnitFromUserToEdit(),
  101.     'filter'                  => true,
  102.     'sorting'                  => true,
  103.     'search'                  => true,
  104.     'inputType'               => 'select',
  105.     'reference'               => OperationTool::getUnits(0,1), 
  106.     'options_callback'          => array('tl_calendar_eventsCM''getUnits'),
  107.     'eval'                    => array('mandatory'=>true,'chosen'=>true'includeBlankOption'=>true,'tl_class'=>'w50'),
  108.     'sql'                     => "int(10) unsigned NOT NULL default '0'"
  109. );
  110. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkEventType'] = array
  111. (
  112.     'filter'                  => true,
  113.     'inputType'               => 'select',
  114.     'reference'               => OperationTool::getMasterdataValues(0,"eventType",1), 
  115.     'options_callback'          => array('tl_calendar_eventsCM''getEventType'),
  116.     'eval'                    => array('mandatory'=>true,'chosen'=>true,'includeBlankOption'=>true'tl_class'=>'w50''doNotSaveEmpty' => true),
  117.     'sql'                     => "int(10) unsigned NOT NULL default '0'",
  118. );
  119. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkEventSector1'] = array
  120. (
  121.     'filter'                  => true,
  122.     'inputType'               => 'select',
  123.     'options_callback'          => array('tl_calendar_eventsCM''getEventSector1'),
  124.     'eval'                    => array('chosen'=>true,'multiple'=>true'tl_class'=>'w50'),
  125.     'save_callback'              => array(array('tl_calendar_eventsCM''saveCheckEventSector')),
  126.     'sql'                     => "blob NULL"
  127. );
  128. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkEventSector2'] = array
  129. (
  130.     'filter'                  => true,
  131.     'inputType'               => 'select',
  132.     'options_callback'          => array('tl_calendar_eventsCM''getEventSector2'),
  133.     'eval'                    => array('chosen'=>true,'multiple'=>true'tl_class'=>'w50'),
  134.     'save_callback'              => array(array('tl_calendar_eventsCM''saveCheckEventSector')),
  135.     'sql'                     => "blob NULL"
  136. );
  137. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmMoreDate'] = array
  138. (
  139.     'inputType'               => 'checkbox',
  140.     'eval'                    => array('tl_class'=>'clr w50 m12','submitOnChange'=>true),
  141.     'sql'                     => "char(1) NOT NULL default ''"
  142. );
  143. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmMoreDateTime'] = array
  144. (
  145.     'inputType'         => 'multiColumnWizard',
  146.     'eval'              => array('tl_class'=>'cmWizard',
  147.                                  'columnFields'=>array(
  148.                                      'cmMoreStartDate' => array(
  149.                                          'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['startDate'],
  150.                                          'inputType' => 'text',
  151.                                          'eval'      => array('mandatory'=>false'rgxp'=>'date''datepicker'=>true'submitOnChange'=>false'doNotCopy'=>true'style'=>'width:100px''tl_class'=>'wizard')
  152.                                      ),
  153.                                      'cmMoreStartTime' => array
  154.                                      (
  155.                                          'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['startTime'],
  156.                                          'inputType' => 'text',
  157.                                          'eval'      => array('rgxp'=>'time''datepicker'=>true'submitOnChange'=>false'doNotCopy'=>true'style'=>'width:100px')
  158.                                      ),
  159.                                      'cmMoreEndTime' => array
  160.                                      (
  161.                                          'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['endTime'],
  162.                                          'inputType' => 'text',
  163.                                          'eval'      => array('rgxp'=>'time''datepicker'=>true'submitOnChange'=>false'doNotCopy'=>true'style'=>'width:100px;')
  164.                                      )
  165.                                  )
  166.                                 ),
  167.     'sql'               => "blob NULL"
  168. );
  169. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmLocation'] = array
  170. (
  171.     'search'                  => true,
  172.     'inputType'               => 'text',
  173.     'eval'                    => array('mandatory'=>true,'maxlength'=>35,'tl_class'=>'w50'),
  174.     'sql'                     => "varchar(255) NOT NULL default ''"
  175. );
  176. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmCost'] = array
  177. (
  178.     'inputType'               => 'text',
  179.     'eval'                    => array('mandatory'=>true,'maxlength'=>255,'tl_class'=>'w50'),
  180.     'sql'                     => "varchar(255) NOT NULL default ''"
  181. );
  182. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmClosingDate'] = array
  183. (
  184.     'filter'                  => true,
  185.     'flag'                    => 6,
  186.     'inputType'               => 'text',
  187.     'eval'                    => array('mandatory'=>false,'rgxp'=>'date','datepicker'=>true,'maxlength'=>255,'tl_class'=>'w50 wizard'),
  188.     'sql'                     => "varchar(10) NOT NULL default ''"
  189. );
  190. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmMaxTn'] = array
  191. (
  192.     'inputType'               => 'text',
  193.     'eval'                    => array('maxlength'=>255,'tl_class'=>'w50','rgxp'=>'natural'),
  194.     'sql'                     => "varchar(255) NOT NULL default ''"
  195. );
  196. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmCoursLeader'] = array
  197. (
  198.     'sorting'                  => true,
  199.     'inputType'               => 'text',
  200.     'eval'                    => array('maxlength'=>255,'tl_class'=>'clr w50'),
  201.     'sql'                     => "varchar(255) NOT NULL default ''"
  202. );
  203. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkUnitConfirmationMail'] = array
  204. (
  205.     'filter'                  => true,
  206.     'inputType'               => 'select',
  207.     'options_callback'          => array('tl_calendar_eventsCM''getUnitsMembers'),
  208.     'eval'                    => array('mandatory'=>true,'chosen'=>true,
  209.                                        'includeBlankOption'=>true,'multiple'=>false'tl_class'=>'w50'),
  210.     'sql'                     => "blob NULL"
  211. );
  212. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmContact'] = array
  213. (
  214.     'inputType'         => 'multiColumnWizard',
  215.     'eval'                => array
  216.     (
  217.         'buttons'           => array('up' => false'down' => false),
  218.         'tl_class'          => 'clr long cmWizard',
  219.         'mandatory'            => true,
  220.         'columnFields'        =>array(
  221.                                 'cmName' => array(
  222.                                     'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmName'],
  223.                                     'inputType' => 'text',
  224.                                     //'mandatory' => true,
  225.                                     'eval'      => array('doNotCopy'=>true'style'=>'width:130px')
  226.                                 ),
  227.                                 'cmPhone' => array
  228.                                 (
  229.                                     'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmPhone'],
  230.                                     'inputType' => 'text',
  231.                                     'eval'      => array('doNotCopy'=>true'style'=>'width:80px')
  232.                                 ),
  233.                                 'cmMail' => array
  234.                                 (
  235.                                     'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmMail'],
  236.                                     'inputType' => 'text',
  237.                                     'eval'      => array('doNotCopy'=>true'style'=>'width:200px')
  238.                                 ),
  239.                                 'cmComment' => array
  240.                                 (
  241.                                     'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmComment'],
  242.                                     'inputType' => 'text',
  243.                                     'eval'      => array('doNotCopy'=>true'style'=>'width:180px')
  244.                                 )
  245.                             )
  246.     ),
  247.     'save_callback'            => array(array('tl_calendar_eventsCM''saveCmContact')),
  248.     'sql'                   => "blob NULL"
  249. );
  250. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmRegistrationVariant'] = array
  251. (
  252.     'default'                 => 'plattform',
  253.     'filter'                  => true,
  254.     'inputType'               => 'radio',
  255.     'options'                  => array('plattform''url''noreg'),
  256.     'reference'               => &$GLOBALS['TL_LANG']['tl_calendar_events'],
  257.     'eval'                    => array('submitOnChange'=>true,'helpwizard'=>true,'tl_class'=>'clr w50'),
  258.     'sql'                     => "varchar(32) NOT NULL default ''"
  259. );
  260. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['urlExtern'] = array
  261. (
  262.     'inputType'               => 'text',
  263.     'eval'                    => array('mandatory'=>true'decodeEntities'=>true'maxlength'=>255'tl_class'=>'w50'),
  264.     'sql'                     => "varchar(255) NOT NULL default ''"
  265. );
  266. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['fkUnitRightEvent'] = array
  267. (
  268.     'inputType'         => 'multiColumnWizard',
  269.     'eval'                => array
  270.     (
  271.         'columnsCallback'   => array('tl_calendar_eventsCM''getUnitRightEvent'),
  272.         'buttons'           => array('up' => false'down' => false),
  273.         'tl_class'          => 'clr w50 cmWizard',
  274.     ),
  275.     'sql'               => "blob NULL"
  276. );
  277. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmMoreConfirmationMail'] = array
  278. (
  279.     'sorting'                  => true,
  280.     'inputType'               => 'text',
  281.     'eval'                    => array('tl_class'=>'clr long'),
  282.     'sql'                     => "text NULL"
  283. );
  284. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmEventRequestType'] = array
  285. (
  286.     'exclude'                 => true,
  287.     'filter'                  => true,
  288.     'inputType'               => 'select',
  289.     'options'                 => array('modul','eve-zertifikat'),
  290.     'reference'               => &$GLOBALS['TL_LANG']['cmglobal']['cmEventRequestType'],
  291.     'eval'                    => array('includeBlankOption'=>true'tl_class'=>'w50'),
  292.     'sql'                     => "varchar(32) NOT NULL default ''"
  293. );
  294. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmTarget'] = array
  295. (
  296.     'inputType'         => 'multiColumnWizard',
  297.     'eval'                => array
  298.     (
  299.         'columnFields'   => array(
  300.                                       'f1' => array
  301.                                       (
  302.                                         'label'            => &$GLOBALS['TL_LANG']['tl_calendar_events']['cmTargetF1'],
  303.                                         'inputType'        => 'text',
  304.                                         'eval'            => array('style' => 'width:300px')
  305.                                         ),
  306.                                   ),
  307.         'buttons'           => array(),
  308.         'tl_class'          => 'w50 cmWizard',
  309.     ),
  310.     'sql'               => "blob NULL"
  311. );
  312. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmTeaserShort'] = array
  313. (
  314.     'inputType'               => 'text',
  315.     'eval'                    => array('mandatory'=>true,'decodeEntities'=>true'maxlength'=>234'tl_class'=>'long'),    
  316.     //'save_callback'            => array(array('tl_calendar_eventsCM', 'saveCmTeaserShort')),
  317.     'sql'                     => "varchar(234) NOT NULL default ''"
  318. );
  319. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmEventCanceled'] = array
  320. (
  321.     'inputType'               => 'checkbox',
  322.     'eval'                    => array('tl_class'=>'w50 m12','submitOnChange'=>true),
  323.     'sql'                     => "char(1) NOT NULL default ''"
  324. );
  325. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmEventHybrid'] = array
  326. (
  327.     'inputType'               => 'checkbox',
  328.     'eval'                    => array('tl_class'=>'w50 m12','submitOnChange'=>true),
  329.     'sql'                     => "char(1) NOT NULL default ''"
  330. );
  331. $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['cmEventHybridTool'] = array
  332. (
  333.     'inputType'               => 'text',
  334.     'eval'                    => array('mandatory'=>true,'decodeEntities'=>true'maxlength'=>255'tl_class'=>'w50'),
  335.     'sql'                     => "varchar(255) NOT NULL default ''"
  336. );
  337. class tl_calendar_eventsCM extends tl_calendar_events
  338. {
  339.     public function permissionEdit(DataContainer $dc null)
  340.     {
  341.         
  342.         $arrUnits = array();
  343.         $objRights OperationTool::getUserRights(\BackendUser::getInstance()->id,1,array("AND fkModuleAction IN ('MOD09SHOWUNIT','MOD09EDITUNIT')"));
  344.         
  345.         //Laden der Veranstaltungen, die man sehen darf
  346.         if(!$this->User->isAdmin){
  347.             
  348.             if (count($objRights['entryUnitList'])>0)
  349.             {
  350.                 $arrUnits OperationTool::getUnitsHierarchy($objRights['entryUnitList']);
  351.             }
  352.             
  353.             $objRes \Database::getInstance()->prepare("SELECT DISTINCT pid FROM tl_zEventIndex WHERE fkUnit IN (".implode(',',array_keys($arrUnits)).")")->execute();
  354.             
  355.             $arrUnitFilter = array();
  356.             if(!$objRes->numRows)$arrUnitFilter = array(0);
  357.             while($objRes->next())
  358.             {    
  359.                 $arrUnitFilter[] = $objRes->pid;
  360.             }            
  361.             $GLOBALS['TL_DCA']['tl_calendar_events']['list']['sorting']['filter'][] = array('id IN ('.implode(','$arrUnitFilter).') AND pid<>?','');
  362.         }
  363.         
  364.         //direkt Zugriff auf User
  365.         if(!$this->User->isAdmin && \Input::get('act')=='edit'){
  366.             
  367.             $objEvent $this->Database->prepare("SELECT fkUnit,tstamp FROM tl_calendar_events WHERE id = ?")->execute(\Input::get('id'));
  368.             //keinen tstamp vorhanden, dann ist er erst neu erstellt.            
  369.             if($objEvent->tstamp==0)return;
  370.             
  371.             if (count($objRights['entryUnitList'])>0)
  372.             {
  373.                 $arrUnits OperationTool::getUnitsHierarchy($objRights['entryUnitList']);
  374.             }
  375.             
  376.             $objRes \Database::getInstance()->prepare("SELECT DISTINCT pid FROM tl_zEventIndex 
  377.                                     WHERE pid=?
  378.                                       AND fkUnit IN (".implode(',',array_keys($arrUnits)).")")->execute(\Input::get('id'));
  379.             //unset();
  380.             if($objRes->numRows==0)
  381.             {                
  382.                 \System::log('Zugriffs Versuch von "'.$this->User->username.'" beim Event '.\Input::get('id').' verweigert.'__METHOD__"CM_ACCESS_BACKEND"); 
  383.                 $this->redirect('contao?do=calendar&act=error');
  384.             }            
  385.         }
  386.     }
  387.         
  388.     public function generateIndex(DataContainer $dc)
  389.     {    
  390.         OperationCM::setIndexCalendar($dc->activeRecord->id,$dc->activeRecord->fkUnit,$dc->activeRecord->fkUnitRightEvent,
  391.                                      $dc->activeRecord->fkEventSector1,$dc->activeRecord->fkEventSector2);
  392.     }
  393.     
  394.     public function listEvents($arrRow)
  395.     {        
  396.         $span Calendar::calculateSpan($arrRow['startTime'], $arrRow['endTime']);
  397.         if ($span 0)
  398.         {
  399.             $date Date::parse(Config::get(($arrRow['addTime'] ? 'datimFormat' 'dateFormat')), $arrRow['startTime']) . $GLOBALS['TL_LANG']['MSC']['cal_timeSeparator'] . Date::parse(Config::get(($arrRow['addTime'] ? 'datimFormat' 'dateFormat')), $arrRow['endTime']);
  400.         }
  401.         elseif ($arrRow['startTime'] == $arrRow['endTime'])
  402.         {
  403.             $date Date::parse(Config::get('dateFormat'), $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' Date::parse(Config::get('timeFormat'), $arrRow['startTime']) : '');
  404.         }
  405.         else
  406.         {
  407.             $date Date::parse(Config::get('dateFormat'), $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' Date::parse(Config::get('timeFormat'), $arrRow['startTime']) . $GLOBALS['TL_LANG']['MSC']['cal_timeSeparator'] . Date::parse(Config::get('timeFormat'), $arrRow['endTime']) : '');
  408.         }
  409.         
  410.         $pastEve "";
  411.         if($arrRow['startDate'] < time())
  412.         {
  413.             $pastEve 'background-color:#d7d7d7;font-style:italic;';
  414.         }
  415.         $fullyBookedStyle "";
  416.         $fullyBookedText  "";
  417.         $checkBookable OperationCM::replaceInsertTags('CMEvent::bookableArray::'.$arrRow['id']);
  418.         
  419.         if($checkBookable['fullyBooked']==true)
  420.         {
  421.             $fullyBookedStyle 'border: 1px solid red;';    
  422.             $fullyBookedText  '<span style="color:red;padding-left:3px">ausgebucht</span>';
  423.         }
  424.         if($arrRow['cmEventCanceled']==true)
  425.         {
  426.             $fullyBookedText  .= '<span style="color:red;padding-left:3px">abgesagt</span>';
  427.         }
  428.         return '<div class="tl_content_left" style="'.$pastEve.$fullyBookedStyle.'">' 
  429.                 $arrRow['title']
  430.                 . ' <span style="color:#b3b3b3;padding-left:3px">[' $date ']</span>'
  431.                 ' <span style="color:blue;padding-left:3px">'.OperationTool::getUnit($arrRow['fkUnit'],true)->uName.'</span>'
  432.                 $fullyBookedText
  433.                 '</div>';
  434.     }
  435.     
  436.     public function buttonGlobal($href$label$title$icon$attributes)
  437.     {
  438.         if($this->User->isAdmin || $this->User->hasAccess('eveGlobalEdit''coursManagementRight'))return '<a href="'.$this->addToUrl($href).'" class="'.$icon.'" title="'.specialchars($title).'"'.$attributes.'>'.$label.'</a> ';
  439.         return '';
  440.     }
  441.     
  442.     public function buttonDelete($row$href$label$title$icon$attributes)
  443.     {
  444.         if ( (\Controller::replaceInsertTags('{{CMEvent::countRegistration::'.$row['id'].'}}')==&& $row['startDate'] > time()) || $this->User->isAdmin){ 
  445.             
  446.             return '<a href="' $this->addToUrl($href '&amp;id=' $row['id']) . '" title="' StringUtil::specialchars($title) . '"' $attributes '>' Image::getHtml($icon$label) . '</a> ';
  447.         } else {
  448.             return "";
  449.         }
  450.     }
  451.     
  452.     public function buttonBooking($row$href$label$title$icon$attributes)
  453.     {        
  454.         $objEvent $this->Database->prepare("SELECT id FROM tl_zEventBooking WHERE pid = ?")->execute($row['id']);
  455.         if ($objEvent->numRows){ 
  456.             return '<a href="' $this->addToUrl($href '&amp;id=' $row['id']) . '" title="' StringUtil::specialchars($title) . '"' $attributes '>' Image::getHtml($icon$label) . '</a> ';
  457.         } else {
  458.             return '<a href="' $this->addToUrl($href '&amp;id=' $row['id']) . '" title="' StringUtil::specialchars($title) . '"' $attributes '>' Image::getHtml(preg_replace('/\.png$/i''_.png'$icon), $label) . '</a> ';
  459.         }
  460.     }
  461.     
  462.     public function editButtonAtEdit($arrButtons)
  463.     {
  464.         //dump($arrButtons);
  465.         unset($arrButtons['saveNback']);
  466.         
  467.         if(!$this->User->isAdmin && \Input::get('act')=='edit'){
  468.             
  469.             $objEvent OperationCM::getEvent(\Input::get('id'),true);
  470.             
  471.             //Wenn neu erstellt wird, sind die Daten noch nicht gefüllt
  472.             if($objEvent->fkEventType==0||$objEvent->startDate==0)return $arrButtons;
  473.             
  474.             $arrUnits = array();
  475.             $objRights OperationTool::getUserRights(\BackendUser::getInstance()->id,1,array("AND fkModuleAction IN ('MOD09EDITUNIT')"));
  476.             
  477.             if (count($objRights['entryUnitList'])>0)
  478.             {
  479.                 $arrUnits OperationTool::getUnitsHierarchy($objRights['entryUnitList']);
  480.             }
  481.             
  482.             $objRes \Database::getInstance()->prepare("SELECT DISTINCT pid FROM tl_zEventIndex 
  483.                                     WHERE pid=?
  484.                                       AND fkUnit IN (".implode(',',array_keys($arrUnits)).")")->execute(\Input::get('id'));
  485.             if($objRes->numRows==0)
  486.             {                
  487.                 $arrButtons = array();
  488.             }    
  489.         }
  490.         
  491.         return $arrButtons;
  492.     }
  493.     
  494.     
  495.     
  496.     public function getUnits($dc)
  497.     {    
  498.         return OperationTool::getUnitsFromRights($dc->activeRecord->{$dc->field},'user',array('MOD09EDITUNIT'));
  499.     }
  500.     
  501.     public function getEventType(Contao\DataContainer $dc)
  502.     {
  503.         return OperationTool::getMasterdataValues($dc->activeRecord->{$dc->field},"eventType");
  504.     }
  505.     
  506.     public function getEventSector1(Contao\DataContainer $dc)
  507.     {
  508.         return OperationTool::getMasterdataValues(($dc->activeRecord?deserialize($dc->activeRecord->{$dc->field}):0),"eventSectorSub",0,array("AND fkEventSector=".\Config::get('eventSector1')));
  509.     }
  510.     
  511.     public function getEventSector2(Contao\DataContainer $dc)
  512.     {
  513.         return OperationTool::getMasterdataValues(($dc->activeRecord?deserialize($dc->activeRecord->{$dc->field}):0),"eventSectorSub",0,array("AND fkEventSector=".\Config::get('eventSector2')));
  514.     }
  515.     public function saveCheckEventSector($varValueDataContainer $dc)
  516.     {
  517.         if($varValue && count(deserialize($varValue))>2)throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['addtoomuch'], 2));
  518.         return $varValue;
  519.     }
  520.     
  521.     public function getUnitsMembers($dc)
  522.     {
  523.         $res = array();
  524.         
  525.         $arrUnits = array();
  526.         $objRights OperationTool::getUserRights(\BackendUser::getInstance()->id,1,array("AND fkModule = 'mod09'"));
  527.         if (count($objRights['entry'])>0)
  528.         {
  529.             $arrIDs = array();
  530.             foreach($objRights['entry'] as $arrRight){
  531.                 $arrIDs[$arrRight['fkUnit']] = '';
  532.             }
  533.             $arrUnits OperationTool::getUnitsHierarchy($arrIDs);
  534.         }
  535.         
  536.         $idUser=0;
  537.         if($dc->activeRecord)$idUser $dc->activeRecord->{$dc->field};
  538.         $objUsers \Database::getInstance()->prepare("
  539.                                 SELECT DISTINCT tl_user.id, tl_user.name
  540.                                   FROM tl_zLinkUserRight,tl_user 
  541.                                  WHERE tl_user.id = tl_zLinkUserRight.pid
  542.                                    AND fkUnit IN (".implode(',',array_keys($arrUnits)).") 
  543.                                    OR tl_user.id IN (".($idUser?$idUser:0).")
  544.                               ORDER BY name")->execute();
  545.         
  546.         while($objUsers->next())
  547.         {
  548.             $res[$objUsers->id] = $objUsers->name;
  549.         }
  550.         
  551.         //Prüfen ob User exisitert
  552.         if($idUser<>&& !array_key_exists($idUser,$res)){//
  553.             \Message::addError('Empfänger vom Bestätitungsmail muss korrigiert werden');
  554.         }
  555.         
  556.         return $res;
  557.     }
  558.     public function saveCmContact($varValueDataContainer $dc)
  559.     {
  560.         $arrVarValue deserialize($varValue);
  561.         //$arrVarValue = var_dump($arrVarValue[0]['cmName']);
  562.         $varExcept = array();
  563.         
  564.         foreach($arrVarValue as $arrValue){
  565.             if($arrValue['cmName']=='')$varExcept[] = sprintf($GLOBALS['TL_LANG']['ERR']['valueMissingCmName'], '');
  566.             if($arrValue['cmMail']=='')$varExcept[] = sprintf($GLOBALS['TL_LANG']['ERR']['valueMissingCmMail'], '');    
  567.         }
  568.         
  569.         if($varExcept)throw new Exception(implode('; ',$varExcept));
  570.         
  571.         return $varValue;
  572.     }
  573.     /*public function saveCmTeaserShort($varValue, DataContainer $dc)
  574.     {dump($varValue);
  575.         if ($varValue && mb_strlen($varValue) > 234)
  576.         {
  577.             throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['maxlength'], $GLOBALS['TL_LANG']['tl_calendar_events']['cmTeaserShort'][0], 234));
  578.         }
  579.         
  580.         return $varValue;
  581.     }*/
  582.     
  583.     public function getUnitRightEvent($var1)
  584.     {
  585.         $columnFields null;
  586.         
  587.         $arrAnbieter OperationTool::getUnitsHierarchy(OperationTool::getUnitsTop());
  588.         $columnFields = array
  589.         (
  590.             'f1' => array
  591.             (
  592.                 'label'     => &$GLOBALS['TL_LANG']['tl_calendar_events']['fkUnitRightEventF1'],
  593.                 'inputType' => 'select',
  594.                 'options'    => $arrAnbieter,
  595.                 'eval'      => array('doNotCopy'=>true,'chosen'=>true'includeBlankOption'=>true'style'=>'width:350px')
  596.             )
  597.         );
  598.         return $columnFields;
  599.     }
  600.     
  601. }
  602. ?>