On branch master
[event_calendar.git] / admin.eventcalendar.php
blobde838565aa30f8384d07bd30c7f1f3de8942f6b6
1 <?php
3 /*
4 * Event Calendar for Elxis CMS 2008.x and 2009.x
6 * Backend Event Handler
8 * @version 1.1
9 * @package eventCalendar
10 * @author Apostolos Koutsoulelos <akoutsoulelos@yahoo.gr>
11 * @copyright Copyright (C) 2009-2010 Apostolos Koutsoulelos. All rights reserved.
12 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
13 * @link
16 // Prevent direct inclusion of this file
17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
19 // Check if the user is allowed to access this component. If not then re-direct him to the administration's front-page.
20 if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' )
21 | $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_eventcalendar' ))) {
22 mosRedirect( 'index2.php', $adminLanguage->A_NOT_AUTH );
25 // Includes
26 require_once($mainframe->getCfg('absolute_path' ).'/components/com_eventcalendar/eventcalendar.class.php'); // Component's general classes
27 require_once($mainframe->getCfg('absolute_path' ).'/administrator/components/com_eventcalendar/admin.eventcalendar.html.php'); // Component's html file for the administration area
28 require_once($mainframe->getCfg('absolute_path' ).'/administrator/includes/pageNavigation.php'); // Elxis core pageNavigation component
30 /*************************************************************************/
31 /* THE CLASS THAT WILL CONTAIN THE COMPONENT'S BACK-END FUNCTIONALITY */
32 /*************************************************************************/
33 class clsEventCalendarAdmin {
35 // Initialize variables
36 public $task = ''; // component's current task
37 public $apath = ''; // component's back-end absolute path
38 public $hpath = ''; // component's front-end absolute path
39 public $live_apath = ''; // component's back-end absolute path
40 public $live_hpath = ''; // component's front-end absolute path
41 public $lng = null; // component's language
42 public $event_id = '';
43 public $cat_id = '';
44 public $cid = '';
45 public $field = '';
46 public $order = '';
48 /****************************/
49 /* The class' constructor */
50 /****************************/
51 public function __construct() {
52 global $alang, $mainframe; $mosConfig_live_site; // Pass global variables or objects
54 // Set variables
55 $this->task = htmlspecialchars(mosGetParam($_REQUEST, 'task', 'events'));
56 $this->apath = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar';
57 $this->hpath = $mainframe->getCfg('absolute_path').'/components/com_eventcalendar';
58 $this->live_apath = $mainframe->getCfg('live_site').'/administrator/components/com_eventcalendar';
59 $this->live_hpath = $mainframe->getCfg('live_site').'/components/com_eventcalendar';
60 $this->event_id = mosGetParam( $_REQUEST, 'cid', array(0) );
61 $this->cat_id = mosGetParam( $_REQUEST, 'catid', '0' );
62 $this->cid = $event_id;
63 $this->field = mosGetParam($_REQUEST, 'field', false);
64 $this->order = mosGetParam($_REQUEST, 'order', 'none');
66 // Load component's language
67 if (file_exists($this->hpath.'/language/'.$alang.'.php')) {
68 require_once($this->hpath.'/language/'.$alang.'.php');
69 } else if (file_exists($this->hpath.'/language/'.$mainframe->getCfg('alang').'.php')) {
70 require_once($this->hpath.'/language/'.$mainframe->getCfg('alang').'.php');
71 } else {
72 require_once($this->hpath.'/language/english.php');
74 $this->lng = new clsEventCalendarLanguage();
77 /******************************/
78 /* The class' main function */
79 /******************************/
80 public function main() {
82 switch ($this->task) {
83 // Control Panel
84 case 'cp':
85 $this->showControlPanel();
86 break;
87 case 'cp_apply':
88 case 'cp_save':
89 $this->saveConfiguration();
90 break;
91 case 'cp_cancel':
92 mosRedirect( 'index2.php?option=com_eventcalendar' );
93 break;
95 // Templates
96 case 'cp_addtemp':
97 $this->addTemplate();
98 break;
99 case 'cp_remtemp':
100 $this->removeTemplate();
101 break;
103 // Events
104 case 'edit':
105 $this->event_id = (is_array($this->event_id))?$this->event_id[0]:$this->event_id;
106 $this->editEvent($this->event_id);
107 break;
108 case 'new':
109 $this->editEvent();
110 break;
111 case 'save':
112 case 'apply':
113 $this->saveEvent(); //
114 break;
115 case 'cancel':
116 $this->cancelEvent(); //
117 break;
118 case 'publish':
119 $this->publishEvent($this->event_id, 1); //
120 break;
121 case 'unpublish':
122 $this->publishEvent($this->event_id, 0); //
123 break;
124 case 'remove':
125 $this->deleteEvent($this->event_id); //
126 break;
128 // AJAX
129 case 'validate':
130 $this->validateSEO();
131 break;
132 case 'suggest':
133 $this->suggestSEO();
134 break;
135 case 'ajaxpub':
136 $this->ajaxchangeContent();
137 break;
139 // Default action
140 case 'events':
141 default:
142 $this->listEvents();
143 break;
147 /**********************/
148 /* Template handler */
149 /**********************/
150 protected function addTemplate() {
151 global $fmanager, $mosConfig_absolute_path, $adminLanguage;
153 require_once($mosConfig_absolute_path.'/administrator/includes/pcl/pclzip.lib.php');
155 $size_str = @ini_get('upload_max_filesize');
156 if ($size_str) {
157 $i=0;
158 while(ctype_digit($size_str[$i])) {
159 $size .= $size_str[$i];
160 $i++;
162 if ($size_str[$i]=="M"||$size_str[$i]=="m") {
163 $size = $size*1024*1024;
164 } else if ($size_str[$i]=="K"||$size_str[$i]=="k") {
165 $size = $size*1024;
166 } else {
167 $size = 1024*1024*1024;
169 } else {
170 $size = 2048*1024*1024;
173 $validFileTypes = array('zip');
174 $userfile = $_FILES['userfile'];
175 if ( ($userfile['name'] <> '') || ($userfile['size'] <= $size) ) {
176 $source = $userfile['tmp_name'];
177 if (in_array($fmanager->fileExt($userfile['name']), $validFileTypes)) {
178 $dest = $mosConfig_absolute_path.'/tmpr/'.$userfile['name'];
179 $fmanager->upload($source, $dest);
180 } else {
181 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $this->lng->CP_MSG_TEMPLATE_ADD_ERROR );
183 } else {
184 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $this->lng->CP_MSG_TEMPLATE_ADD_ERROR );
187 $zipfile = $dest;
189 @chdir($this->hpath.'/templates');
190 if (is_file($zipfile)) {
191 $path_parts = pathinfo($zipfile);
192 if (strtolower($path_parts['extension']) == 'zip') {
193 $zip = new PclZip($zipfile);
194 $list = $zip->extract(".");
195 } else {
196 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $adminLanguage->A_CMP_ME_FINOZIP );
198 } else {
199 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $adminLanguage->A_CMP_ME_FILNEX );
201 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $this->lng->CP_MSG_TEMPLATE_ADD_OK );
204 protected function removeTemplate() {
205 global $fmanager;
207 $css_filename = mosGetParam( $_REQUEST, 'css_filename', '' );
209 if ($css_filename) {
210 if ( ($fmanager->deleteFile($this->hpath."/templates/".$css_filename)) && ($fmanager->deleteFolder($this->hpath."/templates/f_".$css_filename."/")) ) {
211 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $this->lng->CP_MSG_TEMPLATE_REM_OK );
213 } else {
214 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $this->lng->CP_MSG_TEMPLATE_REM_ERROR );
218 /***********************************/
219 /* Prepare to show control panel */
220 /***********************************/
221 protected function showControlPanel() {
222 global $mainframe, $database; // Pass global variables or objects
224 // Initialize variables
225 $borders = null; // store the borders of Public Backend user group
226 $groups = null; // store Public Backend groups
227 $text = ''; // get params from database
228 $config_values = null; // store params
230 // Get Public Backend user groups
231 $groups = $mainframe->backGroups();
233 // Load params values
234 $database->setQuery( "SELECT params FROM #__components WHERE link = 'option=com_eventcalendar'" );
235 $text = $database->loadResult();
236 $config_values = new mosParameters( $text );
238 // Show CP html
239 clsEventCalendarAdminHTML::showControlPanelHTML( $config_values, $groups );
242 /************************/
243 /* Save configuration */
244 /************************/
245 protected function saveConfiguration() {
246 global $database, $mainframe, $fmanager; // Pass global variables or objects
248 // Initialize variables
249 $params = new mosParameters('');
251 // Get group_role_permissions from Post-Data
252 $group_roles_new_auto = mosGetParam( $_REQUEST, 'newauto', array('') );
253 $group_roles_new_all = mosGetParam( $_REQUEST, 'newall', array('') );
254 $group_roles_changes_auto = mosGetParam( $_REQUEST, 'changesauto', array('') );
255 $group_roles_changes_all = mosGetParam( $_REQUEST, 'changesall', array('') );
256 $params->set( 'newauto', implode( ',', $group_roles_new_auto ) );
257 $params->set( 'newall', implode( ',', $group_roles_new_all ) );
258 $params->set( 'changesauto', implode( ',', $group_roles_changes_auto ) );
259 $params->set( 'changesall', implode( ',', $group_roles_changes_all ) );
261 // Get timetable from Post Data and implode it to an array
262 $timetable = mosGetParam( $_REQUEST, 'timetable', array() );
263 $timetable = serialize( $timetable );
264 $params->set( 'timetable', $timetable);
265 $timetable_selected = mosGetParam( $_REQUEST, 'timetable_selected', 0 );
266 $params->set( 'timetable_selected', $timetable_selected);
268 // Get the rest settings
269 $who_can_post_events = intval(mosGetParam( $_REQUEST, 'who_can_post_events', 2 ));
270 $who_can_edit_events = intval(mosGetParam( $_REQUEST, 'who_can_edit_events', 2 ));
271 $week_startingday = intval(mosGetParam( $_REQUEST, 'week_startingday', 0 ));
272 $show_weeknumber = intval(mosGetParam( $_REQUEST, 'show_weeknumber', 1 ));
273 $week_number_links = intval(mosGetParam( $_REQUEST, 'week_number_links', 0 ));
274 $default_view = mosGetParam( $_REQUEST, 'default_view', 'monthview' );
275 $view_nav = mosGetParam( $_REQUEST, 'view_nav', true );
276 $view_print = mosGetParam( $_REQUEST, 'view_print', true );
277 $view_rss = mosGetParam( $_REQUEST, 'view_rss', true );
278 $view_catlist = mosGetParam( $_REQUEST, 'view_catlist', true );
279 $view_periodicity = mosGetParam( $_REQUEST, 'view_periodicity', true );
280 $view_reservation = mosGetParam( $_REQUEST, 'view_reservation', false );
281 $col_catlist = mosGetParam( $_REQUEST, 'col_catlist', 2 );
282 $rss_cache = mosGetParam( $_REQUEST, 'rss_cache', '0' );
283 $rss_cachetime = mosGetParam( $_REQUEST, 'rss_cachetime', '3600' );
284 $rss_num = mosGetParam( $_REQUEST, 'rss_num', '5' );
285 $rss_title = mosGetParam( $_REQUEST, 'rss_title', 'EventCalendar RSS feeds' );
286 $rss_description = mosGetParam( $_REQUEST, 'rss_description', 'EventCalendar web syndication.' );
287 $rss_img = mosGetParam( $_REQUEST, 'rss_img', 'elxis_rss.png' );
288 $rss_imgalt = mosGetParam( $_REQUEST, 'rss_imgalt', 'EventCalendar RSS feeds' );
289 $rss_limittext = mosGetParam( $_REQUEST, 'rss_limittext', '0' );
290 $rss_textlength = mosGetParam( $_REQUEST, 'rss_textlength', '20' );
291 $rss_multilang = mosGetParam( $_REQUEST, 'rss_multilang', '0' );
292 $rss_live = mosGetParam( $_REQUEST, 'rss_live', '0' );
293 $pp_mail = mosGetParam( $_REQUEST, 'pp_mail', 'mypaypal@email.com' );
294 $pp_curlist = mosGetParam( $_REQUEST, 'pp_curlist', 'EUR' );
295 $css_filename = mosGetParam( $_REQUEST, 'css_filename', '' );
296 $date_format = mosGetParam( $_REQUEST, 'date_format', 'd-m-Y' );
297 $params->set( 'who_can_post_events', $who_can_post_events );
298 $params->set( 'who_can_edit_events', $who_can_edit_events );
299 $params->set( 'week_startingday', $week_startingday );
300 $params->set( 'show_weeknumber', $show_weeknumber );
301 $params->set( 'week_number_links', $week_number_links );
302 $params->set( 'default_view', $default_view );
303 $params->set( 'view_nav', $view_nav );
304 $params->set( 'view_print', $view_print );
305 $params->set( 'view_rss', $view_rss );
306 $params->set( 'view_catlist', $view_catlist );
307 $params->set( 'view_periodicity', $view_periodicity );
308 $params->set( 'view_reservation', $view_reservation );
309 $params->set( 'col_catlist', $col_catlist );
310 $params->set( 'rss_cache', $rss_cache );
311 $params->set( 'rss_cachetime', $rss_cachetime );
312 $params->set( 'rss_num', $rss_num );
313 $params->set( 'rss_title', $rss_title );
314 $params->set( 'rss_description', $rss_description );
315 $params->set( 'rss_img', $rss_img );
316 $params->set( 'rss_imgalt', $rss_imgalt );
317 $params->set( 'rss_multilang', $rss_multilang );
318 $params->set( 'rss_limittext', $rss_limittext );
319 $params->set( 'rss_textlength', $rss_textlength );
320 $params->set( 'rss_live', $rss_live );
321 $params->set( 'pp_mail', $pp_mail );
322 $params->set( 'pp_curlist', $pp_curlist );
323 $params->set( 'css_filename', $css_filename );
324 $params->set( 'date_format', $date_format );
326 // Store params to database
327 $params_as_text = array();
328 foreach ($params->_params as $k=>$v) {
329 $params_as_text[] = "$k=$v";
331 $database->setQuery( "UPDATE #__components SET params = \n'" . mosParameters::textareaHandling( $params_as_text ) . "'\n WHERE link = 'option=com_eventcalendar'" );
332 if ($database->query()) {
333 $msg = $this->lng->CP_MSG_CONFIGURATION_STORED;
334 } else {
335 $msg = $this->lng->CP_MSG_CONFIGURATION_ERROR;
338 // Activate IOS Sitemap extension
339 if (mosGetParam( $_REQUEST, 'sitemap_ext') == 'on') {
340 $source = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar/eventcalendar.sitemap.php';
341 $destination = $mainframe->getCfg('absolute_path').'/administrator/components/com_sitemap/extensions/eventcalendar.sitemap.php';
342 $success = $fmanager->copyFile($source, $destination);
345 // Check if task is apply or save and redirect respectively
346 switch ( $this->task ) {
347 case 'cp_apply':
348 mosRedirect( 'index2.php?option=com_eventcalendar&task=cp', $msg );
349 break;
350 case 'cp_save':
351 default:
352 mosRedirect( 'index2.php?option=com_eventcalendar', $msg );
353 break;
357 /*********************************/
358 /* Prepare to show events list */
359 /*********************************/
360 protected function listEvents () {
361 global $mainframe, $database, $mosConfig_list_limit; // Pass global variables or objects
363 if ( $this->field && $this->order <> "none" ) {
364 $ordering = "\n ORDER BY e.$this->field " . $this->order;
365 } else {
366 $ordering = "\n ORDER BY e.start_date DESC, e.recur_week";
369 if (isset($searchstring)) $searcharray[] = $searchstring;
371 if(($this->cat_id <> 0) && is_numeric($this->cat_id) ) {
372 $searcharray[] = " e.catid=" . $this->cat_id;
373 } else if ($this->cat_id === "old") {
374 $today = getDate();
375 $searcharray[] = "e.end_date < $today[0]";
378 if ($this->task == "unpublished") {$searcharray[] = "e.published = '0'";}
380 //filter-options
381 $search = mosGetParam($_REQUEST, "search", false);
382 if ($search) $searcharray[] = "(e.title LIKE '%$search%' OR e.description LIKE '%$search%')";
383 $searchstring = (@$searcharray)?implode(" AND ", $searcharray):"1";
384 $database->setQuery( "SELECT COUNT(*) FROM #__eventcalendar e WHERE $searchstring");
386 // page navigation
387 $total = $database->loadResult();
388 $limitstart = $mainframe->getUserStateFromRequest( "view{eventcalendar}", 'limitstart', 0 );
389 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
390 $pageNav = new mosPageNav( $total, $limitstart, $limit );
392 $database->setQuery(
393 "SELECT e.*, u.name AS editor, c.title AS cat_name, c.params AS cat_params FROM #__eventcalendar e" .
394 "\n LEFT JOIN #__users u ON u.id = e.checked_out" .
395 "\n LEFT JOIN #__categories c ON c.id = e.catid" .
396 "\n WHERE " . $searchstring .
397 $ordering, '#__', $pageNav->limit, $pageNav->limitstart
399 $results = $database->loadObjectList();
400 $categories[] = mosHTML::makeOption( "0", $this->lng->LST_ALL_EVENTS );
401 $categories[] = mosHTML::makeOption( "old", $this->lng->LST_OLD_EVENTS );
403 $query = "SELECT id AS value, name AS text"
404 . "\n FROM #__categories"
405 . "\n WHERE section = 'com_eventcalendar'"
406 . "\n AND published = '1'";
407 $database->setQuery( $query );
408 $categories = array_merge( $categories, $database->loadObjectList() );
410 $catlist = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $this->cat_id );
412 clsEventCalendarAdminHTML::listEventsHTML($results, $pageNav, $catlist );
415 /*******************************/
416 /* Prepare to edit/add event */
417 /*******************************/
418 protected function editEvent($existing = NULL) {
419 global $my, $database;
421 if (is_numeric($existing)) {
422 $event = new mosEventCalendar_Event($database);
423 $event->load($existing);
424 $existing = $event;
425 $existing->checkout( $my->id );
427 clsEventCalendarAdminHTML::editEventHTML($existing);
430 /****************/
431 /* Save event */
432 /****************/
433 protected function saveEvent() {
434 global $objEventCalendar, $database, $adminLanguage, $my;
436 //CSRF prevention
437 $tokname = 'token'.$my->id;
438 if ( !isset($_POST[$tokname]) || !isset($_SESSION[$tokname]) || ($_POST[$tokname] != $_SESSION[$tokname]) ) {
439 die( 'Detected CSRF attack! Someone is forging your requests.' );
442 foreach ($_POST['languages'] as $xlang) {
443 if (trim($xlang) == '') { $newlangs = ''; }
445 if (!isset($newlangs)) {
446 $newlangs = implode(',', $_POST['languages']);
448 $_POST['language'] = $newlangs;
450 $event = new mosEventCalendar_Event($database);
451 $event->bind( $_POST );
452 if ($event->check($error)) {
453 if ($event->store()) {
454 // Update category color
455 $cat_col = new mosCategory( $database );
456 $cat_col->load($_POST['catid']);
457 $cat_col_par = new mosParameters( $cat_col->params );
459 if($_POST['color'.$_POST['id'].'display'] != "")
460 $cat_col_par->set("color", $_POST['color'.$_POST['id'].'display']);
462 $cat_col_par_txt = array();
463 foreach ($cat_col_par->_params as $k=>$v) {
464 $cat_col_par_txt[] = "$k=$v";
466 $cat_col->params = mosParameters::textareaHandling( $cat_col_par_txt );
467 if ($cat_col->store()) {
468 $msg = $objEventCalendar->lng->EDT_MSG_STORED;
469 } else {
470 echo "<script type=\"text/javascript\">alert('".$objEventCalendar->lng->GEN_COMPONENT_TITLE.": ".$objEventCalendar->lng->EDT_MSG_ERROR."'); window.history.go(-1);</script>"._LEND;
471 exit();
473 } else {
474 echo "<script type=\"text/javascript\">alert('".$objEventCalendar->lng->GEN_COMPONENT_TITLE.": ".$objEventCalendar->lng->EDT_MSG_ERROR."'); window.history.go(-1);</script>"._LEND;
475 exit();
477 } else {
478 echo "<script type=\"text/javascript\">alert('".$objEventCalendar->lng->GEN_COMPONENT_TITLE.": ".$error."'); window.history.go(-1);</script>"._LEND;
479 exit();
482 // Validate SEO
483 require_once($this->apath.'/eventcalendar.seovs.class.php');
484 $seo = new seovsEventCalendar('com_eventcalendar', '', $event->seotitle);
485 $seo->id = intval($event->id);
486 $seo->catid = intval($event->catid);
487 $seoval = $seo->validate();
488 if (!$seoval) {
489 echo "<script type=\"text/javascript\">alert('".$adminLanguage->A_SEOTITLE.": ".$seo->message."'); window.history.go(-1);</script>"._LEND;
490 exit();
493 // Check if task is apply or save and redirect respectively
494 switch ( $this->task ) {
495 case 'apply':
496 mosRedirect( 'index2.php?option=com_eventcalendar&task=edit&hidemainmenu=1&cid='.$event->id, $msg );
497 break;
498 case 'save':
499 default:
500 mosRedirect( 'index2.php?option=com_eventcalendar', $msg );
501 break;
505 /*********************/
506 /* Cancel add/edit */
507 /*********************/
508 protected function cancelEvent() {
509 global $database;
511 $event = new mosEventCalendar_Event($database);
512 $event->checkin($_POST['id']); //the id is defined globally
513 $this->cat_id = 0;
515 $this->listEvents();
518 /******************/
519 /* Delete event */
520 /******************/
521 protected function deleteEvent($itemids) {
522 global $database;
524 $event = new mosEventCalendar_Event($database);
525 foreach($itemids AS $itemid) {
526 $event->delete($itemid);
529 $this->listEvents();
532 /***********************/
533 /* Un-/Publish event */
534 /***********************/
535 protected function publishEvent($event_id, $value) {
536 global $database;
538 $event = new mosEventCalendar_Event($database);
539 foreach($event_id AS $id) {
540 $event->load($id);
541 $event->published = ''.intval($value).'';
542 $event->store();
544 $this->listEvents();
547 /*****************************/
548 /* Validate SEO Title (AJAX) */
549 /*****************************/
550 protected function validateSEO() {
551 global $mainframe;
553 $coid = intval(mosGetParam($_POST, 'coid', 0));
554 $cocatid = intval(mosGetParam($_POST, 'cocatid', 0));
555 $seotitle = eUTF::utf8_trim(mosGetParam($_POST, 'seotitle', ''));
557 require_once($this->apath.'/eventcalendar.seovs.class.php');
558 $seo = new seovsEventCalendar('com_eventcalendar', '', $seotitle);
559 $seo->id = $coid;
560 $seo->catid = $cocatid;
561 $seo->validate();
562 echo $seo->message;
563 exit();
567 /****************************/
568 /* Suggest SEO Title (AJAX) */
569 /****************************/
570 protected function suggestSEO() {
571 global $mainframe;
573 $coid = intval(mosGetParam($_POST, 'coid', 0));
574 $cocatid = intval(mosGetParam($_POST, 'cocatid', 0));
575 $cotitle = mosGetParam($_POST, 'cotitle', '');
577 require_once($this->apath.'/eventcalendar.seovs.class.php');
578 $seo = new seovsEventCalendar('com_eventcalendar', $cotitle);
579 $seo->id = $coid;
580 $seo->catid = $cocatid;
581 $sname = $seo->suggest();
583 @ob_end_clean();
584 @header('Content-Type: text/plain; Charset: utf-8');
585 if ($sname) {
586 echo '|1|'.$sname;
587 } else {
588 echo '|0|'.$seo->message;
590 exit();
593 /*******************************/
594 /* Change publish state (AJAX) */
595 /*******************************/
596 function ajaxchangeContent() {
597 global $database, $my, $adminLanguage;
599 $elem = intval(mosGetParam($_REQUEST, 'elem', 0));
600 $id = intval(mosGetParam($_REQUEST, 'id', 0));
601 $state = intval(mosGetParam($_REQUEST, 'state', 0));
603 if (!$id) {
604 echo '<img src="../includes/js/ThemeOffice/warning.png" width="16" height="16" border="0" title="'.$adminLanguage->A_ERROR.': Invalid Item id" />'._LEND;
605 exit();
608 $error = 0;
609 $database->setQuery( "UPDATE #__eventcalendar SET published='$state' WHERE id='$id' AND (checked_out=0 OR (checked_out='".$my->id."'))");
610 if (!$database->query()) { $error = 1; }
612 if ($error) { $state = $state ? 0 : 1; }
613 $img = $state ? 'publish_g.png' : 'publish_x.png';
614 $alt = $state ? $adminLanguage->A_PUBLISHED : $adminLanguage->A_UNPUBLISHED; ?>
615 <a href="javascript: void(0);"
616 onclick="changeContentState('<?php echo $elem; ?>', '<?php echo $id; ?>', '<?php echo ($state) ? 0 : 1; ?>');" title="<?php echo $alt; ?>">
617 <img src="images/<?php echo $img; ?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" /></a>
618 <?php exit();
623 // Initiate the class/ and execute it, then unset the
624 // object in order to free the allocated PHP memory.
625 $objEventCalendar = new clsEventCalendarAdmin();
626 $objEventCalendar->main();
627 unset($objEventCalendar);