Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

bulkMailFilters


Przejdź do rozwiązania Rozwiązane przez teez,

Rekomendowane odpowiedzi

Hej. Chcę zrobić dodatkową opcję w mailingu dla mojej aplikacji. Coś próbuję, kombinuję - szkielet jako taki mam. Chodzi mi teraz o ostatnią funkcję, a dokładniej getMembers, która nie do końca się spisuje - nic się nie dzieje ( nie ważne, czy wybieram opcję, która powinna skutkować brakiem odbiorców, czy nie ).

<?php
class bulkMailFilters_region
{
	public $filters = array( 'region' );
}

class bulkMailFilter_region_region extends bulkMailFilter
{
	/** 
	 * Get Setting Field
	 *
	 * @param	mixed	Value as returned by the save method
	 * @return	string	HTML to show in ACP when adding a reminder that will allow admins to set up a reminder
	 */
	public function getSettingField( $criteria )
	{
		$regions_id = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
		foreach($regions_id as $regions_id)
		{
			$regions[] = array( $regions_id, $regions_id );
		}	
		

        $selectBox = ipsRegistry::getClass('output')->formMultiDropdown( 'bmf_members_region[]', $regions, isset( $criteria['region'] ) ? explode( ',', $criteria['region'] ) : $_POST['bmf_members_region'] );
		return "{$selectBox}";
	}
	/**
	 * Save Setting Field
	 *
	 * @param	array		POST data from the form using the form elements provided in the getSettingField method
	 * @return	mixed		If this criteria should be ignored, return FALSE. Otherwise, return whatever data you will need in your
	 *						getMembers method to fetch members that match the chosen criteria
	 * @throws	Exception	You can throw an Exception with the message being the error to display if the user has provided invalid data
	 */
	public function save( $post )
	{
		if ( !$post['bmf_members_regions'] )
		{
			return false;
		}
		else
		{
			return array( 'region' => implode( ',', $post['bmf_members_regions'] ));
		}

	}
	
	/**
	 * Get Members
	 *
	 * @param	mixed	Whatever data was returned by save method
	 * @return	array	Array with two elements:
	 *						'joins' should be an array of any additional tables to join (as per ipsRegistry::DB()->build)
	 *						'where' should be an array of where clauses
	 *					The table 'members' is already available with the prefix 'm'
	 */
	public function getMembers( $data )
	{
		print_r($data);
		if ( $data['region'] )
		{
			foreach($data as $regions)
			{
				$add_join = array(
									array( 
																'select' => 'l.member_id',
																'from'	 => array( 'l' => 'my_regions' ),
																'where'	 => 'l.member_id = '.$regions,
																'type'	 => 'left'
															)
														);
			}
			$where = array( "m.member_id=l.member_id" );
			
			return array( 'add_join' => array( $return ), $where = array( $where ) );
		}
	}
}

Mailing powinien iść do osób w następujący sposób:

 

Multiselect od 1 do 16 ID -> Wybieram np. 2,3,4,5,6 -> Wyszukuje member_id z tabeli my_regions gdzie ktoś ma jedno z tych ID -> wysyła mailing do tych osób

 

Jakieś pomysły? Myślałem też użyć DB->buildWherePermission, ale wydaje mi się, że w tej sekcji oddziałowuje ona wyłącznie na tabelę members, więc nic mi to nie da.

Edytowane przez teez

Znajdziesz mnie na LinkedIn

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.