/**
  * return HTML block
  *
  * @access	public
  * @param	array		Member information
  * @return	string		HTML block
  */
 public function return_html_block($member = array())
 {
     /* Get blog API */
     require_once IPS_ROOT_PATH . 'api/api_core.php';
     require_once IPS_ROOT_PATH . 'api/blog/api_blog.php';
     /* Create API Object */
     $blog_api = new apiBlog();
     /* Language */
     $this->lang->loadLanguageFile(array('public_portal'), 'blog');
     $content = '';
     $blog_url = $blog_api->getBlogUrl($blog_api->getBlogID($member['member_id']));
     $this->lang->words['visit_blog'] = "<a href=\"{$blog_url}\">{$this->lang->words['visit_blog']}</a>";
     $entry_content = '';
     $entries = $blog_api->lastXEntries('member', $member['member_id'], 5);
     if (is_array($entries) && count($entries)) {
         $attachments = 0;
         $entry_ids = array();
         foreach ($entries as $row) {
             $row['_post_date'] = ipsRegistry::getClass('class_localization')->getDate($row['entry_date'], 'SHORT');
             $row['_date_array'] = IPSTime::date_getgmdate($row['entry_date'] + ipsRegistry::getClass('class_localization')->getTimeOffset());
             $entry_ids[$row['entry_id']] = $row['entry_id'];
             IPSText::getTextClass('bbcode')->parse_html = $row['entry_html_state'] ? 1 : 0;
             IPSText::getTextClass('bbcode')->parse_nl2br = $row['entry_html_state'] == 2 ? 1 : 0;
             IPSText::getTextClass('bbcode')->parse_bbcode = 1;
             IPSText::getTextClass('bbcode')->parsing_section = 'blog';
             $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['entry']);
             $row['post'] = IPSText::getTextClass('bbcode')->memberViewImages($row['post']);
             if ($row['entry_has_attach']) {
                 $parseAttachments = true;
             }
             $entry_content .= $this->registry->output->getTemplate('profile')->tabSingleColumn($row, $this->lang->words['readentry'], $row['entry_url'], $row['entry_name']);
         }
         //-----------------------------------------
         // Attachments (but only if necessary)
         //-----------------------------------------
         if ($parseAttachments and !is_object($this->class_attach)) {
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
             $this->class_attach->type = 'blogentry';
             $this->class_attach->init();
             $entry_content = $this->class_attach->renderAttachments($entry_content, $entry_ids, 'blog_show');
             $entry_content = $entry_content[0]['html'];
         }
         $content = $this->registry->output->getTemplate('blog_portal')->profileTabWrap($this->lang->words['visit_blog'], $entry_content);
     } else {
         $content .= $this->registry->output->getTemplate('profile')->tabNoContent('noblogentries');
     }
     //-----------------------------------------
     // Return content..
     //-----------------------------------------
     return $content;
 }
Exemplo n.º 2
0
 /**
  * Builds the html for the monthly events
  *
  * @param	int		$month		Numeric value of the month to get events from
  * @param	int		$year		Year to get events from
  * @param	bool	$minical	Set to 1 if this is for the minicalendar
  * @return	string	Calendar HTML output
  */
 public function getMonthEvents($month, $year, $minical = false)
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $birthdays = array();
     //-----------------------------------------
     // Work out timestamps
     //-----------------------------------------
     $our_datestamp = gmmktime(12, 0, 0, $month, 1, $year);
     $_firstDay = gmdate('w', $our_datestamp);
     if ($this->settings['ipb_calendar_mon']) {
         $_firstDay = $_firstDay == 0 ? 7 : $_firstDay;
     }
     //-----------------------------------------
     // Get the birthdays from the database
     //-----------------------------------------
     if ($this->settings['show_bday_calendar'] and !$minical) {
         $birthdays = $this->_getBirthdaysForMonth($month);
     }
     //-----------------------------------------
     // Get the events
     //-----------------------------------------
     if (!$minical) {
         $this->calendarGetEventsSQL($month, $year);
     }
     //-----------------------------------------
     // Get events
     //-----------------------------------------
     $seen_days = array();
     $seen_events = array();
     $output = "";
     //-----------------------------------------
     // Loop (42 is 7 days x 6 "weeks" potential)
     //-----------------------------------------
     for ($c = 0; $c < 42; $c++) {
         //-----------------------------------------
         // Get data for each day
         //-----------------------------------------
         list($_year, $_month, $_day) = explode('-', gmstrftime('%Y-%m-%d', $our_datestamp));
         $day_array = IPSTime::date_getgmdate($our_datestamp);
         //-----------------------------------------
         // If this is a new week, reset row
         //-----------------------------------------
         if ($c % 7 == 0) {
             //-----------------------------------------
             // Kill the loop if we are no longer on our month
             //-----------------------------------------
             if ($day_array['mon'] != $month) {
                 break;
             }
             $output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_new_row($our_datestamp, $this->calendar) : $this->registry->output->getTemplate('calendar')->cal_new_row($our_datestamp, $this->calendar);
         }
         $_c = $this->settings['ipb_calendar_mon'] ? $c + 1 : $c;
         //-----------------------------------------
         // Run out of legal days for this month?
         // Or have we yet to get to the first day?
         //-----------------------------------------
         if ($_c < $_firstDay or $day_array['mon'] != $month) {
             $output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_blank_cell() : $this->registry->output->getTemplate('calendar')->cal_blank_cell();
         } else {
             if (isset($seen_days[$day_array['yday']])) {
                 $our_datestamp += 86400;
                 continue;
             }
             $seen_days[$day_array['yday']] = true;
             $tmp_cevents = array();
             $this_day_events = "";
             $_hasQueued = false;
             //-----------------------------------------
             // Get events
             //-----------------------------------------
             if (!$minical) {
                 $events = $this->calendarGetDayEvents($_month, $_day, $_year);
                 if (is_array($events) and count($events)) {
                     foreach ($events as $event) {
                         if (empty($seen_events[$_month . '-' . $_day . '-' . $_year][$event['event_id']])) {
                             //$event	= $this->calendarMakeEventHTML( $event, true );
                             if (isset($event['recurring'])) {
                                 $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap_recurring($event, 'month');
                             } else {
                                 if (isset($event['ranged'])) {
                                     $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap_range($event, 'month');
                                 } else {
                                     $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap($event, 'month');
                                 }
                             }
                             $seen_events[$_month . '-' . $_day . '-' . $_year][$event['event_id']] = 1;
                             //-----------------------------------------
                             // Queued events?
                             //-----------------------------------------
                             if (!$event['event_approved'] and $this->memberData['g_is_supmod']) {
                                 $_hasQueued = true;
                             }
                         }
                     }
                     //-----------------------------------------
                     // How many events?
                     //-----------------------------------------
                     if (count($tmp_cevents) > $this->calendar['cal_event_limit']) {
                         $this_day_events = $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual(array('url' => "cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y=" . $_year . "&amp;m=" . $_month . "&amp;d=" . $_day, 'template' => 'cal_day', 'title' => $this->calendar['cal_title_seo']), sprintf($this->lang->words['show_n_events'], intval(count($tmp_cevents))));
                     } else {
                         if (count($tmp_cevents)) {
                             $this_day_events = implode("\n", $tmp_cevents);
                         }
                     }
                 }
                 //-----------------------------------------
                 // Birthdays
                 //-----------------------------------------
                 if ($this->calendar['cal_bday_limit']) {
                     if (isset($birthdays[$_day]) and count($birthdays[$_day]) > 0) {
                         $no_bdays = count($birthdays[$_day]);
                         if ($no_bdays <= $this->calendar['cal_bday_limit']) {
                             foreach ($birthdays[$_day] as $user) {
                                 $this_day_events .= $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual(array('url' => "cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y=" . $_year . "&amp;m=" . $_month . "&amp;d=" . $_day, 'template' => 'cal_day', 'title' => $this->calendar['cal_title_seo']), $user['members_display_name'] . $this->lang->words['bd_birthday']);
                             }
                         } else {
                             $this_day_events .= $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual(array('url' => "cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y=" . $_year . "&amp;m=" . $_month . "&amp;d=" . $_day, 'template' => 'cal_day', 'title' => $this->calendar['cal_title_seo']), sprintf($this->lang->words['entry_birthdays'], $no_bdays));
                         }
                     }
                 }
             }
             //-----------------------------------------
             // If we have events, show them
             //-----------------------------------------
             $_dateLink = '';
             $_queueLink = '';
             $_dateLink = array('url' => "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y=" . $year . "&amp;m=" . $month . "&amp;d=" . $day_array['mday'], 'seotitle' => $this->calendar['cal_title_seo'], 'template' => 'cal_day', 'day' => $day_array['mday']);
             if ($this_day_events and !$minical) {
                 $_queueLink = $this->registry->getClass('output')->buildSEOUrl("app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y=" . $year . "&amp;m=" . $month . "&amp;d=" . $day_array['mday'] . "&amp;modfilter=queued", 'public', $this->calendar['cal_title_seo'], 'cal_day');
                 $this_day_events = $this->registry->output->getTemplate('calendar')->eventsWrapper($this_day_events);
             }
             /* Apply TZ offset so that we show the correct 'today' */
             if ($day_array['mday'] == strftime('%d', time() + $this->lang->getTimeOffset()) and $day_array['mon'] == strftime('%m', time() + $this->lang->getTimeOffset()) and $day_array['year'] == strftime('%Y', time() + $this->lang->getTimeOffset())) {
                 $output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_date_cell_today($_dateLink) : $this->registry->output->getTemplate('calendar')->cal_date_cell_today($_dateLink, $this_day_events, $_queueLink, $_hasQueued, $this->_buildDayID($this->chosen_date['year'], $this->chosen_date['month'], $_day));
             } else {
                 $output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_date_cell($_dateLink) : $this->registry->output->getTemplate('calendar')->cal_date_cell($_dateLink, $this_day_events, $_queueLink, $_hasQueued, $this->_buildDayID($this->chosen_date['year'], $this->chosen_date['month'], $_day));
             }
             $our_datestamp += 86400;
         }
     }
     return $output;
 }
