Exemplo n.º 1
0
 public function getInput()
 {
     jimport('joomla.filesystem.file');
     $mainframe = JFactory::getApplication();
     if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/libraries/MCAPI.class.php')) {
         $mainframe->enqueueMessage(JText::_('JM_PLEASE_INSTALL_JOOMLAMAILER'), 'error');
         $mainframe->redirect('index.php');
     }
     jimport('joomla.plugin.plugin');
     require_once JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/libraries/MCAPI.class.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/helpers/JoomlamailerMC.php';
     $params = JComponentHelper::getParams('com_joomailermailchimpintegration');
     $MCapi = $params->get('params.MCapi');
     $JoomlamailerMC = new JoomlamailerMC();
     if (!$MCapi || !$JoomlamailerMC->pingMC()) {
         $mainframe->enqueueMessage(JText::_('APIKEY ERROR'), 'error');
         $mainframe->redirect('index.php?option=com_joomailermailchimpintegration&view=main');
     }
     $api = new joomlamailerMCAPI($MCapi);
     $lists = $api->lists();
     $options = array();
     $options[] = array('id' => '', 'name' => '-- ' . JText::_('JM_PLEASE_SELECT_A_LIST') . ' --');
     foreach ($lists as $list) {
         $options[] = array('id' => $list['id'], 'name' => $list['name']);
     }
     $attribs = 'onchange="submitbutton(\'module.apply\')"';
     if (count($options)) {
         return JHtml::_('select.genericlist', $options, 'jform[params][listid]', $attribs, 'id', 'name', $this->value, $this->id);
     }
     return '';
 }
Exemplo n.º 2
0
	    function fetchElement($name, $value, &$node, $control_name)
	    {
		jimport( 'joomla.filesystem.file' );
		$option = JRequest::getCmd('option');
		    $mainframe = & JFactory::getApplication();
		    if(!JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'libraries'.DS.'MCAPI.class.php')) {
			    $mainframe->redirect('index.php',JText::_('INSTALLJOOMAILER'),'error');
		    } else {
			    $moduleParams = new JParameter( $this->_parent->_raw );
			    $value = $moduleParams->get('listid');
			    require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'libraries'.DS.'MCAPI.class.php');
			    require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'helpers'.DS.'MCauth.php' );
			    $params = & JComponentHelper::getParams('com_joomailermailchimpintegration');
			    $apikey = $params->get('MCapi');
			    $MCauth = new MCauth();
			    if( !$apikey || !$MCauth->MCauth() ) {
				    $mainframe->redirect('index.php?option=com_joomailermailchimpintegration&view=main',JText::_('APIKEY ERROR'),'error');
			    }
			    $api = new joomlamailerMCAPI($apikey);
			    $lists = $api->lists();
			    $key = 'id';
			    $val = 'name';
			    $options[] = array($key=>'',$val=>JText::_('JM_PLEASE_SELECT_A_LIST'));
			    foreach ($lists as $list){
				$options[]=array($key=>$list[$key],$val=>$list[$val]);
			    }

			    if( $option == 'com_joomfish' ){
				$submitTask = 'translate.';
			    } else {
				$submitTask = '';
			    }
			    $attribs = "onchange='submitbutton(\"".$submitTask."apply\")'";
			   
			    $name = 'listid';
			    if($options){
				    $content =  JHTML::_('select.genericlist',$options, $control_name.'[listid]', $attribs, $key, $val, $value, $control_name.$name);
			    }

			    return $content;
		    }
	    }
