@SuppressWarnings(PHPMD.BooleanArgumentFlag)

@param string $zoneID
@param PageRulesTargets $target
@param PageRulesActions $actions
@param bool $active
@param int|null $priority
@return bool
971606
public function createPageRule(
        string $zoneID,
        PageRulesTargets $target,
        PageRulesActions $actions,
        bool $active = true,
        int $priority = null
    ): bool {
        $options = [
            'targets' => $target->getArray(),
            'actions' => $actions->getArray()
        ];

        if ($active !== null) {
            $options['status'] = $active == true ? 'active' : 'disabled';
        }

        if ($priority !== null) {
            $options['priority'] = $priority;
        }


        $query = $this->adapter->post('zones/' . $zoneID . '/pagerules', $options);

        $this->body = json_decode($query->getBody());

        if (isset($this->body->result->id)) {
            return true;
        }

        return false;
    }
915121
public function checkPermission($roleId, $action)
    {
        if ($roleId == ROLE_ID_ADMINISTRATOR) {
            return true;
        }

        $this->_loadPermissions();
        $rule = $this->_permissions
            ->filter(function ($rule) use ($roleId, $action) {
                return $rule->get('role_id') == $roleId && $rule->get('action') == $action;
            })
            ->first();

        return !empty($rule);
    }
850456
private function evaluateTargetGroupRule(TargetGroupRuleInterface $targetGroupRule)
    {
        foreach ($targetGroupRule->getConditions() as $targetGroupCondition) {
            $rule = $this->ruleCollection->getRule($targetGroupCondition->getType());

            if (!$rule->evaluate($targetGroupCondition->getCondition())) {
                return false;
            }
        }

        return true;
    }
189726
public static function do_process_action($target, $action, $courseid = null) {
        global $DB;
        // TODO: this code should be in some grade_tree static method
        $targettype = substr($target, 0, 2);
        $targetid = substr($target, 2);
        // TODO: end

        if ($targettype !== 'cg') {
            // The following code only works with categories.
            return true;
        }

        if (!$courseid) {
            debugging('Function grade_report_grader::do_process_action() now requires additional argument courseid',
                DEBUG_DEVELOPER);
            if (!$courseid = $DB->get_field('grade_categories', 'courseid', array('id' => $targetid), IGNORE_MISSING)) {
                return true;
            }
        }

        $collapsed = static::get_collapsed_preferences($courseid);

        switch ($action) {
            case 'switch_minus': // Add category to array of aggregatesonly
                if (!in_array($targetid, $collapsed['aggregatesonly'])) {
                    $collapsed['aggregatesonly'][] = $targetid;
                    static::set_collapsed_preferences($courseid, $collapsed);
                }
                break;

            case 'switch_plus': // Remove category from array of aggregatesonly, and add it to array of gradesonly
                $key = array_search($targetid, $collapsed['aggregatesonly']);
                if ($key !== false) {
                    unset($collapsed['aggregatesonly'][$key]);
                }
                if (!in_array($targetid, $collapsed['gradesonly'])) {
                    $collapsed['gradesonly'][] = $targetid;
                }
                static::set_collapsed_preferences($courseid, $collapsed);
                break;
            case 'switch_whole': // Remove the category from the array of collapsed cats
                $key = array_search($targetid, $collapsed['gradesonly']);
                if ($key !== false) {
                    unset($collapsed['gradesonly'][$key]);
                    static::set_collapsed_preferences($courseid, $collapsed);
                }

                break;
            default:
                break;
        }

        return true;
    }
293380
private function IsActive()
    {
        $pageItem = $this->naviItem->GetPageItem();
        if (!$pageItem)
        {
            return false;
        }
        return $pageItem->GetPage()->Equals(PageRenderer::Page());
    }
391965
@Override
	protected void applyAction(final SubordinateTarget target, final Object value) {
		// Should always be Boolean, but check anyway
		if (value instanceof Boolean) {
			applyEnableAction(target, ((Boolean) value));
		}
	}
421841
public function setActiveResponsible(Model $Model, $responsibleId)
	{
		if (empty($responsibleId)) {
			return false;
		}

		$this->activeResponsibleId = $responsibleId;

		return true;
	}