Exemplo n.º 3
0
 function convert_calevents()
 {
     $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
     $lend = 50;
     $end = $start + $lend;
     //-----------------------------------------
     // In steps...
     //-----------------------------------------
     if (!$this->DB->checkForTable('calendar_events')) {
         $this->registry->output->addMessage("No calendar events found,  Creating new IPB 2.1 skin...");
         $this->request['workact'] = 'skin';
         return FALSE;
     }
     $this->DB->build(array('select' => '*', 'from' => 'calendar_events', 'limit' => array($start, $lend)));
     $o = $this->DB->execute();
     //-----------------------------------------
     // Do it...
     //-----------------------------------------
     if ($this->DB->getTotalRows($o)) {
         //-----------------------------------------
         // Got some to convert!
         //-----------------------------------------
         while ($r = $this->DB->fetch($o)) {
             $recur_remap = array('w' => 1, 'm' => 2, 'y' => 3);
             $begin_date = IPSTime::date_getgmdate($r['unix_stamp']);
             $end_date = IPSTime::date_getgmdate($r['end_unix_stamp']);
             if (!$begin_date or !$end_date) {
                 continue;
             }
             $day = $begin_date['mday'];
             $month = $begin_date['mon'];
             $year = $begin_date['year'];
             $end_day = $end_date['mday'];
             $end_month = $end_date['mon'];
             $end_year = $end_date['year'];
             $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year);
             //-----------------------------------------
             // Recur or ranged...
             //-----------------------------------------
             if ($r['event_repeat'] or $r['event_ranged']) {
                 $_final_unix_to = gmmktime(11, 59, 59, $end_month, $end_day, $end_year);
             } else {
                 $_final_unix_to = 0;
             }
             $new_event = array('event_calendar_id' => 1, 'event_member_id' => $r['userid'], 'event_content' => $r['event_text'], 'event_title' => $r['title'], 'event_smilies' => $r['show_emoticons'], 'event_perms' => $r['read_perms'], 'event_private' => $r['priv_event'], 'event_approved' => 1, 'event_unixstamp' => $r['unix_stamp'], 'event_recurring' => $r['event_repeat'] && $recur_remap[$r['repeat_unit']] ? $recur_remap[$r['repeat_unit']] : 0, 'event_tz' => 0, 'event_unix_from' => $_final_unix_from, 'event_unix_to' => $_final_unix_to);
             //-----------------------------------------
             // INSERT
             //-----------------------------------------
             $this->DB->insert('cal_events', $new_event);
         }
         $this->registry->output->addMessage("Calendar events: {$start} to {$end} completed....");
         $this->request['workact'] = 'calevents';
         $this->request['st'] = $end;
         return FALSE;
     } else {
         $this->registry->output->addMessage("Calendar events converted,  Creating new IPB 2.1 skin...");
         $this->request['workact'] = 'skin';
         return FALSE;
     }
 }
 /**
  * Set the timestamp
  *
  * @access	public
  * @param	int		New timestamp
  * @return	void
  */
 public static function setTimestamp($time)
 {
     self::$timestamp = $time;
 }
