Akcja jsonowa wyszukująca użytkowników w LDAP
432808
public function autocompleteAction()
    {
        //typ odpowiedzi
        $this->getResponse()->setTypeJson();
        //za krótki ciąg
        if (strlen(trim($this->term)) < 3) {
            return json_encode([]);
        }
        //zwraca odpowiedz JSON
        return json_encode((new \Cms\Model\Auth)->ldapAutocomplete($this->term . '*'));
    }
198759
def __ldap_attr(self, fname, lname, type, group,
                    group_api):  # pragma: no cover
        """"""
        return {
            'uid':
            str(self.username).encode(),
            'cn':
            ' '.join([fname, lname]).encode(),
            'sn':
            str(lname).encode(),
            'givenname':
            str(fname).encode(),
            'homedirectory':
            os.path.join(os.path.sep, 'home', self.username).encode(),
            'loginshell':
            os.path.join(os.path.sep, 'bin', 'bash').encode(),
            'mail':
            '@'.join([self.username, self.client.mail_domain]).encode(),
            'uidnumber':
            self.__uidnumber(type),
            'gidnumber':
            API.__gidnumber(group, group_api),
            'userpassword':
            str('{SSHA}' + API.__create_password().decode()).encode(),
        }
310072
public function handleRequest()
    {
        //obsługa danych z POST
        $post = FrontController::getInstance()->getRequest()->getPost();
        //brak posta
        if ($post->isEmpty()) {
            return;
        }
        //niedozwolone na ACL (w edycji na polu operacje)
        if ($this->_checkbox->getGrid()->getColumn('_operation_') && !(new AclAllowed)->aclAllowed($this->_checkbox->getGrid()->getColumn('_operation_')->getOption('editParams'))) {
            return;
        }
        if ($this->_changeRecord($post)) {
            exit;
        }
    }
1211823
def json(self):
        
        return {
            "elevation": self.elevation,
            "latitude": self.latitude,
            "longitude": self.longitude,
            "icao_code": self.icao_code,
            "name": self.name,
            "quality": self.quality,
            "wban_ids": self.wban_ids,
            "recent_wban_id": self.recent_wban_id,
            "climate_zones": {
                "iecc_climate_zone": self.iecc_climate_zone,
                "iecc_moisture_regime": self.iecc_moisture_regime,
                "ba_climate_zone": self.ba_climate_zone,
                "ca_climate_zone": self.ca_climate_zone,
            },
        }
987445
public function exportFileListAction()
    {
        //autoryzacja
        $this->_authenticate();
        //json z plikami
        return json_encode((new Model\ConnectorModel)->getFileList($this->getPost()->fileObjects));
    }
1206451
public function toggleAction()
    {
        //wyszukiwanie relacji do edycji
        if (null === $widgetRelation = (new \Cms\Orm\CmsCategoryWidgetCategoryQuery)
            ->whereCmsCategoryId()->equals($this->categoryId)
            ->findPk($this->id)) {
            return '';
        }
        //zmiana widoczności relacji
        $widgetRelation->toggle();
        return '';
    }
