Zapis danych do obiektu
@return bool
764088
public function save()
    {
        //iteracja po polach
        foreach (($data = ($this->data instanceof DataObject) ? $this->data->toArray() : []) as $field => $value) {
            //usuwanie pustych pól
            if ($value === null) {
                unset($data[$field]);
            }
        }
        //zapis json'a
        $this->data = empty($data) ? null : json_encode($data);
        return parent::save();
    }
944819
public function afterSave()
    {
        //nadawanie uprawnień
        \Cms\Model\Role::grant($this->getRecord()->id, $this->getElement('cmsRoles')->getValue());
        //usunięcie języka z sesji
        $session = new \Mmi\Session\SessionSpace('cms-language');
        $session->unsetAll();
        return true;
    }
606559
public function deleteAction()
    {
        //wyszukiwanie relacji do edycji
        if (null === $widgetRelation = (new \Cms\Orm\CmsCategoryWidgetCategoryQuery)
            ->whereCmsCategoryId()->equals($this->categoryId)
            ->findPk($this->id)) {
            return '';
        }
        //usuwanie relacji
        $widgetRelation->delete();
        return '';
    }
1343350
public function beforeSave()
    {
        $mvcParams = [];
        //parsowanie mvcParams
        parse_str($this->getElement('mvcParams')->getValue(), $mvcParams);
        //zapis do obiektu
        $this->getRecord()->module = isset($mvcParams['module']) ? $mvcParams['module'] : null;
        $this->getRecord()->controller = isset($mvcParams['controller']) ? $mvcParams['controller'] : null;
        $this->getRecord()->action = isset($mvcParams['action']) ? $mvcParams['action'] : null;
    }
1045364
public function blockUser(): bool
    {
        $this->deactivate();
        if (!$this->save()) {
            print_r($this->getErrors());
            throw new Exception(\Yii::t('app', 'Ошибка при блокировании пользователя'));
        }
        return true;
    }
912031
public function stickAction()
    {
        $this->getResponse()->setTypePlain();
        //brak id
        if (!$this->id) {
            return '';
        }
        //brak pliku
        if (null === ($file = (new CmsFileQuery)->findPk($this->id)) || $this->hash != $file->name) {
            return $this->view->getTranslate()->_('Przypinanie nie powiodło się');
        }
        //przypina plik
        $file->setSticky();
        return '';
    }
1147008
public function afterSave()
    {
        //brak filtra
        if (!$this->getElement('fileObjects')) {
            return false;
        }
        //wczytywanie sesji
        $session = new \Mmi\Session\SessionSpace(\Cms\Model\ConnectorModel::SESSION_SPACE);
        try {
            //pobranie plików z connectora
            $remoteFiles = (new \Cms\Model\ConnectorModel)->getData($session->url, 'exportFileList', ['fileObjects' => $this->getElement('fileObjects')->getValue()], $session->identity, $session->credential);
        } catch (\Cms\Exception\ConnectorException $e) {
            //brak plików
            $this->getElement('fileObjects')->addError('form.connectorImportFilesForm.fileObjects.error.empty');
            return false;
        }
        $files = [];
        foreach ($remoteFiles as $name => $userName) {
            if (null !== (new \Cms\Orm\CmsFileQuery)->whereName()->equals($name)->findFirst()) {
                continue;
            }
            $files[$name] = $userName;
        }
        //ustawienie danych na elementy pobrane z connectora
        $this->setOption('data', $files);
        return true;
    }
193905
protected function _createTempFiles()
    {
        //jeśli już są pliki tymczasowe, to wychodzimy
        if ((new \Cms\Orm\CmsFileQuery)
            ->byObject('tmp-' . $this->getUploaderObject(), $this->getUploaderId())
            ->count()) {
            return true;
        }
        $objectId = null;
        if ($this->_form->hasRecord()) {
            $objectId = $this->_form->getRecord()->getPk();
        }
        //tworzymy pliki tymczasowe - linki do oryginałów
        \Cms\Model\File::link($this->getUploaderObject(), $objectId, 'tmp-' . $this->getUploaderObject(), $this->getUploaderId());
        return true;
    }
102318
public function indexAction()
    {
        $config = clone (\App\Registry::$config);
        //za długie dane do wyświetlenia
        $config->navigation = self::THREE_DOTS;
        $config->router = self::THREE_DOTS;
        $this->view->config = \Mmi\Http\ResponseDebugger\Colorify::colorify(print_r($config, true));
        $this->view->server = \Mmi\Http\ResponseDebugger\Colorify::colorify(print_r($_SERVER, true));
    }
1272199
public function save()
    {
        //data modyfikacji
        $this->dateModify = date('Y-m-d H:i:s');
        $this->lang = \Mmi\App\FrontController::getInstance()->getRequest()->lang;
        //usunięcie kompilantów
        foreach (glob(BASE_PATH . '/var/compile/' . $this->lang . '_*.php') as $compilant) {
            unlink($compilant);
        }
        try {
            $result = parent::save();
        } catch (\Exception $e) {
            //duplikat
            return false;
        }
        //usunięcie cache
        \App\Registry::$cache->remove('Cms-text');
        return $result;
    }
532978
public function setSticky()
    {
        //brak pliku
        if ($this->id === null) {
            return false;
        }
        //wyłącza sticky na innych plikach dla tego object+objectId
        foreach (\Cms\Orm\CmsFileQuery::stickyByObject($this->object, $this->objectId)->find() as $related) {
            $related->sticky = 0;
            $related->save();
        }
        $this->sticky = 1;
        return $this->save();
    }