Exemplo n.º 5
0
 /**
  * 2.1.0 Tools: Calendar Events
  *
  * @return	@e void
  */
 public function tools210Calevents()
 {
     $start = intval($_GET['st']);
     $lend = 50;
     $end = $start + $lend;
     $max = intval($_GET['max']);
     //-----------------------------------------
     // Check to make sure table exists
     //-----------------------------------------
     if (!$this->DB->checkForTable('calendar_events')) {
         $this->registry->output->global_message = $this->lang->words['re_calremoved'];
         $this->toolsSplashScreen();
         return;
     }
     //-----------------------------------------
     // Do we need to run this tool?
     //-----------------------------------------
     if (!$max) {
         $original = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as max', 'from' => 'calendar_events'));
         $new = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as max', 'from' => 'cal_events'));
         if ($new['max'] >= $original['max'] or !$original['max']) {
             $this->registry->output->global_message = $this->lang->words['re_calalready'];
             $this->toolsSplashScreen();
         }
     }
     $max = intval($original['max']);
     //-----------------------------------------
     // In steps...
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'calendar_events', 'limit' => array($start, $lend)));
     $o = $this->DB->execute();
     //-----------------------------------------
     // Do it...
     //-----------------------------------------
     if ($this->DB->getTotalRows($o)) {
         //-----------------------------------------
         // Got some to convert!
         //-----------------------------------------
         while ($r = $this->DB->fetch($o)) {
             $recur_remap = array('w' => 1, 'm' => 2, 'y' => 3);
             $begin_date = IPSTime::date_getgmdate($r['unix_stamp']);
             $end_date = IPSTime::date_getgmdate($r['end_unix_stamp']);
             if (!$begin_date or !$end_date) {
                 continue;
             }
             $day = $begin_date['mday'];
             $month = $begin_date['mon'];
             $year = $begin_date['year'];
             $end_day = $end_date['mday'];
             $end_month = $end_date['mon'];
             $end_year = $end_date['year'];
             $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year);
             //-----------------------------------------
             // Recur or ranged...
             //-----------------------------------------
             if ($r['event_repeat'] or $r['event_ranged']) {
                 $_final_unix_to = gmmktime(23, 59, 59, $end_month, $end_day, $end_year);
             } else {
                 $_final_unix_to = 0;
             }
             $new_event = array('event_calendar_id' => 1, 'event_member_id' => $r['userid'], 'event_content' => $r['event_text'], 'event_title' => $r['title'], 'event_smilies' => $r['show_emoticons'], 'event_perms' => $r['read_perms'], 'event_private' => $r['priv_event'], 'event_approved' => 1, 'event_unixstamp' => $r['unix_stamp'], 'event_recurring' => $r['event_repeat'] && $recur_remap[$r['repeat_unit']] ? $recur_remap[$r['repeat_unit']] : 0, 'event_tz' => 0, 'event_unix_from' => $_final_unix_from, 'event_unix_to' => $_final_unix_to);
             //-----------------------------------------
             // INSERT
             //-----------------------------------------
             $this->DB->insert('cal_events', $new_event);
         }
         $this->registry->output->global_message = sprintf($this->lang->words['re_calstartto'], $start, $end);
         $url = "{$this->settings['base_url']}{$this->form_code}&do=" . $this->request['do'] . '&max=' . $max . '&st=' . $end;
     } else {
         $this->registry->output->global_message = $this->lang->words['re_calsconverted'];
         $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
     }
     //-----------------------------------------
     // Bye....
     //-----------------------------------------
     $this->registry->output->redirect($url, $this->registry->output->global_message);
 }
