Applies forced settings on this category

@return bool True if anything changed
15118
public function apply_forced_settings() {
        global $CFG;

        $updated = false;

        foreach ($this->forceable as $property) {

            if (isset($CFG->{"grade_$property"}) and isset($CFG->{"grade_{$property}_flag"}) and
                                                    ((int) $CFG->{"grade_{$property}_flag"} & 1)) {

                if ($CFG->{"grade_$property"} == -1) {
                    continue; //temporary bc before version bump
                }
                $this->$property = $CFG->{"grade_$property"};
                $updated = true;
            }
        }

        return $updated;
    }
692102
protected function applyMetaFilters()
	{
		if (isset($this->meta_filters_applied)) {
			return $this->meta_filters_applied;
		}
		
		if (empty($this->filters)) {
			return $this->meta_filters_applied = false;
		}
		
		$meta_model = $this->model->metaModel();
		$meta_instance = new $meta_model;
		$meta_query = $meta_instance->newQuery();
		
		if (isset($this->meta_context)) {
			if (method_exists($meta_model, 'applyQueryContext')) {
				call_user_func_array(array($meta_model, 'applyQueryContext'), array($meta_query, $this->meta_context));
			}
		}
		
		$filters = $this->filters;
		$meta_query->where(function ($query) use ($filters) {
			foreach ($filters as $filter) {
				foreach ($filter['metas'] as $sub_filter) {
					if (isset($sub_filter['id'])) {
						$query->orWhere('id', $sub_filter['id']);
					}
					else if (isset($sub_filter['name'])) {
						$query->orWhere('name', $sub_filter['name']);
					}
				}
			}
		});
		
		$metas = $meta_query->get();
		$meta_items = $metas->lists('num_items', 'id');
		
		$found = array(
			'id'   => $metas->lists('id', 'id'),
			'name' => $metas->lists('id', 'name'),
		);
		
		foreach ($filters as &$filter) {
			$found_one = false;
			
			foreach ($filter['metas'] as $idx => &$sub_filter) {
				$key = isset($sub_filter['id']) ? 'id' : 'name';
				$key_value = $sub_filter[$key];
				
				if (!array_key_exists($key_value, $found[$key])) {
					unset($filter['metas'][$idx]);
					continue;
				}
				
				$found_one = true;
				$sub_filter['id'] = $found[$key][$key_value];
				
				$num_items = $meta_items[$found[$key][$key_value]];
				if (!isset($filter['num_items']) || $num_items > $filter['num_items']) {
					$filter['num_items'] = $num_items;
				}
			}
			
			if (!$found_one) {
				return $this->meta_filters_applied = false;
			}
			
			if (count($filter['metas']) > 1) {
				$filter['num_items'] += 100000000;
			}
		}
		
		usort($filters, function ($a, $b) {
			return ($a['num_items'] < $b['num_items']) ? -1 : 1;
		});
		
		$set_distinct = false;
		
		$first_filter = current(array_splice($filters, 0, 1));
		if (count($first_filter['metas']) > 1) {
			$this->where(function ($query) use ($first_filter) {
				foreach ($first_filter['metas'] as $f) {
					if (isset($f['value'])) {
						$query->orWhere(function ($query) use ($f) {
							$query->where('m.meta_id', $f['id']);
							$query->where('m.value', $f['operator'], $f['value']);
						});
					}
					else {
						$query->orWhere('m.meta_id', $f['id']);
					}
				}
			});
			
			if (!$set_distinct) {
				$this->distinct();
				$set_distinct = true;
			}
		}
		else {
			foreach ($first_filter['metas'] as $f) {
				$this->where('m.meta_id', $f['id']);
				if (isset($f['value'])) {
					$this->where('m.value', $f['operator'], $f['value']);
				}
			}
		}
		
		foreach ($filters as $i => $cur_filter) {
			$this->join("{$this->model->metableTable()} AS m{$i}", function ($join) use ($i, $cur_filter) {
				$join_query = $join->on('m.xref_id', '=', "m{$i}.xref_id");
				
				if (count($cur_filter['metas']) <= 1) {
					foreach ($cur_filter['metas'] as $f) {
						if (isset($f['value'])) {
							$join_query->where("m{$i}.meta_id", '=', $f['id']);
							$join_query->where("m{$i}.value", $f['operator'], $f['value']);
						}
						else {
							$join_query->where("m{$i}.meta_id", '=', $f['id']);
						}
					}
				}
			});
			
			if (count($cur_filter['metas']) > 1) {
				$this->where(function ($query) use ($cur_filter, $i) {
					foreach ($cur_filter['metas'] as $f) {
						if (isset($f['value'])) {
							$query->orWhere(function ($query2) use ($f, $i) {
								$query2->where("m{$i}.meta_id", $f['id']);
								$query2->where("m{$i}.value", $f['operator'], $f['value']);
							});
						}
						else {
							$query->orWhere("m{$i}.meta_id", $f['id']);
						}
					}
				});
				
				if (!$set_distinct) {
					$this->distinct();
					$set_distinct = true;
				}
			}
		}
		
		return $this->meta_filters_applied = true;
	}
