Messages ¶
This Yii Framework module allows you to add quickly private messaging into your application.
GitHub - https://github.com/weavora/yii-messages
Features included:
- basic private messaging functionality,
- autosuggest,
- custom themes support,
- simple integration
Requirements ¶
This module was tested with 1.1.8 but should work with any version.
MessageModule requires a couple of methods to be defined in your User model (see below):
If you want to use modules' default layout make sure that it is defined via double slash ("//"). Usually default layout is defined in basic controller class.
// class Controller
public $layout='//layouts/column1';
Configuration ¶
Create necessary tables using SQL file - data/message.sql
There are config settings of modules section below:
return array(
'modules' => array(
'message' => array(
'userModel' => 'User',
'getNameMethod' => 'getFullName',
'getSuggestMethod' => 'getSuggest',
),
),
);
In order to use module you should specify User model that is used in the application MessageModule::userModel
.
If necessary, specify relations for Sender and Receiver MessageModule::senderRelation
and MessageModule::receiverRelation
.
'receiverRelation' => array(
CActiveRecord::BELONGS_TO,
'MyUserModel',
'',
'on' => 'MyUserModel.my_custom_id = receiver_id'
)
If you do not use Yii assets build-in functionality you will need to connect jQuery and jQuery UI(with styles) libraries. You can find them in modules folder.
Insert items into zii.widgets.CMenu
array (protected/views/layouts/main.php)
array(
'url' => Yii::app()->getModule('message')->inboxUrl,
'label' => 'Messages' .
(Yii::app()->getModule('message')->getCountUnreadedMessages(Yii::app()->user->getId()) ?
' (' . Yii::app()->getModule('message')->getCountUnreadedMessages(Yii::app()->user->getId()) . ')' : ''),
'visible' => !Yii::app()->user->isGuest),
Examples ¶
// config
return array(
'modules' => array(
'message' => array(
'userModel' => 'User',
'getNameMethod' => 'getFullName',
'getSuggestMethod' => 'getSuggest',
),
),
);
// class User
public function getFullName() {
return $this->username;
}
public function getSuggest($q) {
$c = new CDbCriteria();
$c->addSearchCondition('username', $q, true, 'OR');
$c->addSearchCondition('email', $q, true, 'OR');
return $this->findAll($c);
}
Custom Views ¶
If you are not satisfied with the standard views you can easily replace them with your own just linking path to their folder through MessageModule::viewPath
.
//config
return array(
'modules' => array(
'message' => array(
...
// for app/protected/views/messagesModuleCustom
'viewPath' => '//messagesModuleCustom',
),
),
);
// app/protected/views/messagesModuleCustom directory listing
..
compose.php
inbox.php
sent.php
view.php
Direct messages ¶
It is possible to determine each recipient by URL (for example, under user profile page). To do this, you should add his id at the end of URL.
http://example.com/message/compose/1
In this case recipients' name will be automatically inserted in the form.
Thanks
Thanks - Nice work
Thanks.
Hi perochak,
Thanks for feedback. Did you find it useful for your project? Any ideas on how to improve it?
Regards,
Mike
Testing it:)
This one is cool, It worked flawless right away, adding a table prefix was no problem either.
The fancy bootstrap view files was a huge win! BUT together with the
Yii-Bootstrap extention some of my bootstraped contents (that I had before adding this module) got bugged. So currently I'm testing without the bootstrap css file included in the fancy view folder.
And well, all looks okey:) So, thank you very much for this. If I notice something more I will add another comment.
Example view design.
I must say, now when I have gone thrue it some more, this is just pure quality.
Simple,yet effective and yes, just nice.
Keep doing extentions,weovora!:)
Here Is how I did the layout:
http://dc104.2shared.com/download/1NophlQX/message-compose.png?tsid=20120319-201651-1025a150
Sharing just to give inspiration
Nice but a small error.
Each time I send the message to myself. I will be not able to open the sent page then. It appears:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Users.id' in 'where clause'. The SQL statement executed was: SELECT
receiver
.id
ASt1_c0
,receiver
.username
ASt1_c1
,receiver
.password
ASt1_c2
,receiver
.email
ASt1_c3
,receiver
.activkey
ASt1_c4
,receiver
.createtime
ASt1_c5
,receiver
.lastvisit
ASt1_c6
,receiver
.superuser
ASt1_c7
,receiver
.status
ASt1_c8
,receiver
.fb_uid
ASt1_c9
FROMtbl_users
receiver
WHERE (Users.id = receiver_id)Any ideas?
Cool
Cool extension, thanks
Cool Extension
hi,
I like the private messaging extension, it's been done in a standard way.... but I wish if you could improve it to be AJAX-based and facebook alike :)
take care!
Receiver username
I have a bug with Receiver username then i try to send a message i wrote into Receiver field that user i whant to send message bu i got error, Receiver cannot be blank.
<?php echo CHtml::textField('receiver', $receiverName,array('size'=>35,'maxlength'=>128, 'class'=>'ui-autocomplete-input')) ?> <?php echo $form->hiddenField($model,'receiver_id'); ?> <?php echo $form->error($model,'receiver_id'); ?>
There is bug?
Implementation steps
Please specify the configuration and examples in details..?
Direct message
Hi everybody.
I couldn't send direct message through "/message/compose/1" method. Is there any other way to send direct message ?
autosuggest not working
hi!
very nice extension, my only problem is, that autosuggest is not working. firebug says the data is found, in json it's there, but it doesn't show up, the small loading icon keeps turning around.
I'm also using bootstrap, can it be the problem? is there a workaround for this?
thanks a lot!
c
autosuggest not working
hi!
very nice extension, my only problem is, that autosuggest is not working. firebug says the data is found, in json it's there, but it doesn't show up, the small loading icon keeps turning around.
I'm also using bootstrap, can it be the problem? is there a workaround for this?
thanks a lot!
c
Trouble using autocomplete (Like user below)
First of all, I would like to say that this is a great extension that is going to save me many hours :) I appreciate the contribution. Hoping for a little help here.
I am using the Yii User module (yii-user)
Everything is working, and the direct URL eg: ...
message/compose/1
which prepopulates the receiver wtih valueadmin
from user.username. I am able to send a message this way.However, when typing in the receiver name 'admin' and sending, I get validation error: receiver name must be specified.
Also, while typing in the receiver field, the spining icon spins but does not lookup and find the value. Can you help. I am wondering if i need to configure the relations? But Everything else seems to work so I'm stuck.
Can someone help us out? Thanks!
Trouble using autocomplete (Like user below)
Autocomplete issue update: message/controllers/SuggestController.php
Line6: $q = Yii::app()->request->getParam('name_startsWith');
When I change to $q = Yii::app()->request->getParam('');
I get a popup list in the top left corner of my browser (firefox and chromium) with the username fields from my database. (not filtered by receiver text) but when i select a value it inputs the corresponding receiver_id value and the form submits properly.
[SOLVED] auto suggest doesn't work
Auto suggestion wasn't working for me, but I fixed it.
I went to jQuery UI website and downloaded their newest version of UI (http://jqueryui.com/)
Then I altered
protected/view/layouts/main.php
and between "head" tags just included that donwloaded jQueryUI javascript file.
Then i want to
\protected\modules\message\views\message\default\_suggest.php
and I commented this line
$cs->registerScriptFile($baseUrl.'/js/jquery-ui-1.8.16.custom.min.js');
how to use MessageModule::t
I'm using it to translate my messages, but not sure how to use it, where to put my translated messages?
Awsome..
saved a lot of time for me.. Thanks Weavora...
Translate Messages
In case anyone is still wondering how to translate the messages:
Here is the content of my "message.php" file:
return array( 'Body'=>'Cuerpo', 'compose'=>'redactar', 'Compose'=>'Redactar', 'Compose New Message'=>'Redactar Nuevo Mensaje', 'Date'=>'Fecha', 'Deleted By'=>'Eliminado Por', 'Delete Selected'=>'Eliminar Seleccionados', 'Fields with <span class="required">*</span> are required.'=>'Campos con <span class="required">*</span> son obligatorios.', 'From'=>'De', 'inbox'=>'entrada', 'Inbox'=>'Entrada', 'Messages'=>'Mensajes', 'Receiver'=>'Destinatario', 'Send'=>'Enviar', 'Sender'=>'Remitente', 'sent'=>'enviados', 'Sent'=>'Enviados', 'Subject'=>'Asunto', 'To'=>'A', );
i got this error ----> Method User::getFullName not defined
anyone can help me,
i'm using yii-user+rights and now i want to use private messaging
after i configure main.php
i got this error ----> Method User::getFullName not defined
thanks
good job !
page not found
really good job but...
index.php?r=message/compose/1
return for me page not found
Excellent :)
Really Nice Module ...!
Thank you for this module.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.