Exemplo n.º 6
0
 /**
  * Action: Issue Warning
  */
 public function save()
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $points = 0;
     $mq = 0;
     $mq_unit = 'd';
     $rpa = 0;
     $rpa_unit = 'd';
     $suspend = 0;
     $suspend_unit = 'd';
     $banGroup = 0;
     $removePoints = 0;
     $removePointsUnit = 'd';
     //-----------------------------------------
     // Validate
     //-----------------------------------------
     $errors = array();
     if ($this->request['reason'] === '') {
         /* No reason selected */
         $errors['reason'] = $this->lang->words['warnings_err_reason'];
     } else {
         $reason = intval($this->request['reason']);
         /* "Other" reason selected */
         if (!$reason) {
             /* Check we're actually allowed to use it */
             if (!$this->memberData['g_access_cp'] and !$this->settings['warnings_enable_other']) {
                 /* Nope */
                 $errors['reason'] = $this->lang->words['warnings_err_reason'];
             } else {
                 /* If we select "Other", we determine the number of points and when they expire */
                 $points = floatval($this->request['points']);
                 $removePoints = intval($this->request['remove']);
                 $removePointsUnit = $this->request['remove_unit'] == 'h' ? 'h' : 'd';
             }
         } else {
             $reason = $this->reasons[$reason];
             /* Check it's valid */
             if (!$reason['wr_id']) {
                 /* Nope */
                 $errors['reason'] = $this->lang->words['warnings_err_reason'];
             } else {
                 /* Can we override the number of points for this reason? */
                 if ($this->memberData['g_access_cp'] or $reason['wr_points_override']) {
                     // Yes, get value from input
                     $points = floatval($this->request['points']);
                 } else {
                     // No, take whatever the reason has set
                     $points = $reason['wr_points'];
                 }
                 /* Can we override when the points expire? */
                 if ($this->memberData['g_access_cp'] or $reason['wr_remove_override']) {
                     // Yes, get value from input
                     $removePoints = intval($this->request['remove']);
                     $removePointsUnit = $this->request['remove_unit'] == 'h' ? 'h' : 'd';
                 } else {
                     // No, take whatever the reason has set
                     $removePoints = intval($reason['wr_remove']);
                     $removePointsUnit = $reason['wr_remove_unit'];
                 }
             }
             $reason = $reason['wr_id'];
         }
         /* Now let's get the action */
         $newPointLevel = floatval($this->_member['warn_level'] + $points);
         $action = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_warn_actions', 'where' => "wa_points<={$newPointLevel}", 'order' => 'wa_points DESC', 'limit' => 1));
         if ($action) {
             /* We have an action. Can we override it's punishment? */
             if ($action['wa_override']) {
                 // Yes, get values from input
                 $mq = $this->request['mq_perm'] ? -1 : intval($this->request['mq']);
                 $mq_unit = $this->request['mq_unit'];
                 $rpa = $this->request['rpa_perm'] ? -1 : intval($this->request['rpa']);
                 $rpa_unit = $this->request['rpa_unit'];
                 $suspend = $this->request['suspend_perm'] ? -1 : intval($this->request['suspend']);
                 $suspend_unit = $this->request['suspend_unit'];
                 $banGroup = $this->request['ban_group'] ? intval($this->request['ban_group_id']) : 0;
             } else {
                 // No, do whatever the action says
                 $mq = intval($action['wa_mq']);
                 $mq_unit = $action['wa_mq_unit'];
                 $rpa = intval($action['wa_rpa']);
                 $rpa_unit = $action['wa_rpa_unit'];
                 $suspend = intval($action['wa_suspend']);
                 $suspend_unit = $action['wa_suspend_unit'];
                 $banGroup = intval($action['wa_ban_group']);
             }
         } else {
             /* We don't have an action - are we allowed to give a custom punishment? */
             if ($this->memberData['g_access_cp'] or $this->settings['warning_custom_noaction']) {
                 // Yes, get values from input
                 $mq = $this->request['mq_perm'] ? -1 : intval($this->request['mq']);
                 $mq_unit = $this->request['mq_unit'];
                 $rpa = $this->request['rpa_perm'] ? -1 : intval($this->request['rpa']);
                 $rpa_unit = $this->request['rpa_unit'];
                 $suspend = $this->request['suspend_perm'] ? -1 : intval($this->request['suspend']);
                 $suspend_unit = $this->request['suspend_unit'];
                 $banGroup = $this->request['ban_group'] ? intval($this->request['ban_group_id']) : 0;
             } else {
                 // We're not allowed to give a punishment so this is a verbal warning only.
                 // The values we set earlier during init are fine
             }
         }
     }
     if (!empty($errors)) {
         return $this->form($errors);
     }
     //-----------------------------------------
     // Parse
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $editor = new $classToLoad();
     $noteForMember = $editor->process($_POST['note_member']);
     $noteForMods = $editor->process($_POST['note_mods']);
     //-----------------------------------------
     // Save Log
     //-----------------------------------------
     /* If our points are going to expire, woprk out exactly when */
     $expireDate = 0;
     if ($removePoints) {
         IPSTime::setTimestamp(time());
         if ($removePointsUnit == 'h') {
             IPSTime::add_hours($removePoints);
         } else {
             IPSTime::add_days($removePoints);
         }
         $expireDate = IPSTime::getTimestamp();
     }
     /* Log */
     $warning = array('wl_member' => $this->_member['member_id'], 'wl_moderator' => $this->memberData['member_id'], 'wl_date' => time(), 'wl_reason' => $reason, 'wl_points' => $points, 'wl_note_member' => $noteForMember, 'wl_note_mods' => $noteForMods, 'wl_mq' => $mq, 'wl_mq_unit' => $mq_unit, 'wl_rpa' => $rpa, 'wl_rpa_unit' => $rpa_unit, 'wl_suspend' => $suspend, 'wl_suspend_unit' => $suspend_unit, 'wl_ban_group' => $banGroup, 'wl_expire' => $removePoints, 'wl_expire_unit' => $removePointsUnit, 'wl_acknowledged' => $this->settings['warnings_acknowledge'] ? 0 : 1, 'wl_content_app' => trim($this->request['from_app']), 'wl_content_id1' => $this->request['from_id1'], 'wl_content_id2' => $this->request['from_id2'], 'wl_expire_date' => $expireDate);
     /* Data Hook Location */
     $warning['actionData'] = $action;
     $warning['reasonsData'] = $this->reasons;
     IPSLib::doDataHooks($warning, 'memberWarningPre');
     unset($warning['actionData'], $warning['reasonsData']);
     $this->DB->insert('members_warn_logs', $warning);
     $warning['wl_id'] = $this->DB->getInsertId();
     /* Data Hook Location */
     $warning['actionData'] = $action;
     $warning['reasonsData'] = $this->reasons;
     IPSLib::doDataHooks($warning, 'memberWarningPost');
     unset($warning['actionData'], $warning['reasonsData']);
     //-----------------------------------------
     // Actually do it
     //-----------------------------------------
     $update = array();
     /* Add Points */
     if ($points) {
         $update['warn_level'] = $this->_member['warn_level'] + $points;
     }
     /* Set Punishments */
     if ($mq) {
         $update['mod_posts'] = $mq == -1 ? 1 : IPSMember::processBanEntry(array('unit' => $mq_unit, 'timespan' => $mq));
     }
     if ($rpa) {
         $update['restrict_post'] = $rpa == -1 ? 1 : IPSMember::processBanEntry(array('unit' => $rpa_unit, 'timespan' => $rpa));
     }
     if ($suspend) {
         if ($suspend == -1) {
             $update['member_banned'] = 1;
         } else {
             $update['temp_ban'] = IPSMember::processBanEntry(array('unit' => $suspend_unit, 'timespan' => $suspend));
         }
     }
     if ($banGroup > 0) {
         if (!$this->caches['group_cache'][$banGroup]['g_access_cp'] and !$this->caches['group_cache'][$banGroup]['g_is_supmod'] and $banGroup != $this->settings['guest_group']) {
             $update['member_group_id'] = $banGroup;
         }
     }
     if ($this->settings['warnings_acknowledge']) {
         $update['unacknowledged_warnings'] = 1;
     }
     /* Save */
     if (!empty($update)) {
         IPSMember::save($this->_member['member_id'], array('core' => $update));
     }
     //-----------------------------------------
     // Work out where this warning came from
     //-----------------------------------------
     if ($warning['wl_content_app'] and IPSLib::appIsInstalled($warning['wl_content_app'])) {
         $file = IPSLib::getAppDir($warning['wl_content_app']) . '/extensions/warnings.php';
         if (is_file($file)) {
             $classToLoad = IPSLib::loadLibrary($file, 'warnings_' . $warning['wl_content_app'], $warning['wl_content_app']);
             if (class_exists($classToLoad) and method_exists($classToLoad, 'getContentUrl')) {
                 $object = new $classToLoad();
                 $content = $object->getContentUrl($warning);
             }
         }
     }
     //-----------------------------------------
     // Send notifications
     //-----------------------------------------
     /* Init */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
     $notifyLibrary = new $classToLoad($this->registry);
     /* Send to member being warned */
     if ($this->settings['warnings_acknowledge'] or $noteForMember) {
         try {
             $notifyLibrary->setMember($this->_member);
             $notifyLibrary->setFrom($this->memberData);
             $notifyLibrary->setNotificationKey('warning');
             $notifyLibrary->setNotificationUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}");
             $notifyLibrary->setNotificationTitle(sprintf($this->lang->words['warnings_notify'], $this->registry->output->buildUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}")));
             $notifyLibrary->setNotificationText(sprintf($this->lang->words['warnings_notify_text'], $this->_member['members_display_name'], $this->memberData['members_display_name'], $reason ? $this->reasons[$reason]['wr_name'] : $this->lang->words['warnings_reasons_other'], $noteForMember ? sprintf($this->lang->words['warnings_notify_member_note'], $noteForMember) : '', $this->settings['warn_show_own'] ? sprintf($this->lang->words['warnings_notify_view_link'], $this->registry->output->buildUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}")) : ''));
             $notifyLibrary->sendNotification();
         } catch (Exception $e) {
         }
     }
     /* And all mods that can warn and are super_mods (split this up because of: @link http://community.invisionpower.com/tracker/issue-36960-bad-warn-query/ */
     $mods = array();
     $mids = array();
     $gids = array();
     $canWarnMids = array();
     $canWarnGids = array();
     $this->DB->build(array('select' => 'member_id, allow_warn', 'from' => 'moderators', 'where' => 'is_group=0'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $mids[$row['member_id']] = $row['member_id'];
         if ($row['allow_warn']) {
             $canWarnMids[] = $row['member_id'];
         }
     }
     $this->DB->build(array('select' => 'group_id', 'from' => 'moderators', 'where' => 'is_group=1 AND allow_warn=1'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $gids[] = $row['group_id'];
         $canWarnGids[] = $row['group_id'];
     }
     foreach ($this->caches['group_cache'] as $id => $row) {
         if ($row['g_is_supmod']) {
             $gids[] = $row['g_id'];
         }
     }
     /* Limit this because it could go a bit wrong innit */
     if (count($gids)) {
         $this->DB->build(array('select' => 'member_id', 'from' => 'members', 'where' => 'member_group_id IN (' . implode(',', $gids) . ')', 'limit' => array(0, 750)));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $mids[$row['member_id']] = $row['member_id'];
         }
     }
     $_mods = IPSMember::load($mids, 'all');
     if (count($_mods)) {
         foreach ($_mods as $id => $row) {
             if ($row['member_id'] == $this->memberData['member_id']) {
                 continue;
             }
             if ($row['g_is_supmod'] or in_array($row['member_id'], $canWarnMids) or in_array($row['member_group_id'], $canWarnGids)) {
                 $mods[$row['member_id']] = $row;
             }
         }
     }
     if (count($mods)) {
         $notifyLibrary = new $classToLoad($this->registry);
         $notifyLibrary->setMultipleRecipients($mods);
         $notifyLibrary->setFrom($this->memberData);
         $notifyLibrary->setNotificationKey('warning_mods');
         $notifyLibrary->setNotificationUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}");
         $notifyLibrary->setNotificationTitle(sprintf($this->lang->words['warnings_notify_mod'], $this->_member['members_display_name'], $this->registry->output->buildUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}"), $this->memberData['members_display_name']));
         $notifyLibrary->setNotificationText(sprintf($this->lang->words['warnings_notify_text_mod'], $this->_member['members_display_name'], $this->memberData['members_display_name'], $this->registry->output->buildUrl("app=members&module=profile&section=warnings&member={$this->_member['member_id']}")));
         try {
             $notifyLibrary->sendNotification();
         } catch (Exception $e) {
         }
     }
     //-----------------------------------------
     // Boink
     //-----------------------------------------
     if (empty($content['url'])) {
         $this->registry->getClass('output')->redirectScreen($this->lang->words['warnings_done'], $this->settings['base_url'] . 'app=members&amp;module=profile&amp;section=warnings&amp;member=' . $this->_member['member_id']);
     } else {
         $this->registry->getClass('output')->redirectScreen($this->lang->words['warnings_done'], $content['url']);
     }
 }
 /**
  * Custom Event: Add an announcement
  *
  * @access	private
  * @author	Matt Mecham
  * @return	void
  */
 private function _customEvent_modAnnounceSave($type = 'add')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $forums_to_save = "";
     $start_date = 0;
     $end_date = 0;
     $announce_id = intval($this->request['announce_id']);
     //-----------------------------------------
     // Check to see if we have access
     //-----------------------------------------
     if (!$this->memberData['g_is_supmod']) {
         $this->registry->getClass('output')->showError('announcements_supermods', 2031, true);
         return;
     }
     //-----------------------------------------
     // Turn off global form stuff
     //-----------------------------------------
     $this->hide_form_and_save_button = 1;
     //-----------------------------------------
     // check...
     //-----------------------------------------
     if (!$this->request['announce_title'] or !$this->request['announce_post']) {
         return $this->_customEvent_modAnnounceForm($type, $this->lang->words['announce_error_title']);
     }
     //-----------------------------------------
     // Get forums to add announce in
     //-----------------------------------------
     if (is_array($_POST['announce_forum']) and count($_POST['announce_forum'])) {
         if (in_array('*', $_POST['announce_forum'])) {
             $forums_to_save = '*';
         } else {
             $forums_to_save = implode(",", $_POST['announce_forum']);
         }
     }
     if (!$forums_to_save) {
         return $this->_customEvent_modAnnounceForm($type, $this->lang->words['announce_error_forums']);
     }
     //-----------------------------------------
     // Check Dates
     //-----------------------------------------
     if (strstr($this->request['announce_start'], '-')) {
         $start_array = explode('-', $this->request['announce_start']);
         if ($start_array[0] and $start_array[1] and $start_array[2]) {
             if (!checkdate($start_array[0], $start_array[1], $start_array[2])) {
                 return $this->_customEvent_modAnnounceForm($type, $this->lang->words['announce_error_date']);
             }
         }
         $start_date = IPSTime::date_gmmktime(0, 0, 1, $start_array[0], $start_array[1], $start_array[2]);
     }
     if (strstr($this->request['announce_end'], '-')) {
         $end_array = explode('-', $this->request['announce_end']);
         if ($end_array[0] and $end_array[1] and $end_array[2]) {
             if (!checkdate($end_array[0], $end_array[1], $end_array[2])) {
                 return $this->_customEvent_modAnnounceForm($type, $this->lang->words['announce_error_date']);
             }
         }
         $end_date = IPSTime::date_gmmktime(23, 59, 59, $end_array[0], $end_array[1], $end_array[2]);
     }
     //-----------------------------------------
     // Sort out the content
     //-----------------------------------------
     $announceContent = IPSText::getTextClass('editor')->processRawPost('announce_post');
     IPSText::getTextClass('bbcode')->bypass_badwords = 1;
     IPSText::getTextClass('bbcode')->parse_smilies = 1;
     IPSText::getTextClass('bbcode')->parse_html = $this->request['announce_html_enabled'] ? $this->request['announce_html_enabled'] : 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = $this->request['announce_nlbr_enabled'] ? $this->request['announce_nlbr_enabled'] : 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'announcement';
     //-----------------------------------------
     // Build save array
     //-----------------------------------------
     $save_array = array('announce_title' => $this->request['announce_title'], 'announce_post' => IPSText::getTextClass('bbcode')->preDbParse($announceContent), 'announce_active' => $this->request['announce_active'] ? $this->request['announce_active'] : 0, 'announce_forum' => $forums_to_save, 'announce_html_enabled' => $this->request['announce_html_enabled'] ? $this->request['announce_html_enabled'] : 0, 'announce_nlbr_enabled' => $this->request['announce_nlbr_enabled'] ? $this->request['announce_nlbr_enabled'] : 0, 'announce_start' => $start_date, 'announce_end' => $end_date);
     //-----------------------------------------
     // Save..
     //-----------------------------------------
     if ($type == 'add') {
         $save_array['announce_member_id'] = $this->memberData['member_id'];
         $this->DB->insert('announcements', $save_array);
     } else {
         if ($announce_id) {
             $this->DB->update('announcements', $save_array, 'announce_id=' . $announce_id);
         }
     }
     //-----------------------------------------
     // Update cache
     //-----------------------------------------
     $this->registry->cache()->rebuildCache('announcements', 'forums');
     $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . "app=core&amp;module=usercp&amp;tab=forums&amp;area=mod_announcements");
 }