876587
public function process_actions($left, $right, $moveup, $movedown) {
        //should this action be processed by this list object?
        if (!(array_key_exists($left, $this->records) || array_key_exists($right, $this->records) || array_key_exists($moveup, $this->records) || array_key_exists($movedown, $this->records))) {
            return false;
        }
        if (!empty($left)) {
            $oldparentitem = $this->move_item_left($left);
            if ($this->item_is_last_on_page($oldparentitem->id)) {
                // Item has jumped onto the next page, change page when we redirect.
                $this->page ++;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($right)) {
            $this->move_item_right($right);
            if ($this->item_is_first_on_page($right)) {
                // Item has jumped onto the previous page, change page when we redirect.
                $this->page --;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($moveup)) {
            $this->move_item_up_down('up', $moveup);
            if ($this->item_is_first_on_page($moveup)) {
                // Item has jumped onto the previous page, change page when we redirect.
                $this->page --;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($movedown)) {
            $this->move_item_up_down('down', $movedown);
            if ($this->item_is_last_on_page($movedown)) {
                // Item has jumped onto the next page, change page when we redirect.
                $this->page ++;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else {
            return false;
        }

        redirect($this->pageurl);
    }
1354568
function action(targetAction) {
    return function (target, propertyKey, descriptor) {
        if (targetAction == undefined) {
            var metadata = Reflect.getMetadata('design:paramtypes', target, propertyKey);
            if (metadata == undefined || metadata.length < 2)
                throw new Error('@action() must be applied to a function with two arguments. ' +
                    'eg: reducer(state: State, action: SubclassOfAction): State { }');
            targetAction = metadata[1];
        }
        var statexActions = {};
        if (Reflect.hasMetadata(constance_1.STATEX_ACTION_KEY, target)) {
            statexActions = Reflect.getMetadata(constance_1.STATEX_ACTION_KEY, target);
        }
        statexActions[propertyKey] = targetAction;
        Reflect.defineMetadata(constance_1.STATEX_ACTION_KEY, statexActions, target);
        return {
            value: function (state, payload) {
                return descriptor.value.call(this, state, payload);
            }
        };
    };
}
1125226
public function initializePager(SimplePager $pager, Criteria\Criteria $criteria)
    {
        // now page
        if ($criteria->offset !== null && $criteria->limit !== null) {
            $pager->setNow(floor($criteria->offset / $criteria->limit) + 1);
            $pager->setPerPage($criteria->limit);
        } elseif ($criteria->limit !== null){
            $pager->setPerPage($criteria->limit);
        }

        // get total rows
        $criteria->columns('COUNT(1)')->limit(null)->offset(null);
        $pager->setTotal($this->getOne($criteria));

        return $pager;
    }
537987
public void setActive(boolean active) {
        super.setActive(active);
        if (active) {
            this.start = new AtomicLong(System.currentTimeMillis());
        } else {
            this.start =new AtomicLong( -1);
        }
    }
734242
protected function setZone($zone_id)
    {
        $this->data_zone = array();

        if (is_numeric($zone_id)) {

            $this->data_zone = $this->zone->get($zone_id);

            if (empty($this->data_zone)) {
                $this->outputHttpStatus(404);
            }
        }
    }
644501
public function onPlayerManialinkPageAnswer($login, $actionId, array $entryValues)
    {
        if (isset($this->actions[$actionId])) {
            $this->actions[$actionId]->execute($this->manialinkByAction[$actionId], $login, $entryValues);
        }
    }
67765
public function deleteZone($layoutId, string $zoneIdentifier, ?int $status = null): void
    {
        $query = $this->connection->createQueryBuilder();
        $query->delete('ngbm_zone')
            ->where(
                $query->expr()->andX(
                    $query->expr()->eq('layout_id', ':layout_id'),
                    $query->expr()->eq('identifier', ':identifier')
                )
            )
            ->setParameter('layout_id', $layoutId, Type::INTEGER)
            ->setParameter('identifier', $zoneIdentifier, Type::STRING);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status);
        }

        $query->execute();
    }
1143086
public function canPublishTarget()
    {
        if ($this->CurrentActionID && ($target = $this->getTarget())) {
            return $this->CurrentAction()->canPublishTarget($target);
        }
    }
652231
private void checkBuddyManagerIsActive(BuddyListManager buddyListManager, User sfsOwner) {
        if (!buddyListManager.isActive()) {
            throw new IllegalStateException(
                    String.format("BuddyList operation failure. BuddyListManager is not active. Zone: %s, Sender: %s", new Object[] { sfsOwner.getZone(), sfsOwner }));
          }
    }
727550
private function evaluateTargetGroup(TargetGroupInterface $targetGroup)
    {
        foreach ($targetGroup->getRules() as $targetGroupRule) {
            if ($this->evaluateTargetGroupRule($targetGroupRule)) {
                return true;
            }
        }

        return false;
    }