Exemplo n.º 3
0
	    function fetchElement($name, $value, &$node, $control_name)
	    {
		jimport( 'joomla.filesystem.file' );
		$mainframe = & JFactory::getApplication();
		if(!JFile::exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'libraries'.DS.'MCAPI.class.php')) {
		    $mainframe->redirect('index.php',JText::_('JM_INSTALLJOOMAILER'),'error');
		} else {
		    jimport('joomla.plugin.plugin');
		    $pluginParams = new JParameter( $this->_parent->_raw );
		    $value = $pluginParams->get('listid');
		    require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'libraries'.DS.'MCAPI.class.php');
		    require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomailermailchimpintegration'.DS.'helpers'.DS.'MCauth.php' );
		    $params =& JComponentHelper::getParams( 'com_joomailermailchimpintegration' );
		    $paramsPrefix = (version_compare(JVERSION,'1.6.0','ge')) ? 'params.' : '';
		    $MCapi = $params->get( $paramsPrefix.'MCapi' );
		    $MCauth = new MCauth();
		    if( !$MCapi || !$MCauth->MCauth() ) {
			$mainframe->redirect('index.php?option=com_joomailermailchimpintegration&view=main',JText::_('JM_INVALID_API_KEY'),'error');
		    }
		    $api = new joomlamailerMCAPI($MCapi);
		    $lists = $api->lists();
		    $key = 'id';
		    $val = 'name';
		    $options[] = array($key=>'',$val=>JText::_('JM_PLEASE_SELECT_A_LIST'));
		    foreach ($lists as $list){
			$options[]=array($key=>$list[$key],$val=>$list[$val]);
		    }

		    $attribs = "onchange='submitbutton(\"apply\")'";
		    $control_name = 'params';
		    $name = 'listid';
		    if($options){
			$content =  JHTML::_('select.genericlist',$options, 'params[listid]', $attribs, $key, $val, $value, $control_name.$name);
		    }

		    return $content;
		}
	    }
 function a360_dashboard($a360_api_key, $a360_ga_token, $a360_has_key)
 {
     $notification = isset($_GET['a360_error']) ? '<span class="error" style="padding:3px;"><strong>Error</strong>: ' . esc_html(stripslashes($_GET['a360_error'])) . '</span>' : '';
     $a360_list_options = array();
     if (!empty($a360_api_key)) {
         if (!class_exists('joomlamailerMCAPI')) {
             require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'MCAPI.class.php';
         }
         $api = new joomlamailerMCAPI($a360_api_key);
         if (empty($api->errorCode)) {
             $lists = $api->lists();
             if (is_array($lists)) {
                 foreach ($lists as $list) {
                     $a360_list_options[] = '<option value="' . $list['id'] . '">' . $list['name'] . '</option>';
                 }
             } else {
                 $a360_list_options[] = '<option value="">Error: ' . $api->errorMessage . '</option>';
             }
         } else {
             $a360_list_options[] = '<option value="">API Key Error: ' . $api->errorMessage . '</option>';
         }
     }
     return $a360_list_options;
 }
