I will try to get these features working within a few days...
I am currently developing this module as part of another project. As the project progresses I will continue to update this extension. So please be warned that right now this module is still being developed and unknown bugs/issues may exists. Once all the features have been implemented I will do more extensive bug/browser compatibility checks and hopefully have a stable release candidate for v1.0. So if you decide to use this module in your project it's recommended that you follow this extension for updates until I get a stable version released (ie. v1.0).
Yii 1.1 or above
This module uses Javascript for some of it's features, however, you do not need Javascript enabled to use this module. All features in this module using Javascript should degrade gracefully.
The only known compatibility issues so far are in the HTML/CSS.
I have also tested this module on Netscape 10 and Opera 9 but could not find older versions to test. I will get all browsers to display properly before releasing v1.0.
Unzip to modules directory.
Install data/structure.sql
If you want to alter the table names edit the following lines in MailboxModule.php
const TBL_CONV = '{{mailbox_conversation}}'; const TBL_MSG = '{{mailbox_message}}';
Add the module inside your main config file.
return array( ... 'modules'=array( ... 'mailbox'=> array( 'userClass' => 'User', 'userIdColumn' => 'id', 'usernameColumn' => 'username', ....more options here.... ), ... );
Full list of module config options.
Edit the following functions in the file /module/mailbox/MailboxModule.php
*Note if you are using the User module from Yii extensions (Yii-User) then you do not need to configure the following functions. Unless if you'd like to customize the From label or modify how the auto complete is handled.
getUserId($username='')
getUserName($userid='')
getFromLabel($userid)
getUrl($userid)
isAdmin($userid='')
autoComplete($term)
/** * Lookup user id by username. If no username supplied return current user id. * * @param string $username * @return integer user Id that belongs to $username */ public function getUserId($username='') { ... } /** * Lookup user id by username. If no user id is supplied return current user's username. * @param integer $userid * @return string username belonging to $userid */ public function getUserName($userid=0) { ... } /** * Build the label for the From field when viewing the message. Ie. use the userid input to create a string like 'Username', 'Username "First Last"', '<div> ... </div>' , etc * @param type $userid * @return string label used for From field */ public function getFromLabel($userid) { ... } /** * * @param integer $userid * @return string url to users profile page etc. */ public function getUrl($userid) { ... } /** * Check whether given userid belongs to an administrator. If no userid is supplied check whether the current user is an administrator. * @return boolean */ public function isAdmin($userid=0) { ... } /** * Autocomplete function for 'To' field in view/compose. Search for usernames etc that match the string. * * @param string $term * #return array output json array of usernames and labels. */ public function autoComplete($term) { ... } /** * If the config var userSupport is enabled then the module will use this method to * create a drop down list of contacts in the To field when the user is creating a * new message. This script should return an array, with keys set to the username * and the value set to the username's label (may be the same). If userToUser messaging * is enabled then this will create a drop down along with regular user input. If * userToUser is disabled then the users will only be able to select contacts from this list. * * Tip: If using an authManager you could create a new role called "support" and use * this method to fetch an array of users who are assigned to the "support" role. * * @return array array of admin usernames who provide customer support */ public function getUserSupportList() { ... }
Add the following to your PHP cron script...
MailboxModule::cron();
To setup the site news plugin first create a new user in your database. Add the news user's Id to the module config...
return array( ... 'modules'=array( ... 'mailbox'=> array( ... 'newsUserId' => the news user Id here, ... ), ... );
You can now create news updates by messaging the site news user (admins only). The site news user can also be added to a drop down list for the admins in the getUserSupportList() method. When you message the news user the subject and message will be publicly viewable via mailbox/news.
If you are using v0.1 please change line 473 in models/Mailbox.php from this...
$msg_count=Message::model()->conversation($this->conversation_id)->deleteAll();
to this..
$msg_count=Message::model()->deleteAll('conversation_id=:cid',array(':cid'=>$this->conversation_id));
Total 20 comments
Please note the userClass changes are because I'm using yii-user module.
in config/main.php
change
to
modules/mailbox/MailboxModule.php
change
to
modules/mailbox/controllers/MessageController.php
find and replace all (lines 37, 105, and 267)
with
modules/mailbox/views/message/_list.php
Line 3 change
to
There are a lot of bugs still with how I did this. i.e. when you delete a message it doesn't really delete it, it will still show in the trash folder. However, it is sending the messages between the users.
Maybe it's not the best way but it's a start for someone with more time. I just did this in about 3 minutes so I will over the next few days mess with it some more and hopefully get it fully working like in the demo and post how i did it here.
However, if someone does it first please post how you got it to work.
Also, Rvr101 I assume if you use the same names in your db you will not have to make changes or just edit the main.php and the mailboxmodule.php accordingly to use your table name and structure. Read the instructions above it lays it out somewhat
Edit the following functions in the file /module/mailbox/MailboxModule.php
*Note if you **are using ** the User module from Yii extensions (Yii-User) then you do not need to configure the following functions. Unless if you'd like to customize the From label or modify how the auto complete is handled.
How this extension can use without using the yii-user extension? Which changes and tables are needed without yii-user extension?
As the title said, how can admin send message to all the users? Is there a simple way to do this or i need to add some code in actionNew to send message to every user manually? thanks in advance.
Reply tomyself, found that I have to make the code for any occurance of this
To this: $script = $this->module->getClientScript(); $cs =& $script;
but I got myself into another problem now... 'delete', 'read', 'unread' functions are not working or actually not sending a request, I have defined the module in the main.php as follows:
'mailbox'=>array( 'userClass' => 'User', 'userIdColumn' => 'id', 'usernameColumn' => 'full_name', 'superuserColumn'=>'id',kindly advise basem
Im getting this error : "Only variables should be assigned by reference"
I have configured my main.php like this:
'mailbox'=>array( 'userClass' => 'User', 'userIdColumn' => 'id', 'usernameColumn' => 'full_name', 'superuserColumn'=>'user_type', // 'pageSize' => 50, 'newsUserId' => 'basem@mail.com', ),any suggestions pls?
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{mailbox_message}} WHERE recipient_id='10' ORDER BY created DESC ) AS m ' at line 4. The SQL statement executed was: SELECT SQL_CACHE COUNT(c.conversation_id) AS num_messages FROM mailbox_conversation AS c INNER JOIN ( SELECT message_id,conversation_id FROM {{mailbox_message}} WHERE recipient_id=:userid ORDER BY created DESC ) AS m ON(m.conversation_id=c.conversation_id) WHERE (c.initiator_id=:userid OR c.interlocutor_id=:userid) AND (c.bm_read & IF(c.initiator_id=:userid, :bminit, :bminter)) = 0 AND (c.bm_deleted & IF(c.initiator_id=:userid, :bminit, :bminter)) = 0 GROUP BY c.conversation_id
@ Maclein Got the solution for chrome problem..
just replace the mailbox.js with source js of the online demo
http://www.cgihub.com/mailbox/
forum post
http://www.yiiframework.com/forum/index.php/topic/37562-yii-mailbox-extension-google-chrome-problem/page__gopid__181208
I used the user module for this. But error not changed. Still have the same problem. Is there any method for using this extension without using user module?
I think this error is raised becuae it cant get user id.. so r you using user module?
if not then in config/mail.php
userIdColumn and usernameColumn of your user table and also add,
in db configuration array
and in mailbox module change MailboxModule.php like this,
This is my error in this case- "Only variables should be assigned by reference" C:\xampp\htdocs\yii\demos\mailbox\protected\modules\mailbox\controllers\MessageController.php(37)
public function actionInbox($ajax=null) 35 { 36 $this->module->registerConfig($this->getAction()->getId()); 37 $cs =& $this->module->getClientScript(); 38 $cs->registerScriptFile($this->module->getAssetsUrl().'/js/mailbox.js',CClientScript::POS_END); 39 //$js = '$("#mailbox-list").yiiMailboxList('.$this->module->getOptions().');console.log(1)'; 40 41 //$cs->registerScript('mailbox-js',$js,CClientScript::POS_READY); 42
43
44 if(isset($_POST['convs'])) 45 { 46 $this->buttonAction('inbox'); 47 } 48 $dataProvider = new CActiveDataProvider( Mailbox::model()->inbox($this->module->getUserId()) ); 49 if(isset($ajax))
hii Rvr101,
Is this mailbox working in your application or not? If not working proper then please tell what is the error? Because for basic use of mailbox, Cron job configuration not required at first stage as per my knowledge,i used this mailbox. its working best for me.
I really like this mailbox demo. But i can't implement that in my application. I completed the steps till "Define Wrapper Functions". Where i put this code "MailboxModule::cron();" in my application? i dont knowthe path of php cron script...
Hii jiaming,
you change in modules/mailbox/views/message/compose.php on line no 28,
from here you have to just remove 'id'=>'message-to' and you are done.
Is this project still alive...?...Is there a way to hide the dropdown menu so the user can not see all the user list ?
Hi I am facing a problem in chrome. While i am going to delete any item after selecting and deleting its not deleting. not even read and unread.
In console its giving error
"Uncaught TypeError: Cannot call method 'attr' of null mailbox.js:303 $.yiimailbox.submitAjax mailbox.js:303 $.yiimailbox.updateMailbox.$.draggable.containment mailbox.js:61 jQuery.event.dispatch jquery.js:3332 jQuery.event.add.elemData.handle.eventHandle"
While the same code is running in firefox and Ie.
don't know why.. Please help me. I am stuck.
@derek
What just happened???
God bless you.
Best wishes, jimmy
Hello Derek,
tq for your answer & Get well soon.
I know I had high hopes for getting this project finished a long time ago
but I was struck with some...
severe medical issues that may lead to my death.
BTW anybody want to take this project over if I do die?
I am also dealing with legal issues against some cowards that tried to murder me with poison.
I'm not fully operational at the moment. Give a few days, and I'll get back to it.
Sorry for letting you guys down.
@zainiafzan I'll add the proper fix in the next version. But a hot fix that should work is to simply add the following to your main layout somewhere near the top...
It always gives me undefined column in crontabs..I guess you have some typos or something like that? I tried to fixed but failed..
Hello.. thanks for your great extensions.
when i use this on my site, on index page its display this error in my console. why...?
sorry for my english.
Leave a comment
Please login to leave your comment.