21 if (!defined(
'XOOPS_ROOT_PATH')) {
24 $GLOBALS[
'xoopsLogger']->addDeprecated(
"'/class/xoopstopic.php' is deprecated since XOOPS 2.5.4, please create your own class instead.");
26 include_once XOOPS_ROOT_PATH .
'/class/xoopstree.php';
43 if (is_array($topicid)) {
45 }
else if ($topicid != 0) {
69 $topicid = intval($topicid);
70 $sql =
"SELECT * FROM ".$this->table.
" WHERE topic_id=" . $topicid .
"";
71 $array = $this->db->fetchArray($this->db->query(
$sql));
77 foreach($array as $key => $value){
85 $this->use_permission =
true;
103 $this->
topic_id = $this->db->genId($this->table.
"_topic_id_seq");
104 $sql = sprintf(
"INSERT INTO %s (topic_id, topic_pid, topic_imgurl, topic_title) VALUES (%u, %u, '%s', '%s')", $this->table, $this->
topic_id, $this->
topic_pid, $imgurl,
$title);
106 $sql = sprintf(
"UPDATE %s SET topic_pid = %u, topic_imgurl = '%s', topic_title = '%s' WHERE topic_id = %u", $this->table, $this->
topic_pid, $imgurl,
$title, $this->
topic_id);
111 if ($this->use_permission ==
true) {
113 $this->
topic_id = $this->db->getInsertId();
115 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
116 $parent_topics = $xt->getAllParentId($this->
topic_id);
117 if (!empty($this->m_groups) && is_array($this->m_groups)){
118 foreach ($this->m_groups as $m_g) {
119 $moderate_topics = XoopsPerms::getPermitted($this->mid,
"ModInTopic", $m_g);
122 foreach ($parent_topics as $p_topic) {
123 if (!in_array($p_topic, $moderate_topics)) {
129 $xp =
new XoopsPerms();
130 $xp->setModuleId($this->mid);
131 $xp->setName(
"ModInTopic");
138 if (!empty($this->s_groups) && is_array($this->s_groups)){
139 foreach ($s_groups as $s_g) {
140 $submit_topics = XoopsPerms::getPermitted($this->mid,
"SubmitInTopic", $s_g);
142 foreach ($parent_topics as $p_topic) {
143 if (!in_array($p_topic, $submit_topics)) {
149 $xp =
new XoopsPerms();
150 $xp->setModuleId($this->mid);
151 $xp->setName(
"SubmitInTopic");
158 if (!empty($this->r_groups) && is_array($this->r_groups)){
159 foreach ($r_groups as $r_g) {
160 $read_topics = XoopsPerms::getPermitted($this->mid,
"ReadInTopic", $r_g);
162 foreach ($parent_topics as $p_topic) {
163 if (!in_array($p_topic, $read_topics)) {
169 $xp =
new XoopsPerms();
170 $xp->setModuleId($this->mid);
171 $xp->setName(
"ReadInTopic");
184 $sql = sprintf(
"DELETE FROM %s WHERE topic_id = %u", $this->table, $this->
topic_id);
185 $this->db->query(
$sql);
208 $title =
$myts->htmlSpecialChars(
$myts->stripSlashesGPC($this->topic_title));
224 $imgurl =
$myts->htmlSpecialChars(
$myts->stripSlashesGPC($this->topic_imgurl));
232 if (isset($this->
prefix)) {
240 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
241 $topic_arr = $xt->getFirstChild($this->
topic_id,
"topic_title");
242 if (is_array($topic_arr) && count($topic_arr)) {
243 foreach ($topic_arr as $topic) {
253 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
254 $topic_arr = $xt->getAllChild($this->
topic_id,
"topic_title");
255 if (is_array($topic_arr) && count($topic_arr)) {
256 foreach ($topic_arr as $topic) {
266 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
267 $topic_arr = $xt->getChildTreeArray($this->
topic_id,
"topic_title");
268 if (is_array($topic_arr) && count($topic_arr)) {
269 foreach ($topic_arr as $topic) {
278 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
279 if ($seltopic != -1) {
280 $xt->makeMySelBox(
"topic_title",
"topic_title", $seltopic, $none, $selname, $onchange);
281 }
else if (!empty($this->
topic_id)) {
282 $xt->makeMySelBox(
"topic_title",
"topic_title", $this->
topic_id, $none, $selname, $onchange);
284 $xt->makeMySelBox(
"topic_title",
"topic_title", 0, $none, $selname, $onchange);
291 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
292 $ret = $xt->getNicePathFromId($this->
topic_id,
"topic_title", $funcURL);
298 $xt =
new XoopsTree($this->table,
"topic_id",
"topic_pid");
299 $ret = $xt->getAllChildId($this->
topic_id,
"topic_title");
305 $result = $this->db->query(
'SELECT topic_id, topic_pid, topic_title FROM '.$this->table);
308 while ($myrow = $this->db->fetchArray(
$result)) {
309 $ret[$myrow[
'topic_id']] = array(
'title' =>
$myts->htmlspecialchars($myrow[
'topic_title']),
'pid' => $myrow[
'topic_pid']);
315 $sql =
"SELECT COUNT(*) from ".$this->table.
" WHERE topic_pid = " . intval($pid) .
" AND topic_title = '".trim(
$title).
"'";
317 list($count) = $this->db->fetchRow(
$rs);