Code Duplication    Length = 18-18 lines in 3 locations

class/Utility.php 3 locations

@@ 338-355 (lines=18) @@
335
     * @param  integer $itemID : faqid on which we are setting permissions
336
     * @return boolean : TRUE if the no errors occured
337
     */
338
    public static function saveItemPermissions($groups, $itemID)
339
    {
340
        $result      = true;
341
        $smartModule = self::getModuleInfo();
342
        $module_id   = $smartModule->getVar('mid');
343
344
        $gpermHandler = xoops_getHandler('groupperm');
345
        // First, if the permissions are already there, delete them
346
        $gpermHandler->deleteByModule($module_id, 'item_read', $itemID);
347
        // Save the new permissions
348
        if (count($groups) > 0) {
349
            foreach ($groups as $group_id) {
350
                $gpermHandler->addRight('item_read', $itemID, $group_id, $module_id);
351
            }
352
        }
353
354
        return $result;
355
    }
356
357
    /**
358
     * Saves permissions for the selected category
@@ 368-385 (lines=18) @@
365
     * @return boolean : TRUE if the no errors occured
366
     */
367
368
    public static function saveCategoryPermissions($groups, $categoryid, $perm_name)
369
    {
370
        $result      = true;
371
        $smartModule = self::getModuleInfo();
372
        $module_id   = $smartModule->getVar('mid');
373
374
        $gpermHandler = xoops_getHandler('groupperm');
375
        // First, if the permissions are already there, delete them
376
        $gpermHandler->deleteByModule($module_id, $perm_name, $categoryid);
377
        // Save the new permissions
378
        if (count($groups) > 0) {
379
            foreach ($groups as $group_id) {
380
                $gpermHandler->addRight($perm_name, $categoryid, $group_id, $module_id);
381
            }
382
        }
383
384
        return $result;
385
    }
386
387
    /**
388
     * Saves permissions for the selected category
@@ 397-414 (lines=18) @@
394
     * @return boolean : TRUE if the no errors occured
395
     */
396
397
    public static function saveModerators($moderators, $categoryid)
398
    {
399
        $result      = true;
400
        $smartModule = self::getModuleInfo();
401
        $module_id   = $smartModule->getVar('mid');
402
403
        $gpermHandler = xoops_getHandler('groupperm');
404
        // First, if the permissions are already there, delete them
405
        $gpermHandler->deleteByModule($module_id, 'category_moderation', $categoryid);
406
        // Save the new permissions
407
        if (count($moderators) > 0) {
408
            foreach ($moderators as $uid) {
409
                $gpermHandler->addRight('category_moderation', $categoryid, $uid, $module_id);
410
            }
411
        }
412
413
        return $result;
414
    }
415
416
    /**
417
     * @param  int $faqid