397776
public function forceDelete()
    {
        $this->forceDeleting = true;

        $deleted = $this->delete();

        $this->forceDeleting = false;

        return $deleted;
    }
1275700
public function apply()
    {
        $this->replacingLines = array();
        $this->init();
        if ($this->checkPreconditions()) {
            return $this->execute();
        } else {
            if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed])) {
                $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= ', ';
            } else {
                $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] = '';
            }
            $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= $this->getName();
            return false;
        }
    }
294490
public function setSettingsByRequest()
    {
        $allAllowedSettings = array_keys($this->allSettings()->toArray());

        return $this->settings()->set(request()->only($allAllowedSettings));
    }
1245453
protected function _applyDefaults()
    {
        if (isset($this->_config['all']))
        {
            $this->_has_action = $this->_config['all']['action'];
            $this->_search     = $this->_config['all']['search'];
        }
    }
1218358
protected function forceCollection()
    {
        if (!$this->isCollection()) {
            $this->isCollection = true;
            $this->data = [$this->data];
        }
    }
537454
protected function setBrowser()
    {
        if (is_array(static::$browsers) && count(static::$browsers) > 0) {
            foreach (static::$browsers as $key => $val) {
                if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->string, $match)) {
                    $this->isBrowser = true;
                    $this->browserVersion = $match[ 1 ];
                    $this->browser = $val;
                    $this->setMobile();

                    return true;
                }
            }
        }

        return false;
    }
865616
public function editSettings()
    {
        $this->setTitleEditSettings();
        $this->setBreadcrumbEditSettings();

        $this->setData('stores', $this->store->getList());
        $this->setData('settings', $this->module->getSettings('device'));
        $this->setData('themes', $this->getFrontendThemesSettings());

        $this->submitSettings();
        $this->outputEditSettings();
    }
1220236
private function checkSetting($setting)
    {
        if (array_key_exists($setting, $this->getDefaults())) {
            if (! $this->getSetting($setting)) {
                $this->addSetting($setting);
            }
            
            return true;
        }
    }
531486
protected function apply_defaults() {
        $this->log('applying restore defaults', backup::LOG_DEBUG);
        restore_controller_dbops::apply_config_defaults($this);
        $this->set_status(backup::STATUS_CONFIGURED);
    }
707346
public function forceDelete()
    {
        $this->forceDeleting = true;

        return tap($this->delete(), function ($deleted) {
            $this->forceDeleting = false;

            if ($deleted) {
                $this->fireModelEvent('forceDeleted', false);
            }
        });
    }
24877
protected function updateChanges($forceChanges = false)
    {
        if ($forceChanges) {
            // Force changes, but only for loaded fields
            foreach ($this->record as $field => $value) {
                $this->changed[$field] = static::CHANGE_VALUE;
            }
            return true;
        }
        return $this->isChanged();
    }
847070
public function actionSettings()
    {
        $model = new ConfigForm();
        $data = Yii::$app->request->post('ConfigForm');
        if ($data) {
            if (User::can(Rbac::PERM_CHANGE_SETTINGS)) {
                if ($model->update($data)) {
                    Log::info('Settings updated', null, __METHOD__);
                    $this->success(Yii::t('podium/flash', 'Settings have been updated.'));
                    return $this->refresh();
                }
                $this->error(Yii::t('podium/flash', "One of the setting's values is too long (255 characters max)."));
            } else {
                $this->error(Yii::t('podium/flash', 'You are not allowed to perform this action.'));
            }
        }
        return $this->render('settings', ['model' => $model]);
    }
1036277
public function enabled() {
    $config = $this->config->get('social_lets_connect_usage.settings');
    $usage_data_settings = $config->get('usage_data');

    $plugin_definition = $this->getPluginDefinition();
    if (in_array($plugin_definition['setting'], $usage_data_settings)) {
      return TRUE;
    }
    return FALSE;
  }
1324763
public final function has_admin_settings() {
        global $CFG;

        $pluginroot = $CFG->dirroot . '/mod/assign/' . substr($this->get_subtype(), strlen('assign')) . '/' . $this->get_type();
        $settingsfile = $pluginroot . '/settings.php';
        return file_exists($settingsfile);
    }
195453
protected function validateEditSettings()
    {
        $this->setSubmitted('settings');

        if (!$this->getSubmitted('cron_key')) {
            $this->setSubmitted('cron_key', gplcart_string_random());
        }

        return !$this->hasErrors();
    }