| @@ 372-392 (lines=21) @@ | ||
| 369 | if ($this->use_permission == true) { |
|
| 370 | $xt = new MyXoopsTree($this->table, 'topic_id', 'topic_pid'); |
|
| 371 | $parent_topics = $xt->getAllParentId($this->topic_id); |
|
| 372 | if (!empty($this->m_groups) && is_array($this->m_groups)) { |
|
| 373 | foreach ($this->m_groups as $m_g) { |
|
| 374 | $moderate_topics = XoopsPerms::getPermitted($this->mid, 'ModInTopic', $m_g); |
|
| 375 | $add = true; |
|
| 376 | // only grant this permission when the group has this permission in all parent topics of the created topic |
|
| 377 | foreach ($parent_topics as $p_topic) { |
|
| 378 | if (!in_array($p_topic, $moderate_topics)) { |
|
| 379 | $add = false; |
|
| 380 | continue; |
|
| 381 | } |
|
| 382 | } |
|
| 383 | if ($add == true) { |
|
| 384 | $xp = new XoopsPerms(); |
|
| 385 | $xp->setModuleId($this->mid); |
|
| 386 | $xp->setName('ModInTopic'); |
|
| 387 | $xp->setItemId($this->topic_id); |
|
| 388 | $xp->store(); |
|
| 389 | $xp->addGroup($m_g); |
|
| 390 | } |
|
| 391 | } |
|
| 392 | } |
|
| 393 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 394 | foreach ($this->s_groups as $s_g) { |
|
| 395 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| @@ 393-412 (lines=20) @@ | ||
| 390 | } |
|
| 391 | } |
|
| 392 | } |
|
| 393 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 394 | foreach ($this->s_groups as $s_g) { |
|
| 395 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| 396 | $add = true; |
|
| 397 | foreach ($parent_topics as $p_topic) { |
|
| 398 | if (!in_array($p_topic, $submit_topics)) { |
|
| 399 | $add = false; |
|
| 400 | continue; |
|
| 401 | } |
|
| 402 | } |
|
| 403 | if ($add == true) { |
|
| 404 | $xp = new XoopsPerms(); |
|
| 405 | $xp->setModuleId($this->mid); |
|
| 406 | $xp->setName('SubmitInTopic'); |
|
| 407 | $xp->setItemId($this->topic_id); |
|
| 408 | $xp->store(); |
|
| 409 | $xp->addGroup($s_g); |
|
| 410 | } |
|
| 411 | } |
|
| 412 | } |
|
| 413 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 414 | foreach ($this->s_groups as $r_g) { |
|
| 415 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| @@ 413-432 (lines=20) @@ | ||
| 410 | } |
|
| 411 | } |
|
| 412 | } |
|
| 413 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 414 | foreach ($this->s_groups as $r_g) { |
|
| 415 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| 416 | $add = true; |
|
| 417 | foreach ($parent_topics as $p_topic) { |
|
| 418 | if (!in_array($p_topic, $read_topics)) { |
|
| 419 | $add = false; |
|
| 420 | continue; |
|
| 421 | } |
|
| 422 | } |
|
| 423 | if ($add == true) { |
|
| 424 | $xp = new XoopsPerms(); |
|
| 425 | $xp->setModuleId($this->mid); |
|
| 426 | $xp->setName('ReadInTopic'); |
|
| 427 | $xp->setItemId($this->topic_id); |
|
| 428 | $xp->store(); |
|
| 429 | $xp->addGroup($r_g); |
|
| 430 | } |
|
| 431 | } |
|
| 432 | } |
|
| 433 | } |
|
| 434 | ||
| 435 | return true; |
|
| @@ 142-162 (lines=21) @@ | ||
| 139 | } |
|
| 140 | $xt = new MyXoopsTree($this->table, 'topic_id', 'topic_pid'); |
|
| 141 | $parent_topics = $xt->getAllParentId($this->topic_id); |
|
| 142 | if (!empty($this->m_groups) && is_array($this->m_groups)) { |
|
| 143 | foreach ($this->m_groups as $m_g) { |
|
| 144 | $moderate_topics = XoopsPerms::getPermitted($this->mid, 'ModInTopic', $m_g); |
|
| 145 | $add = true; |
|
| 146 | // only grant this permission when the group has this permission in all parent topics of the created topic |
|
| 147 | foreach ($parent_topics as $p_topic) { |
|
| 148 | if (!in_array($p_topic, $moderate_topics)) { |
|
| 149 | $add = false; |
|
| 150 | continue; |
|
| 151 | } |
|
| 152 | } |
|
| 153 | if ($add == true) { |
|
| 154 | $xp = new XoopsPerms(); |
|
| 155 | $xp->setModuleId($this->mid); |
|
| 156 | $xp->setName('ModInTopic'); |
|
| 157 | $xp->setItemId($this->topic_id); |
|
| 158 | $xp->store(); |
|
| 159 | $xp->addGroup($m_g); |
|
| 160 | } |
|
| 161 | } |
|
| 162 | } |
|
| 163 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 164 | foreach ($s_groups as $s_g) { |
|
| 165 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| @@ 163-182 (lines=20) @@ | ||
| 160 | } |
|
| 161 | } |
|
| 162 | } |
|
| 163 | if (!empty($this->s_groups) && is_array($this->s_groups)) { |
|
| 164 | foreach ($s_groups as $s_g) { |
|
| 165 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
|
| 166 | $add = true; |
|
| 167 | foreach ($parent_topics as $p_topic) { |
|
| 168 | if (!in_array($p_topic, $submit_topics)) { |
|
| 169 | $add = false; |
|
| 170 | continue; |
|
| 171 | } |
|
| 172 | } |
|
| 173 | if ($add == true) { |
|
| 174 | $xp = new XoopsPerms(); |
|
| 175 | $xp->setModuleId($this->mid); |
|
| 176 | $xp->setName('SubmitInTopic'); |
|
| 177 | $xp->setItemId($this->topic_id); |
|
| 178 | $xp->store(); |
|
| 179 | $xp->addGroup($s_g); |
|
| 180 | } |
|
| 181 | } |
|
| 182 | } |
|
| 183 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 184 | foreach ($r_groups as $r_g) { |
|
| 185 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| @@ 183-202 (lines=20) @@ | ||
| 180 | } |
|
| 181 | } |
|
| 182 | } |
|
| 183 | if (!empty($this->r_groups) && is_array($this->r_groups)) { |
|
| 184 | foreach ($r_groups as $r_g) { |
|
| 185 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
|
| 186 | $add = true; |
|
| 187 | foreach ($parent_topics as $p_topic) { |
|
| 188 | if (!in_array($p_topic, $read_topics)) { |
|
| 189 | $add = false; |
|
| 190 | continue; |
|
| 191 | } |
|
| 192 | } |
|
| 193 | if ($add == true) { |
|
| 194 | $xp = new XoopsPerms(); |
|
| 195 | $xp->setModuleId($this->mid); |
|
| 196 | $xp->setName('ReadInTopic'); |
|
| 197 | $xp->setItemId($this->topic_id); |
|
| 198 | $xp->store(); |
|
| 199 | $xp->addGroup($r_g); |
|
| 200 | } |
|
| 201 | } |
|
| 202 | } |
|
| 203 | } |
|
| 204 | ||
| 205 | return true; |
|