|
From: Greg M. <bli...@us...> - 2008-08-23 17:03:38
|
Update of /cvsroot/phpwebsite-comm/modules/mailinglists/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11197/class Modified Files: Email.php MailingListsManager.php Log Message: File Cabinet added to email forms for HTML messages. Index: MailingListsManager.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/mailinglists/class/MailingListsManager.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MailingListsManager.php 22 Aug 2008 03:15:45 -0000 1.2 --- MailingListsManager.php 23 Aug 2008 17:03:16 -0000 1.3 *************** *** 493,496 **** --- 493,498 ---- } + PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); + $form = new PHPWS_Form; $form->addHidden('module', 'mailinglists'); *************** *** 505,519 **** $form->setRows('msg_html', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_html', '80%'); - $form->setLabel('msg_html', dgettext('mailinglists', 'Message (HTML)')); $form->useEditor('msg_html'); $form->addTextArea('msg_text', $email->getMsgText(false)); $form->setRows('msg_text', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_text', '80%'); - $form->setLabel('msg_text', dgettext('mailinglists', 'Message (Plain Text)')); $form->addSubmit('submit', dgettext('mailinglists', 'Send Email (Do Not Click Twice)')); $template = $form->getTemplate(); if (isset($errors['subject'])) { --- 507,525 ---- $form->setRows('msg_html', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_html', '80%'); $form->useEditor('msg_html'); + $manager = Cabinet::fileManager('file_id', $email->getFileId()); + $form->addTplTag('FILE_MANAGER', $manager->get()); + $form->addTextArea('msg_text', $email->getMsgText(false)); $form->setRows('msg_text', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_text', '80%'); $form->addSubmit('submit', dgettext('mailinglists', 'Send Email (Do Not Click Twice)')); $template = $form->getTemplate(); + $template['HTML_EMAIL_LEGEND'] = dgettext('mailinglists', 'Message (HTML)'); + $template['TEXT_EMAIL_LEGEND'] = dgettext('mailinglists', 'Message (Plain Text)'); + if (isset($errors['subject'])) { *************** *** 542,546 **** $errors['subject'] = dgettext('mailinglists', 'You must have a subject.'); } ! if (empty($_POST['msg_text']) && empty($_POST['msg_html'])) { $errors['body'] = dgettext('mailinglists', 'You must have a message body.'); --- 548,552 ---- $errors['subject'] = dgettext('mailinglists', 'You must have a subject.'); } ! if (empty($_POST['msg_text']) && (strlen($_POST['msg_html']) < 15)) { $errors['body'] = dgettext('mailinglists', 'You must have a message body.'); *************** *** 550,553 **** --- 556,560 ---- $email->setMsgText($_POST['msg_text']); $email->setMsgHtml($_POST['msg_html']); + $email->setFileId($_POST['file_id']); $email->setUserId(Current_User::getId()); $email->setListId($list->getId()); *************** *** 843,846 **** --- 850,855 ---- } + PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); + $form = new PHPWS_Form; $form->addHidden('module', 'mailinglists'); *************** *** 854,864 **** $form->setRows('msg_html', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_html', '80%'); - $form->setLabel('msg_html', dgettext('mailinglists', 'Message (HTML)')); $form->useEditor('msg_html'); $form->addTextArea('msg_text', $email->getMsgText(false)); $form->setRows('msg_text', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_text', '80%'); - $form->setLabel('msg_text', dgettext('mailinglists', 'Message (Plain Text)')); if (empty($email->id)) --- 863,874 ---- $form->setRows('msg_html', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_html', '80%'); $form->useEditor('msg_html'); + $manager = Cabinet::fileManager('file_id', $email->getFileId()); + $form->addTplTag('FILE_MANAGER', $manager->get()); + $form->addTextArea('msg_text', $email->getMsgText(false)); $form->setRows('msg_text', MAILINGLISTS_TEXTAREA_ROWS); $form->setWidth('msg_text', '80%'); if (empty($email->id)) *************** *** 873,876 **** --- 883,889 ---- $template = $form->getTemplate(); + $template['HTML_EMAIL_LEGEND'] = dgettext('mailinglists', 'Message (HTML)'); + $template['TEXT_EMAIL_LEGEND'] = dgettext('mailinglists', 'Message (Plain Text)'); + if (isset($errors['subject'])) { *************** *** 891,894 **** --- 904,908 ---- $email->setMsgText($_POST['msg_text']); $email->setMsgHtml($_POST['msg_html']); + $email->setFileId($_POST['file_id']); $email->setUserId(Current_User::getId()); $email->setApproved(0); *************** *** 975,978 **** --- 989,993 ---- $email->setSubject($blog->title); + $email->setFileId($blog->image_id); /* Not calling the setMsgHtml function because the summary is already parsed and encoded. */ Index: Email.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/mailinglists/class/Email.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Email.php 23 Aug 2008 02:55:12 -0000 1.4 --- Email.php 23 Aug 2008 17:03:16 -0000 1.5 *************** *** 31,34 **** --- 31,35 ---- var $msg_text = NULL; var $msg_html = NULL; + var $file_id = 0; var $created = 0; var $user_id = 0; *************** *** 115,120 **** if ($format) { - $address = PHPWS_Core::getHomeHttp(); - /* Support Smart Tags */ $text = PHPWS_Text::parseTag($this->msg_html); --- 116,119 ---- *************** *** 122,131 **** /* Need to add full URL since the text is going into emails. */ ! $src[] = '@(src|href)="\./@'; ! $rpl[] = "\\1=\"$address"; ! $src[] = '@(src|href)="(images|index.php)@'; ! $rpl[] = "\\1=\"$address\\2"; ! ! return preg_replace($src, $rpl, $text); } --- 121,125 ---- /* Need to add full URL since the text is going into emails. */ ! return $this->makeAbsolute($text); } *************** *** 133,136 **** --- 127,140 ---- } + function setFileId($file_id) + { + $this->file_id = (int)$file_id; + } + + function getFileId() + { + return $this->file_id; + } + function setCreated() { *************** *** 166,169 **** --- 170,198 ---- } + function makeAbsolute($text) + { + $address = PHPWS_Core::getHomeHttp(); + + $src[] = '@(src|href)="\./@'; + $rpl[] = "\\1=\"$address"; + $src[] = '@(src|href)="(images|index.php|filecabinet)@'; + $rpl[] = "\\1=\"$address\\2"; + + return preg_replace($src, $rpl, $text); + } + + function getFile() + { + if ($this->getFileId()) + { + PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); + + $file = Cabinet::getFile($this->getFileId()); + return $this->makeAbsolute($file->getTag()); + } + + return NULL; + } + function save() { *************** *** 179,187 **** $db = new PHPWS_DB('mailinglists_emails'); ! $result = $db->saveObject($this); ! if (PEAR::isError($result)) ! { ! return $result; ! } } --- 208,212 ---- $db = new PHPWS_DB('mailinglists_emails'); ! return $db->saveObject($this); } *************** *** 269,272 **** --- 294,298 ---- $template['SUBJECT'] = $this->getSubject(); $template['MESSAGE'] = $this->getMsgHtml(); + $template['FILE'] = $this->getFile(); return PHPWS_Template::process($template, 'mailinglists', 'email/view.tpl'); } *************** *** 333,336 **** --- 359,364 ---- if ($subscriber->getHtml(false)) { + $tpl_html['FILE'] = $this->getFile(); + $mail->setHTMLBody(PHPWS_Template::process($tpl_html, 'mailinglists', 'email/send_html.tpl')); } |