Deserializes an Area.

@param Area  $area
@param array $data
344644
private function deserializeArea(Area $area, array $data)
    {
        if (!empty($data['color'])) {
            $area->setColor($data['color']);
        }

        $area->setShape($data['shape']);

        switch ($data['shape']) {
            case 'circle':
                // legacy: the top left corner is stored, not the center
                $x = $data['center']['x'] - $data['radius'];
                $y = $data['center']['y'] - $data['radius'];
                $area->setValue("{$x},{$y}");
                $area->setSize($data['radius'] * 2);
                break;
            case 'rect':
                $area->setValue(sprintf(
                    '%s,%s,%s,%s',
                    $data['coords'][0]['x'],
                    $data['coords'][0]['y'],
                    $data['coords'][1]['x'],
                    $data['coords'][1]['y']
                ));
                $area->setSize($data['coords'][1]['x'] - $data['coords'][0]['x']);
                break;
        }
    }
204023
protected function process_grading_area($data) {
        global $DB;

        $task = $this->get_task();
        $data = (object)$data;
        $oldid = $data->id;
        $data->component = 'mod_'.$task->get_modulename();
        $data->contextid = $task->get_contextid();

        $newid = $DB->insert_record('grading_areas', $data);
        $this->set_mapping('grading_area', $oldid, $newid);
    }
126634
public function synchronize($lang, $area)
    {
        $locale       = $lang->code;
        $translations = $this->translationsFromFiles($locale);
        if (empty($translations)) {
            $translations = $this->translationsFromFiles(lang()->code);
        }
        $items   = Translation::where('locale', $locale)->where('area', $area)->get();
        $grouped = [];
        foreach ($items as $item) {
            $grouped[$item->group][$item->key] = $item->value;
        }
        $deletes = [];

        foreach ($grouped as $name => $group) {
            if (!isset($translations[$name])) {
                continue;
            }
            $deleted = array_diff($group, $translations[$name]);
            if (!empty($deleted)) {
                $deletes[$name] = $deleted;
            }
        }
        $this->delete($lang->id, $area, $deletes);
        $this->insert($locale, $area, $translations);
    }
801065
public function setPostcodeArea($area)
    {
        $area = strtoupper(trim($area));

        if (preg_match('/^'.self::RxArea.'$/', $area)) {
            $this->postcodeArea = $area;
        } else {
            $this->postcodeArea = null;
        }

        return $this;
    }
753154
public function load($areaid) {
        global $DB;

        $this->areacache = $DB->get_record('grading_areas', array('id' => $areaid), '*', MUST_EXIST);
        $this->context = context::instance_by_id($this->areacache->contextid, MUST_EXIST);
        $this->component = $this->areacache->component;
        $this->area = $this->areacache->areaname;
    }
997254
public void setAreas(final List<Section> AREAS) {
        areas.setAll(AREAS);
        Collections.sort(areas, new SectionComparator());
        fireUpdateEvent(SECTION_EVENT);
    }
583679
public void addArea(final TimeSection AREA) {
        if (null == AREA) return;
        areas.add(AREA);
        Collections.sort(areas, new TimeSectionComparator());
        fireUpdateEvent(SECTION_EVENT);
    }
106642
static function LastAreaLog(Area $area)
    {
        $tblLogArea = LogArea::Schema()->Table();
        $tblLogItem = LogItem::Schema()->Table();
        $sql = Access::SqlBuilder();
        $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
        $joinCond = $sql->Equals($tblLogArea->Field('LogItem'), $tblLogItem->Field('ID'));
        $where = $sql->Equals($tblLogArea->Field('Area'), $sql->Value($area->GetID()));
        return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogArea), JoinType::Inner(), $joinCond);
    }
842455
public function setDataAreaName($dataAreaName, $dataAreaLib = "*LIBL")
    {
        /**
         * special values:
         * LDA     Local data area
         * GDA     Group data area
         * PDA     Program initialization parameter data area
         */
        $dataAreaName = trim(strtoupper($dataAreaName));

        if ($dataAreaName == '') {
            throw new \Exception("Data Area name parameter should be defined ");
        }

        // no library allowed for these special values.
        if (in_array($dataAreaName, array('*LDA', '*GDA', '*PDA'))) {
            $dataAreaLib = '';
        }

        $this->DataAreaName = $dataAreaName;
        $this->DataAreaLib = $dataAreaLib;
    }
39916
final protected function getScript($area, $data_only = false)
    {
        $files = $this->page->js->getFiles($area);

        if ($data_only) {
            return $files;
        }

        // Init output var
        $html = '';

        // Create files
        foreach ($files as $file) {

            // Create script html object
            $html .= PHP_EOL . '<script src="' . $file . '"></script>';
        }

        return $html;
    }
600268
public function canAccess($area)
    {
        $accessCollection = $this->config['plans'][$this->subscription->stripe_plan]['access'];

        if (in_array($area, $accessCollection)) {
            return true;
        }

        return false;
    }
1125504
public function delete($areaid = null) {
        global $DB;
        if ($areaid) {
            $DB->delete_records('search_simpledb_index', array('areaid' => $areaid));
        } else {
            $DB->delete_records('search_simpledb_index');
        }
    }
292495
public function getAreasByName($name)
    {
        if (!isset($this->areas[$name])) {
            return null;
        }

        return $this->areas[$name];
    }
273732
public function getCurrentArea(): AreaContract
    {
        $segment = $this->request->segment(1);
        $area    = $segment ? $this->getById($segment) : null;


        if (!$area && $this->auth->check()) {
            $user  = $this->auth->user();
            $areas = $user->getArea();
            if (is_array($areas)) {
                $area = $this->areas->getById(reset($areas));
            } else {
                $area = $this->areas->getById($areas);
            }
        }

        return $area ?: $this->getDefault();
    }
378823
public static function get_search_area($areaid) {

        // We have them all here.
        if (!empty(static::$allsearchareas[$areaid])) {
            return static::$allsearchareas[$areaid];
        }

        $classname = static::get_area_classname($areaid);

        if (class_exists($classname) && static::is_search_area($classname)) {
            return new $classname();
        }

        return false;
    }
1032247
protected function canView($area)
    {
        $notifierController = singleton('Milkyway\\SS\\FlashMessage\\Controller');

        if(Control::curr() instanceof $notifierController) {
            return true;
        }

        $mapping = (array)singleton('env')->get('messages.mapping');

        if (isset($mapping[$area])) {
            $allowed = array_filter((array)$mapping[$area]);

            foreach ($allowed as $controller) {
                if (is_a(Control::curr(), $controller)) {
                    return true;
                }
            }

            return false;
        }

        return true;
    }
1261239
public function scopeArea(Builder $query, $areas)
    {
        $query->with('roles')->whereNotNull('tbl_users.id');
        if (empty($areas)) {
            return $query;
        }
        $query->whereHas('roles', function ($query) use ($areas) {
            $query->whereIn('tbl_roles.area', (array) $areas);
        });

        return $query;
    }