| @@ 144-164 (lines=21) @@ | ||
| 141 | } |
|
| 142 | $xt = new XoopsTree($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; |
|