phpfox

From amir, 7 Years ago, written in PHP, viewed 2'859 times.
URL https://paste.scratchbook.ch/view/f746b693 Shorturl http://gw.gd/PxZa Embed
Download Paste or View Raw
  1. //Prepare the Preview text
  2. $sMessagePreview = str_replace(array('<', '>'), array('<', '>'), Phpfox::getPhrase('core.welcome_email_content'));
  3. $sMessagePreview = Phpfox::getLib('parse.bbcode')->cleanCode($sMessagePreview);
  4. $sMessagePreview = strip_tags($sMessagePreview);
  5. $sMessagePreview = Phpfox::getLib('parse.input')->clean($sMessagePreview, 255);
  6. //Get the first administrator as the sender
  7. $iAdminId = $this->database()->select('user_id')->from(Phpfox::getT('user'))->where('user_group_id = 1')->limit(1)->order('joined ASC')->execute('getField');
  8. //Load the subject variable
  9. $sSubject = Phpfox::getPhrase('core.welcome_internal_mail_subject', array('site' => Phpfox::getParam('core.site_title')));
  10. //Determine if you are using threaded or legacy message handling
  11. if(Phpfox::getLib('setting')->isParam('mail.threaded_mail_conversation') && Phpfox::getParam('mail.threaded_mail_conversation'))
  12. {
  13. //If using threaded messages, set up users for this thread
  14. $aUserInsert=array($iAdminId, $iId);
  15. //Define the hash_id for the mail_thread table
  16. $sHashId = md5(implode('', $aUserInsert));
  17. //Insert the new thread record into the mail_thread table
  18. $iMid = $this->database()->insert(Phpfox::getT('mail_thread'), array(
  19. 'hash_id' => $sHashId,
  20. 'time_stamp' => PHPFOX_TIME
  21. )
  22. );
  23. //Define a mail_thread_user record for each thread user
  24. foreach ($aUserInsert as $iUserId)
  25. {
  26. $this->database()->insert(Phpfox::getT('mail_thread_user'), array(
  27. 'thread_id' => $iMid,
  28. 'is_read' => ($iUserId == $iAdminId ? '1' : '0'),
  29. 'is_sent' => ($iUserId == $iAdminId ? '1' : '0'),
  30. 'is_sent_update' => ($iUserId == $iAdminId ? '1' : '0'),
  31. 'user_id' => (int) $iUserId
  32. )
  33. );
  34. }
  35. //Insert the mail_thread_text record for your welcome message
  36. $iTextId = $this->database()->insert(Phpfox::getT('mail_thread_text'), array(
  37. 'thread_id' => $iMid,
  38. 'time_stamp' => PHPFOX_TIME,
  39. 'user_id' => $iAdminId,
  40. 'text' => Phpfox::getLib('parse.input')->prepare(Phpfox::getPhrase('core.welcome_email_content')),
  41. 'is_mobile' => ('0')
  42. )
  43. );
  44. //Now that we have a textId we can update the last_id column in the mail_thread entry that we made above
  45. $this->database()->update(Phpfox::getT('mail_thread'), array('last_id' => (int) $iTextId), 'thread_id = ' . (int) $iMid);
  46. }
  47. else
  48. {
  49. //This is for the old message system so we build an array for the mail table entry
  50. $aInsert = array(
  51.          'parent_id' => 0,
  52.          'subject' => $sSubject,
  53.          'preview' => $sMessagePreview,
  54.          'owner_user_id' => $iAdminId,
  55.          'viewer_user_id' => $iId,
  56.          'viewer_is_new' => 1,
  57.          'time_stamp' => PHPFOX_TIME,
  58.          'time_updated' => PHPFOX_TIME,
  59.          'total_attachment' => 0,
  60. );
  61. //Insert the mail table entry
  62. $iMailId = $this->database()->insert(Phpfox::getT('mail'), $aInsert);
  63. //Build an array for the mail_text table
  64. $aContent = array(
  65.          'mail_id' => $iMailId,
  66.          'text' => Phpfox::getLib('parse.input')->clean(Phpfox::getPhrase('core.welcome_email_content')),
  67.          'text_parsed' => Phpfox::getLib('parse.input')->prepare(Phpfox::getPhrase('core.welcome_email_content'))
  68. );
  69. //Insert the mail_text entry
  70. $this->database()->insert(Phpfox::getT('mail_text'), $aContent);
  71. }

Replies to phpfox rss

Title Name Language When
Re: phpfox Botched Goat php 7 Years ago.

Reply to "phpfox"

Here you can reply to the paste above