@@ 211-248 (lines=38) @@ | ||
208 | * @param $permissionName |
|
209 | * @param $mid |
|
210 | */ |
|
211 | function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid) |
|
212 | { |
|
213 | $permissionArray = $myArray; |
|
214 | if ($id > 0) { |
|
215 | $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;"; |
|
216 | $GLOBALS['xoopsDB']->query($sql); |
|
217 | } |
|
218 | //admin |
|
219 | $gperm = $gpermHandler->create(); |
|
220 | $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN); |
|
221 | $gperm->setVar('gperm_name', $permissionName); |
|
222 | $gperm->setVar('gperm_modid', $mid); |
|
223 | $gperm->setVar('gperm_itemid', $id); |
|
224 | $gpermHandler->insert($gperm); |
|
225 | unset($gperm); |
|
226 | //non-Admin groups |
|
227 | if (is_array($permissionArray)) { |
|
228 | foreach ($permissionArray as $key => $cat_groupperm) { |
|
229 | if ($cat_groupperm > 0) { |
|
230 | $gperm = $gpermHandler->create(); |
|
231 | $gperm->setVar('gperm_groupid', $cat_groupperm); |
|
232 | $gperm->setVar('gperm_name', $permissionName); |
|
233 | $gperm->setVar('gperm_modid', $mid); |
|
234 | $gperm->setVar('gperm_itemid', $id); |
|
235 | $gpermHandler->insert($gperm); |
|
236 | unset($gperm); |
|
237 | } |
|
238 | } |
|
239 | } elseif ($permissionArray > 0) { |
|
240 | $gperm = $gpermHandler->create(); |
|
241 | $gperm->setVar('gperm_groupid', $permissionArray); |
|
242 | $gperm->setVar('gperm_name', $permissionName); |
|
243 | $gperm->setVar('gperm_modid', $mid); |
|
244 | $gperm->setVar('gperm_itemid', $id); |
|
245 | $gpermHandler->insert($gperm); |
|
246 | unset($gperm); |
|
247 | } |
|
248 | } |
|
249 | ||
250 | //setPermissions for View items |
|
251 | $permissionGroup = 'groupsRead'; |
@@ 226-263 (lines=38) @@ | ||
223 | * @param $permissionName |
|
224 | * @param $mid |
|
225 | */ |
|
226 | function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid) |
|
227 | { |
|
228 | $permissionArray = $myArray; |
|
229 | if ($id > 0) { |
|
230 | $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;"; |
|
231 | $GLOBALS['xoopsDB']->query($sql); |
|
232 | } |
|
233 | //admin |
|
234 | $gperm = $gpermHandler->create(); |
|
235 | $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN); |
|
236 | $gperm->setVar('gperm_name', $permissionName); |
|
237 | $gperm->setVar('gperm_modid', $mid); |
|
238 | $gperm->setVar('gperm_itemid', $id); |
|
239 | $gpermHandler->insert($gperm); |
|
240 | unset($gperm); |
|
241 | //non-Admin groups |
|
242 | if (is_array($permissionArray)) { |
|
243 | foreach ($permissionArray as $key => $cat_groupperm) { |
|
244 | if ($cat_groupperm > 0) { |
|
245 | $gperm = $gpermHandler->create(); |
|
246 | $gperm->setVar('gperm_groupid', $cat_groupperm); |
|
247 | $gperm->setVar('gperm_name', $permissionName); |
|
248 | $gperm->setVar('gperm_modid', $mid); |
|
249 | $gperm->setVar('gperm_itemid', $id); |
|
250 | $gpermHandler->insert($gperm); |
|
251 | unset($gperm); |
|
252 | } |
|
253 | } |
|
254 | } elseif ($permissionArray > 0) { |
|
255 | $gperm = $gpermHandler->create(); |
|
256 | $gperm->setVar('gperm_groupid', $permissionArray); |
|
257 | $gperm->setVar('gperm_name', $permissionName); |
|
258 | $gperm->setVar('gperm_modid', $mid); |
|
259 | $gperm->setVar('gperm_itemid', $id); |
|
260 | $gpermHandler->insert($gperm); |
|
261 | unset($gperm); |
|
262 | } |
|
263 | } |
|
264 | ||
265 | //setPermissions for View items |
|
266 | $permissionGroup = 'groupsRead'; |