Retrouve les éventuels critères de recherche en _POST

@return void
189081
protected function setSearchCriteriaFromPost()
    {
        $this->initSearchCriteria();

        foreach ($this->aCriteria as $sIndex => $mValue) {
            $this->aCriteria[$sIndex] = $this->app['request']->request->get($sIndex, $mValue);
        }
    }
757968
public function index()
    {
        $this->request->allowMethod(['post', 'put', 'patch']);
        $calendarsTable = TableRegistry::get('Qobo/Calendar.Calendars');

        $events = [];
        $data = $this->request->getData();
        $data = is_array($data)? $data : [];
        if (!empty($data['calendar_id'])) {
            $calendar = $calendarsTable->get($data['calendar_id']);
            $events = $this->CalendarEvents->getEvents($calendar, $data);
        }

        $this->set(compact('events'));
        $this->set('_serialize', 'events');
    }
70303
public function initPosts() {

		/** @var $wpdb \wpdb */
		global $wpdb;

		$posts = [
			[
				'post_title' => __( 'Custom Style for Ebook', 'pressbooks' ),
				'post_name' => 'epub',
				'post_type' => 'custom-style',
			],
			[
				'post_title' => __( 'Custom Style for PDF', 'pressbooks' ),
				'post_name' => 'prince',
				'post_type' => 'custom-style',
			],
			[
				'post_title' => __( 'Custom Style for Web', 'pressbooks' ),
				'post_name' => 'web',
				'post_type' => 'custom-style',
			],
		];

		$post = [
			'post_status' => 'publish',
			'post_author' => wp_get_current_user()->ID,
		];

		foreach ( $posts as $item ) {
			$exists = $wpdb->get_var(
				$wpdb->prepare(
					"SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = %s AND post_name = %s AND post_status = 'publish' ",
					[ $item['post_title'], $item['post_type'], $item['post_name'] ]
				)
			);
			if ( empty( $exists ) ) {
				$data = array_merge( $item, $post );
				wp_insert_post( $data );
			}
		}
	}
808447
function query_posts()
   	{
   		// vars
   		$r = array(
   			'next_page_exists' => 1,
   			'html' => ''
   		);
   		
   		
   		// options
		$options = array(
			'post_type'					=>	'all',
			'taxonomy'					=>	'all',
			'posts_per_page'			=>	10,
			'paged'						=>	1,
			'orderby'					=>	'title',
			'order'						=>	'ASC',
			'post_status'				=>	'any',
			'suppress_filters'			=>	false,
			's'							=>	'',
			'lang'						=>	false,
			'update_post_meta_cache'	=>	false,
			'field_key'					=>	'',
			'nonce'						=>	'',
			'ancestor'					=>	false,
		);
		
		$options = array_merge( $options, $_POST );
		
		
		// validate
		if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
		{
			die();
		}
		
		
		// WPML
		if( $options['lang'] )
		{
			global $sitepress;
			
			if( !empty($sitepress) )
			{
				$sitepress->switch_lang( $options['lang'] );
			}
		}
		
		
		// convert types
		$options['post_type'] = explode(',', $options['post_type']);
		$options['taxonomy'] = explode(',', $options['taxonomy']);
		
		
		// load all post types by default
		if( in_array('all', $options['post_type']) )
		{
			$options['post_type'] = apply_filters('acf/get_post_types', array());
		}
		
		
		// attachment doesn't work if it is the only item in an array???
		if( is_array($options['post_type']) && count($options['post_type']) == 1 )
		{
			$options['post_type'] = $options['post_type'][0];
		}
		
		
		// create tax queries
		if( ! in_array('all', $options['taxonomy']) )
		{
			// vars
			$taxonomies = array();
			$options['tax_query'] = array();
			
			foreach( $options['taxonomy'] as $v )
			{
				
				// find term (find taxonomy!)
				// $term = array( 0 => $taxonomy, 1 => $term_id )
				$term = explode(':', $v); 
				
				
				// validate
				if( !is_array($term) || !isset($term[1]) )
				{
					continue;
				}
				
				
				// add to tax array
				$taxonomies[ $term[0] ][] = $term[1];
				
			}
			
			
			// now create the tax queries
			foreach( $taxonomies as $k => $v )
			{
				$options['tax_query'][] = array(
					'taxonomy' => $k,
					'field' => 'id',
					'terms' => $v,
				);
			}
		}
		
		unset( $options['taxonomy'] );
		
		
		// load field
		$field = array();
		if( $options['ancestor'] )
		{
			$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
			$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
		}
		else
		{
			$field = apply_filters('acf/load_field', array(), $options['field_key'] );
		}
		
		
		// get the post from which this field is rendered on
		$the_post = get_post( $options['post_id'] );
		
		
		// filters
		$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
		$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
		$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
		
		
		// query
		$wp_query = new WP_Query( $options );

		
		// global
		global $post;
		
		
		// loop
		while( $wp_query->have_posts() ) {
			
			$wp_query->the_post();
			
			
			// get title
			$title = $this->get_result($post, $field, $the_post, $options);
			
			
			// update html
			$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title .  '<span class="acf-button-add"></span></a></li>';
				
		}
		
		
		// next page
		if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
			
			$r['next_page_exists'] = 0;
			
		}
		
		
		// reset
		wp_reset_postdata();
		
		
		// return JSON
		echo json_encode( $r );
		
		die();
			
	}
