Example #1
0
// | as published by the Free Software Foundation; either version 2           |
// | of the License, or (at your option) any later version.                   |
// |                                                                          |
// | This program is distributed in the hope that it will be useful,          |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with this program; if not, write to the Free Software Foundation,  |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.          |
// |                                                                          |
// +--------------------------------------------------------------------------+
require_once '../lib-common.php';
if (!in_array('forum', $_PLUGINS)) {
    COM_404();
    exit;
}
USES_forum_functions();
USES_forum_format();
require_once $_CONF['path_system'] . 'classes/timer.class.php';
$forum = isset($_REQUEST['forum']) ? COM_applyFilter($_REQUEST['forum'], true) : 0;
$show = isset($_REQUEST['show']) ? COM_applyFilter($_REQUEST['show'], true) : 0;
$page = isset($_REQUEST['page']) ? COM_applyFilter($_REQUEST['page'], true) : 0;
$order = isset($_REQUEST['order']) ? COM_applyFilter($_REQUEST['order'], true) : 0;
$sort = isset($_REQUEST['sort']) ? COM_applyFilter($_REQUEST['sort'], true) : 0;
$cat_id = isset($_REQUEST['cat_id']) ? COM_applyFilter($_REQUEST['cat_id'], true) : 0;
$forum_id = isset($_REQUEST['forum_id']) ? COM_applyFilter($_REQUEST['forum_id'], true) : 0;
$op = isset($_REQUEST['op']) ? COM_applyFilter($_REQUEST['op']) : '';
//Check is anonymous users can access
if ($_FF_CONF['registration_required'] && COM_isAnonUser()) {
Example #2
0
 /**
  *  Creates the edit form
  *  @param integer $id Optional ID, current record used if zero
  *  @return string HTML for edit form
  */
 public function Edit($eid = '', $rp_id = 0, $saveaction = '')
 {
     global $_CONF, $_EV_CONF, $_TABLES, $_USER, $LANG_EVLIST, $LANG_ADMIN, $_GROUPS, $LANG_ACCESS, $_SYSTEM;
     // If an eid is specified and this is an object, then read the
     // event data- UNLESS a repeat ID is given in which case we're
     // editing a repeat and already have the info we need.
     // This probably needs to change, since we should always read event
     // data during construction.
     if (!$this->isSubmitter) {
         // At least submit privilege required
         COM_404();
     } elseif ($eid != '' && $rp_id == 0 && is_object($this)) {
         // If an id is passed in, then read that record
         if (!$this->Read($eid)) {
             return 'Invalid object ID';
         }
     } elseif (isset($_POST['eid']) && !empty($_POST['eid'])) {
         // Returning to an existing form, probably due to errors
         $this->SetVars($_POST);
         // Make sure the current user has access to this event.
         if (!$this->hasAccess(3)) {
             COM_404();
         }
     }
     $T = new Template($_CONF['path'] . 'plugins/evlist/templates/');
     if ($_SYSTEM['disable_jquery_slimbox']) {
         $T->set_file('editor', 'editor.uikit.thtml');
     } else {
         $T->set_file('editor', 'editor.thtml');
     }
     // Basic tabs for editing both events and instances, show up on
     // all edit forms
     //$tabs = array('ev_info', 'ev_schedule', 'ev_location', 'ev_contact',);
     $tabs = array('ev_info', 'ev_location', 'ev_contact');
     $rp_id = (int) $rp_id;
     if ($rp_id > 0) {
         // Make sure the current user has access to this event.
         if (!$this->hasAccess(3)) {
             COM_404();
         }
         if ($saveaction == 'savefuturerepeat') {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_future'], 'warning');
         } else {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_instance'], 'info');
         }
         //$T->clear_var('contact_section');
         $T->clear_var('category_section');
         $T->clear_var('permissions_editor');
         // Set the static calendar name for the edit form.  Can't
         // change it for a single instance.
         $cal_name = DB_getItem($_TABLES['evlist_calendars'], 'cal_name', "cal_id='" . (int) $this->cal_id . "'");
         $T->set_var(array('contact_section' => 'true', 'is_repeat' => 'true', 'cal_name' => $cal_name));
         // Override our dates & times with those from the repeat.
         // $rp_id is passed when this is called from class evRepeat.
         // Maybe that should pass in the repeat's data instead to avoid
         // another DB lookup.  An array of values could be used.
         $Rep = DB_fetchArray(DB_query("SELECT * \n                    FROM {$_TABLES['evlist_repeat']}\n                    WHERE rp_id='{$rp_id}'"), false);
         if ($Rep) {
             $this->date_start1 = $Rep['rp_date_start'];
             $this->date_end1 = $Rep['rp_date_end'];
             $this->time_start1 = $Rep['rp_time_start1'];
             $this->time_end1 = $Rep['rp_time_end1'];
             $this->time_start2 = $Rep['rp_time_start2'];
             $this->time_end2 = $Rep['rp_time_end2'];
         }
     } else {
         // Editing the main event record
         if ($this->id != '' && $this->recurring == 1) {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_series'], 'error');
         }
         if ($this->isAdmin) {
             $tabs[] = 'ev_perms';
             // Add permissions tab, event edit only
             $T->set_var('permissions_editor', 'true');
         }
         $T->set_var(array('contact_section' => 'true', 'category_section' => 'true', 'upcoming_chk' => $this->show_upcoming ? EVCHECKED : ''));
     }
     $action_url = EVLIST_URL . '/event.php';
     $delaction = 'delevent';
     if (isset($_GET['from']) && $_GET['from'] == 'admin') {
         $cancel_url = EVLIST_ADMIN_URL . '/index.php';
     } else {
         $cancel_url = EVLIST_URL . '/index.php';
     }
     switch ($saveaction) {
         case 'saverepeat':
         case 'savefuturerepeat':
         case 'saveevent':
             break;
         case 'moderate':
             // Approving a submission
             $saveaction = 'approve';
             $delaction = 'disapprove';
             $action_url = EVLIST_ADMIN_URL . '/index.php';
             $cancel_url = $_CONF['site_admin_url'] . '/moderation.php';
             break;
         default:
             $saveaction = 'saveevent';
             break;
     }
     $retval = '';
     //$recinterval = '';
     $recweekday = '';
     $ownerusername = DB_getItem($_TABLES['users'], 'username', "uid='{$this->owner_id}'");
     $retval .= COM_startBlock($LANG_EVLIST['event_editor']);
     $summary = $this->Detail->summary;
     $full_description = $this->Detail->full_description;
     $location = $this->Detail->location;
     if (($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) && $A['postmode'] == 'html') {
         $postmode = '2';
         //html
     } else {
         $postmode = '1';
         //plaintext
         $summary = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->summary)));
         $full_description = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->full_description)));
         $location = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->location)));
     }
     $starthour2 = '';
     $startminute2 = '';
     $endhour2 = '';
     $endminute2 = '';
     if ($this->date_end1 == '' || $this->date_end1 == '0000-00-00') {
         $this->date_end1 = $this->date_start1;
     }
     if ($this->date_start1 != '' && $this->date_start1 != '0000-00-00') {
         list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts($this->date_start1, $this->time_start1);
     } else {
         list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts(date('Y-m-d', time()), date('H:i:s', time()));
     }
     // The end date can't be before the start date
     if ($this->date_end1 >= $this->date_start1) {
         list($endmonth1, $endday1, $endyear1, $endhour1, $endminute1) = $this->DateParts($this->date_end1, $this->time_end1);
         $days_interval = Date_Calc::dateDiff($endday1, $endmonth1, $endyear1, $startday1, $startmonth1, $startyear1);
     } else {
         $days_interval = 0;
         $endmonth1 = $startmonth1;
         $endday1 = $startday1;
         $endyear1 = $startyear1;
         $endhour1 = $starthour1;
         $endminute1 = $startminute1;
     }
     if ($this->recurring != '1') {
         $T->set_var(array('recurring_show' => ' style="display:none;"', 'format_opt' => '0'));
         //for ($i = 1; $i <= 6; $i++) {
         //    $T->set_var('format' . $i . 'show', ' style="display:none;"');
         //}
     } else {
         $option = empty($this->rec_data['type']) ? '0' : (int) $this->rec_data['type'];
         $T->set_var(array('recurring_show' => '', 'recurring_checked' => EVCHECKED, 'format_opt' => $option));
     }
     if (isset($this->rec_data['stop']) && !empty($this->rec_data['stop'])) {
         $T->set_var(array('stopdate' => $this->rec_data['stop'], 'd_stopdate' => EVLIST_formattedDate($this->rec_data['stop'])));
     }
     if (!empty($this->rec_data['skip'])) {
         $T->set_var("skipnext{$this->rec_data['skip']}_checked", EVCHECKED);
     }
     if (!empty($this->rec_data['freq'])) {
         $freq = (int) $this->rec_data['freq'];
         if ($freq < 1) {
             $freq = 1;
         }
     } else {
         $freq = 1;
     }
     $T->set_var(array('freq_text' => $LANG_EVLIST['rec_periods'][$this->rec_data['type']] . '(s)', 'rec_freq' => $freq));
     foreach ($LANG_EVLIST['rec_intervals'] as $key => $str) {
         $T->set_var('dom_int_txt_' . $key, $str);
         if (is_array($this->rec_data['interval'])) {
             if (in_array($key, $this->rec_data['interval'])) {
                 $T->set_var('dom_int_chk_' . $key, EVCHECKED);
             }
         }
     }
     // Set up the recurring options needed for the current event
     switch ($option) {
         case 0:
             break;
         case EV_RECUR_MONTHLY:
             if (is_array($this->rec_data['listdays'])) {
                 foreach ($this->rec_data['listdays'] as $mday) {
                     $T->set_var('mdchk' . $mday, EVCHECKED);
                 }
             }
             break;
         case EV_RECUR_WEEKLY:
             $T->set_var('listdays_val', COM_stripslashes($rec_data[0]));
             if (is_array($this->rec_data['listdays']) && !empty($this->rec_data['listdays'])) {
                 foreach ($this->rec_data['listdays'] as $day) {
                     $day = (int) $day;
                     if ($day > 0 && $day < 8) {
                         $T->set_var('daychk' . $day, EVCHECKED);
                     }
                 }
             }
             break;
         case EV_RECUR_DOM:
             $recweekday = $this->rec_data['weekday'];
             break;
         case EV_RECUR_DATES:
             $T->set_var(array('stopshow' => 'style="display:none;"', 'custom_val' => implode(',', $this->rec_data['custom'])));
             break;
     }
     $start1 = EVLIST_TimeSelect('start1', $this->time_start1);
     $start2 = EVLIST_TimeSelect('start2', $this->time_start2);
     $end1 = EVLIST_TimeSelect('end1', $this->time_end1);
     $end2 = EVLIST_TimeSelect('end2', $this->time_end2);
     $cal_select = COM_optionList($_TABLES['evlist_calendars'], 'cal_id,cal_name', $this->cal_id, 1, 'cal_status = 1 ' . COM_getPermSQL('AND', 0, 2));
     USES_class_navbar();
     $navbar = new navbar();
     $cnt = 0;
     foreach ($tabs as $id) {
         $navbar->add_menuitem($LANG_EVLIST[$id], 'showhideEventDiv("' . $id . '",' . $cnt . ');return false;', true);
         $cnt++;
     }
     $navbar->set_selected($LANG_EVLIST['ev_info']);
     if ($this->AdminMode) {
         $action_url .= '?admin=true';
     }
     $T->set_var(array('action_url' => $action_url, 'navbar' => $navbar->generate(), 'alert_msg' => $alert_msg, 'cancel_url' => $cancel_url, 'eid' => $this->id, 'rp_id' => $rp_id, 'title' => $this->Detail->title, 'summary' => $summary, 'description' => $full_description, 'location' => $location, 'status_checked' => $this->status == 1 ? EVCHECKED : '', 'url' => $this->Detail->url, 'street' => $this->Detail->street, 'city' => $this->Detail->city, 'province' => $this->Detail->province, 'country' => $this->Detail->country, 'postal' => $this->Detail->postal, 'contact' => $this->Detail->contact, 'email' => $this->Detail->email, 'phone' => $this->Detail->phone, 'startdate1' => $this->date_start1, 'enddate1' => $this->date_end1, 'd_startdate1' => EVLIST_formattedDate($this->date_start1), 'd_enddate1' => EVLIST_formattedDate($this->date_end1), 'start_hour_options1' => $start1['hour'], 'start_minute_options1' => $start1['minute'], 'startdate1_ampm' => $start1['ampm'], 'end_hour_options1' => $end1['hour'], 'end_minute_options1' => $end1['minute'], 'enddate1_ampm' => $end1['ampm'], 'start_hour_options2' => $start2['hour'], 'start_minute_options2' => $start2['minute'], 'startdate2_ampm' => $start2['ampm'], 'end_hour_options2' => $end2['hour'], 'end_minute_options2' => $end2['minute'], 'enddate2_ampm' => $end2['ampm'], 'recurring_format_options' => EVLIST_GetOptions($LANG_EVLIST['rec_formats'], $option), 'recurring_weekday_options' => EVLIST_GetOptions(Date_Calc::getWeekDays(), $recweekday, 1), 'dailystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['day_by_date'], ''), 'monthlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'yearlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year'], $LANG_EVLIST['if_any']), 'listdays_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['days_of_week'], ''), 'listdaystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['date_l'], $LANG_EVLIST['if_any']), 'intervalstop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'custom_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['dates'], ''), 'datestart_note' => $LANG_EVLIST['datestart_note'], 'src' => isset($_GET['src']) && $_GET['src'] == 'a' ? '1' : '0', 'rem_status_checked' => $this->enable_reminders == 1 ? EVCHECKED : '', 'del_button' => $this->id == '' ? '' : 'true', 'saveaction' => $saveaction, 'delaction' => $delaction, 'owner_id' => $this->owner_id, 'enable_reminders' => $_EV_CONF['enable_reminders'], 'iso_lang' => EVLIST_getIsoLang(), 'hour_mode' => $_CONF['hour_mode'], 'days_interval' => $days_interval, 'display_format' => $_CONF['shortdate'], 'ts_start' => strtotime($this->date_start1), 'ts_end' => strtotime($this->date_end1), 'cal_select' => $cal_select, 'contactlink_chk' => $this->options['contactlink'] == 1 ? EVCHECKED : '', 'lat' => $this->Detail->lat, 'lng' => $this->Detail->lng, 'perm_msg' => $LANG_ACCESS['permmsg'], 'last' => $LANG_EVLIST['rec_intervals'][5], 'doc_url' => EVLIST_getDocURL('event.html'), 'mootools' => $_SYSTEM['disable_mootools'] ? '' : 'true'));
     if ($_EV_CONF['enable_rsvp']) {
         USES_evlist_class_tickettype();
         $TickTypes = evTicketType::GetTicketTypes();
         //$T->set_block('editor', 'Tickets', 'tTypes');
         $tick_opts = '';
         foreach ($TickTypes as $tick_id => $tick_obj) {
             // Check enabled tickets. Ticket type 1 enabled by default
             if (isset($this->options['tickets'][$tick_id]) || $tick_id == 1) {
                 $checked = 'checked="checked"';
                 $fee = (double) $this->options['tickets'][$tick_id]['fee'];
             } else {
                 $checked = '';
                 $fee = 0;
             }
             $tick_opts .= '<tr><td><input name="tickets[' . $tick_id . ']" type="checkbox" ' . $checked . ' value="' . $tick_id . '" /></td>' . '<td>' . $tick_obj->description . '</td>' . '<td><input type="text" name="tick_fees[' . $tick_id . ']" value="' . $fee . '" size="8" /></td></tr>' . LB;
             /*$T->set_var(array(
                   'tick_id' => $tic['id'],
                   'tick_desc' => $tic['description'],
                   'tick_fee' => $fee,
                   'tick_enabled' => $enabled ? 'checked="checked"' : '',
               ) ) ;
               //$T->parse('tTypes', 'Tickets', true);*/
         }
         if ($_EV_CONF['rsvp_print'] > 0) {
             $rsvp_print_chk = 'rsvp_print_chk' . $this->options['rsvp_print'];
             $rsvp_print = 'true';
         } else {
             $rsvp_print = '';
             $rsvp_print_chk = 'no_rsvp_print';
         }
         $T->set_var(array('enable_rsvp' => 'true', 'reg_chk' . $this->options['use_rsvp'] => EVCHECKED, 'rsvp_wait_chk' => $this->options['rsvp_waitlist'] == 1 ? EVCHECKED : '', 'max_rsvp' => $this->options['max_rsvp'], 'max_user_rsvp' => $this->options['max_user_rsvp'], 'rsvp_cutoff' => $this->options['rsvp_cutoff'], 'use_rsvp' => $this->options['use_rsvp'], 'rsvp_waitlist' => $this->options['rsvp_waitlist'], 'tick_opts' => $tick_opts, 'rsvp_print' => $rsvp_print, $rsvp_print_chk => 'checked="checked"'));
     }
     // if rsvp_enabled
     // Split & All-Day settings
     if ($this->allday == 1) {
         // allday, can't be split, no times
         $T->set_var(array('starttime1_show' => 'style="display:none;"', 'endtime1_show' => 'style="display:none;"', 'datetime2_show' => 'style="display:none;"', 'allday_checked' => EVCHECKED, 'split_checked' => '', 'split_show' => 'style="display:none;"'));
     } elseif ($this->split == '1') {
         $T->set_var(array('split_checked' => EVCHECKED, 'allday_checked' => '', 'allday_show' => 'style="display:none"'));
     } else {
         $T->set_var(array('datetime2_show' => 'style="display:none;"'));
     }
     // Category fields. If $_POST['categories'] is set, then this is a
     // form re-entry due to an error saving. Populate checkboxes from the
     // submitted form. Include the user-added category, if any.
     // If not from a form re-entry, get the checked categories from the
     // evlist_lookup table.
     if ($_EV_CONF['enable_categories'] == '1') {
         $cresult = DB_query("SELECT tc.id, tc.name\n                FROM {$_TABLES['evlist_categories']} tc \n                WHERE tc.status='1' ORDER BY tc.name");
         while ($A = DB_fetchArray($cresult, false)) {
             if (isset($_POST['categories']) && is_array($_POST['categories'])) {
                 // Coming from a form re-entry
                 $chk = in_array($A['id'], $_POST['categories']) ? EVCHECKED : '';
             } else {
                 $chk = in_array($A['id'], $this->categories) ? EVCHECKED : '';
             }
             $catlist .= '<input type="checkbox" name="categories[]" ' . 'value="' . $A['id'] . '" ' . $chk . ' />' . '&nbsp;' . $A['name'] . '&nbsp;&nbsp;';
         }
         $T->set_var('catlist', $catlist);
         if (isset($_POST['newcat'])) {
             $T->set_var('newcat', $_POST['newcat']);
         }
         if ($_USER['uid'] > 1 && $rp_id == 0) {
             $T->set_var('category_section', 'true');
             $T->set_var('add_cat_input', 'true');
         }
     }
     // Enable the post mode selector if we allow HTML and the user is
     // logged in, or if this user is an authorized editor
     if ($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) {
         $T->set_var(array('postmode_options' => EVLIST_GetOptions($LANG_EVLIST['postmodes'], $postmode), 'allowed_html' => COM_allowedHTML('evlist.submit')));
         if ($postmode == 'plaintext') {
             // plaintext, hide postmode selector
             $T->set_var('postmode_show', ' style="display:none"');
         }
         $T->parse('event_postmode', 'edit_postmode');
     }
     if ($this->isAdmin) {
         $T->set_var(array('owner_username' => COM_stripslashes($ownerusername), 'owner_dropdown' => COM_optionList($_TABLES['users'], 'uid,username', $this->owner_id, 1, "uid <> 1"), 'group_dropdown' => SEC_getGroupDropdown($this->group_id, 3)));
         if ($rp_id == 0) {
             // can only change permissions on main event
             $T->set_var('permissions_editor', SEC_getPermissionsHTML($this->perm_owner, $this->perm_group, $this->perm_members, $this->perm_anon));
         }
     } else {
         $T->set_var('group_id', $this->group_id);
     }
     // Latitude & Longitude part of location, if Location plugin is used
     if ($_EV_CONF['use_locator']) {
         $T->set_var(array('use_locator' => 'true', 'loc_selection' => GEO_optionList()));
     }
     $T->parse('output', 'editor');
     $retval .= $T->finish($T->get_var('output'));
     $retval .= COM_endBlock();
     return $retval;
 }