Exemplo n.º 8
0
 /**
  * Feturn HTML block
  *
  * @param	array		Member information
  * @return	string		HTML block
  */
 public function return_html_block($member = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $content = '';
     $last_x = 5;
     $forumIdsOk = array(0 => 0);
     $date_cut = '';
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!is_array($member) or !count($member)) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     //-----------------------------------------
     // Some words
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_topic'), 'forums');
     //-----------------------------------------
     // Can view other member's topics?
     //-----------------------------------------
     if (!$this->memberData['g_other_topics'] and $this->memberData['member_id'] != $member['member_id']) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     /* Get list of good forum IDs */
     $forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds();
     //-----------------------------------------
     // Get last X posts
     //-----------------------------------------
     if (is_array($forumIdsOk) and count($forumIdsOk)) {
         /* Init vars */
         $pids = array();
         $parseAttachments = false;
         /* Set up joins */
         $_post_joins = array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'), array('select' => 'm.member_group_id, m.mgroup_others', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'));
         /* Cache? */
         if (IPSContentCache::isEnabled()) {
             if (IPSContentCache::fetchSettingValue('post')) {
                 $_post_joins[] = IPSContentCache::join('post', 'p.pid');
             }
         }
         if ($this->settings['search_ucontent_days']) {
             $_date_cut = ($member['last_post'] ? $member['last_post'] : time()) - 86400 * intval($this->settings['search_ucontent_days']);
             $date_cut = ' AND p.post_date > ' . $_date_cut;
         }
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), 'p.');
         $_approved = $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), 't.');
         /* Let's just run this if the member has posted within the cutoff period */
         if ($member['last_post'] > $_date_cut) {
             $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => $_queued . " AND " . $_approved . " AND p.author_id={$member['member_id']} AND p.new_topic=0 AND t.forum_id IN (" . implode(",", $forumIdsOk) . ") " . $date_cut, 'order' => 'p.pid DESC', 'limit' => array(0, $last_x), 'add_join' => $_post_joins));
             $o = $this->DB->execute();
             while ($row = $this->DB->fetch($o)) {
                 $pids[$row['pid']] = $row['pid'];
                 if ($row['topic_hasattach']) {
                     $parseAttachments = true;
                 }
                 if (!$row['cache_content']) {
                     IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
                     IPSText::getTextClass('bbcode')->parse_html = ($row['use_html'] and $this->caches['group_cache'][$row['member_group_id']]['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
                     IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
                     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
                     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                     IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
                     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
                     $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
                     IPSContentCache::update($row['pid'], 'post', $row['post']);
                 } else {
                     $row['post'] = $row['cache_content'];
                 }
                 $row['_post_date'] = ipsRegistry::getClass('class_localization')->getDate($row['post_date'], 'SHORT');
                 $row['_raw_date'] = $row['post_date'];
                 $row['_date_array'] = IPSTime::date_getgmdate($row['post_date'] + ipsRegistry::getClass('class_localization')->getTimeOffset());
                 $row['post'] .= "\n<!--IBF.ATTACHMENT_" . $row['pid'] . "-->";
                 $url = $this->registry->output->buildSEOUrl("showtopic={$row['topic_id']}&amp;view=findpost&amp;p={$row['pid']}", 'public', $row['title_seo'], 'showtopic');
                 $content .= $this->registry->getClass('output')->getTemplate('profile')->tabSingleColumn($row, $this->lang->words['profile_read_topic'], $url, $this->lang->words['profile_in_topic'] . $row['title']);
             }
             //-----------------------------------------
             // Attachments (but only if necessary)
             //-----------------------------------------
             if ($parseAttachments and !is_object($this->class_attach)) {
                 $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
                 $this->class_attach = new $classToLoad($this->registry);
                 $this->class_attach->type = 'post';
                 $this->class_attach->init();
                 if (IPSMember::checkPermissions('download') === false) {
                     $this->settings['show_img_upload'] = 0;
                 }
                 $content = $this->class_attach->renderAttachments($content, $pids);
                 $content = $content[0]['html'];
             }
             //-----------------------------------------
             // Macros...
             //-----------------------------------------
             $content = $this->registry->output->replaceMacros($content);
         }
     }
     //-----------------------------------------
     // Return content..
     //-----------------------------------------
     return $content ? $this->registry->getClass('output')->getTemplate('profile')->tabPosts($content) : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
 }