257695
public function index()
    {











$article = Article::load()->findOrFail(1);
echo '<pre>'; print_r($article );

$article = Article::load()->find(1);
echo '<pre>'; print_r($article );





// Récupérer un article WHERE slug
$article = Article::load()->where('slug', '=', 'article-1')->find();
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"


$article->testQuery();

// Récupérer un article WHERE slug ou une erreur HTTP 404
$article = Article::load()->where('slug', '=', 'article-1')->findOrFail();
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"



// Récupérer un article WHERE slug
$article = Article::load()->findBySlug('article-1');
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"

// Récupérer un article WHERE slug ou une erreur HTTP 404
$article = Article::load()->findOrFailBySlug('article-1');
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"



// Récupérer une collection d'articles avec un WHERE
$articles = Article::load()->where('status', '=', 1)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1"



// Récupérer une collection d'articles avec un WHERE
$articles = Article::load()->findAllByStatus(1);
// Résultat SQL : "SELECT * FROM articles WHERE status = 1"



$articles = Article::load()->where('status', '=', 1)->where('status', '=', 2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 AND online = 1"



$articles = Article::load()->where('status', '=', 1)->orWhere('status', '=', 2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 OR online = 1"




$articles = Article::load()->whereIn('id', [1, 2, 3])->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE id IN (1, 2, 3)"



$articles = Article::load()->whereIn('id', [1, 2, 3])->orWhereIn('id', [7, 8, 9])->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE id IN (1, 2, 3) OR id IN (20, 21, 22)"


$articles = Article::load()->where('status', '=', 1)->orderBy('title', 'ASC')->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 ORDER BY 'title' ASC"



$articles = Article::load()->where('status', '=', 1)->limit(5)->offset(2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 LIMIT 5 OFFSET 2"




$article = new Article();

$articles = $article->paginate();
// Résultats SQL :
// SELECT COUNT(id) AS nb FROM articles WHERE status = 1
// Et :
// SELECT * FROM articles WHERE status = 1 LIMIT 10 OFFSET ? 

echo '<pre>'; print_r($article->getTotal());  // return int - Nombre d'articles paginés

$pagination = $article->getPagination();

foreach ($articles as $article) {
    echo $article->title;
}

echo $pagination->render();  // return string
echo $pagination->perPage();  // return string




$article = new Article();

$articles = $article->paginate(5);





// Par exemple, récupérer tous les articles qui sont joints à une catégorie WHERE son id avec un INNER JOIN
$articlesJoinedToCategory = Article::load()
    ->join(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// INNER JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);


echo '<hr>';

// Par exemple, récupérer tout les articles qui sont joints à une catégorie WHERE son id avec un LEFT JOIN
$articlesJoinedToCategory = Article::load()
    ->leftJoin(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// LEFT JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);

echo '<hr>';

// Par exemple, récupérer tout les articles qui sont joints à une catégorie WHERE son id avec un RIGHT JOIN
$articlesJoinedToCategory = Article::load()
    ->rightJoin(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// RIGHT JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);




Article::load()->select('title, description, content')->where('id', '=', 1)->find();

Article::load()->select('title', 'description', 'content')->where('id', '=', 1)->find();

Article::load()->select(['title', 'description', 'content'])->where('id', '=', 1)->find();




$countArticles = Article::load()->count('id');
// return int - Résultat SQL : "SELECT COUNT(id) AS nb FROM articles"
// PS : Le paramètres 'id' n'est pas obligatoire. Est '*' par défaut.
echo '<pre>'; print_r($countArticles);


$countArticlesByStatus =  Article::load()->countByStatus(1);
// return int - Résultat SQL : "SELECT COUNT(*) AS nb FROM articles WHERE status = 1"
// PS : En 2ème paramètres de "countByStatus" on peut préciser la colonne en ajoutant un 2ème paramètres. Est '*' par défaut.




$sumIdArticles = Article::load()->sum('id');
// return int - Résultat SQL : "SELECT SUM(id) AS sum FROM articles"
echo '<pre>'; print_r($sumIdArticles);




$maxIdArticles = Article::load()->max('id');
// return int - Résultat SQL : "SELECT MAX(id) AS max FROM articles"
echo '<pre>'; print_r($maxIdArticles);




$condition = true;
$articles = Article::load()
    ->select('title, description, content')
    ->where('id', '!=', 1)
    ->when($condition === true, function ($query) {
        return $query->where('status', '=', 1);
    })
    ->findAll();
// Si $condition = true - Résultat SQL : "SELECT title, description, content FROM articles WHERE id != 1 AND status = 1"
// Si $condition = false - Résultat SQL : "SELECT title, description, content FROM articles WHERE id != 1"






$article = new Article();
$articles = $article->runRowCount(true)->findAll();
echo '<pre>'; print_r($article->getRowCount());
// return int - Nombre de lignes affectées



/*

$article = new Article();
$article->setStatus(2);
$article->setH1('Article 18');
$article->setDescription('Description Article 18');
$article->setContent('Content Article 18');
$article->setTitle('Title Article 18');
$article->setSlug('article-120');
$article->setUserId(2);
$article->save();


echo $article->getLastInsertId();
die;

Article::load()->create([
    'status' => 2,
    'h1' => 'Article 12',
    'description' => 'Description Article 12',
    'content' => 'Content Article 12',
    'title' => 'Title Article 12',
    'user_id' => 1,
    'slug' => 'article-12',
]);
// Résultat SQL :
// "INSERT INTO articles (status, h1, description, content, title, slug)
//  VALUES (1, 'Article 12', 'Description Article 12', 'Content Article 12', 'Title Article 12', 'article-12')"

*/








$article = Article::load()->findById(1);
$article->setStatus(2);
$article->setH1('Article 1');
$article->setDescription('Description Article 1');
$article->setContent('Content Article 1');
$article->setTitle('Title Article 1');
$article->setSlug('article-1');
$article->save();



echo $article->getNow();



Article::load()
    ->where('id', '=', 1)
    ->limit(1)
    ->update([
        'status' => 2,
        'h1' => 'Article 1',
        'description' => 'Description Article 1',
        'content' => 'Content Article 1',
        'title' => 'Title Article 1',
        'slug' => 'article-1',
    ]);



$_POST = [
    'status' => 2,
    'h1' => 'Article 1',
    'description' =>
    'Description Article 1',
    'content' => 'Content Article 1',
    'title' => 'Title Article 1',
    'slug' => 'article-1',
];

$article = Article::load()->findById(1);
$article->fill($_POST);
$article->save();

$_POST = [];


// Résultat SQL :
// "UPDATE articles SET
//  status = 1, h1 = 'Article 1', description = 'Description Article 1', content = 'Content Article 1', title = 'Title Article 1', slug = 'article-1'
//  WHERE id = 1 LIMIT 1"




$_POST = [
    'status' => 2,
    'h1' => 'Article 1',
    'description' =>
    'Description Article 1',
    'content' => 'Content Article 1',
    'title' => 'Title Article 1',
    'slug' => 'article-1',
];

$article = Article::load()->findById(1);

var_dump( $article->getTitle() );

$article->fill($_POST);

var_dump( $article->getTitle() );

$article->save();

var_dump( $article->getTitle() );

$_POST = [];












/*
$article = Article::load()->findById(18);
$article->delete();
// Résultats SQL :
// "SELECT * FROM articles WHERE id = 13 LIMIT 1"
// Et :
// "DELETE FROM articles WHERE id = 13 LIMIT 1"


Article::load()->where('id', '=', 17)->limit(1)->delete();

*/





$article = Article::load()->findById(1);
echo '<pre>'; print_r($article->getH1());





$article = new Article();

/*
try {
    // Démarrer une transaction
    $article->beginTransaction();

    // Valider une transaction
    $article->validTransaction();
} catch (\Exception $e) {
    // Annuler une transaction
    $article->cancelTransaction();
}
*/



echo '<hr>';




// Récupérer l'article WHERE son id :
$article = Article::load()->findById(1);
// Résultat SQL : "SELECT * FROM articles WHERE id = 1 LIMIT 1"

// Prenons pour exemple que la colonne 'user_id' de l'article a pour valeur "2"
// Récupérer l'user relié à cette article :
$userJoinedTiArticle = $article->user();
echo '<pre>'; print_r($userJoinedTiArticle);
// Résultat SQL : SELECT users.* FROM users WHERE users.id = 2 LIMIT 1



echo '<hr>';




$user = User::load()->findById(1);
// Résultat SQL : "SELECT * FROM users WHERE id = 1 LIMIT 1"

// Récupérer tous les articles reliés à cette user
$articlesJoinedToUser = $user->articles();
echo '<pre>'; print_r($articlesJoinedToUser);




echo '<hr>';






// Récupérer l'article WHERE son id :
$article = Article::load()->findById(1);
// Résultat SQL : "SELECT * FROM articles WHERE id = ? LIMIT 1"

// Récupérer toute les catégories jointes à cette article :
$articleCategories = $article->articleCategories();
echo '<pre>'; print_r($articleCategories);
// Résultat SQL :
// SELECT articles_categories.* FROM articles_categories
// INNER JOIN articles_categories_intermediate
//   ON articles_categories.id = articles_categories_intermediate.category_id
// WHERE articles_categories_intermediate.article_id = 2



$a = new Article;
$a->testQuery();




$article = new Article();
echo '<pre>'; print_r($article->getDbTable());




$article = new Article();
echo '<pre>'; print_r($article->getTable());





        return $this->view('article/index', [
            'baliseTitle' => 'Article listing title',
            'metaDescription' => 'Article listing desciption',
        ]);  
    }
209772
public function view()
    {
        $response = [
            'success' => false,
            'data' => [],
            'errors' => []
        ];

        if ($this->request->is(['post', 'patch', 'put'])) {
            $data = $this->request->getData();
            $result = $this->CalendarEvents->getEventInfo($data['id']);

            if (!empty($result)) {
                $response['success'] = true;
                $response['data'] = $result;
            } else {
                $response['errors'][] = "Couldn't find Event with id {$data['id']}";
            }
        }

        $this->set(compact('response'));
        $this->set('_serialize', 'response');
    }
1330001
public function onYiiEvent()
    {
        Event::on(ActiveRecord::className(), ActiveRecord::EVENT_INIT, function ($event) {
            /** @var ActiveRecord $model */
            $model = $event->sender;
            $model->getTableSchema();
        });
    }
231469
public function listReportEvent()
    {
        $this->clearReportEvent();
        $this->actionListReportEvent();

        $this->setTitleListReportEvent();
        $this->setBreadcrumbListReportEvent();
        $this->setFilterListReportEvent();
        $this->setPagerListReportEvent();

        $this->setData('types', $this->report->getTypes());
        $this->setData('severities', $this->report->getSeverities());
        $this->setData('records', $this->getListReportEvent());

        $this->outputListReportEvent();
    }
539895
public function eventsList()
    {
        $eventList = $this->eventManager()->entries();
        foreach ($eventList as $event) {
            yield $this->eventFormatShort($event);
        }
    }
535877
public function afterRequest()
    {

        if (count($this->afterRequestEvents) > 0) {
            foreach ($this->afterRequestEvents as $event) {
                $event->OnEvent($this);
            }
        }
    }
553235
protected function ensureEvents()
	{
		if ($this->_events === null) {
			$this->_events = [];
			if (method_exists($this, 'events')) {
			    if ($events = $this->events()) foreach ($events as $name => $handler) {
					$this->on($name, $handler);
				}
			}
		}
	}
416430
public function post()
    {
        $this->setPostedAt(new \DateTime());

        $this->getAccount()->setPostedBalance(
            $this->getAccount()->getPostedBalance() + $this->getAmount()
        );
    }
194195
protected function bindEvents(): void
    {
        $userConfig = $this->app['config'][static::$abstract];

        $handler = new EventHandler($this->app->events, $userConfig);

        $handler->subscribe();

        $handler->subscribeQueueEvents($this->app->queue);

        if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) {
            $handler->subscribeAuthEvents();
        }
    }
783859
public function postPersist()
    {
        if ($this->lifecycleEventsActive) {
            $collection = $this->resourceManager->getCollection($this->collectionName);
            $collection->getTarget()->publishResource($this, $collection);
        }
    }
153154
private function postData()
    {
        if (empty($this->post)) {
            return;
        }

        $post = array_filter($this->post);

        return http_build_query($post);
    }
401938
protected function method_post()
	{
		$params = is_array($this->params) ? $this->encode($this->params) : $this->params;

		$this->set_option(CURLOPT_POST, true);
		$this->set_option(CURLOPT_POSTFIELDS, $params);
	}
54642
public function index(): void
    {
        if (!userHasPermission('admin:auth:settings:update:.*')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        $oSocial                 = Factory::service('SocialSignOn', 'nails/module-auth');
        $providers               = $oSocial->getProviders();
        $this->data['providers'] = $providers;

        // --------------------------------------------------------------------------

        if ($this->input->post()) {

            //  Prepare update
            $settings          = [];
            $settingsEncrypted = [];

            if (userHasPermission('admin:auth:settings:update:registration')) {

                $settings['user_registration_enabled'] = $this->input->post('user_registration_enabled');
            }

            if (userHasPermission('admin:auth:settings:update:password')) {

                //  @todo
            }

            if (userHasPermission('admin:auth:settings:update:social')) {

                /**
                 * Disable social signon, if any providers are proeprly enabled it'll
                 * turn itself on again.
                 */

                $settings['auth_social_signon_enabled'] = false;

                foreach ($providers as $provider) {

                    $settings['auth_social_signon_' . $provider['slug'] . '_enabled'] = (bool) $this->input->post('auth_social_signon_' . $provider['slug'] . '_enabled');

                    if ($settings['auth_social_signon_' . $provider['slug'] . '_enabled']) {

                        //  null out each key
                        if ($provider['fields']) {

                            foreach ($provider['fields'] as $key => $label) {

                                if (is_array($label) && !isset($label['label'])) {

                                    foreach ($label as $key1 => $label1) {

                                        $value = $this->input->post('auth_social_signon_' . $provider['slug'] . '_' . $key . '_' . $key1);

                                        if (!empty($label1['required']) && empty($value)) {
                                            $error = 'Provider "' . $provider['label'] . '" was enabled, but was missing required field "' . $label1['label'] . '".';
                                            break 3;
                                        }

                                        if (empty($label1['encrypted'])) {
                                            $settings['auth_social_signon_' . $provider['slug'] . '_' . $key . '_' . $key1] = $value;
                                        } else {
                                            $settingsEncrypted['auth_social_signon_' . $provider['slug'] . '_' . $key . '_' . $key1] = $value;
                                        }
                                    }

                                } else {

                                    $value = $this->input->post('auth_social_signon_' . $provider['slug'] . '_' . $key);

                                    if (!empty($label['required']) && empty($value)) {
                                        $error = 'Provider "' . $provider['label'] . '" was enabled, but was missing required field "' . $label['label'] . '".';
                                        break 2;
                                    }

                                    if (empty($label['encrypted'])) {
                                        $settings['auth_social_signon_' . $provider['slug'] . '_' . $key] = $value;
                                    } else {
                                        $settingsEncrypted['auth_social_signon_' . $provider['slug'] . '_' . $key] = $value;
                                    }
                                }
                            }
                        }

                        //  Turn on social signon
                        $settings['auth_social_signon_enabled'] = true;

                    } else {

                        //  null out each key
                        if ($provider['fields']) {

                            foreach ($provider['fields'] as $key => $label) {

                                /**
                                 * Secondary conditional detects an actual array fo fields rather than
                                 * just the label/required array. Design could probably be improved...
                                 **/

                                if (is_array($label) && !isset($label['label'])) {

                                    foreach ($label as $key1 => $label1) {
                                        $settings['auth_social_signon_' . $provider['slug'] . '_' . $key . '_' . $key1] = null;
                                    }

                                } else {
                                    $settings['auth_social_signon_' . $provider['slug'] . '_' . $key] = null;
                                }
                            }
                        }
                    }
                }
            }

            //  Save
            if (!empty($settings)) {

                if (empty($error)) {

                    $oDb = Factory::service('Database');
                    $oDb->trans_begin();

                    $bRollback          = false;
                    $oAppSettingService = Factory::service('AppSetting');

                    if (!empty($settings)) {
                        if (!$oAppSettingService->set($settings, 'auth')) {
                            $error     = $oAppSettingService->lastError();
                            $bRollback = true;
                        }
                    }

                    if (!empty($settingsEncrypted)) {
                        if (!$oAppSettingService->set($settingsEncrypted, 'auth', null, true)) {
                            $error     = $oAppSettingService->lastError();
                            $bRollback = true;
                        }
                    }

                    if ($bRollback) {

                        $oDb->trans_rollback();
                        $this->data['error'] = 'There was a problem saving authentication settings.';

                    } else {

                        $oDb->trans_commit();
                        $this->data['success'] = 'Authentication settings were saved.';

                    }

                } else {
                    $this->data['error'] = 'There was a problem saving authentication settings. ' . $error;
                }

            } else {
                $this->data['message'] = 'No settings to save.';
            }
        }

        // --------------------------------------------------------------------------

        //  Existing settings
        $this->data['settings'] = appSetting(null, 'auth', true);

        // --------------------------------------------------------------------------

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->load('nails.admin.settings.min.js', 'NAILS');

        // --------------------------------------------------------------------------

        //  Set page title
        $this->data['page']->title = 'Settings &rsaquo; Authentication';

        // --------------------------------------------------------------------------

        //  Load view
        Helper::loadView('index');
    }