196630
public function automatic_rest_api(){
		@header('text/json; charset=UTF-8');

		$rtn = array();
		$rtn['result'] = false;
		// $rtn['options'] = $this->options;
		// $rtn['_SERVER'] = $_SERVER;
		// $rtn['_GET'] = $_GET;
		// $rtn['_POST'] = $_POST;

		if( $this->options['method'] == 'POST' ){
			// --------------------------------------
			// 投稿系リクエスト
			if( !strlen($this->options['table']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Table name not set.';
				echo json_encode( $rtn );
				return null;
			}
			if( strlen($this->options['id']) ){
				// 対象のテーブルが指定された場合はエラー
				$rtn['error'] = 'Resource ID was set.';
				echo json_encode( $rtn );
				return null;
			}

			$params = $this->options['post_params'];
			$result = $this->exdb->insert($this->options['table'], $params);
			$rtn['result'] = $result;
			$last_insert_info = $this->exdb->get_last_insert_info();
			$rtn['given_id'] = $last_insert_info->value;
			echo json_encode( $rtn );
			return null;

		}elseif( $this->options['method'] == 'GET' ){
			// --------------------------------------
			// 取得系リクエスト
			if( !strlen($this->options['table']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Table name not set.';
				echo json_encode( $rtn );
				return null;
			}

			if( !strlen($this->options['id']) ){
				// ID無指定の場合、一覧情報を返す
				$rtn['list'] = $this->exdb->select($this->options['table'], $this->options['get_params'], $this->query_options);
				$rtn['count'] = $this->exdb->count($this->options['table'], $this->options['get_params']);
				$rtn['result'] = true;
				if( count($this->table_definition->system_columns->password) ){
					foreach( $rtn['list'] as $key=>$val ){
						foreach($this->table_definition->system_columns->password as $column_name){
							unset($rtn['list'][$key][$column_name]);
						}
					}
				}
				echo json_encode( $rtn );
				return null;
			}else{
				// ID指定がある場合、詳細情報1件を返す
				$where = $this->options['get_params'];
				// $rtn['table_definition'] = $this->table_definition;
				$where[$this->table_definition->key_column] = $this->options['id'];
				$row = $this->exdb->select($this->options['table'], $where);
				$rtn['row'] = @$row[0];
				foreach($this->table_definition->system_columns->password as $column_name){
					unset($rtn['row'][$column_name]);
				}
				$rtn['result'] = true;
				echo json_encode( $rtn );
				return null;
			}

		}elseif( $this->options['method'] == 'PUT' ){
			// --------------------------------------
			// 更新系リクエスト
			if( !strlen($this->options['table']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Table name not set.';
				echo json_encode( $rtn );
				return null;
			}
			if( !strlen($this->options['id']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Resource ID not set.';
				echo json_encode( $rtn );
				return null;
			}

			$params = $this->options['post_params'];
			$result = $this->exdb->update(
				$this->options['table'],
				array(
					$this->table_definition->key_column => $this->options['id'],
				),
				$params
			);
			$rtn['result'] = ($result ? true : false);
			$rtn['affected_rows'] = $result;
			echo json_encode( $rtn );
			return null;

		}elseif( $this->options['method'] == 'DELETE' ){
			// --------------------------------------
			// 削除系リクエスト
			if( !strlen($this->options['table']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Table name not set.';
				echo json_encode( $rtn );
				return null;
			}
			if( !strlen($this->options['id']) ){
				// 対象のテーブルが不明な場合はエラー
				$rtn['error'] = 'Resource ID not set.';
				echo json_encode( $rtn );
				return null;
			}

			$result = $this->exdb->delete(
				$this->options['table'],
				array(
					$this->table_definition->key_column => $this->options['id'],
				)
			);
			$rtn['result'] = ($result ? true : false);
			$rtn['affected_rows'] = $result;
			echo json_encode( $rtn );
			return null;

		}

		$rtn['error'] = 'Unknown method';

		echo json_encode( $rtn );
		return null;
	}
303082
public function validateAndPrepareBackendData($key, $data)
    {
        //niepoprawna serializacja
        if (!($data = \unserialize($data))) {
            return;
        }
        //dane niepoprawne
        if (!array_key_exists('e', $data) || !array_key_exists('d', $data)) {
            return;
        }
        //dane wygasłe
        if ($data['e'] <= time()) {
            return;
        }
        //zapis danych do rejestru
        $this->getRegistry()->setOption($key, $data['d']);
        //zwrot danych
        return $data['d'];
    }
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;
    }
843857
public function copyAction()
    {
        $this->getResponse()->setTypeJson();
        if (null === $category = (new \Cms\Orm\CmsCategoryQuery)->findPk($this->getPost()->id)) {
            return json_encode(['status' => false, 'error' => 'Strona nie istnieje']);
        }
        //model do kopiowania kategorii
        $copyModel = new \Cms\Model\CategoryCopy($category);
        //kopiowanie z transakcją
        if ($copyModel->copyWithTransaction()) {
            return json_encode(['status' => true, 'id' => $copyModel->getCopyRecord()->id, 'message' => $this->view->_('controller.category.copy.message')]);
        }
        return json_encode(['status' => false, 'error' => $this->view->_('controller.category.copy.error')]);
    }
1318840
def _create_json(self):
        
        data_json = super(GroupLDAP, self)._create_json()
        data_json.update({
            'realmAttributes': self.realmAttributes,
            'external': True,
        })
        return data_json
879149
def json(self):
        '''  '''
        ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0]
        if ctype == 'application/json':
            b = self._get_body_string()
            if not b:
                return None
            return json_loads(b)
        return None
416915
def _create_json(self):
        
        data_json = {
            "name": self.name,
            "includesPattern": self.includesPattern,
            "excludesPattern": self.excludesPattern,
            "repositories": self._repositories,
            "principals": {
                'users': self._users,
                'groups': self._groups,
            }
        }
        return data_json
969676
protected function getApplicationCommands()
    {
        $commands = [];
        foreach (StructureParser::getModules() as $module) {
            //namespace modułu
            $moduleNamespace = substr($module, strrpos($module, DIRECTORY_SEPARATOR) + 1, strlen($module));
            //iteracja po komendach konsolowych
            foreach (glob($module . '/Console/*Command.php') as $command) {
                $className = basename($command, '.php');
                $class = '\\' . $moduleNamespace . '\\Console\\' . $className;

                //reflection do sprawdzenia pochodzenia
                $r = new \ReflectionClass($class);
                if ($r->isSubclassOf('Mmi\\Console\\CommandAbstract')
                    && !$r->isAbstract()
                    && !$r->getConstructor()->getNumberOfRequiredParameters()
                ) {
                    $commands[] = $r->newInstance();
                }
            }
        }
        return $commands;
    }
81164
public function getFileObjects()
    {
        $fileObjects = [];
        //iteracja po unikalnych obiektach
        foreach ((new \Cms\Orm\CmsFileQuery)->findUnique('object') as $object) {
            //pominięcie plików tymczasowych
            if ('tmp-' == substr($object, 0, 4)) {
                continue;
            }
            //dodanie pliku
            $fileObjects[$object] = $object;
        }
        return $fileObjects;
    }
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;
    }
617190
public static function idAuthenticate($id)
    {
        //wyszukiwanie aktywnego użytkownika
        if (null === $record = self::_findUserByIdentity($id)) {
            return;
        }
        return self::_authSuccess($record);
    }