/** * 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); }