| @@ 405-425 (lines=21) @@ | ||
| 402 | if ($this->use_permission === true) { |
|
| 403 | $xt = new MyXoopsTree($this->table, 'topic_id', 'topic_pid'); |
|
| 404 | $parent_topics = $xt->getAllParentId($this->topic_id); |
|
| 405 | if (!empty($this->m_groups) && is_array($this->m_groups)) { |
|
| 406 | foreach ($this->m_groups as $m_g) { |
|
| 407 | $moderate_topics = XoopsPerms::getPermitted($this->mid, 'ModInTopic', $m_g); |
|
| 408 | $add = true; |
|
| 409 | // only grant this permission when the group has this permission in all parent topics of the created topic |
|
| 410 | foreach ($parent_topics as $p_topic) { |
|
| 411 | if (!in_array($p_topic, $moderate_topics)) { |
|
| 412 | $add = false; |
|
| 413 | continue; |
|
| 414 | } |
|
| 415 | } |
|
| 416 | if ($add === true) { |
|
| 417 | $xp = new XoopsPerms(); |
|
| 418 | $xp->setModuleId($this->mid); |
|
| 419 | $xp->setName('ModInTopic'); |
|
| 420 | $xp->setItemId($this->topic_id); |
|
| 421 | $xp->store(); |
|
| 422 | $xp->addGroup($m_g); |
|
| 423 | } |
|
| 424 | } |
|
| 425 | } |
|
| 426 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 427 | foreach ($this->s_groups as $s_g) { |
|
| 428 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| @@ 426-445 (lines=20) @@ | ||
| 423 | } |
|
| 424 | } |
|
| 425 | } |
|
| 426 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 427 | foreach ($this->s_groups as $s_g) { |
|
| 428 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| 429 | $add = true; |
|
| 430 | foreach ($parent_topics as $p_topic) { |
|
| 431 | if (!in_array($p_topic, $submit_topics)) { |
|
| 432 | $add = false; |
|
| 433 | continue; |
|
| 434 | } |
|
| 435 | } |
|
| 436 | if ($add === true) { |
|
| 437 | $xp = new XoopsPerms(); |
|
| 438 | $xp->setModuleId($this->mid); |
|
| 439 | $xp->setName('SubmitInTopic'); |
|
| 440 | $xp->setItemId($this->topic_id); |
|
| 441 | $xp->store(); |
|
| 442 | $xp->addGroup($s_g); |
|
| 443 | } |
|
| 444 | } |
|
| 445 | } |
|
| 446 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 447 | foreach ($this->s_groups as $r_g) { |
|
| 448 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| @@ 446-465 (lines=20) @@ | ||
| 443 | } |
|
| 444 | } |
|
| 445 | } |
|
| 446 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 447 | foreach ($this->s_groups as $r_g) { |
|
| 448 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| 449 | $add = true; |
|
| 450 | foreach ($parent_topics as $p_topic) { |
|
| 451 | if (!in_array($p_topic, $read_topics)) { |
|
| 452 | $add = false; |
|
| 453 | continue; |
|
| 454 | } |
|
| 455 | } |
|
| 456 | if ($add === true) { |
|
| 457 | $xp = new XoopsPerms(); |
|
| 458 | $xp->setModuleId($this->mid); |
|
| 459 | $xp->setName('ReadInTopic'); |
|
| 460 | $xp->setItemId($this->topic_id); |
|
| 461 | $xp->store(); |
|
| 462 | $xp->addGroup($r_g); |
|
| 463 | } |
|
| 464 | } |
|
| 465 | } |
|
| 466 | } |
|
| 467 | ||
| 468 | return true; |
|
| @@ 144-164 (lines=21) @@ | ||
| 141 | } |
|
| 142 | $xt = new MyXoopsTree($this->table, 'topic_id', 'topic_pid'); |
|
| 143 | $parent_topics = $xt->getAllParentId($this->topic_id); |
|
| 144 | if (!empty($this->m_groups) && is_array($this->m_groups)) { |
|
| 145 | foreach ($this->m_groups as $m_g) { |
|
| 146 | $moderate_topics = XoopsPerms::getPermitted($this->mid, 'ModInTopic', $m_g); |
|
| 147 | $add = true; |
|
| 148 | // only grant this permission when the group has this permission in all parent topics of the created topic |
|
| 149 | foreach ($parent_topics as $p_topic) { |
|
| 150 | if (!in_array($p_topic, $moderate_topics)) { |
|
| 151 | $add = false; |
|
| 152 | continue; |
|
| 153 | } |
|
| 154 | } |
|
| 155 | if ($add == true) { |
|
| 156 | $xp = new XoopsPerms(); |
|
| 157 | $xp->setModuleId($this->mid); |
|
| 158 | $xp->setName('ModInTopic'); |
|
| 159 | $xp->setItemId($this->topic_id); |
|
| 160 | $xp->store(); |
|
| 161 | $xp->addGroup($m_g); |
|
| 162 | } |
|
| 163 | } |
|
| 164 | } |
|
| 165 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 166 | foreach ($s_groups as $s_g) { |
|
| 167 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| @@ 165-184 (lines=20) @@ | ||
| 162 | } |
|
| 163 | } |
|
| 164 | } |
|
| 165 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 166 | foreach ($s_groups as $s_g) { |
|
| 167 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| 168 | $add = true; |
|
| 169 | foreach ($parent_topics as $p_topic) { |
|
| 170 | if (!in_array($p_topic, $submit_topics)) { |
|
| 171 | $add = false; |
|
| 172 | continue; |
|
| 173 | } |
|
| 174 | } |
|
| 175 | if ($add == true) { |
|
| 176 | $xp = new XoopsPerms(); |
|
| 177 | $xp->setModuleId($this->mid); |
|
| 178 | $xp->setName('SubmitInTopic'); |
|
| 179 | $xp->setItemId($this->topic_id); |
|
| 180 | $xp->store(); |
|
| 181 | $xp->addGroup($s_g); |
|
| 182 | } |
|
| 183 | } |
|
| 184 | } |
|
| 185 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 186 | foreach ($r_groups as $r_g) { |
|
| 187 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| @@ 185-204 (lines=20) @@ | ||
| 182 | } |
|
| 183 | } |
|
| 184 | } |
|
| 185 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 186 | foreach ($r_groups as $r_g) { |
|
| 187 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| 188 | $add = true; |
|
| 189 | foreach ($parent_topics as $p_topic) { |
|
| 190 | if (!in_array($p_topic, $read_topics)) { |
|
| 191 | $add = false; |
|
| 192 | continue; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | if ($add == true) { |
|
| 196 | $xp = new XoopsPerms(); |
|
| 197 | $xp->setModuleId($this->mid); |
|
| 198 | $xp->setName('ReadInTopic'); |
|
| 199 | $xp->setItemId($this->topic_id); |
|
| 200 | $xp->store(); |
|
| 201 | $xp->addGroup($r_g); |
|
| 202 | } |
|
| 203 | } |
|
| 204 | } |
|
| 205 | } |
|
| 206 | ||
| 207 | return true; |
|