Example #3
0
/**
 * Get an existing static page
 *
 * @param   array   args    Contains all the data provided by the client
 * @param   string  &output OUTPUT parameter containing the returned text
 * @param   string  &svc_msg OUTPUT parameter containing any service messages
 * @return  int		    Response code as defined in lib-plugins.php
 */
function service_get_staticpages($args, &$output, &$svc_msg)
{
    global $_CONF, $_TABLES, $LANG_ACCESS, $LANG12, $LANG_STATIC, $LANG_LOGIN, $_SP_CONF;
    $output = '';
    $svc_msg['output_fields'] = array('sp_hits', 'sp_format', 'owner_id', 'group_id', 'perm_owner', 'perm_group', 'perm_members', 'perm_anon', 'sp_help', 'sp_php', 'sp_inblock', 'commentcode');
    if (empty($args['sp_id']) && !empty($args['id'])) {
        $args['sp_id'] = $args['id'];
    }
    if ($args['gl_svc']) {
        if (isset($args['sp_id'])) {
            $args['sp_id'] = COM_applyBasicFilter($args['sp_id']);
        }
        if (isset($args['mode'])) {
            $args['mode'] = COM_applyBasicFilter($args['mode']);
        }
        if (empty($args['sp_id'])) {
            $svc_msg['gl_feed'] = true;
        } else {
            $svc_msg['gl_feed'] = false;
        }
    } else {
        $svc_msg['gl_feed'] = false;
    }
    if (!$svc_msg['gl_feed']) {
        $page = '';
        if (isset($args['sp_id'])) {
            $page = $args['sp_id'];
        }
        $mode = '';
        if (isset($args['mode'])) {
            $mode = $args['mode'];
        }
        $error = 0;
        if ($page == '') {
            $error = 1;
        }
        $perms = SP_getPerms();
        if (!empty($perms)) {
            $perms = ' AND ' . $perms;
        }
        $sql = "SELECT sp_title,sp_content,sp_hits,sp_date,sp_format," . "commentcode,sp_uid,owner_id,group_id,perm_owner,perm_group," . "perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']} " . "WHERE (sp_id = '{$page}') AND (sp_status = 1)" . $perms;
        $result = DB_query($sql);
        $count = DB_numRows($result);
        if ($count == 0 || $count > 1) {
            $error = 1;
        }
        if (!$error) {
            $output = DB_fetchArray($result, false);
            // WE ASSUME $output doesn't have any confidential fields
            if ($mode !== 'autotag') {
                $_CONF['pagetitle'] = $output['sp_title'];
            }
        } else {
            // an error occured (page not found, access denied, ...)
            if (empty($page)) {
                $failflg = 0;
            } else {
                $failflg = DB_getItem($_TABLES['staticpage'], 'sp_nf', "sp_id='{$page}'");
            }
            if ($failflg) {
                if ($mode !== 'autotag') {
                    $output = COM_siteHeader('menu');
                }
                $output .= SEC_loginRequiredForm();
                if ($mode !== 'autotag') {
                    $output .= COM_siteFooter();
                }
            } else {
                if ($mode !== 'autotag') {
                    COM_404();
                }
            }
            return PLG_RET_ERROR;
        }
        if ($args['gl_svc']) {
            // This date format is PHP 5 only,
            // but only the web-service uses the value
            $output['published'] = date('c', strtotime($output['sp_date']));
            $output['updated'] = date('c', strtotime($output['sp_date']));
            $output['id'] = $page;
            $output['title'] = $output['sp_title'];
            $output['category'] = array($output['sp_tid']);
            $output['content'] = $output['sp_content'];
            $output['content_type'] = 'html';
            $output['author_name'] = DB_getItem($_TABLES['users'], 'username', 'uid=' . (int) $output['owner_id']);
            $output['link_edit'] = $page;
        }
    } else {
        $output = array();
        $mode = '';
        if (isset($args['mode'])) {
            $mode = $args['mode'];
        }
        $perms = SP_getPerms();
        if (!empty($perms)) {
            $perms = ' AND ' . $perms;
        }
        $offset = 0;
        if (isset($args['offset'])) {
            $offset = COM_applyBasicFilter($args['offset'], true);
        }
        $max_items = $_SP_CONF['atom_max_items'] + 1;
        $limit = " LIMIT {$offset}, {$max_items}";
        $order = " ORDER BY sp_date DESC";
        $sql = "SELECT sp_id,sp_title,sp_content,sp_hits,sp_date,sp_format,owner_id," . "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']} WHERE (sp_status = 1)" . $perms . $order . $limit;
        $result = DB_query($sql);
        $count = 0;
        while (($output_item = DB_fetchArray($result, false)) !== false) {
            // WE ASSUME $output doesn't have any confidential fields
            $count += 1;
            if ($count == $max_items) {
                $svc_msg['offset'] = $offset + $_SP_CONF['atom_max_items'];
                break;
            }
            if ($args['gl_svc']) {
                // This date format is PHP 5 only, but only the web-service uses the value
                $output_item['published'] = date('c', strtotime($output_item['sp_date']));
                $output_item['updated'] = date('c', strtotime($output_item['sp_date']));
                $output_item['id'] = $output_item['sp_id'];
                $output_item['title'] = $output_item['sp_title'];
                $output_item['category'] = array($output_item['sp_tid']);
                $output_item['content'] = $output_item['sp_content'];
                $output_item['content_type'] = 'html';
                $output_item['author_name'] = DB_getItem($_TABLES['users'], 'username', 'uid=' . (int) $output['owner_id']);
            }
            $output[] = $output_item;
        }
    }
    return PLG_RET_OK;
}
Example #4
0
function _createMailStory($sid)
{
    global $_CONF, $_TABLES, $LANG_DIRECTION, $LANG01, $LANG08;
    USES_lib_story();
    $story = new Story();
    $args = array('sid' => $sid, 'mode' => 'view');
    $output = STORY_LOADED_OK;
    $result = PLG_invokeService('story', 'get', $args, $output, $svc_msg);
    if ($result == PLG_RET_OK) {
        /* loadFromArray cannot be used, since it overwrites the timestamp */
        reset($story->_dbFields);
        while (list($fieldname, $save) = each($story->_dbFields)) {
            $varname = '_' . $fieldname;
            if (array_key_exists($fieldname, $output)) {
                $story->{$varname} = $output[$fieldname];
            }
        }
        $story->_username = $output['username'];
        $story->_fullname = $output['fullname'];
    }
    if ($output == STORY_PERMISSION_DENIED) {
        $display = COM_siteHeader('menu', $LANG_ACCESS['accessdenied']) . COM_showMessageText($LANG_ACCESS['storydenialmsg'], $LANG_ACCESS['accessdenied'], true, 'error') . COM_siteFooter();
        echo $display;
        exit;
    } elseif ($output == STORY_INVALID_SID) {
        COM_404();
    } else {
        $T = new Template($_CONF['path_layout'] . 'article');
        $T->set_file('article', 'mailable.thtml');
        list($cacheFile, $style_cache_url) = COM_getStyleCacheLocation();
        $T->set_var('direction', $LANG_DIRECTION);
        $T->set_var('css_url', $style_cache_url);
        $T->set_var('page_title', $_CONF['site_name'] . ': ' . $story->displayElements('title'));
        $T->set_var('story_title', $story->DisplayElements('title'));
        $T->set_var('story_subtitle', $story->DisplayElements('subtitle'));
        $story_image = $story->DisplayElements('story_image');
        if ($story_image != '') {
            $T->set_var('story_image', $story_image);
        } else {
            $T->unset_var('story_image');
        }
        if ($_CONF['hidestorydate'] != 1) {
            $T->set_var('story_date', $story->displayElements('date'));
        }
        if ($_CONF['contributedbyline'] == 1) {
            $T->set_var('lang_contributedby', $LANG01[1]);
            $authorname = COM_getDisplayName($story->displayElements('uid'));
            $T->set_var('author', $authorname);
            $T->set_var('story_author', $authorname);
            $T->set_var('story_author_username', $story->DisplayElements('username'));
        }
        $T->set_var('story_introtext', $story->DisplayElements('introtext'));
        $T->set_var('story_bodytext', $story->DisplayElements('bodytext'));
        $T->set_var('site_name', $_CONF['site_name']);
        $T->set_var('site_slogan', $_CONF['site_slogan']);
        $T->set_var('story_id', $story->getSid());
        $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid());
        if ($story->DisplayElements('commentcode') >= 0) {
            $commentsUrl = $articleUrl . '#comments';
            $comments = $story->DisplayElements('comments');
            $numComments = COM_numberFormat($comments);
            $T->set_var('story_comments', $numComments);
            $T->set_var('comments_url', $commentsUrl);
            $T->set_var('comments_text', $numComments . ' ' . $LANG01[3]);
            $T->set_var('comments_count', $numComments);
            $T->set_var('lang_comments', $LANG01[3]);
            $comments_with_count = sprintf($LANG01[121], $numComments);
            if ($comments > 0) {
                $comments_with_count = COM_createLink($comments_with_count, $commentsUrl);
            }
            $T->set_var('comments_with_count', $comments_with_count);
        }
        $T->set_var('lang_full_article', $LANG08[33]);
        $T->set_var('article_url', $articleUrl);
        COM_setLangIdAndAttribute($T);
        $T->parse('output', 'article');
        $htmlMsg = $T->finish($T->get_var('output'));
        return $htmlMsg;
    }
}