Exemplo n.º 5
0
 function send()
 {
     $db =& JFactory::getDBO();
     $msg = false;
     $error = '';
     $list_error = false;
     $params =& JComponentHelper::getParams('com_joomailermailchimpintegration');
     $paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : '';
     $archiveDir = $params->get($paramsPrefix . 'archiveDir', '/administrator/components/com_joomailermailchimpintegration/archive');
     $model =& $this->getModel('send');
     $clientDetails = $model->getClientDetails();
     $MCapi = $params->get($paramsPrefix . 'MCapi');
     $MC = new joomlamailerMCAPI($MCapi);
     //	$MCSTS = new jmsts($MCapi);
     $time = JRequest::getVar('time', 0, '', 'string');
     $listId = JRequest::getVar('listId', '', 'post', 'string');
     $test = JRequest::getVar('test', 0, 'post', 'int');
     $trackOpens = (bool) JRequest::getBool('trackOpens', false, 'post');
     $trackHTML = (bool) JRequest::getBool('trackHTML', false, 'post');
     $trackText = (bool) JRequest::getBool('trackText', false, 'post');
     $ecomm360 = (bool) JRequest::getBool('ecomm360', false, 'post');
     $campaignType = JRequest::getVar('campaignType', 0, 'post');
     $offsetTime = JRequest::getVar('offset-time', 0, 'post');
     $offsetUnits = JRequest::getVar('offset-units', 0, 'post');
     $offsetDir = JRequest::getVar('offset-dir', 0, 'post');
     $event = JRequest::getVar('event', 0, 'post');
     $mergefield = JRequest::getVar('mergefield', 0, 'post');
     $emails = JRequest::getVar('email', '', '', 'array');
     $noGos = array('Email 1', 'Email 2', 'Email 3', 'Email 4', 'Email 5');
     foreach ($emails as $key => $value) {
         if ($value == "" || in_array($value, $noGos)) {
             unset($emails[$key]);
         }
     }
     $emails = array_values($emails);
     $timewarp = JRequest::getVar('timewarp', 0, '', 'int');
     $schedule = JRequest::getVar('schedule', 0, '', 'int');
     if (!$schedule) {
         $delivery = 'Immediately';
     } else {
         $deliveryDate = JRequest::getVar('deliveryDate', 'Immediately', '', 'string');
         $deliveryTime = JRequest::getVar('deliveryTime', '', '', 'string');
         //		if($test) { $delivery = 'Immediately'; }
         //		else
         if ($deliveryDate != 'Immediately') {
             $delivery = $deliveryDate . ' ' . $deliveryTime . ':00';
             // convert time to GMT
             setlocale(LC_TIME, 'en_GB');
             $delivery = gmstrftime("%Y-%m-%d %H:%M:%S", strtotime($delivery));
         } else {
             $delivery = 'Immediately';
         }
     }
     $useSegments = JRequest::getVar('useSegments', 0, '', 'int');
     if ($useSegments) {
         $type = $condition = $conditionDetailValue = array();
         for ($i = 1; $i < 11; $i++) {
             $type[] = JRequest::getVar('segmenttype' . $i, '');
             $condition[] = JRequest::getVar('segmentTypeCondition_' . $i, '');
             $conditionDetailValue[] = JRequest::getVar('segmentTypeConditionDetailValue_' . $i, '');
         }
         // remove empty values
         $type = array_values(array_filter($type));
         $condition = array_values(array_filter($condition));
         $conditionDetailValue = array_values(array_filter($conditionDetailValue));
         $conditions = array();
         for ($i = 0; $i < count($type); $i++) {
             if (is_numeric($type[$i])) {
                 $type[$i] = 'interests-' . $type[$i];
             }
             $conditions[] = array('field' => $type[$i], 'op' => $condition[$i], 'value' => $conditionDetailValue[$i]);
         }
         $segment_opts = array('match' => JRequest::getVar('match', 'any', 'post', 'string'), 'conditions' => $conditions);
     } else {
         $segment_opts = '';
     }
     $query = "SELECT * FROM #__joomailermailchimpintegration_campaigns WHERE creation_date = '" . $time . "'";
     $db->setQuery($query);
     $cDetails = $db->loadObjectList();
     $cDetails = $cDetails[0];
     $campaign_name_ent = htmlentities($cDetails->name);
     $campaign_name_ent = str_replace(' ', '_', $campaign_name_ent);
     $html_file = JURI::root() . substr($archiveDir, 1) . "/" . $campaign_name_ent . ".html";
     $content = array('url' => $html_file);
     // remove cache-preventing meta tags from campaign to avoid rendering issues in email clients
     $metaData = array("<meta http-Equiv=\"Cache-Control\" Content=\"no-cache\">\n", "<meta http-Equiv=\"Pragma\" Content=\"no-cache\">\n", "<meta http-Equiv=\"Expires\" Content=\"0\">\n");
     $filename = JPATH_SITE . $archiveDir . '/' . $campaign_name_ent . ".html";
     $template = JFile::read($filename);
     $template = str_replace($metaData, '', $template);
     $handle = JFile::write($filename, $template);
     if (!$msg) {
         $lists = $MC->lists();
         if (!$listId) {
             $i = 0;
             if ($clientDetails['plan_type'] == 'free') {
                 for ($i = 0; $i < count($lists); $i++) {
                     if ($lists[$i]['member_count'] <= 2000) {
                         $listId = $lists[$i]['id'];
                         $memberCount = $lists[$i]['member_count'];
                         break;
                     }
                 }
                 if (!$listId) {
                     $error = 'error';
                     $msg = JText::_('JM_TO_MANY_RECIPIENTS');
                     $link = 'index.php?option=com_joomailermailchimpintegration&view=send&campaign=' . $time;
                     $this->setRedirect($link, $msg);
                 }
             } else {
                 $listId = $lists[$i]['id'];
             }
         } else {
             foreach ($lists as $list) {
                 if ($list['id'] == $listId) {
                     $memberCount = $list['member_count'];
                     break;
                 }
             }
         }
         if (!$test && $clientDetails['plan_type'] == 'free' && $memberCount > 2000) {
             $error = 'error';
             $msg = JText::_('JM_TO_MANY_RECIPIENTS');
             $link = 'index.php?option=com_joomailermailchimpintegration&view=send&campaign=' . $time;
         } else {
             // submit to MC
             $type = 'regular';
             //		$opts['list_id']	= $cDetails->list_id;
             $opts['list_id'] = $listId;
             $opts['title'] = $cDetails->name;
             if ($test) {
                 $opts['subject'] = JText::_('JM_CAMPAIGN_TEST') . ': ' . $cDetails->subject;
             } else {
                 $opts['subject'] = $cDetails->subject;
                 if ($timewarp) {
                     $opts['timewarp'] = true;
                 }
             }
             $opts['from_email'] = $cDetails->from_email;
             $opts['from_name'] = $cDetails->from_name;
             $opts['tracking'] = array('opens' => $trackOpens, 'html_clicks' => $trackHTML, 'text_clicks' => $trackText);
             $opts['ecomm360'] = $ecomm360;
             $opts['authenticate'] = true;
             //		$opts['analytics'] = array('google'=>'my_google_analytics_key');
             $opts['inline_css'] = true;
             $opts['generate_text'] = true;
             $opts['auto_footer'] = false;
             $opts['folder_id'] = $cDetails->folder_id;
             //Check for auto_tweet
             $tweet = JRequest::getVar('useTwitter');
             if ($tweet) {
                 $opts['auto_tweet'] = true;
             }
             //Check for autoresponder
             $type_opts = array();
             if ($campaignType == 1) {
                 $type = 'auto';
                 $type_opts['offset-units'] = $offsetUnits;
                 $type_opts['offset-time'] = $offsetTime;
                 $type_opts['offset-dir'] = $offsetDir;
                 $type_opts['event'] = $event;
                 $type_opts['event-datemerge'] = $mergefield;
                 // TODO: implement autoresponder folders
                 unset($opts['folder_id']);
             }
             $c_id = $MC->campaignCreate($type, $opts, $content, $segment_opts, $type_opts);
             if (!$MC->errorCode) {
                 if ($test) {
                     $send = $MC->campaignSendTest($c_id, $emails);
                     if ($c_id) {
                         // wait 5 seconds for the campaign to be sent
                         sleep(5);
                         $MC->campaignDelete($c_id);
                     }
                 } else {
                     if (!$schedule) {
                         $send = $MC->campaignSendNow($c_id);
                     } else {
                         $send = $MC->campaignSchedule($c_id, $delivery);
                     }
                 }
             }
             if ($MC->errorCode) {
                 $msg = MCerrorHandler::getErrorMsg($MC);
                 $link = 'index.php?option=com_joomailermailchimpintegration&view=send&campaign=' . $time;
             } else {
                 if ($test) {
                     $msg = JText::_('JM_TEST_CAMPAIGN_SENT');
                     $link = 'index.php?option=com_joomailermailchimpintegration&view=send&campaign=' . $time;
                 } else {
                     if ($schedule) {
                         $query = "UPDATE #__joomailermailchimpintegration_campaigns SET `sent`=1, `cid`='" . $c_id . "' WHERE creation_date = '" . $time . "'";
                         $db->setQuery($query);
                         $db->query();
                         $msg = JText::_('JM_CAMPAIGN_SCHEDULED');
                         $link = 'index.php?option=com_joomailermailchimpintegration&view=main';
                     } else {
                         $query = "UPDATE #__joomailermailchimpintegration_campaigns SET `sent`=2, `cid`='" . $c_id . "' WHERE creation_date = '" . $time . "'";
                         $db->setQuery($query);
                         $db->query();
                         if ($campaignType == 1) {
                             $msg = JText::_('JM_AUTORESPONDER_CREATED');
                         } else {
                             $msg = JText::_('JM_CAMPAIGN_SENT');
                             // clear reports cache
                             require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomailermailchimpintegration' . DS . 'controllers' . DS . 'campaigns.php';
                             joomailermailchimpintegrationsControllerCampaigns::clearReportsCache();
                         }
                         $link = 'index.php?option=com_joomailermailchimpintegration&view=campaigns';
                     }
                 }
             }
         }
     }
     $this->setRedirect($link, $msg, $error);
 }