Code Duplication    Length = 18-18 lines in 6 locations

include/functions.php 3 locations

@@ 328-345 (lines=18) @@
325
 * @param  integer $itemID : faqid on which we are setting permissions
326
 * @return boolean : TRUE if the no errors occured
327
 */
328
function sf_saveItemPermissions($groups, $itemID)
329
{
330
    $result      = true;
331
    $smartModule = sf_getModuleInfo();
332
    $module_id   = $smartModule->getVar('mid');
333
334
    $gpermHandler = xoops_getHandler('groupperm');
335
    // First, if the permissions are already there, delete them
336
    $gpermHandler->deleteByModule($module_id, 'item_read', $itemID);
337
    // Save the new permissions
338
    if (count($groups) > 0) {
339
        foreach ($groups as $group_id) {
340
            $gpermHandler->addRight('item_read', $itemID, $group_id, $module_id);
341
        }
342
    }
343
344
    return $result;
345
}
346
347
/**
348
 * Saves permissions for the selected category
@@ 358-375 (lines=18) @@
355
 * @return boolean : TRUE if the no errors occured
356
 */
357
358
function sf_saveCategory_Permissions($groups, $categoryid, $perm_name)
359
{
360
    $result      = true;
361
    $smartModule = sf_getModuleInfo();
362
    $module_id   = $smartModule->getVar('mid');
363
364
    $gpermHandler = xoops_getHandler('groupperm');
365
    // First, if the permissions are already there, delete them
366
    $gpermHandler->deleteByModule($module_id, $perm_name, $categoryid);
367
    // Save the new permissions
368
    if (count($groups) > 0) {
369
        foreach ($groups as $group_id) {
370
            $gpermHandler->addRight($perm_name, $categoryid, $group_id, $module_id);
371
        }
372
    }
373
374
    return $result;
375
}
376
377
/**
378
 * Saves permissions for the selected category
@@ 387-404 (lines=18) @@
384
 * @return boolean : TRUE if the no errors occured
385
 */
386
387
function sf_saveModerators($moderators, $categoryid)
388
{
389
    $result      = true;
390
    $smartModule = sf_getModuleInfo();
391
    $module_id   = $smartModule->getVar('mid');
392
393
    $gpermHandler = xoops_getHandler('groupperm');
394
    // First, if the permissions are already there, delete them
395
    $gpermHandler->deleteByModule($module_id, 'category_moderation', $categoryid);
396
    // Save the new permissions
397
    if (count($moderators) > 0) {
398
        foreach ($moderators as $uid) {
399
            $gpermHandler->addRight('category_moderation', $categoryid, $uid, $module_id);
400
        }
401
    }
402
403
    return $result;
404
}
405
406
/**
407
 * @param  int $faqid

class/utility.php 3 locations

@@ 468-485 (lines=18) @@
465
     * @param  integer $itemID : faqid on which we are setting permissions
466
     * @return boolean : TRUE if the no errors occured
467
     */
468
    public static function sf_saveItemPermissions($groups, $itemID)
469
    {
470
        $result      = true;
471
        $smartModule = sf_getModuleInfo();
472
        $module_id   = $smartModule->getVar('mid');
473
474
        $gpermHandler = xoops_getHandler('groupperm');
475
        // First, if the permissions are already there, delete them
476
        $gpermHandler->deleteByModule($module_id, 'item_read', $itemID);
477
        // Save the new permissions
478
        if (count($groups) > 0) {
479
            foreach ($groups as $group_id) {
480
                $gpermHandler->addRight('item_read', $itemID, $group_id, $module_id);
481
            }
482
        }
483
484
        return $result;
485
    }
486
487
    /**
488
     * Saves permissions for the selected category
@@ 498-515 (lines=18) @@
495
     * @return boolean : TRUE if the no errors occured
496
     */
497
498
    public static function sf_saveCategory_Permissions($groups, $categoryid, $perm_name)
499
    {
500
        $result      = true;
501
        $smartModule = sf_getModuleInfo();
502
        $module_id   = $smartModule->getVar('mid');
503
504
        $gpermHandler = xoops_getHandler('groupperm');
505
        // First, if the permissions are already there, delete them
506
        $gpermHandler->deleteByModule($module_id, $perm_name, $categoryid);
507
        // Save the new permissions
508
        if (count($groups) > 0) {
509
            foreach ($groups as $group_id) {
510
                $gpermHandler->addRight($perm_name, $categoryid, $group_id, $module_id);
511
            }
512
        }
513
514
        return $result;
515
    }
516
517
    /**
518
     * Saves permissions for the selected category
@@ 527-544 (lines=18) @@
524
     * @return boolean : TRUE if the no errors occured
525
     */
526
527
    public static function sf_saveModerators($moderators, $categoryid)
528
    {
529
        $result      = true;
530
        $smartModule = sf_getModuleInfo();
531
        $module_id   = $smartModule->getVar('mid');
532
533
        $gpermHandler = xoops_getHandler('groupperm');
534
        // First, if the permissions are already there, delete them
535
        $gpermHandler->deleteByModule($module_id, 'category_moderation', $categoryid);
536
        // Save the new permissions
537
        if (count($moderators) > 0) {
538
            foreach ($moderators as $uid) {
539
                $gpermHandler->addRight('category_moderation', $categoryid, $uid, $module_id);
540
            }
541
        }
542
543
        return $result;
544
    }
545
546
    /**
547
     * @param  int $faqid