Exemplo n.º 9
0
 /**
  * Build A Chart
  */
 private function _buildChart($startTime)
 {
     //-----------------------------------------
     // Silly Timezones
     //-----------------------------------------
     $this->DB->setTimeZone($this->memberData['time_offset']);
     //-----------------------------------------
     // Init Graph
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classGraph.php';
     /*noLibHook*/
     $graph = new classGraph();
     $graph->options['font'] = DOC_IPS_ROOT_PATH . '/public/style_captcha/captcha_fonts/DejaVuSans.ttf';
     $graph->options['width'] = 800;
     $graph->options['height'] = 300;
     $graph->options['style3D'] = 0;
     $graph->options['charttype'] = 'Area';
     $graph->options['showgridlinesx'] = 0;
     $graph->options['showdatalabels'] = 0;
     $graph->options['title'] = '';
     $graph->options['showlegend'] = 0;
     //-----------------------------------------
     // Add Labels
     //-----------------------------------------
     $labels = array();
     if ($this->days == 1) {
         for (IPSTime::setTimestamp($startTime); IPSTime::getTimestamp() < time() + 3600; IPSTime::add_minutes(60)) {
             $labels[] = date('ga', IPSTime::getTimestamp());
         }
     } else {
         for (IPSTime::setTimestamp($startTime); IPSTime::getTimestamp() < time(); IPSTime::add_days(1)) {
             $labels[] = date('M j', IPSTime::getTimestamp());
         }
     }
     $graph->addLabels($labels);
     //-----------------------------------------
     // Return
     //-----------------------------------------
     return $graph;
 }
 /**
  * Generates mod options dropdown
  *
  * @access	protected
  * @param	array 	Topic data
  * @param	string	Type of form (new/edit/reply)
  * @return	string	HTML of dropdown box
  */
 protected function _generateModOptions($topic, $type = 'new')
 {
     /* INIT */
     $can_close = 0;
     $can_pin = 0;
     $can_unpin = 0;
     $can_open = 0;
     $can_move = 0;
     $html = "";
     $mytimes = array();
     //-----------------------------------------
     // Mod options
     //-----------------------------------------
     if ($type != 'edit') {
         if ($this->getAuthor('g_is_supmod')) {
             $can_close = 1;
             $can_open = 1;
             $can_pin = 1;
             $can_unpin = 1;
             $can_move = 1;
         } else {
             if ($this->getAuthor('member_id') != 0) {
                 if ($this->moderator['mid'] != "") {
                     if ($this->moderator['close_topic']) {
                         $can_close = 1;
                     }
                     if ($this->moderator['open_topic']) {
                         $can_open = 1;
                     }
                     if ($this->moderator['pin_topic']) {
                         $can_pin = 1;
                     }
                     if ($this->moderator['unpin_topic']) {
                         $can_unpin = 1;
                     }
                     if ($this->moderator['move_topic']) {
                         $can_move = 1;
                     }
                 }
             } else {
                 // Guest
                 return "";
             }
         }
         if (!($can_pin == 0 and $can_close == 0 and $can_move == 0)) {
             $selected = $this->getModOptions() == 'nowt' ? " selected='selected'" : '';
             $html = "<select id='forminput' name='mod_options' class='forminput'>\n<option value='nowt'{$selected}>" . $this->lang->words['mod_nowt'] . "</option>\n";
         }
         if ($can_pin and !$topic['pinned']) {
             $selected = $this->getModOptions() == 'pin' ? " selected='selected'" : '';
             $html .= "<option value='pin'{$selected}>" . $this->lang->words['mod_pin'] . "</option>";
         } else {
             if ($can_unpin and $topic['pinned']) {
                 $selected = $this->getModOptions() == 'unpin' ? " selected='selected'" : '';
                 $html .= "<option value='unpin'{$selected}>" . $this->lang->words['mod_unpin'] . "</option>";
             }
         }
         if ($can_close and ($topic['state'] == 'open' or !$topic['state'])) {
             $selected = $this->getModOptions() == 'close' ? " selected='selected'" : '';
             $html .= "<option value='close'{$selected}>" . $this->lang->words['mod_close'] . "</option>";
         } else {
             if ($can_open and $topic['state'] == 'closed') {
                 $selected = $this->getModOptions() == 'open' ? " selected='selected'" : '';
                 $html .= "<option value='open'{$selected}>" . $this->lang->words['mod_open'] . "</option>";
             }
         }
         if ($can_close and $can_pin and $topic['state'] == 'open' and !$topic['pinned']) {
             $selected = $this->getModOptions() == 'pinclose' ? " selected='selected'" : '';
             $html .= "<option value='pinclose'{$selected}>" . $this->lang->words['mod_pinclose'] . "</option>";
         } else {
             if ($can_open and $can_pin and $topic['state'] == 'closed' and !$topic['pinned']) {
                 $selected = $this->getModOptions() == 'pinopen' ? " selected='selected'" : '';
                 $html .= "<option value='pinopen'{$selected}>" . $this->lang->words['mod_pinopen'] . "</option>";
             } else {
                 if ($can_close and $can_unpin and $topic['state'] == 'open' and $topic['pinned']) {
                     $selected = $this->getModOptions() == 'unpinclose' ? " selected='selected'" : '';
                     $html .= "<option value='unpinclose'{$selected}>" . $this->lang->words['mod_unpinclose'] . "</option>";
                 } else {
                     if ($can_open and $can_unpin and $topic['state'] == 'closed' and $topic['pinned']) {
                         $selected = $this->getModOptions() == 'unpinopen' ? " selected='selected'" : '';
                         $html .= "<option value='unpinopen'{$selected}>" . $this->lang->words['mod_unpinopen'] . "</option>";
                     }
                 }
             }
         }
         if ($can_move and $type != 'new') {
             $selected = $this->getModOptions() == 'move' ? " selected='selected'" : '';
             $html .= "<option value='move'{$selected}>" . $this->lang->words['mod_move'] . "</option>";
         }
     }
     //-----------------------------------------
     // If we're replying, kill off time boxes
     //-----------------------------------------
     if ($type == 'reply') {
         $this->can_set_open_time = 0;
         $this->can_set_close_time = 0;
     } else {
         //-----------------------------------------
         // Check dates...
         //-----------------------------------------
         $mytimes['open_time'] = isset($_POST['open_time_time']) ? $_POST['open_time_time'] : '';
         $mytimes['open_date'] = isset($_POST['open_time_date']) ? $_POST['open_time_date'] : '';
         $mytimes['close_time'] = isset($_POST['close_time_time']) ? $_POST['close_time_time'] : '';
         $mytimes['close_date'] = isset($_POST['close_time_date']) ? $_POST['close_time_date'] : '';
         if ($this->_originalPost['new_topic']) {
             if (!isset($mytimes['open_date']) or !$mytimes['open_date']) {
                 if (isset($topic['topic_open_time']) and $topic['topic_open_time']) {
                     $date = IPSTime::unixstamp_to_human($topic['topic_open_time']);
                     $mytimes['open_date'] = sprintf("%02d/%02d/%04d", $date['month'], $date['day'], $date['year']);
                     $mytimes['open_time'] = sprintf("%02d:%02d", $date['hour'], $date['minute']);
                 }
             }
             if (!isset($mytimes['close_date']) or !$mytimes['close_date']) {
                 if (isset($topic['topic_close_time']) and $topic['topic_close_time']) {
                     $date = IPSTime::unixstamp_to_human($topic['topic_close_time']);
                     $mytimes['close_date'] = sprintf("%02d/%02d/%04d", $date['month'], $date['day'], $date['year']);
                     $mytimes['close_time'] = sprintf("%02d:%02d", $date['hour'], $date['minute']);
                 }
             }
         } else {
             if ($type != 'new') {
                 $this->can_set_open_time = 0;
                 $this->can_set_close_time = 0;
             }
         }
     }
     return array('dropDownOptions' => $html, 'canSetOpenTime' => $this->can_set_open_time, 'canSetCloseTime' => $this->can_set_close_time, 'myTimes' => $mytimes);
 }
 /**
  * Builds the html for the monthly events
  *
  * @access	public
  * @param	int		$month		Numeric value of the month to get events from
  * @param	int		$year		Year to get events from
  * @param	bool	$minical	Set to 1 if this is for the minicalendar
  * @return	string	Calendar HTML output
  */
 public function getMonthEvents($month, $year, $minical = 0)
 {
     //-----------------------------------------
     // Reset shown events
     //-----------------------------------------
     $this->shown_events = array();
     //-----------------------------------------
     // Work out timestamps
     //-----------------------------------------
     $our_datestamp = gmmktime(0, 0, 0, $month, 1, $year);
     $first_day_array = IPSTime::date_getgmdate($our_datestamp);
     if ($this->settings['ipb_calendar_mon']) {
         $first_day_array['wday'] = $first_day_array['wday'] == 0 ? 7 : $first_day_array['wday'];
     }
     //-----------------------------------------
     // Get the birthdays from the database
     //-----------------------------------------
     if ($this->settings['show_bday_calendar']) {
         $birthdays = array();
         $this->calendarGetBirthdaySQL($month);
         $birthdays = $this->query_bday_cache[$month];
     }
     //-----------------------------------------
     // Get the events
     //-----------------------------------------
     $this->calendarGetEventsSQL($month, $year);
     //-----------------------------------------
     // Get events
     //-----------------------------------------
     $seen_days = array();
     $seen_ids = array();
     $cal_output = "";
     $calendar_data = array();
     for ($c = 0; $c < 42; $c++) {
         //-----------------------------------------
         // Work out timestamps
         //-----------------------------------------
         $_year = gmdate('Y', $our_datestamp);
         $_month = gmdate('n', $our_datestamp);
         $_day = gmdate('j', $our_datestamp);
         $day_array = IPSTime::date_getgmdate($our_datestamp);
         $check_against = $c;
         if ($this->settings['ipb_calendar_mon']) {
             $check_against = $c + 1;
         }
         if ($c % 7 == 0) {
             //-----------------------------------------
             // Kill the loop if we are no longer on our month
             //-----------------------------------------
             if ($day_array['mon'] != $month) {
                 break;
             }
             if ($minical) {
                 $cal_output .= $this->registry->output->getTemplate('calendar')->mini_cal_new_row($our_datestamp);
             } else {
                 $cal_output .= $this->registry->output->getTemplate('calendar')->cal_new_row($our_datestamp);
             }
         }
         //-----------------------------------------
         // Run out of legal days for this month?
         // Or have we yet to get to the first day?
         //-----------------------------------------
         if ($check_against < $first_day_array['wday'] or $day_array['mon'] != $month) {
             $cal_output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_blank_cell() : $this->registry->output->getTemplate('calendar')->cal_blank_cell();
         } else {
             if (isset($seen_days[$day_array['yday']]) and $seen_days[$day_array['yday']] == 1) {
                 continue;
             }
             $seen_days[$day_array['yday']] = 1;
             $tmp_cevents = array();
             $this_day_events = "";
             $cal_date = $day_array['mday'];
             $queued_event = 0;
             $cal_date_queued = "";
             //-----------------------------------------
             // Get events
             //-----------------------------------------
             $events = $this->calendarGetDayEvents($_month, $_day, $_year);
             if (is_array($events) and count($events)) {
                 foreach ($events as $event) {
                     if (!isset($this->shown_events[$_month . '-' . $_day . '-' . $_year][$event['event_id']]) or !$this->shown_events[$_month . '-' . $_day . '-' . $_year][$event['event_id']]) {
                         //-----------------------------------------
                         // Recurring
                         //-----------------------------------------
                         if (isset($event['recurring'])) {
                             $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap_recurring($event);
                         } else {
                             if (isset($event['single'])) {
                                 $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap($event);
                             } else {
                                 $tmp_cevents[$event['event_id']] = $this->registry->output->getTemplate('calendar')->cal_events_wrap_range($event);
                             }
                         }
                         $this->shown_events[$_month . '-' . $_day . '-' . $_year][$event['event_id']] = 1;
                         //-----------------------------------------
                         // Queued events?
                         //-----------------------------------------
                         if (!$event['event_approved'] and $this->can_moderate) {
                             $queued_event = 1;
                         }
                     }
                 }
                 //-----------------------------------------
                 // How many events?
                 //-----------------------------------------
                 if (count($tmp_cevents) >= $this->calendar['cal_event_limit']) {
                     $this_day_events = $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual("cal_id={$this->calendar_id}&amp;do=showday&amp;y=" . $day_array['year'] . "&amp;m=" . $day_array['mon'] . "&amp;d=" . $day_array['mday'], sprintf($this->lang->words['show_n_events'], intval(count($tmp_cevents))));
                 } else {
                     if (count($tmp_cevents)) {
                         $this_day_events = implode("\n", $tmp_cevents);
                     }
                 }
                 $tmp_cevents[] = array();
             }
             //-----------------------------------------
             // Birthdays
             //-----------------------------------------
             if ($this->calendar['cal_bday_limit']) {
                 if (isset($birthdays[$day_array['mday']]) and count($birthdays[$day_array['mday']]) > 0) {
                     $no_bdays = count($birthdays[$day_array['mday']]);
                     if ($no_bdays) {
                         if ($this->calendar['cal_bday_limit'] and $no_bdays <= $this->calendar['cal_bday_limit']) {
                             foreach ($birthdays[$day_array['mday']] as $user) {
                                 $this_day_events .= $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual("cal_id={$this->calendar_id}&amp;do=birthdays&amp;y=" . $day_array['year'] . "&amp;m=" . $day_array['mon'] . "&amp;d=" . $day_array['mday'], $user['members_display_name'] . $this->lang->words['bd_birthday']);
                             }
                         } else {
                             $this_day_events .= $this->registry->output->getTemplate('calendar')->cal_events_wrap_manual("cal_id={$this->calendar_id}&amp;do=birthdays&amp;y=" . $day_array['year'] . "&amp;m=" . $day_array['mon'] . "&amp;d=" . $day_array['mday'], sprintf($this->lang->words['entry_birthdays'], $no_bdays));
                         }
                     }
                 }
             }
             //-----------------------------------------
             // Show it
             //-----------------------------------------
             if ($this_day_events != "") {
                 $cal_date = "<a href='" . $this->registry->getClass('output')->buildSEOUrl("app=calendar&amp;module=calendar&amp;cal_id={$this->calendar_id}&amp;do=showday&amp;y=" . $year . "&amp;m=" . $month . "&amp;d=" . $day_array['mday'], 'public', 'false', 'cal_day') . "'>{$day_array['mday']}</a>";
                 $cal_date_queued = "" . $this->settings['base_url'] . "app=calendar&amp;cal_id={$this->calendar_id}&amp;modfilter=queued&amp;do=showday&amp;y=" . $year . "&amp;m=" . $month . "&amp;d=" . $day_array['mday'];
                 $this_day_events = $this->registry->output->getTemplate('calendar')->cal_events_start() . $this_day_events . $this->registry->output->getTemplate('calendar')->cal_events_end();
             }
             if ($day_array['mday'] == $this->now_date['mday'] and $this->now_date['mon'] == $day_array['mon'] and $this->now_date['year'] == $day_array['year']) {
                 $cal_output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_date_cell_today($cal_date, $this_day_events) : $this->registry->output->getTemplate('calendar')->cal_date_cell_today($cal_date, $this_day_events, $cal_date_queued, $queued_event, $this->_buildDayID($this->chosen_year, $this->chosen_month, $_day));
             } else {
                 $cal_output .= $minical ? $this->registry->output->getTemplate('calendar')->mini_cal_date_cell($cal_date, $this_day_events) : $this->registry->output->getTemplate('calendar')->cal_date_cell($cal_date, $this_day_events, $cal_date_queued, $queued_event, $this->_buildDayID($this->chosen_year, $this->chosen_month, $_day));
             }
             unset($this_day_events);
             $our_datestamp += 86400;
         }
     }
     return $cal_output;
 }
 /**
  * Feturn HTML block
  *
  * @access	public
  * @param	array		Member information
  * @return	string		HTML block
  */
 public function return_html_block($member = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $content = '';
     $last_x = 5;
     $forum_ids = array();
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!is_array($member) or !count($member)) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     //-----------------------------------------
     // Some words
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_topic'), 'forums');
     //-----------------------------------------
     // Can view other member's topics?
     //-----------------------------------------
     if (!$this->memberData['g_other_topics'] and $this->memberData['member_id'] != $member['member_id']) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     //-----------------------------------------
     // Remove trash can...
     //-----------------------------------------
     $trash_can_remove = '';
     if ($this->settings['forum_trash_can_id']) {
         $trash_can_remove = ' AND i.perm_type_id <> ' . $this->settings['forum_trash_can_id'];
     }
     $pids = array();
     //-----------------------------------------
     // And limit by post count...
     //-----------------------------------------
     $posts = intval($this->memberData['posts']);
     $trash_can_remove .= " AND f.min_posts_view <= {$posts}";
     //-----------------------------------------
     // And "can view others"
     //-----------------------------------------
     $trash_can_remove .= " AND f.can_view_others=1";
     //-----------------------------------------
     // Will we need to parse attachments?
     //-----------------------------------------
     $parseAttachments = false;
     //-----------------------------------------
     // Get last X posts
     //-----------------------------------------
     $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => "p.queued=0 AND t.approved=1 AND p.author_id={$member['member_id']} AND p.new_topic=0 AND {$this->registry->permissions->buildPermQuery('i')} AND {$this->registry->permissions->buildPermQuery('i', 'perm_2')} {$trash_can_remove} AND (f.password='' OR f.password" . $this->DB->buildIsNull() . ")", 'order' => 'p.post_date DESC', 'limit' => array(0, $last_x), 'add_join' => array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'), array('from' => array('permission_index' => 'i'), 'where' => "i.perm_type='forum' AND i.perm_type_id=t.forum_id", 'type' => 'left'), array('select' => 'f.use_html', 'from' => array('forums' => 'f'), 'where' => 'f.id=t.forum_id', 'type' => 'left'), array('select' => 'm.member_group_id, m.mgroup_others', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'))));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         $pids[$row['pid']] = $row['pid'];
         if ($row['topic_hasattach']) {
             $parseAttachments = true;
         }
         IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
         IPSText::getTextClass('bbcode')->parse_html = ($row['use_html'] and $this->memberData['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
         $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
         $row['post'] = IPSText::getTextClass('bbcode')->memberViewImages($row['post']);
         $row['_post_date'] = ipsRegistry::getClass('class_localization')->getDate($row['post_date'], 'SHORT');
         $row['_date_array'] = IPSTime::date_getgmdate($row['post_date'] + ipsRegistry::getClass('class_localization')->getTimeOffset());
         $row['post'] .= "\n<!--IBF.ATTACHMENT_" . $row['pid'] . "-->";
         $content .= $this->registry->getClass('output')->getTemplate('profile')->tabSingleColumn($row, $this->lang->words['profile_read_topic'], $this->settings['base_url'] . 'app=forums&amp;module=forums&amp;section=findpost&amp;pid=' . $row['pid'], $this->lang->words['profile_in_topic'] . $row['title']);
     }
     //-----------------------------------------
     // Attachments (but only if necessary)
     //-----------------------------------------
     if ($parseAttachments and !is_object($this->class_attach)) {
         require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
         $this->class_attach = new class_attach($this->registry);
         $this->class_attach->type = 'post';
         $this->class_attach->init();
         if (IPSMember::checkPermissions('download') === false) {
             $this->settings['show_img_upload'] = 0;
         }
         $content = $this->class_attach->renderAttachments($content, $pids);
         $content = $content[0]['html'];
     }
     //-----------------------------------------
     // Macros...
     //-----------------------------------------
     $content = $this->registry->output->replaceMacros($content);
     //-----------------------------------------
     // Return content..
     //-----------------------------------------
     return $content ? $this->registry->getClass('output')->getTemplate('profile')->tabPosts($content) : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
 }