dev-master
9999999-devAgileToolkit universal messaging system
The Requires
- php >=5.3.3
- atk4/atk4 4.3.*@dev
- nesbot/carbon *
The Development Requires
by Vadym Radvansky
by Konstantin Kolodnitsky
atk4 addon
AgileToolkit universal messaging system
composer.json, (*1)
"atk4/messages": "dev-master"
By default add-on supports only few types of users, (*2)
protected static $from_types = ['admin'=>'Administrator']; protected static $to_types = ['admin'=>'Administrator','broadcast'=>'Broadcast message'];
You can extend this list by creating your own model extended from atk4/messages/Model_Message
and adding
same static properties to your newly created model., (*3)
protected static $from_types = [ 'reader' => 'Reader', 'author' => 'Author' ]; protected static $to_types = [ 'reader' => 'Reader', 'author' => 'Author' ];
Also you have to let add-on know that it should use your custom model, (*4)
atk4\messages\Config::getInstance()->setMessageModelClassName('Model_MyMessage')
The original set of roles and your own will be mixed. Use {{your_model_name}}::getFromTypes()
and {{your_model_name}}::getToTypes()
to get all available roles., (*5)
Important!!! There are two separate lists of roles - "to" and "from" , (*6)
After you added custom roles you must let add-on know what model to use for each role. Use atk4/messages/Config singleton to make your add-on settings available globally., (*7)
atk4\messages\Config::getInstance() ->setTypeModelClassName( 'reader', 'Model_Reader' ) ->setTypeModelClassName( 'author', 'Model_Author' ) ;
Create page for message management, (*8)
class page_messages extends Page { function init(){ parent::init(); $this->title = 'Messages'; $m = $this->add('atk4/messages/Model_Message'); // $m = $this->add('Model_MyMessage'); // <~~~~~~~~~~~~ for custom model $m->setOrder('created_dts',true); $crud = $this->add('atk4/messages/CRUD_Messages'); $crud->setModel($m); // optional paginator if ($crud->grid) { $crud->grid->addPaginator(); } } }
Done! Now you have fully functional admin panel for message management., (*9)
You can change some css class using atk4/messages/Config singleton. List of available ... provided, (*10)
'message-from-class' => 'atk-label atk-effect-warning atk-block', 'message-to-class' => 'atk-label atk-effect-warning atk-block', 'message-text-class' => 'atk-swatch-gray atk-box',
It is your responsibility to create user UI., (*11)
AgileToolkit universal messaging system
atk4 addon