/** * Display the detail page for the event occurrence. * * @param integer $rp_id ID of the repeat to display * @param string $query Optional query string, for highlighting * @param string $tpl Optional template filename, e.g. 'event_print' * @return string HTML for the page. */ public function Render($rp_id = 0, $query = '', $tpl = '') { global $_CONF, $_USER, $_EV_CONF, $_TABLES, $LANG_EVLIST, $LANG_WEEK, $_SYSTEM; $retval = ''; $url = ''; $location = ''; $street = ''; $city = ''; $province = ''; $country = ''; $postal = ''; $name = ''; $email = ''; $phone = ''; if ($rp_id != 0) { $this->Read($rp_id); } if ($this->rp_id == 0) { return EVLIST_alertMessage($LANG_EVLIST['access_denied']); } //update hit count evlist_hit($this->ev_id); $template = 'event'; if (!empty($tpl)) { $template .= '_' . $tpl; } else { $template .= $_SYSTEM['framework'] == 'uikit' ? '.uikit' : ''; } $T = new Template(EVLIST_PI_PATH . '/templates/'); $T->set_file(array('event' => $template . '.thtml', 'datetime' => 'date_time.thtml', 'address' => 'address.thtml', 'contact' => 'contact.thtml')); // If plain text then replace newlines with <br> tags if ($this->Event->postmode == '1') { //plaintext $this->Event->Detail->summary = nl2br($this->Event->Detail->summary); $this->Event->Detail->full_description = nl2br($this->Event->Detail->full_description); $this->Event->Detail->location = nl2br($this->Event->Detail->location); } $title = $this->Event->Detail->title; if ($this->postmode != 'plaintext') { $summary = PLG_replaceTags($this->Event->Detail->summary); $fulldescription = PLG_replaceTags($this->Event->Detail->full_description); $location = $this->Event->Detail->location != '' ? PLG_replaceTags($this->Event->Detail->location) : ''; } else { $summary = $this->Event->Detail->summary; $fulldescription = $this->Event->Detail->full_description; $location = $this->Event->Detail->location; } if ($query != '') { $title = COM_highlightQuery($title, $query); if (!empty($summary)) { $summary = COM_highlightQuery($summary, $query); } if (!empty($fulldescription)) { $fulldescription = COM_highlightQuery($fulldescription, $query); } if (!empty($location)) { $location = COM_highlightQuery($location, $query); } } $date_start = EVLIST_formattedDate($this->date_start); if ($this->date_start != $this->date_end) { $date_end = EVLIST_formattedDate($this->date_end); } else { $date_end = ''; } if ($this->Event->allday == '1') { $allday = '<br />' . $LANG_EVLIST['all_day_event']; } else { $allday = ''; if ($this->time_start1 != '') { $time_start1 = EVLIST_formattedTime($this->time_start1); $time_end1 = EVLIST_formattedTime($this->time_end1); } else { $time_start1 = ''; $time_end1 = ''; } //$time_period = $time_start . $time_end; if ($this->Event->split == '1') { $time_start2 = EVLIST_formattedTime($this->time_start2); $time_end2 = EVLIST_formattedTime($this->time_end2); } } $url = $this->Event->Detail->url; $street = $this->Event->Detail->street; $city = $this->Event->Detail->city; $province = $this->Event->Detail->province; $postal = $this->Event->Detail->postal; $country = $this->Event->Detail->country; // Now get the text description of the recurring interval, if any if ($this->Event->recurring && $this->Event->rec_data['type'] < EV_RECUR_DATES) { $rec_data = $this->Event->rec_data; $rec_string = $LANG_EVLIST['recur_freq_txt'] . ' ' . $this->Event->RecurDescrip(); switch ($rec_data['type']) { case EV_RECUR_WEEKLY: // sequential days $weekdays = array(); if (is_array($rec_data['listdays'])) { foreach ($rec_data['listdays'] as $daynum) { $weekdays[] = $LANG_WEEK[$daynum]; } $days_text = implode(', ', $weekdays); } else { $days_text = ''; } $rec_string .= ' ' . sprintf($LANG_EVLIST['on_days'], $days_text); break; case EV_RECUR_DOM: $days = array(); foreach ($rec_data['interval'] as $key => $day) { $days[] = $LANG_EVLIST['rec_intervals'][$day]; } $days_text = implode(', ', $days) . ' ' . $LANG_WEEK[$rec_data['weekday']]; $rec_string .= ' ' . sprintf($LANG_EVLIST['on_the_days'], $days_text); break; } if ($this->Event->rec_data['stop'] != '' && $this->Event->rec_data['stop'] < EV_MAX_DATE) { $rec_string .= ' ' . sprintf($LANG_EVLIST['recur_stop_desc'], EVLIST_formattedDate($this->Event->rec_data['stop'])); } } else { $rec_string = ''; } $T->set_var(array('pi_url' => EVLIST_URL, 'webcal_url' => preg_replace('/^https?/', 'webcal', EVLIST_URL), 'rp_id' => $this->rp_id, 'ev_id' => $this->ev_id, 'title' => $title, 'summary' => $summary, 'full_description' => $fulldescription, 'can_edit' => $this->isAdmin ? 'true' : '', 'start_time1' => $time_start1, 'end_time1' => $time_end1, 'start_time2' => $time_start2, 'end_time2' => $time_end2, 'start_date' => $date_start, 'end_date' => $date_end, 'start_datetime1' => $date_start . $time_start, 'end_datetime1' => $date_end . $time_end, 'allday_event' => $this->Event->allday == 1 ? 'true' : '', 'is_recurring' => $this->Event->recurring, 'can_subscribe' => $this->Event->Calendar->cal_ena_ical, 'recurring_event' => $rec_string, 'owner_id' => $this->Event->owner_id, 'cal_name' => $this->Event->Calendar->cal_name, 'cal_id' => $this->Event->cal_id, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'more_info_link' => sprintf($LANG_EVLIST['click_here'], $url))); if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) { if ($this->Event->options['rsvp_cutoff'] > 0) { $dt = new Date($this->event->date_start1 . ' ' . $this->Event->time_start1, $_CONF['timezone']); if (time() > $dt->toUnix() - $this->Event->options['rsvp_cutoff'] * 86400) { $past_cutoff = false; } else { $past_cutoff = true; } } if (COM_isAnonUser()) { // Just show a must-log-in message $T->set_var('login_to_register', 'true'); } elseif (!$past_cutoff) { $num_free_tickets = $this->isRegistered(0, true); $total_tickets = $this->isRegistered(0, false); if ($num_free_tickets > 0) { // If the user is already registered for any free tickets, // show the cancel link $T->set_var(array('unregister_link' => 'true', 'num_free_reg' => $num_free_tickets)); } // Show the registration link if (($this->Event->options['max_rsvp'] == 0 || $this->Event->options['rsvp_waitlist'] == 1 || $this->Event->options['max_rsvp'] > $this->TotalRegistrations()) && ($this->Event->options['max_user_rsvp'] == 0 || $total_tickets < $this->Event->options['max_user_rsvp'])) { USES_evlist_class_tickettype(); $Ticks = evTicketType::GetTicketTypes(); if ($this->Event->options['max_user_rsvp'] > 0) { $T->set_block('event', 'tickCntBlk', 'tcBlk'); $T->set_var('register_multi', true); //$rsvp_user_count = ''; $avail_tickets = $this->Event->options['max_user_rsvp'] - $total_tickets; for ($i = 1; $i <= $avail_tickets; $i++) { $T->set_var('tick_cnt', $i); $T->parse('tcBlk', 'tickCntBlk', true); //$rsvp_user_count .= '<option value="'.$i.'">'.$i. // '</option>'.LB; } //$T->set_var('register_multi', $rsvp_user_count); } else { // max_rsvp == 0 indicates openended registration $T->set_var('register_unltd', 'true'); } $T->set_block('event', 'tickTypeBlk', 'tBlk'); foreach ($this->Event->options['tickets'] as $tick_id => $data) { /*$options .= '<option value="' . $tick_id . '">' . $Ticks[$tick_id]->description; if ($data['fee'] > 0) { $options .= ' - ' . COM_numberFormat($data['fee'], 2); } $options .= '</option>' . LB;*/ $status = LGLIB_invokeService('paypal', 'formatAmount', array('amount' => $data['fee']), $pp_fmt_amt, $svc_msg); $fmt_amt = $status == PLG_RET_OK ? $pp_fmt_amt : COM_numberFormat($data['fee'], 2); $T->set_var(array('tick_type' => $tick_id, 'tick_descr' => $Ticks[$tick_id]->description, 'tick_fee' => $data['fee'] > 0 ? $fmt_amt : 'FREE')); $T->parse('tBlk', 'tickTypeBlk', true); } $T->set_var(array('register_link' => 'true', 'ticket_options' => $options, 'ticket_types_multi' => count($this->Event->options['tickets']) > 1 ? 'true' : '')); } } // If ticket printing is enabled for this event, see if the // current user has any tickets to print. if ($this->Event->options['rsvp_print'] > 0) { $paid = $this->Event->options['rsvp_print'] == 1 ? 'paid' : ''; USES_evlist_class_ticket(); $tickets = evTicket::GetTickets($this->ev_id, '', $this->uid, $paid); if (count($tickets) > 0) { $T->set_var('have_tickets', 'true'); } } } // if enable_rsvp if (!empty($date_start) || !empty($date_end)) { $T->parse('datetime_info', 'datetime'); } // Only process the location block if at least one element exists. // Don't want an empty block showing. if (!empty($location) || !empty($street) || !empty($city) || !empty($province) || !empty($postal)) { $T->set_var(array('location' => $location, 'street' => $street, 'city' => $city, 'province' => $province, 'country' => $country, 'postal' => $postal)); $T->parse('address_info', 'address'); // Get info from the Weather plugin, if configured and available // There has to be at least some location data for this to work. if ($_EV_CONF['use_weather']) { // The postal code works best, but not internationally. // Try the regular address first. $loc = ''; if (!empty($city) && !empty($province)) { $loc = $city . ', ' . $province . ' ' . $country; } if (!empty($postal)) { $loc .= ' ' . $postal; } if (!empty($loc)) { // Location info was found, get the weather LGLIB_invokeService('weather', 'embed', array('loc' => $loc), $weather, $svc_msg); if (!empty($weather)) { // Weather info was found $T->set_var('weather', $weather); } } } } // Get a map from the Locator plugin, if configured and available if ($_EV_CONF['use_locator'] == 1 && $this->Event->Detail->lat != 0 && $this->Event->Detail->lng != 0) { $status = LGLIB_invokeService('locator', 'getMap', array('lat' => $this->Event->Detail->lat, 'lng' => $this->Event->Detail->lng), $map, $svc_msg); if ($status == PLG_RET_OK) { $T->set_var(array('map' => $map, 'lat' => number_format($this->Event->Detail->lat, 8, '.', ''), 'lng' => number_format($this->Event->Detail->lng, 8, '.', ''))); } } //put contact info here: contact, email, phone# $name = $this->Event->Detail->contact != '' ? COM_applyFilter($this->Event->Detail->contact) : ''; if ($this->Event->Detail->email != '') { $email = COM_applyFilter($this->Event->Detail->email); $email = EVLIST_obfuscate($email); } else { $email = ''; } $phone = $this->Event->Detail->phone != '' ? COM_applyFilter($this->Event->Detail->phone) : ''; if (!empty($name) || !empty($email) || !empty($phone)) { $T->set_var(array('name' => $name, 'email' => $email, 'phone' => $phone)); $T->parse('contact_info', 'contact'); } // TODO: Is the range needed? if (!empty($range)) { $andrange = '&range=' . $range; } else { $andrange = '&range=2'; } if (!empty($cat)) { $andcat = '&cat=' . $cat; } else { $andcat = ''; } $cats = $this->Event->GetCategories(); $catcount = count($cats); if ($catcount > 0) { $catlinks = array(); for ($i = 0; $i < $catcount; $i++) { $catlinks[] = '<a href="' . COM_buildURL(EVLIST_URL . '/index.php?op=list' . $andrange . '&cat=' . $cats[$i]['id']) . '">' . $cats[$i]['name'] . '</a> '; } $catlink = join('| ', $catlinks); $T->set_var('category_link', $catlink, true); } // reminders must be enabled globally first and then per event in // order to be active if (!isset($_EV_CONF['reminder_days'])) { $_EV_CONF['reminder_days'] = 1; } $hasReminder = 0; if ($_EV_CONF['enable_reminders'] == '1' && $this->Event->enable_reminders == '1' && time() < strtotime("-" . $_EV_CONF['reminder_days'] . " days", strtotime($this->date_start))) { //form will not appear within XX days of scheduled event. $show_reminders = true; // Let's see if we have already asked for a reminder... if ($_USER['uid'] > 1) { $hasReminder = DB_count($_TABLES['evlist_remlookup'], array('eid', 'uid', 'rp_id'), array($this->ev_id, $_USER['uid'], $this->rp_id)); } } else { $show_reminders = false; } if ($this->Event->options['contactlink'] == 1) { $ownerlink = $_CONF['site_url'] . '/profiles.php?uid=' . $this->Event->owner_id; $ownerlink = sprintf($LANG_EVLIST['contact_us'], $ownerlink); } else { $ownerlink = ''; } $T->set_var(array('owner_link' => $ownerlink, 'reminder_set' => $hasReminder ? 'true' : 'false', 'reminder_email' => isset($_USER['email']) ? $_USER['email'] : '', 'notice' => 1, 'rp_id' => $this->rp_id, 'eid' => $this->ev_id, 'show_reminderform' => $show_reminders ? 'true' : '')); USES_evlist_class_tickettype(); $tick_types = evTicketType::GetTicketTypes(); $T->set_block('event', 'registerBlock', 'rBlock'); if (is_array($this->Event->options['tickets'])) { foreach ($this->Event->options['tickets'] as $tic_type => $info) { $T->set_var(array('tic_description' => $tick_types[$tic_type]->description, 'tic_fee' => COM_numberFormat($info['fee'], 2))); $T->parse('rBlock', 'registerBlock', true); } } // Show the "manage reservations" link to the event owner if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) { if ($this->isAdmin) { $T->set_var('admin_rsvp', EVLIST_adminRSVP($this->rp_id)); } } $T->parse('output', 'event'); $retval .= $T->finish($T->get_var('output')); return $retval; }
/** * Get status date * * @param object $row * @return string HTML */ public function getStatusDate($row = NULL) { if ($row === NULL) { $row = $this->version; } $status = $row && isset($row->state) ? $row->state : $this->get('state'); switch ($status) { case 0: $date = strtolower(Lang::txt('COM_PUBLICATIONS_UNPUBLISHED')) . ' ' . Date::of($row->published_down)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 1: $date = Date::of($row->published_up)->toUnix() > Date::toUnix() ? Lang::txt('to be') . ' ' : ''; $date .= strtolower(Lang::txt('COM_PUBLICATIONS_RELEASED')) . ' ' . Date::of($row->published_up)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 3: case 4: default: $date = strtolower(Lang::txt('COM_PUBLICATIONS_STARTED')) . ' ' . Date::of($row->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 5: case 7: $date = strtolower(Lang::txt('COM_PUBLICATIONS_SUBMITTED')) . ' ' . Date::of($row->submitted)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; } return $date; }
function MG_saveMediaEdit($album_id, $media_id, $actionURL) { global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $_POST, $_FILES; $back = COM_applyFilter($_POST['rpath']); if ($back != '') { $sLength = strlen($_CONF['site_url']); if (substr($back, 0, $sLength) != $_CONF['site_url']) { $back = $_CONF['site_url']; } $actionURL = $back; } $queue = COM_applyFilter($_POST['queue'], true); if (isset($_POST['replacefile'])) { $replacefile = COM_applyFilter($_POST['replacefile']); } else { $replacefile = 0; } if ($replacefile == 1) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; $repfilename = $_FILES['repfilename']; $filename = $repfilename['name']; $file = $repfilename['tmp_name']; list($rc, $msg) = MG_getFile($file, $filename, $album_id, '', '', 1, 0, '', 0, '', '', 0, 0, $media_id); COM_errorLog($msg); } // see if we had an attached thumbnail before... $thumb = $_FILES['attthumb']; $thumbnail = $thumb['tmp_name']; $att = isset($_POST['attachtn']) ? COM_applyFilter($_POST['attachtn'], true) : 0; if ($att == 1) { $attachtn = 1; } else { $attachtn = 0; } if ($queue) { $old_attached_tn = DB_getItem($_TABLES['mg_mediaqueue'], 'media_tn_attached', 'media_id="' . DB_escapeString($media_id) . '"'); } else { $old_attached_tn = DB_getItem($_TABLES['mg_media'], 'media_tn_attached', 'media_id="' . DB_escapeString($media_id) . '"'); } if ($old_attached_tn == 0 && $att == 1 && $thumbnail == '') { $attachtn = 0; } if ($old_attached_tn == 1 && $attachtn == 0) { $remove_old_tn = 1; } else { $remove_old_tn = 0; } if ($queue) { $remote_media = DB_getItem($_TABLES['mg_mediaqueue'], 'remote_media', 'media_id="' . DB_escapeString($media_id) . '"'); } else { $remote_media = DB_getItem($_TABLES['mg_media'], 'remote_media', 'media_id="' . DB_escapeString($media_id) . '"'); } if ($remote_media) { $remote_url = isset($_POST['remoteurl']) ? DB_escapeString($_POST['remoteurl']) : ''; } else { $remote_url = ''; } if ($_MG_CONF['htmlallowed']) { $media_title = COM_checkWords($_POST['media_title']); $media_desc = COM_checkWords($_POST['media_desc']); } else { $media_title = htmlspecialchars(strip_tags(COM_checkWords($_POST['media_title']))); $media_desc = htmlspecialchars(strip_tags(COM_checkWords($_POST['media_desc']))); } $media_time_month = COM_applyFilter($_POST['media_month']); $media_time_day = COM_applyFilter($_POST['media_day']); $media_time_year = COM_applyFilter($_POST['media_year']); $media_time_hour = COM_applyFilter($_POST['media_hour']); $media_time_minute = COM_applyFilter($_POST['media_minute']); $original_filename = COM_applyFilter($_POST['original_filename']); if ($replacefile == 1) { $original_filename = $filename; } $cat_id = COM_applyFilter($_POST['cat_id'], true); $media_keywords = $_POST['media_keywords']; $media_keywords_safe = substr($media_keywords, 0, 254); $media_keywords = DB_escapeString(htmlspecialchars(strip_tags(COM_checkWords($media_keywords_safe)))); $artist = isset($_POST['artist']) ? DB_escapeString(COM_applyFilter($_POST['artist'])) : ''; $musicalbum = isset($_POST['musicalbum']) ? DB_escapeString(COM_applyFilter($_POST['musicalbum'])) : ''; $genre = isset($_POST['genre']) ? DB_escapeString(COM_applyFilter($_POST['genre'])) : ''; $dtObject = new Date('now', $_USER['tzid']); $dtObject->setDateTimestamp($media_time_year, $media_time_month, $media_time_day, $media_time_hour, $media_time_minute, 0); $media_time = $dtObject->toUnix(); if (isset($_POST['owner_name'])) { $owner_id = COM_applyFilter($_POST['owner_name'], true); $owner_sql = ',media_user_id=' . $owner_id . ' '; } else { $owner_sql = ''; } $sql = "UPDATE " . ($queue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . "\n SET media_title='" . DB_escapeString($media_title) . "',\n media_desc='" . DB_escapeString($media_desc) . "',\n media_original_filename='" . DB_escapeString($original_filename) . "',\n media_time=" . $media_time . ",\n media_tn_attached=" . $attachtn . ",\n media_category=" . intval($cat_id) . ",\n media_keywords='" . $media_keywords . "',\n artist='" . $artist . "',\n album='" . $musicalbum . "',\n genre='" . $genre . "',\n remote_url='" . $remote_url . "' " . $owner_sql . "WHERE media_id='" . DB_escapeString($media_id) . "'"; DB_query($sql); if (DB_error() != 0) { echo COM_errorLog("Media Gallery: ERROR Updating image in media database"); } PLG_itemSaved($media_id, 'mediagallery'); $media_id_db = DB_escapeString($media_id); // process playback options if any... if (isset($_POST['autostart'])) { // asf $playback_option['autostart'] = intval(COM_applyFilter($_POST['autostart'], true)); $playback_option['enablecontextmenu'] = intval(COM_applyFilter($_POST['enablecontextmenu'], true)); $playback_option['stretchtofit'] = isset($_POST['stretchtofit']) ? intval(COM_applyFilter($_POST['stretchtofit'], true)) : 0; $playback_option['showstatusbar'] = COM_applyFilter($_POST['showstatusbar'], true); $playback_option['uimode'] = COM_applyFilter($_POST['uimode']); $playback_option['height'] = isset($_POST['height']) ? COM_applyFilter($_POST['height'], true) : 0; $playback_option['width'] = isset($_POST['width']) ? COM_applyFilter($_POST['width'], true) : 0; $playback_option['bgcolor'] = isset($_POST['bgcolor']) ? COM_applyFilter($_POST['bgcolor']) : 0; $playback_option['playcount'] = isset($_POST['playcount']) ? COM_applyFilter($_POST['playcount'], true) : 0; $playback_option['loop'] = isset($_POST['loop']) ? COM_applyFilter($_POST['loop'], true) : 0; if ($playback_option['playcount'] < 1) { $playback_option['playcount'] = 1; } DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','autostart',{$playback_option['autostart']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','enablecontextmenu',{$playback_option['enablecontextmenu']}"); if ($playback_option['stretchtofit'] != '') { DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','stretchtofit',{$playback_option['stretchtofit']}"); } DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','showstatusbar',{$playback_option['showstatusbar']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','uimode', '{$playback_option['uimode']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','height',{$playback_option['height']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','width',{$playback_option['width']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','bgcolor','{$playback_option['bgcolor']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','playcount','{$playback_option['playcount']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','loop','{$playback_option['loop']}'"); } if (isset($_POST['play'])) { //swf $playback_option['play'] = COM_applyFilter($_POST['play'], true); $playback_option['menu'] = isset($_POST['menu']) ? COM_applyFilter($_POST['menu'], true) : ''; $playback_option['quality'] = isset($_POST['quality']) ? DB_escapeString(COM_applyFilter($_POST['quality'])) : ''; $playback_option['flashvars'] = isset($_POST['flashvars']) ? DB_escapeString(COM_applyFilter($_POST['flashvars'])) : ''; $playback_option['height'] = COM_applyFilter($_POST['height'], true); $playback_option['width'] = COM_applyFilter($_POST['width'], true); $playback_option['loop'] = isset($_POST['loop']) ? COM_applyFilter($_POST['loop'], true) : 0; $playback_option['scale'] = isset($_POST['scale']) ? DB_escapeString(COM_applyFilter($_POST['scale'])) : ''; $playback_option['wmode'] = isset($_POST['wmode']) ? DB_escapeString(COM_applyFilter($_POST['wmode'])) : ''; $playback_option['allowscriptaccess'] = isset($_POST['allowscriptaccess']) ? DB_escapeString(COM_applyFilter($_POST['allowscriptaccess'])) : ''; $playback_option['bgcolor'] = isset($_POST['bgcolor']) ? DB_escapeString(COM_applyFilter($_POST['bgcolor'])) : ''; $playback_option['swf_version'] = isset($_POST['swf_version']) ? COM_applyFilter($_POST['swf_version'], true) : 9; DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','play', {$playback_option['play']}"); if ($playback_option['menu'] != '') { DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','menu', {$playback_option['menu']}"); } DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','quality', '{$playback_option['quality']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','height', {$playback_option['height']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','width', {$playback_option['width']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','flashvars', '{$playback_option['flashvars']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','scale', '{$playback_option['scale']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','wmode', '{$playback_option['wmode']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','loop', '{$playback_option['loop']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','allowscriptaccess','{$playback_option['allowscriptaccess']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','bgcolor', '{$playback_option['bgcolor']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id}','swf_version', '{$playback_option['swf_version']}'"); } if (isset($_POST['autoplay'])) { //quicktime $playback_option['autoplay'] = COM_applyFilter($_POST['autoplay'], true); $playback_option['autoref'] = COM_applyFilter($_POST['autoref'], true); $playback_option['controller'] = COM_applyFilter($_POST['controller'], true); $playback_option['kioskmode'] = COM_applyFilter($_POST['kioskmode'], true); $playback_option['scale'] = DB_escapeString(COM_applyFilter($_POST['scale'])); $playback_option['height'] = COM_applyFilter($_POST['height'], true); $playback_option['width'] = COM_applyFilter($_POST['width'], true); $playback_option['bgcolor'] = COM_applyFilter($_POST['bgcolor']); $playback_option['loop'] = COM_applyFilter($_POST['loop'], true); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','autoref',{$playback_option['autoref']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','autoplay',{$playback_option['autoplay']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','controller',{$playback_option['controller']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','kioskmode',{$playback_option['kioskmode']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','scale','{$playback_option['scale']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','height',{$playback_option['height']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','width',{$playback_option['width']}"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','bgcolor','{$playback_option['bgcolor']}'"); DB_save($_TABLES['mg_playback_options'], 'media_id,option_name,option_value', "'{$media_id_db}','loop','{$playback_option['loop']}'"); } if ($attachtn == 1 && $thumbnail != '') { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; $media_filename = DB_getItem($_TABLES['mg_media'], 'media_filename', 'media_id="' . $media_id . '"'); $thumbFilename = $_MG_CONF['path_mediaobjects'] . 'tn/' . $media_filename[0] . '/tn_' . $media_filename; MG_attachThumbnail($album_id, $thumbnail, $thumbFilename); } if ($remove_old_tn == 1) { $media_filename = DB_getItem($_TABLES['mg_media'], 'media_filename', 'media_id="' . $media_id . '"'); foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $media_filename[0] . '/tn_' . $media_filename . $ext)) { @unlink($_MG_CONF['path_mediaobjects'] . 'tn/' . $media_filename[0] . '/tn_' . $media_filename . $ext); break; } } } if ($queue) { echo COM_refresh($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=moderate'); } else { require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; MG_buildAlbumRSS($album_id); CACHE_remove_instance('whatsnew'); echo COM_refresh($actionURL); } exit; }
/** * Create a weekly view. * * @param integer $year Year to display, default is current year * @param integer $month Starting month * @param integer $day Starting day * @param integer $cat Event category * @param integer $cal Calendar to show * @return string HTML for calendar page */ function EVLIST_weekview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '') { global $_CONF, $_EV_CONF, $LANG_MONTH, $LANG_EVLIST; USES_class_date(); EVLIST_setViewSession('week', $year, $month, $day); $retval = ''; list($currentyear, $currentmonth, $currentday) = explode('-', $_EV_CONF['_today']); // Default to the current month if ($year == 0) { $year = $currentyear; } if ($month == 0) { $month = $currentmonth; } if ($day == 0) { $day = $currentday; } $cat = (int) $cat; $cal = (int) $cal; // Get the events $calendarView = Date_Calc::getCalendarWeek($day, $month, $year, '%Y-%m-%d'); $start_date = $calendarView[0]; $end_date = $calendarView[6]; $calendars_used = array(); $dtStart = new Date(strtotime($start_date), $_CONF['timezone']); $dtToday = $dtStart; // used to update date strings each day $week_secs = 86400 * 7; $dtPrev = new Date($dtStart->toUnix() - $week_secs, $_CONF['timezone']); $dtNext = new Date($dtStart->toUnix() + $week_secs, $_CONF['timezone']); // Set up next and previous week links list($sYear, $sMonth, $sDay) = explode('-', $start_date); $tpl = 'weekview'; $T = new Template(EVLIST_PI_PATH . '/templates/weekview'); if ($opt == 'print') { $tpl .= '_print'; } elseif ($_EV_CONF['cal_tmpl'] == 'json') { $tpl .= '_json'; } $T->set_file(array('week' => $tpl . '.thtml')); $daynames = EVLIST_getDayNames(); $events = EVLIST_getEvents($start_date, $end_date, array('cat' => $cat, 'cal' => $cal)); $start_mname = $LANG_MONTH[(int) $sMonth]; $last_date = getdate($dtStart->toUnix() + 86400 * 6); $end_mname = $LANG_MONTH[$last_date['mon']]; $end_ynum = $last_date['year']; $end_dnum = sprintf('%02d', $last_date['mday']); $date_range = $start_mname . ' ' . $sDay; if ($year != $end_ynum) { $date_range .= ', ' . $year . ' - '; } else { $date_range .= ' - '; } if ($start_mname != $end_mname) { $date_range .= $end_mname . ' '; } $date_range .= "{$end_dnum}, {$end_ynum}"; $T->set_var('date_range', $date_range); $T->set_block('week', 'dayBlock', 'dBlk'); foreach ($calendarView as $idx => $weekData) { list($curyear, $curmonth, $curday) = explode('-', $weekData); $dtToday->setDateTimestamp($curyear, $curmonth, $curday, 0, 0, 0); $T->clear_var('eBlk'); if ($weekData == $_EV_CONF['_today']) { $T->set_var('dayclass', 'weekview-curday'); } else { $T->set_var('dayclass', 'weekview-offday'); } $monthname = $LANG_MONTH[(int) $curmonth]; $T->set_var('dayinfo', $daynames[$idx] . ', ' . COM_createLink($dtToday->format($_CONF['shortdate']), EVLIST_URL . "/index.php?view=day&day={$curday}" . "&cat={$cat}&cal={$cal}" . "&month={$curmonth}&year={$curyear}")); if ($_EV_CONF['_can_add']) { $T->set_var(array('can_add' => 'true', 'curday' => $curday, 'curmonth' => $curmonth, 'curyear' => $curyear)); } if (!isset($events[$weekData])) { // Make sure it's a valid but empty array if no events today $events[$weekData] = array(); } $T->set_block('week', 'eventBlock', 'eBlk'); foreach ($events[$weekData] as $A) { //$fgstyle = 'color:' . $A['fgcolor'].';'; if ($A['allday'] == 1 || $A['rp_date_start'] < $weekData && $A['rp_date_end'] > $weekData) { $event_time = $LANG_EVLIST['allday']; /*$event_div = '<div class="monthview_allday" style="background-color:'. $event['bgcolor'].';">';*/ } else { if ($A['rp_date_start'] == $weekData) { $startstamp = strtotime($weekData . ' ' . $A['rp_time_start1']); $starttime = date('g:i a', $startstamp); } else { $starttime = ' ... '; } if ($A['rp_date_end'] == $weekData) { $endstamp = strtotime($weekData . ' ' . $A['rp_time_end1']); $endtime = date('g:i a', $endstamp); } else { $endtime = ' ... '; } $event_time = $starttime . ' - ' . $endtime; if ($A['split'] == 1 && !empty($A['rp_time_start2'])) { $startstamp2 = strtotime($weekData . ' ' . $A['rp_time_start2']); $starttime2 = date('g:i a', $startstamp2); $endstamp2 = strtotime($weekData . ' ' . $A['rp_time_end2']); $endtime2 = date('g:i a', $endstamp2); $event_time .= ' & ' . $starttime2 . ' - ' . $endtime2; } } $calendars_used[$A['cal_id']] = array('cal_name' => $A['cal_name'], 'cal_ena_ical' => $A['cal_ena_ical'], 'cal_id' => $event['cal_id'], 'fgcolor' => $A['fgcolor'], 'bgcolor' => $A['bgcolor']); /*$eventlink = '<a class="cal-event" style="' . $fgstyle . '" href="' . EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . '">' . stripslashes($A['title']) . '</a>';*/ $T->set_var(array('event_times' => $event_time, 'event_title' => htmlspecialchars($A['title']), 'event_id' => $A['rp_id'], 'cal_id' => $A['cal_id'], 'delete_imagelink' => EVLIST_deleteImageLink($A, $token), 'pi_url' => EVLIST_URL, 'fgcolor' => $A['fgcolor'])); $T->parse('eBlk', 'eventBlock', true); } $T->parse('dBlk', 'dayBlock', true); } $T->set_var(array('pi_url' => EVLIST_URL, 'cal_header' => EVLIST_calHeader($year, $month, $day, 'week', $cat, $cal), 'cal_footer' => EVLIST_calFooter($calendars_used), 'prevmonth' => $dtPrev->format('n', false), 'prevday' => $dtPrev->format('j', false), 'prevyear' => $dtPrev->format('Y', false), 'nextmonth' => $dtNext->format('n', false), 'nextday' => $dtNext->format('j', false), 'nextyear' => $dtNext->format('Y', false), 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal, 'cal_checkboxes' => EVLIST_cal_checkboxes($calendars_used), 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'year' => $year, 'month' => $month, 'day' => $day)); $T->parse('output', 'week'); return $T->finish($T->get_var('output')); }
/** * Register View for Event * * @return string */ private function register() { //create the view $view = $this->view('register', 'calendar'); //get request varse $eventId = Request::getVar('event_id', ''); //load event data $view->event = new \Components\Events\Models\Event($eventId); //get registrants count $eventsRespondent = new \Components\Events\Tables\Respondent(array('id' => $eventId)); $view->registrants = $eventsRespondent->getCount(); //do we have a registration deadline if ($view->event->get('registerby') == '' || $view->event->get('registerby') == '0000-00-00 00:00:00') { App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=details&event_id=' . $view->event->get('id')), Lang::txt('This event does not have registration.'), 'warning'); return; } //make sure registration is open $now = Date::toUnix(); $registerby = Date::of($view->event->get('registerby'))->toUnix(); if ($registerby >= $now) { //get the password $password = Request::getVar('passwrd', '', 'post'); //is the event restricted if ($view->event->get('restricted') != '' && $view->event->get('restricted') != $password && !isset($this->register)) { //if we entered a password and it was bad lets tell the user if (isset($password) && $password != '') { $this->setError('The password entered is incorrect.'); } $view->setLayout('register_restricted'); } } else { $view->setLayout('register_closed'); } //push some vars to the view $view->month = $this->month; $view->year = $this->year; $view->group = $this->group; $view->option = $this->option; $view->authorized = $this->authorized; $view->user = $this->user; $view->register = isset($this->register) ? $this->register : null; $view->arrival = isset($this->arrival) ? $this->arrival : null; $view->departure = isset($this->departure) ? $this->departure : null; $view->dietary = isset($this->dietary) ? $this->dietary : null; $view->dinner = isset($this->dinner) ? $this->dinner : null; $view->disability = isset($this->disability) ? $this->disability : null; $view->race = isset($this->race) ? $this->race : null; //add params to view $view->params = new \Hubzero\Config\Registry($view->event->get('params')); if (!$this->user->get('guest')) { $profile = new \Hubzero\User\Profile(); $profile->load($this->user->get('id')); $view->register['first_name'] = $profile->get('givenName'); $view->register['last_name'] = $profile->get('surname'); $view->register['affiliation'] = $profile->get('organization'); $view->register['email'] = $profile->get('email'); $view->register['telephone'] = $profile->get('phone'); $view->register['website'] = $profile->get('url'); } //get any errors if there are any foreach ($this->getErrors() as $error) { $view->setError($error); } //load the view return $view->loadTemplate(); }
/** * Saves a publication * Redirects to main listing * * @param boolean $redirect * @return void */ public function saveTask($redirect = false) { // Check for request forgeries Request::checkToken(); // Incoming $id = Request::getInt('id', 0); $action = Request::getVar('admin_action', ''); $published_up = Request::getVar('published_up', ''); $version = Request::getVar('version', 'default'); // Is this a new publication? Cannot create via back-end $isnew = $id ? 0 : 1; if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_ERROR_LOAD_PUBLICATION'), 'error'); return; } // Load publication model $this->model = new Models\Publication($id, $version); if (!$this->model->exists()) { throw new Exception(Lang::txt('COM_PUBLICATIONS_NOT_FOUND'), 404); } // Checkin resource $this->model->publication->checkin(); // Set redirect URL $url = Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=edit' . '&id[]=' . $id . '&version=' . $version, false); $authors = $this->model->authors(); $project = $this->model->project(); $this->model->setCuration(); $requireDoi = isset($this->model->_curationModel->_manifest->params->require_doi) ? $this->model->_curationModel->_manifest->params->require_doi : 0; // Incoming updates $title = trim(Request::getVar('title', '', 'post')); $title = htmlspecialchars($title); $abstract = trim(Request::getVar('abstract', '', 'post')); $abstract = htmlspecialchars(\Hubzero\Utility\Sanitize::clean($abstract)); $description = trim(Request::getVar('description', '', 'post', 'none', 2)); $release_notes = stripslashes(trim(Request::getVar('release_notes', '', 'post', 'none', 2))); $group_owner = Request::getInt('group_owner', 0, 'post'); $published_up = trim(Request::getVar('published_up', '', 'post')); $published_down = trim(Request::getVar('published_down', '', 'post')); $state = Request::getInt('state', 0); $metadata = ''; $activity = ''; // Save publication record $this->model->publication->alias = trim(Request::getVar('alias', '', 'post')); $this->model->publication->category = trim(Request::getInt('category', 0, 'post')); $this->model->publication->access = Request::getInt('access', 0, 'post'); if (!$project->get('owned_by_group')) { $this->model->publication->group_owner = $group_owner; } $this->model->publication->store(); // Get metadata if (isset($_POST['nbtag'])) { $category = $this->model->category(); $fields = array(); if (trim($category->customFields) != '') { $fs = explode("\n", trim($category->customFields)); foreach ($fs as $f) { $fields[] = explode('=', $f); } } $nbtag = Request::getVar('nbtag', array(), 'request', 'array'); foreach ($nbtag as $tagname => $tagcontent) { $tagcontent = trim(stripslashes($tagcontent)); if ($tagcontent != '') { $metadata .= "\n" . '<nb:' . $tagname . '>' . $tagcontent . '</nb:' . $tagname . '>' . "\n"; } else { foreach ($fields as $f) { if ($f[0] == $tagname && end($f) == 1) { echo Helpers\Html::alert(Lang::txt('COM_PUBLICATIONS_REQUIRED_FIELD_CHECK', $f[1])); exit; } } } } } // Save incoming $this->model->version->title = $title; $this->model->version->abstract = \Hubzero\Utility\String::truncate($abstract, 250); $this->model->version->description = $description; $this->model->version->metadata = $metadata; $this->model->version->release_notes = $release_notes; $this->model->version->license_text = trim(Request::getVar('license_text', '', 'post')); $this->model->version->license_type = Request::getInt('license_type', 0, 'post'); $this->model->version->access = Request::getInt('access', 0, 'post'); // Get DOI service $doiService = new Models\Doi($this->model); // DOI manually entered? $doi = trim(Request::getVar('doi', '', 'post')); if ($doi && (!$this->model->version->doi || !preg_match("/" . $doiService->_configs->shoulder . "/", $this->model->version->doi))) { $this->model->version->doi = $doi; } $this->model->version->published_up = $published_up ? Date::of($published_up, Config::get('offset'))->toSql() : '0000-00-00 00:00:00'; $this->model->version->published_down = $published_down && trim($published_down) != 'Never' ? Date::of($published_down, Config::get('offset'))->toSql() : '0000-00-00 00:00:00'; // Determine action (if status is flipped) if ($this->model->version->state != $state) { switch ($state) { case 1: $action = $this->model->version->state == 0 ? 'republish' : 'publish'; break; case 0: $action = 'unpublish'; break; case 3: case 4: $action = 'revert'; break; case 7: $action = 'wip'; break; } $this->model->version->state = $state; } // Update DOI with latest information if ($this->model->version->doi && !$action) { // Update DOI if locally issued if (preg_match("/" . $doiService->_configs->shoulder . "/", $this->model->version->doi)) { $doiService->update($this->model->version->doi, true); } } // Incoming tags $tags = Request::getVar('tags', '', 'post'); // Save the tags $rt = new Helpers\Tags($this->database); $rt->tag_object(User::get('id'), $id, $tags, 1, true); // Email config $pubtitle = \Hubzero\Utility\String::truncate($this->model->version->title, 100); $subject = Lang::txt('Version') . ' ' . $this->model->version->version_label . ' ' . Lang::txt('COM_PUBLICATIONS_OF') . ' ' . strtolower(Lang::txt('COM_PUBLICATIONS_PUBLICATION')) . ' "' . $pubtitle . '" '; $sendmail = 0; $message = rtrim(\Hubzero\Utility\Sanitize::clean(Request::getVar('message', ''))); $output = Lang::txt('COM_PUBLICATIONS_SUCCESS_SAVED_ITEM'); // Admin actions if ($action) { $output = ''; switch ($action) { case 'publish': case 'republish': // Unset the published_down timestamp if publishing $this->model->version->published_down = '0000-00-00 00:00:00'; $activity = $action == 'publish' ? Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_REPUBLISHED'); $subject .= $action == 'publish' ? Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REPUBLISHED'); $this->model->version->state = 1; // Is service enabled? - Issue/update a DOI if ($doiService->on()) { if ($this->model->version->doi && preg_match("/" . $doiService->_configs->shoulder . "/", $this->model->version->doi)) { // Update $doiService->update($this->model->version->doi, true); if ($doiService->getError()) { $this->setError($doiService->getError()); } } elseif ($requireDoi) { // Register $doi = $doiService->register(true); if (!$doi) { App::redirect($url, Lang::txt('COM_PUBLICATIONS_ERROR_DOI') . ' ' . $doiService->getError(), 'error'); return; } else { $this->model->version->doi = $doi; } } } // Save date accepted if ($action == 'publish') { $this->model->version->accepted = Date::toSql(); $this->model->version->published_up = $published_up ? Date::of($published_up, Config::get('offset'))->toSql() : Date::toSql(); // Get and save manifest and its version $versionNumber = $this->model->_curationModel->checkCurationVersion(); $this->model->version->set('curation', json_encode($this->model->_curationModel->_manifest)); $this->model->version->set('curation_version_id', $versionNumber); // Check if publication is within grace period (published status) $gracePeriod = $this->config->get('graceperiod', 0); $allowArchive = $gracePeriod ? false : true; if ($allowArchive && $this->model->version->accepted && $this->model->version->accepted != '0000-00-00 00:00:00') { $monthFrom = Date::of($this->model->version->accepted . '+1 month')->toSql(); if (strtotime($monthFrom) < Date::toUnix()) { $allowArchive = true; } } // Run mkAIP if no grace period set or passed if (!$this->getError() && $this->model->version->doi && $allowArchive == true && (!$this->model->version->archived || $this->model->version->archived == '0000-00-00 00:00:00') && Helpers\Utilities::mkAip($this->model->version)) { $this->model->version->archived = Date::toSql(); } } if (!$this->getError()) { $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' '; $output .= $action == 'publish' ? Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REPUBLISHED'); } break; case 'revert': // What is this? This sets it to the state it's alreayd in. //$this->model->version->state = $state ? $state : 4; $this->model->version->state = 3; $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_REVERTED'); $subject .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REVERTED'); $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' '; $output .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REVERTED'); break; case 'unpublish': $this->model->version->state = 0; $this->model->version->published_down = Date::toSql(); $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_UNPUBLISHED'); $subject .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_UNPUBLISHED'); $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' '; $output .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_UNPUBLISHED'); break; case 'wip': $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_REQUESTED_CHANGES'); $subject .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REQUESTED_CHANGES'); $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' '; $output .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REQUESTED_CHANGES'); break; } } // Updating entry if anything changed if (!$this->getError()) { $this->model->version->modified = Date::toSql(); $this->model->version->modified_by = User::get('id'); // Store content if (!$this->model->version->store()) { App::redirect($url, $this->model->version->getError(), 'error'); return; } elseif ($action) { // Add activity $activity .= ' ' . strtolower(Lang::txt('version')) . ' ' . $this->model->version->version_label . ' ' . Lang::txt('COM_PUBLICATIONS_OF') . ' ' . strtolower(Lang::txt('publication')) . ' "' . $pubtitle . '" '; // Build return url $link = '/projects/' . $project->get('alias') . '/publications/' . $id . '/?version=' . $this->model->version->version_number; if ($action != 'message' && !$this->getError()) { $aid = $project->recordActivity($activity, $id, $pubtitle, $link, 'publication', 0, $admin = 1); $sendmail = $this->config->get('email') ? 1 : 0; // Append comment to activity if ($message && $aid) { require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'comment.php'; $objC = new \Components\Projects\Tables\Comment($this->database); $comment = \Hubzero\Utility\String::truncate($message, 250); $comment = \Hubzero\Utility\Sanitize::stripAll($comment); $objC->itemid = $aid; $objC->tbl = 'activity'; $objC->parent_activity = $aid; $objC->comment = $comment; $objC->admin = 1; $objC->created = Date::toSql(); $objC->created_by = User::get('id'); $objC->store(); // Get new entry ID if (!$objC->id) { $objC->checkin(); } if ($objC->id) { $what = Lang::txt('COM_PROJECTS_AN_ACTIVITY'); $curl = Route::url($project->link('feed')) . '#tr_' . $aid; // same-page link $caid = $project->recordActivity(Lang::txt('COM_PROJECTS_COMMENTED') . ' ' . Lang::txt('COM_PROJECTS_ON') . ' ' . $what, $objC->id, $what, $curl, 'quote', 0, 1); // Store activity ID if ($caid) { $objC->activityid = $aid; $objC->store(); } } } } } } // Save parameters $params = Request::getVar('params', '', 'post'); if (is_array($params)) { foreach ($params as $k => $v) { $this->model->version->saveParam($this->model->version->id, $k, $v); } } // Do we have a message to send? if ($message) { $subject .= ' - ' . Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_NEW_MESSAGE'); $sendmail = 1; $output .= ' ' . Lang::txt('COM_PUBLICATIONS_MESSAGE_SENT'); } // Send email if ($sendmail && !$this->getError()) { // Get ids of publication authors with accounts $notify = $this->model->table('Author')->getAuthors($this->model->version->id, 1, 1, 1, true); $notify[] = $this->model->version->created_by; $notify = array_unique($notify); $this->_emailContributors($subject, $message, $notify, $action); } // Append any errors if ($this->getError()) { $output .= ' ' . $this->getError(); } // Redirect to edit view? if ($redirect) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=edit' . '&id[]=' . $id . '&version=' . $this->model->get('version_number'), false), $output); } else { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $output); } return; }
$status = $this->pub->getStatusName(); $class = $this->pub->getStatusCss(); // Is draft ready? $complete = $this->pub->curation('complete'); $showCitations = $this->pub->_category->_params->get('show_citations', 1); $allowUnpublish = $this->pub->_category->_params->get('option_unpublish', 0); // We also need a citations block $blockActive = $this->pub->curation()->blockExists('citations'); $showCitations = $blockActive ? $showCitations : 0; // Check if publication is within grace period (published status) $allowArchive = \Components\Publications\Helpers\Utilities::archiveOn(); $archiveDate = $this->pub->futureArchivalDate(); $revertAllowed = $this->pub->config('graceperiod'); if ($revertAllowed && $this->pub->accepted()) { $monthFrom = Date::of($this->pub->accepted() . '+1 month')->toSql(); if (strtotime($monthFrom) < Date::toUnix()) { $revertAllowed = 0; } } ?> <form action="<?php echo Route::url($this->pub->link('edit')); ?> " method="post" id="plg-form" enctype="multipart/form-data"> <?php echo \Components\Publications\Helpers\Html::showPubTitle($this->pub, $this->title); ?> <fieldset> <input type="hidden" name="id" value="<?php
function MG_getUserDateTimeFormat($date = 'now') { global $_TABLES, $_CONF, $_USER, $_MG_CONF, $_SYSTEM; if ($date == '99') { return ''; } // Get display format for time $dfid = $_MG_CONF['dfid']; if ($dfid == '0') { $dateformat = $_CONF['date']; } else { $dateformat = $_MG_CONF['dateformat'][$dfid]; } $dtObject = new Date($date, $_USER['tzid']); if (empty($date) || $date == 'now') { // Date is empty, get current date/time $stamp = time(); } else { if (is_numeric($date)) { // This is a timestamp $stamp = $date; } else { // This is a string representation of a date/time $stamp = $dtObject->toUnix(); } } $date = $dtObject->format($dateformat, true); return array($date, $stamp); }
/** * Takes a user's session identifier and session expiry * timestamp and checks to see if they represent a currently * active session. Note: This method does not verify that * $session_id is a valid session identifier, but rather * expects these values to have come from a database source * and hence be validated prior to this method being called. * If the $session_id value is empty however, it will return * false. Compares $expires against the current time to * determine if the session has expired or not. * * @access public * @param string $session_id * @param integer $expires * @return boolean * */ function isActive($session_id, $expires) { if (empty($session_id)) { return false; } global $loader; $loader->import('saf.Date'); if (Date::compare($expires, Date::toUnix()) >= 0) { return false; } return true; }
$form = new SitewikiEditForm(); if ($form->editable && !isset($cgi->editing)) { if (!session_valid()) { global $session; $session->username = ''; } if (lock_exists('sitewiki_page', $cgi->page)) { if ($cgi->break_lock == 1) { lock_remove('sitewiki_page', $cgi->page); if (!session_valid()) { $session->username = '******'; } lock_add('sitewiki_page', $cgi->page); } else { $info = lock_info('sitewiki_page', $cgi->page); loader_import('saf.Date'); $now = time(); $then = Date::toUnix($info->expires) - 3600; $diff = $now - $then; $info->min = round($diff / 60); echo template_simple('locked.spt', $info); return; } } else { if (!session_valid()) { $session->username = '******'; } lock_add('sitewiki_page', $cgi->page); } } echo $form->run();
/** * Subtracts from the specified date and returns the finished * calculation. $date is in the format Y-m-d, and $amount can be either * '# year', '# month', '# week', or '# day', where # is any number. * * @access public * @param string $date * @param string $amount * @return string * */ function subtract($date, $amount) { //$stamp = Date::format ($date, 'U'); if (strpos($date, ' ') === false) { $date .= ' 05:05:05'; } $stamp = Date::toUnix($date); $amounts = array('year' => 31536000, 'month' => 0, 'week' => 604800, 'day' => 86400); if (preg_match('/^([0-9]+) ?(' . join('|', array_keys($amounts)) . ')s?$/', $amount, $regs)) { if ($regs[2] == 'month') { $hour = date('H', $stamp); $minute = date('i', $stamp); $second = date('s', $stamp); $year = date('Y', $stamp); $month = date('m', $stamp); $day = date('d', $stamp); $month -= $regs[1]; //$month--; $stamp = mktime($hour, $minute, $second, $month, $day, $year); return date('Y-m-d', $stamp); } elseif ($regs[2] == 'year') { $hour = date('H', $stamp); $minute = date('i', $stamp); $second = date('s', $stamp); $year = date('Y', $stamp); $month = date('m', $stamp); $day = date('d', $stamp); $year -= $regs[1]; //$year--; $stamp = mktime($hour, $minute, $second, $month, $day, $year); return date('Y-m-d', $stamp); } else { return date('Y-m-d', $stamp - $regs[1] * $amounts[$regs[2]]); } } else { return false; } }
function FF_saveTopic($forumData, $postData, $action) { global $_CONF, $_TABLES, $_FF_CONF, $_USER, $LANG03, $LANG_GF01, $LANG_GF02; $retval = ''; $uploadErrors = ''; $msg = ''; $errorMessages = ''; $email = ''; $forumfiles = array(); $okToSave = true; $dt = new Date('now', $_USER['tzid']); $date = $dt->toUnix(); $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; if (COM_isAnonUser()) { $uid = 1; } else { $uid = $_USER['uid']; } // verify postmode is allowed if (strtolower($postData['postmode']) == 'html') { if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) { $postData['postmode'] = 'html'; } else { $postData['postmode'] = 'text'; } } // is forum readonly? if ($forumData['is_readonly'] == 1) { // Check if this user has moderation rights now to allow a post to a locked topic if (!forum_modPermission($forumData['forum'], $uid, 'mod_edit')) { _ff_accessError(); } } if ($action == 'saveedit') { // does the forum match the forum id of the posted data? if ($forumData['forum'] != 0 && $forumData['forum'] != $postData['forum']) { _ff_accessError(); } $editid = COM_applyFilter($postData['editid'], true); $forum = COM_applyFilter($postData['forum'], true); $editAllowed = false; if (forum_modPermission($forumData['forum'], $_USER['uid'], 'mod_edit')) { $editAllowed = true; } else { if ($_FF_CONF['allowed_editwindow'] > 0) { $t1 = DB_getItem($_TABLES['ff_topic'], 'date', "id=" . (int) $postData['id']); $t2 = $_FF_CONF['allowed_editwindow']; $time = time(); if (time() - $t2 < $t1) { $editAllowed = true; } } else { $editAllowed = true; } } if ($postData['editpid'] < 1 && trim($postData['subject']) == '') { $retval .= FF_BlockMessage('', $LANG_GF02['msg18'], false); $okToSave = false; } elseif (!$editAllowed) { $link = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . (int) $postData['$id']; $retval .= _ff_alertMessage('', $LANG_GF02['msg189'], sprintf($LANG_GF02['msg187'], $link)); $okToSave = false; } } else { if (!COM_isAnonUser() && $_FF_CONF['use_sfs']) { $email = isset($_USER['email']) ? $_USER['email'] : ''; } } if (isset($postData['name']) && $postData['name'] != '') { $name = _ff_preparefordb(@htmlspecialchars(strip_tags(trim(COM_checkWords(USER_sanitizeName($postData['name'])))), ENT_QUOTES, COM_getEncodingt()), 'text'); $name = urldecode($name); } else { $okToSave = false; $errorMessages .= $LANG_GF02['invalid_name'] . '<br />'; } // speed limit check if (!SEC_hasRights('forum.edit')) { COM_clearSpeedlimit($_FF_CONF['post_speedlimit'], 'forum'); $last = COM_checkSpeedlimit('forum'); if ($last > 0) { $errorMessages .= sprintf($LANG_GF01['SPEEDLIMIT'], $last, $_FF_CONF['post_speedlimit']) . '<br/>'; $okToSave = false; } } // standard edit checks if (strlen(trim($postData['name'])) < $_FF_CONF['min_username_length'] || strlen(trim($postData['subject'])) < $_FF_CONF['min_subject_length'] || strlen(trim($postData['comment'])) < $_FF_CONF['min_comment_length']) { $errorMessages .= $LANG_GF02['msg18'] . '<br/>'; $okToSave = false; } // CAPTCHA check if (function_exists('plugin_itemPreSave_captcha') && $okToSave == true) { if (!isset($postData['captcha'])) { $postData['captcha'] = ''; } $msg = plugin_itemPreSave_captcha('forum', $postData['captcha']); if ($msg != '') { $errorMessages .= $msg . '<br/>'; $okToSave = false; } } // spamx check if ($_FF_CONF['use_spamx_filter'] == 1 && $okToSave == true) { // Check for SPAM $spamcheck = '<h1>' . $postData['subject'] . '</h1><p>' . $postData['comment'] . '</p>'; $result = PLG_checkforSpam($spamcheck, $_CONF['spamx']); // Now check the result and redirect to index.php if spam action was taken if ($result > 0) { // then tell them to get lost ... $errorMessages .= $LANG_GF02['spam_detected']; $okToSave = false; } } if ($_FF_CONF['use_sfs'] == 1 && COM_isAnonUser() && function_exists('plugin_itemPreSave_spamx')) { $spamCheckData = array('username' => $postData['name'], 'email' => $email, 'ip' => $REMOTE_ADDR); $msg = plugin_itemPreSave_spamx('forum', $spamCheckData); if ($msg) { $errorMessages .= $msg; $okToSave = false; } } if ($okToSave == false) { $retval .= _ff_alertMessage($errorMessages, $LANG_GF01['ERROR'], ' '); return array(false, $retval); } if ($okToSave == true) { if (!isset($postData['postmode_switch'])) { $postData['postmode_switch'] = 0; } $postmode = _ff_chkpostmode($postData['postmode'], $postData['postmode_switch']); // validate postmode if ($postmode == 'html' || $postmode == 'HTML') { if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) { $postmode = 'html'; } else { $postmode = 'text'; } } $subject = _ff_preparefordb(strip_tags($postData['subject']), 'text'); $comment = _ff_preparefordb($postData['comment'], $postmode); $mood = isset($postData['mood']) ? COM_applyFilter($postData['mood']) : ''; $id = COM_applyFilter($postData['id'], true); $forum = COM_applyFilter($postData['forum'], true); $notify = isset($postData['notify']) ? COM_applyFilter($postData['notify']) : ''; $status = 0; if (isset($postData['disable_bbcode']) && $postData['disable_bbcode'] == 1) { $status += DISABLE_BBCODE; } if (isset($postData['disable_smilies']) && $postData['disable_smilies'] == 1) { $status += DISABLE_SMILIES; } if (isset($postData['disable_urlparse']) && $postData['disable_urlparse'] == 1) { $status += DISABLE_URLPARSE; } // If user has moderator edit rights only $locked = 0; $sticky = 0; if (isset($postData['modedit']) && $postData['modedit'] == 1) { if (isset($postData['locked_switch']) && $postData['locked_switch'] == 1) { $locked = 1; } if (isset($postData['sticky_switch']) && $postData['sticky_switch'] == 1) { $sticky = 1; } } if ($action == 'savetopic') { $fields = "forum,name,email,date,lastupdated,subject,comment,postmode,ip,mood,uid,pid,sticky,locked,status"; $sql = "INSERT INTO {$_TABLES['ff_topic']} ({$fields}) "; $sql .= "VALUES (" . (int) $forum . "," . "'" . DB_escapeString($name) . "'," . "'" . DB_escapeString($email) . "'," . "'" . DB_escapeString($date) . "'," . "'" . DB_escapeString($date) . "'," . "'" . $subject . "'," . "'" . $comment . "'," . "'" . DB_escapeString($postmode) . "'," . "'" . DB_escapeString($REMOTE_ADDR) . "'," . "'" . DB_escapeString($mood) . "'," . (int) $uid . "," . "0," . (int) $sticky . "," . (int) $locked . "," . (int) $status . ")"; DB_query($sql); // Find the id of the last inserted topic list($lastid) = DB_fetchArray(DB_query("SELECT max(id) FROM {$_TABLES['ff_topic']} ")); $savedPostID = $lastid; $topicPID = $lastid; /* Check for any uploaded files - during add of new topic */ $uploadErrors = _ff_check4files($lastid); // Check and see if there are no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it $imagerecs = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $lastid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); // Update forums record DB_query("UPDATE {$_TABLES['ff_forums']} SET post_count=post_count+1, topic_count=topic_count+1, last_post_rec=" . (int) $lastid . " WHERE forum_id=" . (int) $forum); if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $lastid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $lastid); } DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } else { if ($action == 'savereply') { $fields = "name,email,date,subject,comment,postmode,ip,mood,uid,pid,forum,status"; $sql = "INSERT INTO {$_TABLES['ff_topic']} ({$fields}) "; $sql .= "VALUES (" . "'" . DB_escapeString($name) . "'," . "'" . DB_escapeString($email) . "'," . "'" . DB_escapeString($date) . "'," . "'{$subject}'," . "'{$comment}'," . "'" . DB_escapeString($postmode) . "'," . "'" . DB_escapeString($REMOTE_ADDR) . "'," . "'" . DB_escapeString($mood) . "'," . (int) $uid . "," . (int) $id . "," . (int) $forum . "," . (int) $status . ")"; DB_query($sql); // Find the id of the last inserted topic list($lastid) = DB_fetchArray(DB_query("SELECT max(id) FROM {$_TABLES['ff_topic']} ")); $savedPostID = $lastid; $topicPID = $id; /* Check for any uploaded files - during adding reply post */ $uploadErrors = _ff_check4files($lastid); // Check and see if there are no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it $imagerecs = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $lastid; if ($imagerecs != '') { $sql .= " AND id NOT IN ({$imagerecs})"; } DB_query($sql); DB_query("UPDATE {$_TABLES['ff_topic']} SET replies=replies+1, lastupdated='" . DB_escapeString($date) . "',last_reply_rec=" . (int) $lastid . " WHERE id=" . (int) $id); DB_query("UPDATE {$_TABLES['ff_forums']} SET post_count=post_count+1, last_post_rec=" . (int) $lastid . " WHERE forum_id=" . (int) $forum); if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $lastid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $id); } DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } elseif ($action == 'saveedit') { $sql = "UPDATE {$_TABLES['ff_topic']} SET " . "subject='{$subject}'," . "comment='{$comment}'," . "postmode='" . DB_escapeString($postmode) . "'," . "mood='" . DB_escapeString($mood) . "'," . "sticky=" . (int) $sticky . "," . "locked=" . (int) $locked . "," . "status=" . (int) $status . " " . "WHERE (id=" . (int) $editid . ")"; DB_query($sql); /* Check for any uploaded files - during save of edit */ $uploadErrors = _ff_check4files($editid); // Check and see if there are no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it $imagerecs = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $editid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); $topicPID = DB_getITEM($_TABLES['ff_topic'], "pid", "id=" . (int) $editid); if ($topicPID == 0) { $topicPID = $editid; } $savedPostID = $editid; if ($postData['silentedit'] != 1) { DB_query("UPDATE {$_TABLES['ff_topic']} SET lastupdated='" . DB_escapeString($date) . "' WHERE id=" . (int) $topicPID); //Remove any lastviewed records in the log so that the new updated topic indicator will appear DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $editid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $topicPID); } $topicparent = $topicPID; } } COM_updateSpeedLimit('forum'); PLG_itemSaved($savedPostID, 'forum'); CACHE_remove_instance('forumcb'); if (!COM_isAnonUser()) { //NOTIFY - Checkbox variable in form set to "on" when checked and they don't already have subscribed to forum or topic $nid = -$topicPID; $currentForumNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id=0 AND uid=" . (int) $uid); $currentTopicNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id='" . DB_escapeString($topicPID) . "' AND uid=" . (int) $uid); $currentTopicUnNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id='" . DB_escapeString($nid) . "' AND uid=" . (int) $uid); $forum_name = DB_getItem($_TABLES['ff_forums'], 'forum_name', 'forum_id=' . (int) $forum); $topic_name = $subject; if ($notify == 'on' and ($currentForumNotifyRecID < 1 and $currentTopicNotifyRecID < 1)) { $sql = "INSERT INTO {$_TABLES['subscriptions']} (type,category,category_desc,id,id_desc,uid,date_added) "; $sql .= "VALUES ('forum','" . DB_escapeString($forum) . "','" . DB_escapeString($forum_name) . "','" . DB_escapeString($topicPID) . "','" . $subject . "'," . (int) $uid . ",now() )"; DB_query($sql); } elseif ($notify == 'on' and $currentTopicUnNotifyRecID > 1) { // Had un-subcribed to topic and now wants to subscribe DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE sub_id=" . (int) $currentTopicUnNotifyRecID); } elseif ($notify == '' and $currentTopicNotifyRecID > 1) { // Subscribed to topic - but does not want to be notified anymore DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($topicPID) . "'"); } elseif ($notify == '' and $currentForumNotifyRecID > 1) { // Subscribed to forum - but does not want to be notified about this topic DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($topicPID) . "'"); DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($nid) . "'"); DB_query("INSERT INTO {$_TABLES['subscriptions']} (type,category,category_desc,id,id_desc,uid,date_added) VALUES ('forum','" . DB_escapeString($forum) . "','" . DB_escapeString($forum_name) . "','" . DB_escapeString($nid) . "','" . $subject . "'," . (int) $uid . ",now() )"); } } if ($action != 'saveedit') { _ff_chknotifications($forum, $savedPostID, $uid); } $link = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $topicPID . '&topic=' . $savedPostID . '#' . $savedPostID; if ($uploadErrors != '') { $autorefresh = false; } else { $autorefresh = true; } $retval .= FF_statusMessage($uploadErrors . $LANG_GF02['msg19'], $link, $LANG_GF02['msg19'], false, '', $autorefresh); } else { $retval .= _ff_alertMessage($LANG_GF02['msg18']); } return array(true, $retval); }
/** * Loads the basic details of an article into the internal * variables, cleaning them up nicely. * @access Private * @param $array Array of POST/GET data (by ref). * @return Nothing. */ function _loadBasics(&$array) { global $_CONF, $_USER; /* For the really, really basic stuff, we can very easily load them * based on an array that defines how to COM_applyFilter them. */ foreach ($this->_postFields as $key => $value) { $vartype = $value[0]; $varname = $value[1]; // If we have a value if (array_key_exists($key, $array)) { // And it's alphanumeric or numeric, filter it and use it. if ($vartype == STORY_AL_ALPHANUM || $vartype == STORY_AL_NUMERIC) { $this->{$varname} = COM_applyFilter($array[$key], $vartype); } elseif ($array[$key] === 'on' || $array[$key] === 1) { // If it's a checkbox that is on $this->{$varname} = 1; } else { // Otherwise, it must be a checkbox that is off: $this->{$varname} = 0; } } elseif ($vartype == STORY_AL_NUMERIC || $vartype == STORY_AL_CHECKBOX) { // If we don't have a value, and have a numeric or text box, default to 0 $this->{$varname} = 0; } } // SID's are a special case: $sid = COM_sanitizeID($array['sid']); if (isset($array['old_sid'])) { $oldsid = COM_sanitizeID($array['old_sid'], false); } else { $oldsid = ''; } if (empty($sid)) { $sid = $oldsid; } if (empty($sid)) { $sid = COM_makeSid(); } $this->_sid = $sid; $this->_originalSid = $oldsid; /* Need to deal with the postdate and expiry date stuff */ $publish_ampm = ''; if (isset($array['publish_ampm'])) { $publish_ampm = COM_applyFilter($array['publish_ampm']); } $publish_hour = 0; if (isset($array['publish_hour'])) { $publish_hour = COM_applyFilter($array['publish_hour'], true); } $publish_minute = 0; if (isset($array['publish_minute'])) { $publish_minute = COM_applyFilter($array['publish_minute'], true); } $publish_second = 0; if (isset($array['publish_second'])) { $publish_second = COM_applyFilter($array['publish_second'], true); } if ($publish_ampm == 'pm') { if ($publish_hour < 12) { $publish_hour = $publish_hour + 12; } } if ($publish_ampm == 'am' and $publish_hour == 12) { $publish_hour = '00'; } $publish_year = 0; if (isset($array['publish_year'])) { $publish_year = COM_applyFilter($array['publish_year'], true); } $publish_month = 0; if (isset($array['publish_month'])) { $publish_month = COM_applyFilter($array['publish_month'], true); } $publish_day = 0; if (isset($array['publish_day'])) { $publish_day = COM_applyFilter($array['publish_day'], true); } $dtPublish = new Date('now', $_USER['tzid']); $dtPublish->setDateTimestamp($publish_year, $publish_month, $publish_day, $publish_hour, $publish_minute, $publish_second); $this->_date = $dtPublish->toUnix(); $archiveflag = 0; if (isset($array['archiveflag'])) { $archiveflag = COM_applyFilter($array['archiveflag'], true); } /* Override status code if no archive flag is set: */ if ($archiveflag != 1) { $this->_statuscode = 0; } $dtExpire = new Date('now', $_USER['tzid']); if (array_key_exists('expire_ampm', $array)) { $expire_ampm = COM_applyFilter($array['expire_ampm']); $expire_hour = COM_applyFilter($array['expire_hour'], true); $expire_minute = COM_applyFilter($array['expire_minute'], true); $expire_second = COM_applyFilter($array['expire_second'], true); $expire_year = COM_applyFilter($array['expire_year'], true); $expire_month = COM_applyFilter($array['expire_month'], true); $expire_day = COM_applyFilter($array['expire_day'], true); if ($expire_ampm == 'pm') { if ($expire_hour < 12) { $expire_hour = $expire_hour + 12; } } if ($expire_ampm == 'am' and $expire_hour == 12) { $expire_hour = '00'; } $dtExpire->setDateTimestamp($expire_year, $expire_month, $expire_day, $expire_hour, $expire_minute, $expire_second); $expiredate = $dtExpire->toUnix(); } else { $expiredate = $dtExpire->toUnix(); } $this->_expire = $expiredate; $dtCmtClose = new Date('now', $_USER['tzid']); //comment expire time if (isset($array['cmt_close_flag'])) { $cmt_close_ampm = COM_applyFilter($array['cmt_close_ampm']); $cmt_close_hour = COM_applyFilter($array['cmt_close_hour'], true); $cmt_close_minute = COM_applyFilter($array['cmt_close_minute'], true); $cmt_close_second = COM_applyFilter($array['cmt_close_second'], true); $cmt_close_year = COM_applyFilter($array['cmt_close_year'], true); $cmt_close_month = COM_applyFilter($array['cmt_close_month'], true); $cmt_close_day = COM_applyFilter($array['cmt_close_day'], true); if ($cmt_close_ampm == 'pm') { if ($cmt_close_hour < 12) { $cmt_close_hour = $cmt_close_hour + 12; } } if ($cmt_close_ampm == 'am' and $cmt_close_hour == 12) { $cmt_close_hour = '00'; } $dtCmtClose->setDateTimestamp($cmt_close_year, $cmt_close_month, $cmt_close_day, $cmt_close_hour, $cmt_close_minute, $cmt_close_second); $cmt_close_date = $dtCmtClose->toUnix(); $this->_comment_expire = $cmt_close_date; } else { $this->_comment_expire = 0; } /* Then grab the permissions */ if (!isset($array['perm_anon'])) { $array['perm_anon'] = array(); } if (!isset($array['perm_members'])) { $array['perm_members'] = array(); } if (!isset($array['perm_group'])) { $array['perm_group'] = array(); } if (!isset($array['perm_owner'])) { $array['perm_owner'] = array(); } // Convert array values to numeric permission values if (is_array($array['perm_owner']) || is_array($array['perm_group']) || is_array($array['perm_members']) || is_array($array['perm_anon'])) { list($this->_perm_owner, $this->_perm_group, $this->_perm_members, $this->_perm_anon) = SEC_getPermissionValues($array['perm_owner'], $array['perm_group'], $array['perm_members'], $array['perm_anon']); } else { $this->_perm_owner = $array['perm_owner']; $this->_perm_group = $array['perm_group']; $this->_perm_members = $array['perm_members']; $this->_perm_anon = $array['perm_anon']; } }
/** * Returns formatted date/time for user * * This function COM_takes a date in either unixtimestamp or in english and * formats it to the users preference. If the user didn't specify a format * the format in the config file is used. This returns an array where array[0] * is the formatted date and array[1] is the unixtimestamp * * @param string $date date to format, otherwise we format current date/time * @return array array[0] is the formatted date and array[1] is the unixtimestamp. */ function COM_getUserDateTimeFormat($date = 'now') { global $_TABLES, $_USER, $_CONF, $_SYSTEM; $dtObject = new Date($date, $_USER['tzid']); // Get display format for time if (!COM_isAnonUser()) { if (empty($_USER['format'])) { $dateformat = $_CONF['date']; } else { $dateformat = $_USER['format']; } } else { $dateformat = $_CONF['date']; } if (empty($date) || $date == 'now') { // Date is empty, get current date/time $stamp = time(); } else { if (is_numeric($date)) { // This is a timestamp $stamp = $date; } else { // This is a string representation of a date/time $stamp = $dtObject->toUnix(); } } $date = $dtObject->format($dateformat, true); return array($date, $stamp); }
/** * Send a message to one or more users * * @param string $type Message type (maps to #__xmessage_component table) * @param string $subject Message subject * @param string $message Message to send * @param array $from Message 'from' data (e.g., name, address) * @param array $to List of user IDs * @param string $component Component name * @param integer $element ID of object that needs an action item * @param string $description Action item description * @param integer $group_id Parameter description (if any) ... * @return mixed True if no errors else error message */ public function onSendMessage($type, $subject, $message, $from = array(), $to = array(), $component = '', $element = null, $description = '', $group_id = 0, $bypassGroupsCheck = false) { // Do we have a message? if (!$message) { return false; } $database = App::get('db'); // Create the message object $xmessage = Hubzero\Message\Message::blank(); if ($type == 'member_message') { $time_limit = intval($this->params->get('time_limit', 30)); $daily_limit = intval($this->params->get('daily_limit', 100)); // First, let's see if they've surpassed their daily limit for sending messages $filters = array('created_by' => User::get('id'), 'daily_limit' => $daily_limit); $number_sent = $xmessage->getSentMessagesCount($filters); if ($number_sent >= $daily_limit) { return false; } // Next, we see if they've passed the time limit for sending consecutive messages $filters['limit'] = 1; $filters['start'] = 0; $sent = $xmessage->getSentMessages($filters); if ($sent->count() > 0) { $last_sent = $sent->first(); $last_time = 0; if ($last_sent->created) { $last_time = Date::of($last_sent->created)->toUnix(); } $time_difference = Date::toUnix() + $time_limit - $last_time; if ($time_difference < $time_limit) { return false; } } } // Store the message in the database $xmessage->set('message', is_array($message) && isset($message['plaintext']) ? $message['plaintext'] : $message); // Do we have a subject line? If not, create it from the message if (!$subject && $xmessage->get('message')) { $subject = substr($xmessage->get('message'), 0, 70); if (strlen($subject) >= 70) { $subject .= '...'; } } $xmessage->set('subject', $subject); $xmessage->set('created', Date::toSql()); $xmessage->set('created_by', User::get('id')); $xmessage->set('component', $component); $xmessage->set('type', $type); $xmessage->set('group_id', $group_id); if (!$xmessage->save()) { return $xmessage->getError(); } if (is_array($message)) { $xmessage->set('message', $message); } // Do we have any recipients? if (count($to) > 0) { $mconfig = Component::params('com_members'); // Get all the sender's groups if ($mconfig->get('user_messaging', 1) == 1 && !$bypassGroupsCheck) { $xgroups = User::groups('all'); $usersgroups = array(); if (!empty($xgroups)) { foreach ($xgroups as $group) { if ($group->regconfirmed) { $usersgroups[] = $group->cn; } } } } // Loop through each recipient foreach ($to as $uid) { // Create a recipient object that ties a user to a message $recipient = Hubzero\Message\Recipient::blank(); $recipient->set('uid', $uid); $recipient->set('mid', $xmessage->get('id')); $recipient->set('created', Date::toSql()); $recipient->set('expires', Date::of(time() + 168 * 24 * 60 * 60)->toSql()); $recipient->set('actionid', 0); //(is_object($action)) ? $action->id : 0; [zooley] Phasing out action items // Get the user's methods for being notified $notify = Hubzero\Message\Notify::blank(); $methods = $notify->getRecords($uid, $type); $user = User::getInstance($uid); if (!is_object($user) || !$user->get('username')) { continue; } if ($mconfig->get('user_messaging', 1) == 1 && ($type == 'member_message' || $type == 'group_message')) { $pgroups = \Hubzero\User\Helper::getGroups($user->get('id'), 'all', 1); $profilesgroups = array(); if (!empty($pgroups)) { foreach ($pgroups as $group) { if ($group->regconfirmed) { $profilesgroups[] = $group->cn; } } } // Find the common groups if (!$bypassGroupsCheck) { $common = array_intersect($usersgroups, $profilesgroups); if (count($common) <= 0) { continue; } } } // Do we have any methods? if ($methods->count()) { // Loop through each method foreach ($methods as $method) { $action = strtolower($method->method); if ($action == 'internal') { if (!$recipient->save()) { $this->setError($recipient->getError()); } } else { if (!Event::trigger('onMessage', array($from, $xmessage, $user, $action))) { $this->setError(Lang::txt('PLG_XMESSAGE_HANDLER_ERROR_UNABLE_TO_MESSAGE', $uid, $action)); } } } } else { // First check if they have ANY methods saved (meaning they've changed their default settings) // If They do have some methods, then they simply turned off everything for this $type $methods = $notify->getRecords($uid); if (!$methods || $methods->count() <= 0) { // Load the default method $p = Plugin::byType('members', 'messages'); $pp = new \Hubzero\Config\Registry(is_object($p) ? $p->params : ''); $d = $pp->get('default_method', 'email'); if (!$recipient->save()) { $this->setError($recipient->getError()); } // Use the Default in the case the user has no methods if (!Event::trigger('onMessage', array($from, $xmessage, $user, $d))) { $this->setError(Lang::txt('PLG_XMESSAGE_HANDLER_ERROR_UNABLE_TO_MESSAGE', $uid, $d)); } } } } } return true; }
<?php if ($this->getError()) { ?> <p class="error"><?php echo $this->getError(); ?> </p> <?php } ?> <div id="themanager" class="manager"> <div class="input-wrap"> <label> <?php echo Lang::txt('COM_GROUPS_MEDIA_DIRECTORY'); ?> <?php echo $this->dirPath; ?> </label> </div> <iframe src="<?php echo Route::url('index.php?option=' . $this->option . '&tmpl=component&controller=' . $this->controller . '&gidNumber=' . $this->group->get('gidNumber') . '&task=list' . ($this->dir ? '&dir=' . $this->dir : '') . '&t=' . Date::toUnix()); ?> " name="filer" id="filer" width="98%" height="400"></iframe> </div> </form> </div>
/** * Sort remote revisions * * @param integer $id Remote resource ID * @param integer $converted Converted for remote editing? * @param string $lastModifiedBy Last modified by (name) * @param integer $uid User ID * @param string $service Service name (google or dropbox) * @param string $file File path * @param array &$versions Versions collector array * @param array &$timestamps Collector array * @param integer $original Source file? * * @return array */ public function sortRemoteRevisions($id, $converted = 0, $lastModifiedBy = '', $uid, $service, $file, &$versions = array(), &$timestamps = array(), $original = 0) { // Get remote revisions $revisions = $this->getFileHistory($id, $uid, $service); // Go through remote revisions if (!empty($revisions)) { $timestampsG = array(); foreach ($revisions as $rev) { $timestampsG[] = strtotime($rev['modifiedDate']); } array_multisort($timestampsG, SORT_DESC, $revisions); $r = 1; foreach ($revisions as $rev) { $order = $r == count($revisions) ? 'first' : ''; $order = $r == 1 ? 'last' : $order; // If remote, make sure current version is remote if ($converted == 1 && $order == 'last') { $timestamps[] = Date::toUnix(); } else { $timestamps[] = strtotime($rev['modifiedDate']); } $author = isset($rev['lastModifyingUser']['displayName']) ? strtolower($rev['lastModifyingUser']['displayName']) : NULL; $author = !$author && isset($rev['lastModifyingUserName']) ? strtolower($rev['lastModifyingUserName']) : NULL; if (!$author && $order == 'last') { $author = utf8_decode($lastModifiedBy); } $revision = array('date' => $rev['modifiedDate'], 'author' => $author, 'email' => NULL, 'hash' => $rev['id'], 'file' => $file, 'base' => '', 'remote' => $id, 'local' => false, 'content' => NULL, 'preview' => NULL, 'original' => $original, 'hide' => 0, 'message' => '', 'rename' => '', 'change' => '', 'movedTo' => '', 'size' => '', 'name' => Lang::txt('PLG_PROJECTS_FILES_REMOTE_FILE_' . strtoupper($service)), 'order' => $order, 'count' => count($revisions), 'commitStatus' => $r == count($revisions) ? 'A' : 'M'); $versions[] = $revision; $r++; } } }
?> </div> </div><!-- / .grid --> </div> <div id="page-files" class="tab"> <fieldset class="adminform"> <?php if ($this->group->gidNumber) { ?> <legend><span><?php echo Lang::txt('COM_GROUPS_MEDIA_PATH', substr(PATH_APP, strlen(PATH_ROOT)) . DS . trim(Component::params('com_groups')->get('uploadpath', '/site/groups'), DS) . DS . $this->group->get('gidNumber')); ?> </span></legend> <iframe width="100%" height="500" name="media" id="media" frameborder="0" src="<?php echo Route::url('index.php?option=' . $this->option . '&controller=media&tmpl=component&gidNumber=' . $this->group->gidNumber . '&t=' . Date::toUnix()); ?> "></iframe> <?php } else { ?> <p class="warning"><?php echo Lang::txt('COM_GROUPS_MEDIA_FILES_WARNING'); ?> </p> <?php } ?> </fieldset> </div> </div>