public function ajaxEmailPage($uri, $emails, $message = '') { $filter = JFilterInput::getInstance(); $uri = $filter->clean($uri, 'string'); $emails = $filter->clean($emails, 'string'); $message = $filter->clean($message, 'string'); $message = stripslashes($message); $mainframe =& JFactory::getApplication(); $bookmarks = CFactory::getBookmarks($uri); $mailqModel = CFactory::getModel('mailq'); $config = CFactory::getConfig(); $response = new JAXResponse(); if (empty($emails)) { $content = '<div>' . JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL') . '</div>'; $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>'; } else { $emails = explode(',', $emails); $errors = array(); // Add notification CFactory::load('libraries', 'notification'); foreach ($emails as $email) { $email = JString::trim($email); CFactory::load('helpers', 'validate'); if (!empty($email) && CValidateHelper::email($email)) { $params = new CParameter(''); $params->set('uri', $uri); $params->set('message', $message); CNotificationLibrary::add('etype_system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params); } else { // If there is errors with email, inform the user. $errors[] = $email; } } if ($errors) { $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>'; foreach ($errors as $error) { $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>'; } $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>'; } else { $content = '<div>' . JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS') . '</div>'; $actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>'; } } $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS')); $response->addScriptCall('cWindowAddContent', $content, $actions); return $response->sendResponse(); }
public function ajaxEmailPage($uri, $emails, $message = '') { $message = stripslashes($message); $mainframe =& JFactory::getApplication(); $bookmarks = CFactory::getBookmarks($uri); $mailqModel = CFactory::getModel('mailq'); $config = CFactory::getConfig(); $response = new JAXResponse(); if (empty($emails)) { $content = '<div>' . JText::_('CC SHARE INVALID EMAIL') . '</div>'; $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>'; } else { $emails = explode(',', $emails); $errors = array(); // Add notification CFactory::load('libraries', 'notification'); foreach ($emails as $email) { $email = JString::trim($email); if (!empty($email) && preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$/i", $email)) { $params = new JParameter(''); $params->set('uri', $uri); $params->set('message', $message); CNotificationLibrary::add('system.bookmarks.email', '', $email, JText::sprintf('CC SHARE EMAIL SUBJECT', $config->get('sitename')), '', 'bookmarks', $params); } else { // If there is errors with email, inform the user. $errors[] = $email; } } if ($errors) { $content = '<div>' . JText::_('CC EMAILS ARE INVALID') . '</div>'; foreach ($errors as $error) { $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>'; } $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>'; } else { $content = '<div>' . JText::_('CC EMAIL SENT TO RECIPIENTS') . '</div>'; $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC BUTTON DONE') . '"/>'; } } $response->addAssign('cwin_logo', 'innerHTML', JText::_('CC SHARE THIS')); $response->addAssign('cWindowContent', 'innerHTML', $content); $response->addScriptCall('cWindowActions', $buttons); $response->addScriptCall('cWindowResize', 100); return $response->sendResponse(); }
public function ajaxEmailPage($uri, $emails, $message = '') { $filter = JFilterInput::getInstance(); $uri = $filter->clean($uri, 'string'); $emails = $filter->clean($emails, 'string'); $message = $filter->clean($message, 'string'); $message = stripslashes($message); $mainframe = JFactory::getApplication(); $bookmarks = CFactory::getBookmarks($uri); $mailqModel = CFactory::getModel('mailq'); $config = CFactory::getConfig(); $response = new JAXResponse(); $json = array(); if (empty($emails)) { $json['error'] = JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL'); } else { $emails = explode(',', $emails); $errors = array(); // Add notification //CFactory::load( 'libraries' , 'notification' ); foreach ($emails as $email) { $email = JString::trim($email); if (!empty($email) && CValidateHelper::email($email)) { $params = new CParameter(''); $params->set('uri', $uri); $params->set('message', $message); CNotificationLibrary::add('system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params); } else { // If there is errors with email, inform the user. $errors[] = $email; } } if ($errors) { $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>'; foreach ($errors as $error) { $content .= '<div style="font-weight:bold; color:red;">' . $error . '</div>'; } $json['error'] = $content; } else { $content = JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS'); $json['message'] = $content; } } die(json_encode($json)); }