예제 #1
0
 public function ajaxGuestReply($email = null, $name = null)
 {
     require_once DISCUSS_HELPERS . '/email.php';
     $disjax = new Disjax();
     if (empty($email)) {
         $disjax->script("EasyDiscuss.\$('#usertype_status .msg_in').html('" . JText::_('COM_EASYDISCUSS_PLEASE_INSERT_YOUR_EMAIL_ADDRESS_TO_PROCEED') . "');");
         $disjax->script("EasyDiscuss.\$('#usertype_status .msg_in').addClass('alert alert-error');");
         $disjax->script("EasyDiscuss.\$('#edialog-guest-reply').removeAttr('disabled');");
         $disjax->send();
         return false;
     }
     if (DiscussEmailHelper::isValidInetAddress($email) == false) {
         $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').html(\'' . JText::_('COM_EASYDISCUSS_INVALID_EMAIL_ADDRESS') . '\');');
         $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').addClass(\'alert alert-error\');');
         $disjax->script("EasyDiscuss.\$('#edialog-guest-reply').removeAttr('disabled');");
     } else {
         $session = JFactory::getSession();
         if ($session->has('guest_reply_authentication', 'discuss')) {
             $session->clear('guest_reply_authentication', 'discuss');
         }
         $name = $name ? $name : $email;
         $session->set('guest_reply_authentication', "email=" . $email . ",name=" . $name . "", 'discuss');
         $disjax->script('EasyDiscuss.$(\'#user_type\').val(\'guest\');');
         $disjax->script('EasyDiscuss.$(\'#poster_name\').val(EasyDiscuss.$(\'#discuss_usertype_guest_name\').val());');
         $disjax->script('EasyDiscuss.$(\'#poster_email\').val(EasyDiscuss.$(\'#discuss_usertype_guest_email\').val());');
         $disjax->script('disjax.closedlg();');
         $disjax->script('discuss.reply.submit();');
     }
     $disjax->send();
 }
예제 #2
0
파일: posts.php 프로젝트: pguilford/vcomcc
 function _fieldValidate($post)
 {
     $mainframe = JFactory::getApplication();
     $valid = true;
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $message = '<ul class="unstyled">';
     if (!isset($post['title']) || JString::strlen($post['title']) == 0 || $post['title'] == JText::_('COM_EASYDISCUSS_POST_TITLE_EXAMPLE')) {
         $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_TITLE_CANNOT_EMPTY') . '</li>';
         $valid = false;
     }
     // quick_question_reply_content is from the module quick question
     if ((!isset($post['dc_reply_content']) || JString::strlen($post['dc_reply_content']) == 0) && (!isset($post['quick_question_reply_content']) || JString::strlen($post['quick_question_reply_content']) == 0)) {
         $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_CONTENT_IS_EMPTY') . '</li>';
         $valid = false;
     }
     if (JString::strlen($post['dc_reply_content']) < $config->get('main_post_min_length')) {
         $message .= '<li>' . JText::sprintf('COM_EASYDISCUSS_POST_CONTENT_LENGTH_IS_INVALID', $config->get('main_post_min_length')) . '</li>';
         $valid = false;
     }
     if (empty($post['category_id'])) {
         $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_CATEGORY_IS_EMPTY') . '</li>';
         $valid = false;
     }
     if (empty($user->id)) {
         if (empty($post['poster_name'])) {
             $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_NAME_IS_EMPTY') . '</li>';
             $valid = false;
         }
         if (empty($post['poster_email'])) {
             $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_EMAIL_IS_EMPTY') . '</li>';
             $valid = false;
         } else {
             require_once DISCUSS_HELPERS . '/email.php';
             if (!DiscussEmailHelper::isValidInetAddress($post['poster_email'])) {
                 $message .= '<li>' . JText::_('COM_EASYDISCUSS_POST_EMAIL_IS_INVALID') . '</li>';
                 $valid = false;
             }
         }
     }
     $message .= '</ul>';
     if (!$valid) {
         DiscussHelper::setMessageQueue($message, 'error');
     }
     return $valid;
 }