800362
protected function _prepareData()
	{
        //próba pobrania struktury uprawnień z cache
        if (null !== $this->_acl = \App\Registry::$cache->load($cacheKey = 'categories-roles')) {
			return;
        }
		$this->_acl = [];
		//zapytanie o całą strukturę powiązań: kategorie - role
		foreach ((new \Cms\Orm\CmsCategoryRoleQuery())
					->join('cms_role')->on('cms_role_id')
					->orderAscCmsCategoryId()
					->find() as $record) {
			if (!array_key_exists($record->cmsCategoryId, $this->_acl)) {
				$this->_acl[$record->cmsCategoryId] = [];
			}
			$this->_acl[$record->cmsCategoryId][] = $record->getJoined('cms_role')->name;
		}
        //zapis struktury uprawnień do cache
        \App\Registry::$cache->save($this->_acl, $cacheKey, 0);
	}
1140261
protected function _setupDatabase()
    {
        //brak konfiguracji bazy
        if (!\App\Registry::$config->db || !\App\Registry::$config->db->driver) {
            return $this;
        }
        //obliczanie nazwy drivera
        $driver = '\\Mmi\\Db\\Adapter\\Pdo' . ucfirst(\App\Registry::$config->db->driver);
        //próba powołania drivera
        \App\Registry::$db = new $driver(\App\Registry::$config->db);
        //jeśli aplikacja w trybie debug
        if (\App\Registry::$config->debug) {
            //wstrzyknięcie profilera do adaptera bazodanowego
            \App\Registry::$db->setProfiler(new \Mmi\Db\DbProfiler);
        }
        //wstrzyknięcie do ORM
        \Mmi\Orm\DbConnector::setAdapter(\App\Registry::$db);
        return $this;
    }
987146
public function currentAction()
    {
        $objectId = !empty($this->getPost()->objectId) ? $this->getPost()->objectId : null;
        switch ($this->getPost()->fileTypes) {
            case 'images' :
                //zapytanie o obrazki
                $query = CmsFileQuery::imagesByObject($this->getPost()->object, $objectId);
                break;
            case 'notImages' :
                //wszystkie pliki bez obrazków
                $query = CmsFileQuery::notImagesByObject($this->getPost()->object, $objectId);
                break;
            default :
                //domyślne zapytanie o wszystkie pliki
                $query = CmsFileQuery::byObject($this->getPost()->object, $objectId);
        }

        $records = $query->find();
        foreach ($records as $record) {
            $record->data = $record->data->toArray();
        }

        //zwrot json'a z plikami
        return json_encode([
            'result' => 'OK',
            'files' => $records->toArray()
        ]);
    }
696980
public static function run()
    {
        foreach (Orm\CmsCronQuery::active()->find() as $cron) {
            if (!self::_getToExecute($cron)) {
                continue;
            }
            $output = '';
            try {
                $start = microtime(true);
                $output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action]));
                $elapsed = round(microtime(true) - $start, 2);
            } catch (\Exception $e) {
                //error logging
                \Mmi\App\FrontController::getInstance()->getLogger()->error('CRON failed: @' . gethostname() . $cron->name . ' ' . $e->getMessage());
                return;
            }
            //zmień datę ostatniego wywołania
            $cron->dateLastExecute = date('Y-m-d H:i:s');
            //ponowne łączenie
            \App\Registry::$db->connect();
            //zapis do bazy bez modyfikowania daty ostatniej modyfikacji
            $cron->saveWithoutLastDateModify();
            //logowanie uruchomienia
            \Mmi\App\FrontController::getInstance()->getLogger()->info('CRON done: @' . gethostname() . ' ' . $cron->name . ' ' . $output .  ' in ' . $elapsed . 's');
        }
    }
1047125
public function updateAction()
    {
        $msg = $this->view->getTranslate()->_('Zmiana właściwości nie powiodła się.');
        $this->getResponse()->setTypePlain();
        $params = explode('-', $this->id);

        //błędne dane wejściowe
        if (!($this->getPost()->selected) || count($params) != 3) {
            return $msg;
        }
        $record = (new \Cms\Orm\CmsAclQuery)->findPk($params[2]);
        if (!$record) {
            return $msg;
        }
        //zmiana zasobu
        if ($params[1] == 'resource') {
            $resource = [];
            parse_str($this->getPost()->selected, $resource);
            $record->module = strtolower($resource['module']);
            $record->controller = isset($resource['controller']) ? strtolower($resource['controller']) : null;
            $record->action = isset($resource['action']) ? strtolower($resource['action']) : null;
        } else {
            //zmiana uprawnienia z allow na deny lub odwrotnie
            $record->access = $this->getPost()->selected == 'allow' ? 'allow' : 'deny';
        }
        $record->save();
        return 1;
    }
1057314
public function thumbnailAction()
    {
        if (!$this->getPost()->cmsFileId) {
            return $this->_jsonError(179);
        }
        //szukamy rekordu pliku
        if (null !== $record = (new CmsFileQuery)->findPk($this->getPost()->cmsFileId)) {
            //sprawdzenie czy obrazek
            if ($record->class === 'image') {
                try {
                    $thumb = new \Cms\Mvc\ViewHelper\Thumb();
                    $url = $thumb->thumb($record, 'scaley', '60');
                    if (!empty($url)) {
                        return json_encode(['result' => 'OK', 'url' => $url]);
                    }
                } catch (\Exception $ex) {
                    
                }
            }
        }
        return $this->_jsonError(179);
    }