Ustawienie opcji przed zapisem
@return boolean
180552
public function beforeSave()
    {
        $this->getRecord()->active = 0;
        $this->getRecord()->cmsAuthIdReply = \App\Registry::$auth->getId();
        return true;
    }
675264
public function isSuccessful()
    {
        $data = $this->getData();

        return
            (isset($data['status']) && $data['status'] !== 'KO') &&
            (isset($data['duplicate']) && $data['duplicate'] !== 'true');
    }
591785
public function beforeSave()
    {
        //brak loginu lub hasła
        if (!$this->getElement('username')->getValue() || !$this->getElement('password')->getValue()) {
            return false;
        }
        //autoryzacja
        $auth = \App\Registry::$auth;
        \App\Registry::$auth->setIdentity($this->getElement('username')->getValue());
        \App\Registry::$auth->setCredential($this->getElement('password')->getValue());
        //autoryzacja
        if (!\App\Registry::$auth->authenticate()) {
            return false;
        }
        //zapamiętanie jeśli zaznaczona opcja
        if ($this->getElement('remember')) {
            \App\Registry::$auth->rememberMe(\App\Registry::$config->session->authRemember);
        }
        return true;
    }
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();
    }
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;
    }
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;
    }
808938
private function _getActiveServer()
    {
        //jeśli serwer jest już wybrany - zwrot
        if ($this->_activeServerResource) {
            return $this->_activeServerResource;
        }
        //jeśli adres nie jest tablicą - tworzy tablicę 1 elementową z nim w środku
        $servers = is_array($this->_config->address) ? $this->_config->address : [$this->_config->address];
        //logowanie kolejności serwerów
        \shuffle($servers);
        //wybór akrywnego serwera
        foreach ($servers as $address) {
            //parsowanie adresu i ping do serwera
            if (!$this->_isServerAlive($serverAddress = $this->_parseAddress($address))) {
                continue;
            }
            //powoływanie zasobu ldap
            $ldap = ldap_connect($serverAddress->protocol . '://' . $serverAddress->host, $serverAddress->port);
            //ustawianie opcji ldap
            ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
            ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
            //zwrot zasobu
            return $this->_activeServerResource = $ldap;
        }
        //brak aktywnego serwera
        throw new LdapException('No alive LDAP server found');
    }
1221952
public static function isItSelfContact(){

        $ppcn_id = false;
        $action = Yii::app()->controller->action->id;
        switch (Yii::app()->controller->action->id) {
            
            //update
            case 'editableSaver':
                $ppcn_id = yii::app()->request->getParam('pk');
            //delete
            case 'delete':                
                if(!$ppcn_id){
                    $ppcn_id = yii::app()->request->getParam('ppcn_id');
                }
                if(!$ppcn_id){
                    return false;
                }
                
                $ppcn = PpcnPersonContact::model()->findByPk($ppcn_id);
                if(!$ppcn || $ppcn->ppcnPprs->pprs_id != Yii::app()->getModule('user')->user()->profile->person_id){
                    return false;            
                }
                
                break;

            //create
            case 'ajaxCreate':
                if(yii::app()->request->getParam('value') != Yii::app()->getModule('user')->user()->profile->person_id){
                    return false;            
                }

                break;

            default:
                return false;
                break;
        }

        return true;
        
    }
981919
public function isSimple(): bool {
        $event = new AccessorOpEvent($this);
        $this->fireOperationEvent(AccessorOpEvent::IS_SIMPLE_EVENT, $event);
        return $event->getResults();
    }
123737
public function deleteAction()
    {
        $this->getResponse()->setTypePlain();
        //nie można skasować
        if (!($this->id > 0)) {
            return 0;
        }
        $rule = (new \Cms\Orm\CmsAclQuery)->findPk($this->id);
        //skasowane
        if ($rule && $rule->delete()) {
            return 1;
        }
    }
1305512
public function sortAction()
    {
        $this->getResponse()->setTypePlain();
        if (!$this->getPost()->__get('item-file')) {
            return $this->view->getTranslate()->_('Przenoszenie nie powiodło się');
        }
        \Cms\Model\File::sortBySerial($this->getPost()->__get('item-file'));
        return '';
    }
437267
private function _hasPrintableAttributes()
    {
        //iteracja po atrybutach
        foreach ($this->_cmsAttributes as $attribute) {
            //nie jest atrybutem odziedziczonym - czyli będzie wypisany przy renderingu
            if (!$attribute->getJoined('cms_attribute_relation')->isMaterializedInherited()) {
                return true;
            }
        }
        return false;
    }
691274
public function delete()
    {
        //usuwanie utworzonych widgetów
        (new CmsCategoryWidgetCategoryQuery)
            ->whereCmsCategoryWidgetId()->equals($this->getPk())
            ->find()
            ->delete();
        //usuwanie widgeta
        return parent::delete();
    }
138286
public function editAction()
    {
        $this->getResponse()->setTypeJson();
        $error = json_encode(['error' => 'Edycja nie powiodła się, brak pliku']);
        //brak id
        if (!$this->id) {
            return $error;
        }
        //brak pliku
        if (null === ($file = (new CmsFileQuery)->findPk($this->id))) {
            return $error;
        }
        //błędny plik
        if ($this->hash != $file->getHashName()) {
            return $error;
        }
        //zapis
        $postData = $this->getPost()->toArray();
        if (!empty($postData)) {
            $file->setFromArray($postData)
                ->save();
        }
        //json na potrzeby wyświetlenia formularza
        return $file->toJson();
    }
700304
public final function rollBack()
    {
        //brak transakcji
        if (!$this->_transactionInProgress) {
            return false;
        }
        //zakończenie transakcji z cofnięciem
        $this->_transactionInProgress = false;
        return $this->_upstreamPdo->rollBack();
    }
1124552
public function delete()
    {
        //usuwanie meta
        if (!parent::delete()) {
            return false;
        }
        //plik jest ciągle potrzebny (ma linki)
        if (0 != (new CmsFileQuery)->whereName()->equals($this->name)->count()) {
            return true;
        }
        //kasowanie z systemu plików
        (new \Cms\Model\FileSystemModel($this->name))->unlink();
        //usuwanie rekordu
        return true;
    }
828178
public function isFieldInRecord()
    {
        //zażądany join
        if (strpos($this->getName(), '.')) {
            return true;
        }
        //sorawdzenie w rekordzie
        return property_exists($this->_grid->getQuery()->getRecordName(), $this->getName());
    }