Hi,
I have a problem.
On my site I have a registration form for mail confirmation.
Each user after registration has a subsite with form to report new objectsleep .
The form requires the name object, address, etc. ...
Form application write in the DataObject.
How to make an application which is stored in the database was set by default to not display on the page
otherwise:
My point is that the notification sent by member in the database which to save the "ObjectSleep" it was turned off for as long as admin does not approve it.
At the moment member send the form saves the object in the database but it is automatically visible to others.
My code:
class Obiekt extends DataObject {
//--------------- BAZA DANYCH --------------- //
static $db = array(
'Title' => 'Varchar(255)',
'NazwaObiektu' => 'Varchar(255)',
'KodPocztowy' => 'Varchar(6)',
'Miejscowosc' => 'Varchar(255)',
'Ulica' => 'Varchar(255)',
'NrDomu' => 'Varchar(6)',
'Telefon' => 'Int',
'TelefonDodatkowy' => 'Int',
'Email' => 'Varchar(255)',
'Strona' => 'Varchar(255)',
'DostepnoscObiektu' => 'Boolean',
'Pokoj1' => 'Boolean',
'Pokoj2' => 'Boolean',
'Pokoj3' => 'Boolean',
'Pokoj4' => 'Boolean',
'Pokoj5' => 'Boolean',
'SrCenaMin' => 'Int',
'SrCenaMax' => 'Int',
'IloscMiejsc' => 'Int',
);
//--------------- ŁĄCZENIA BAZ DANYCH --------------- //
static $has_one = array(
'Wojewodztwo' => 'Wojewodztwo',
'Uzytkownik' => 'Uzytkownik',
'Region' => 'Region',
'Nocleg' => 'Nocleg',
);
//--------------- NAZWA --------------- //
static $singular_name = 'Obiekt';
static $plural_name = 'Obiekty';
function getTitle() {
return "{$this->NazwaObiektu}";
}
//--------------- NAZWY POLA FORMULARZA --------------- //
static $field_labels = array(
'Title' => 'NazwaObiektu',
'NazwaObiektu' => 'Nazwa Obiektu:',
'KodPocztowy' => 'Kod pocztowy:',
'Miejscowosc' => 'Miejscowosc:',
'Ulica' => 'Ulica:',
'NrDomu' => 'Numer domu / lokalu:',
'Telefon' => 'Telefon:',
'TelefonDodatkowy' => 'Telefon dodatkowy:',
'Email' => 'Email:',
'Strona' => 'Strona www (bez http://):',
'DostepnoscObiektu' => 'Obiekt dostepny całorocznie:',
'SrCenaMin' => 'Średnia cena noclegu za osobę od:',
'SrCenaMax' => 'do:',
);
//--------------- NAZWY POLA WYSZUKIWANIA --------------- //
static $searchable_fields = array(
'Miejscowosc' => array (
'title' => 'Nazwa miejscowosci',
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
),
'Wojewodztwo.ID' => array(
'title' => 'Województwo',
),
'Region.ID' => array (
'title' => 'Region',
),
'Nocleg.ID' => array (
'title' => 'Kategoria noclegu',
),
'SrCenaMin' => array(
'field' => 'TextField',
'filter' => 'GreaterThanFilter',
'title' => 'Cena / od'
),
'SrCenaMax' => array(
'field' => 'TextField',
'filter' => 'LessThanFilter',
'title' => 'do / osoba'
),
);
public function getDefaultSearchContext() {
$context = parent::getDefaultSearchContext();
return $context;
}
//--------------- UPRAWNIENIA --------------- //
public function canView($member = null) {
return true;
}
public function canCreate($member = null) {
return true;
}
public function canEdit($member = null) {
if(!$member) $member = Member::currentUser();
return (
Permission::checkMember($member, 'ADMIN')
|| ($member && $member->ID == $this->ID)
);
}
public function canDelete($member = null) {
return $this->canEdit($member);
}
}
I think i must use
'Status' => "Enum('Active,Disabled','Disabled')",
and
'defaults' => array(
'Status' => 'Disabled'
)
but i know idea where i must use this code and
what must be in ContentController which be blocked this object
unless you have a different idea
Sorry for my bad English