Code Duplication    Length = 28-28 lines in 2 locations

class/utility.php 1 location

@@ 430-457 (lines=28) @@
427
     * @param  integer $categoryid :
428
     * @return boolean|array : TRUE if the no errors occured
429
     */
430
    public static function sf_overrideFaqsPermissions($groups, $categoryid)
431
    {
432
        global $xoopsDB;
433
434
        $result      = true;
435
        $smartModule = sf_getModuleInfo();
436
        $module_id   = $smartModule->getVar('mid');
437
438
        $gpermHandler = xoops_getHandler('groupperm');
439
440
        $sql    = 'SELECT faqid FROM ' . $xoopsDB->prefix('smartfaq_faq') . " WHERE categoryid = '$categoryid' ";
441
        $result = $xoopsDB->queryF($sql);
442
443
        if (count($result) > 0) {
444
            while (list($faqid) = $xoopsDB->fetchrow($result)) {
445
                // First, if the permissions are already there, delete them
446
                $gpermHandler->deleteByModule($module_id, 'item_read', $faqid);
447
                // Save the new permissions
448
                if (count($groups) > 0) {
449
                    foreach ($groups as $group_id) {
450
                        $gpermHandler->addRight('item_read', $faqid, $group_id, $module_id);
451
                    }
452
                }
453
            }
454
        }
455
456
        return $result;
457
    }
458
459
    /**
460
     * Saves permissions for the selected faq

include/functions.php 1 location

@@ 290-317 (lines=28) @@
287
 * @param  integer $categoryid :
288
 * @return boolean : TRUE if the no errors occured
289
 */
290
function sf_overrideFaqsPermissions($groups, $categoryid)
291
{
292
    global $xoopsDB;
293
294
    $result      = true;
295
    $smartModule = sf_getModuleInfo();
296
    $module_id   = $smartModule->getVar('mid');
297
298
    $gpermHandler = xoops_getHandler('groupperm');
299
300
    $sql    = 'SELECT faqid FROM ' . $xoopsDB->prefix('smartfaq_faq') . " WHERE categoryid = '$categoryid' ";
301
    $result = $xoopsDB->queryF($sql);
302
303
    if (count($result) > 0) {
304
        while (list($faqid) = $xoopsDB->fetchrow($result)) {
305
            // First, if the permissions are already there, delete them
306
            $gpermHandler->deleteByModule($module_id, 'item_read', $faqid);
307
            // Save the new permissions
308
            if (count($groups) > 0) {
309
                foreach ($groups as $group_id) {
310
                    $gpermHandler->addRight('item_read', $faqid, $group_id, $module_id);
311
                }
312
            }
313
        }
314
    }
315
316
    return $result;
317
}
318
319
/**
320
 * Saves permissions for the selected faq