Пример #1
0
 /** Function that will remove the attachment text save into column attachments in the table #__jnews_mailings
 	 * @param string $filename - name of the file to be removed
 	 * @param int $mailingID - newsletter id
 				  - default to 0 if the should be remove from all newsletters that been using the file
 	*/
 function deleteAttachmentQuery($filename, $mailingID = 0)
 {
     // set database
     static $db = null;
     if (!isset($db)) {
         $db = JFactory::getDBO();
     }
     // check mailing id
     $mailingIDsA = null;
     if (empty($mailingID)) {
         // load the mailing ids that used the file to be detached
         $query = 'SELECT `id` FROM `#__jnews_mailings` WHERE `attachments` LIKE "%' . $filename . '%"';
         $db->setQuery($query);
         $loadResultArray = $db->loadObjectList();
         $mailingIDsA = jnews::convertObjectList2Array($loadResultArray);
         if (!empty($mailingIDsA)) {
             // if found then replace it with an empty string
             foreach ($mailingIDsA as $mailingID) {
                 jNews_Attachment::_setAttachments($mailingID, $filename);
             }
         }
     } else {
         // if found then replace it with an empty string
         jNews_Attachment::_setAttachments($mailingID, $filename);
     }
     return true;
 }
Пример #2
0
 public static function checkAcajoom()
 {
     static $acaExist = null;
     if (is_bool($acaExist)) {
         return $acaExist;
     }
     $db = JFactory::getDBO();
     static $resultAcajoom = null;
     if (empty($resultAcajoom)) {
         $queryshow = "SHOW TABLES LIKE '%acajoom%'";
         $db->setQuery($queryshow);
         $loadResultArray = $db->loadObjectList();
         $resultAcajoom = jnews::convertObjectList2Array($loadResultArray);
         if (empty($resultAcajoom)) {
             return false;
         }
         $query = " SELECT `akey` FROM `#__acajoom_xonfig` ";
         $db->setQuery($query);
         $result = $db->loadResult();
         $acaExist = !empty($result) ? true : false;
     }
     return $acaExist;
 }
Пример #3
0
 public static function importBis()
 {
     @set_time_limit(0);
     $returnMessage = '';
     //If memory_limit less than 128M
     $limit = jnews::convertToBytes(@ini_get('memory_limit'));
     if ($limit < jnews::convertToBytes('128M')) {
         @ini_set('memory_limit', '128M');
     }
     $allAvailableListsA = JRequest::getVar('sub_list_id', '');
     $list2SubcribeToA = JRequest::getVar('subscribed', '');
     $filename = $_FILES['importfile']['name'];
     if (!empty($filename)) {
         //if we import a file
         //the flag is true coz we add subscribers in frontend through rows
         $saveSubsInRows = true;
         $path = JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'];
         $path = str_replace(array('/', '\\'), DS, $path);
         if (!is_writable($path)) {
             $returnMessage .= '<br/>The file could not be imported because the folder is not writable.';
             $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable';
             return $returnMessage;
         }
         if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) {
             $path .= DS;
             if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) {
                 $returnMessage .= _JNEWS_ERROR_MOVING_UPLOAD;
                 $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable';
                 return $returnMessage;
             }
         }
         $import = file_get_contents($path . $filename);
         $import = str_replace(array("\r\n", "\r"), "\n", $import);
         $allLinesA = explode("\n", $import);
     } else {
         //if we add subscribers in frontend through rows
         //the flag is true coz we add subscribers in frontend through rows
         $saveSubsInRows = true;
         //we get the number of rows
         $rows = JRequest::getVar('count', '');
         $nRows = intval($rows) - 1;
         if ($nRows == 0) {
             $nRows = intval($GLOBALS[JNEWS . 'create_newsubsrows']);
         }
         //we get the value of each element from the rows
         for ($count = 1; $count <= $nRows; $count++) {
             $allLinesA[$count] = JRequest::getVar('name' . $count, '') . ', ' . JRequest::getVar('email' . $count, '') . ', ' . JRequest::getVar('receive_html' . $count, '') . ', ' . JRequest::getVar('confirmed' . $count, '') . ', ' . JRequest::getVar('column1' . $count, '') . ', ' . JRequest::getVar('column2' . $count, '') . ', ' . JRequest::getVar('column3' . $count, '') . ', ' . JRequest::getVar('column4' . $count, '') . ', ' . JRequest::getVar('column5' . $count, '');
         }
     }
     if (empty($allLinesA)) {
         return false;
     }
     $db = JFactory::getDBO();
     $insertQuery = '';
     $selectQuery = '';
     $firstValue = true;
     $time = time();
     $totalInsert = 0;
     $allSubscribersIDA = array();
     foreach ($allLinesA as $line) {
         $line = trim($line);
         if (empty($line)) {
             continue;
         }
         $line = str_replace(';', ',', $line);
         $subscriberA = explode(',', $line);
         $email = trim($subscriberA[1], ' "\'');
         if (!jNews_Subscribers::validEmail($email)) {
             if (!$saveSubsInRows) {
                 //if import of file is done
                 echo '<br />' . jnews::printM('red', _JNEWS_EMAIL_INVALID . ': ' . $email);
                 continue;
             } else {
                 continue;
             }
         }
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             $column4 = !empty($subscriberA[4]) ? mysql_escape_string(trim($subscriberA[4], '"')) : '';
             $column5 = !empty($subscriberA[5]) ? mysql_escape_string(trim($subscriberA[5], '"')) : '';
             $column6 = !empty($subscriberA[6]) ? mysql_escape_string(trim($subscriberA[6], '"')) : '';
             $column7 = !empty($subscriberA[7]) ? mysql_escape_string(trim($subscriberA[7], '"')) : '';
             $column8 = !empty($subscriberA[8]) ? mysql_escape_string(trim($subscriberA[8], '"')) : '';
             $ip = !empty($subscriberA[9]) ? mysql_escape_string(trim($subscriberA[9], '"')) : '';
         }
         $comfirmation = $GLOBALS[JNEWS . 'require_confirmation'] ? 0 : (int) trim($subscriberA[3], ' "\'');
         // i need to know if exist user
         $db = JFactory::getDBO();
         $quer = "SELECT id FROM `#__jnews_subscribers` WHERE `email` = '{$email}'";
         $db->setQuery($quer);
         $res = $db->loadResult();
         if ($res) {
             //i need to update
             $isResiveHtml = (int) trim($subscriberA[2], ' "\'');
             $querUpdate = "UPDATE `#__jnews_subscribers` SET confirmed = '{$comfirmation}', receive_html= '{$isResiveHtml}',column1 = '{$column4}', column2 = '{$column5}', column3 = '{$column5}', column4 = '{$column7}', column5= '{$column8}',ip = '{$ip}' WHERE `email` = '{$email}'";
             $db->setQuery($querUpdate);
             $db->query();
             if (!empty($allAvailableListsA) && !empty($list2SubcribeToA)) {
                 foreach ($list2SubcribeToA as $oneneedList => $noneed) {
                     $listId = $allAvailableListsA[$oneneedList];
                     //
                     $query = "INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ({$listId}, {$res}, {$time})";
                     $db->setQuery($query);
                     $db->query();
                 }
             }
             continue;
         }
         if (!$firstValue) {
             $insertQuery .= ',';
         }
         /*$insertQuery .= '(\''. htmlentities(trim($subscriberA[0],' "\'') ) . '\',\''.$email.'\','.$comfirmation.','.(int)trim($subscriberA[2],' "\'').',\''.$time.'\',\''.$column4.'\',\''.$column5.'\',\''.$column6.'' .
         		'\',\''.$column7.'\',\''.$column8.'\',\''.$ip.'\')';*/
         $insertQuery .= '(\'' . addslashes(trim($subscriberA[0], ' "\'')) . '\',\'' . $email . '\',' . $comfirmation . ',' . (int) trim($subscriberA[2], ' "\'') . ',\'' . $time . '\',\'' . $column4 . '\',\'' . $column5 . '\',\'' . $column6 . '' . '\',\'' . $column7 . '\',\'' . $column8 . '\',\'' . $ip . '\')';
         if (!$firstValue) {
             $selectQuery .= ',';
         }
         $selectQuery .= '\'' . $email . '\'';
         $firstValue = false;
         $totalInsert++;
         if ($totalInsert % 50 == 0) {
             if (empty($insertQuery)) {
                 continue;
             }
             $db = JFactory::getDBO();
             $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery;
             $db->setQuery($query);
             $db->query();
             $firstValue = true;
             $insertQuery = '';
             //get the id of the subscribers
             $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $resultsSubClA = jnews::convertObjectList2Array($loadResultArray);
             $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA);
             $selectQuery = '';
         } else {
             if (empty($insertQuery)) {
                 return false;
             }
             $db = JFactory::getDBO();
             $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery;
             $db->setQuery($query);
             $db->query();
         }
     }
     //send confirmation email if required
     if ($GLOBALS[JNEWS . 'require_confirmation'] && !empty($list2SubcribeToA)) {
         $list4Message = $allAvailableListsA[key($list2SubcribeToA)];
         $myList = jNews_Lists::getOneList($list4Message);
         $myList->subscribemessage = trim($myList->subscribemessage);
         if (empty($myList->subscribemessage) || substr_count($myList->subscribemessage, '{tag:confirm}') < 1) {
             $Sub_TAG = '{tag:confirm}';
             //'[CONFIRM]';
         } else {
             $Sub_TAG = '';
         }
         $mailing = new stdClass();
         if (!empty($myList->subscribemessage)) {
             $mailing->htmlcontent = $myList->subscribemessage;
             $mailing->textonly = $myList->subscribemessage;
         } else {
             // default message
             $mailing->textonly = 'Please confirm your subscription to our website by clicking on the following link.';
             $mailing->htmlcontent = '<br />' . $mailing->textonly . '<br /><br />';
         }
         $mailing->textonly .= $Sub_TAG;
         $mailing->htmlcontent .= $Sub_TAG;
         //insert the mailing in the mailing table
         $mailing->mailing_type = 1;
         $mailing->template_id = 0;
         $mailing->senddate = $time;
         $mailing->subject = _JNEWS_SUBSCRIBE_SUBJECT_MESS;
         $mailing->attachments = '';
         $mailing->images = '';
         $mailing->published = 1;
         $mailing->html = 1;
         $mailing->visible = 0;
         $mailing->fromname = '';
         $mailing->fromemail = '';
         $mailing->frombounce = '';
         $mailing->author_id = 0;
         $mailing->delay = 0;
         $mailing->follow_up = 0;
         $mailing->cat_id = 0;
         $mailing->delay_min = 0;
         $mailing->delay_max = 0;
         $mailing->notify_id = 0;
         $mailing->next_date = 0;
         $mailing->start_date = $time - 2;
         $mailing->issue_nb = 0;
         $mailing->createdate = $time;
         $mailing->acc_level = 0;
         $mailingID = jNews_Mailing::insertMailingData($mailing);
         //enter the emails in the queue
         $query = 'INSERT IGNORE INTO `#__jnews_queue` (`subscriber_id`,`mailing_id`,`send_date`,`priority`) ';
         $query .= 'SELECT `id`,' . intval($mailingID) . ',' . $time . ',1';
         $query .= ' FROM `#__jnews_subscribers` ';
         $query .= 'WHERE `subscribe_date`=' . $time . ' AND `confirmed`=0';
         $db->setQuery($query);
         $db->query();
     }
     if (!empty($selectQuery)) {
         //get the id of the subscribers
         $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')';
         $db->setQuery($query);
         $loadResultArray = $db->loadObjectList();
         $resultsSubClA = jnews::convertObjectList2Array($loadResultArray);
         $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA);
     }
     if (!empty($allAvailableListsA)) {
         //if lists in checkbox are not empty
         if (empty($list2SubcribeToA)) {
             jnews::printM('red', 'You need to select at least one list. Emails have been imported but not subscribed.');
             if ($GLOBALS[JNEWS . 'require_confirmation']) {
                 return 'The confirmation email cannot be sent because there is not list selected to subscribe the users.';
             } else {
                 return _JNEWS_IMPORT_FINISHED;
             }
         }
         foreach ($list2SubcribeToA as $oneselected => $vval) {
             $seleeected[] = $allAvailableListsA[$oneselected];
         }
         foreach ($list2SubcribeToA as $oneneedList => $noneed) {
             $listId = $allAvailableListsA[$oneneedList];
             //
             $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ';
             $firstTime = true;
             if (!empty($allSubscribersIDA)) {
                 foreach ($allSubscribersIDA as $oneSubcriber) {
                     if (!$firstTime) {
                         $query .= ',';
                     }
                     $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')';
                     $firstTime = false;
                     if (jNews_Lists::getListType($listId) == 2) {
                         //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list
                         jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId);
                         //
                     } else {
                         if (jNews_Lists::getListType($listId) == 1) {
                             $arrayFollowUp = jNews_Subscribers::followInSelected($listId);
                             if (!$arrayFollowUp) {
                                 continue;
                             }
                             foreach ($arrayFollowUp as $onefollow_id) {
                                 if (in_array($onefollow_id, $seleeected)) {
                                     continue;
                                 }
                                 $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')';
                                 jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id);
                             }
                         }
                     }
                 }
                 $db->setQuery($query);
                 $db->query();
             }
         }
     } else {
         //otherwise we get the value from dropdown box
         $listId = JRequest::getVar('opted_list', '');
         if ($listId) {
             $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ';
             $firstTime = true;
             if (!empty($allSubscribersIDA)) {
                 foreach ($allSubscribersIDA as $oneSubcriber) {
                     if (!$firstTime) {
                         $query .= ',';
                     }
                     $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')';
                     $firstTime = false;
                     if (jNews_Lists::getListType($listId) == 2) {
                         //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list
                         jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId);
                     } else {
                         if (jNews_Lists::getListType($listId) == 1) {
                             $arrayFollowUp = jNews_Subscribers::followInSelected($listId);
                             if (!$arrayFollowUp) {
                                 continue;
                             }
                             foreach ($arrayFollowUp as $onefollow_id) {
                                 if (in_array($onefollow_id, $seleeected)) {
                                     continue;
                                 }
                                 $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')';
                                 jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id);
                             }
                         }
                     }
                 }
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     if ($saveSubsInRows) {
         //if adding subscribers in frontend through rows
         jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully added!');
     } else {
         //otherwise we import subscribers
         jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully imported!');
     }
     return _JNEWS_IMPORT_FINISHED;
 }
Пример #4
0
 public static function remove($subscriber, $subscriberId, $cle = '')
 {
     $db = JFactory::getDBO();
     $listUnsubA = array();
     //unsubscribe listIds
     $allAvailableListsA = JRequest::getVar('sub_list_id', '');
     $unsubListValA = JRequest::getVar('unsubscribed', '');
     $textarea_msg = JRequest::getVar('textareamess', ' ', 'post');
     foreach ($allAvailableListsA as $key => $unsublist) {
         if (!empty($unsubListValA[$key]) == 1) {
             $listidUnsubA[] = $unsublist;
         }
     }
     if (!empty($subscriberId) and !empty($cle)) {
         if (md5($subscriber->email) == $cle) {
             if (!empty($listidUnsubA)) {
                 $query = 'UPDATE `#__jnews_listssubscribers` SET ';
                 $query .= ' `unsubdate`=' . time();
                 $query .= ' ,`unsubscribe`=1';
                 $query .= ' WHERE `subscriber_id`= ' . $subscriberId;
                 $query .= ' AND `list_id` IN (' . implode(',', $listidUnsubA) . ')';
                 $db->setQuery($query);
                 $result = $db->query();
                 $query = 'SELECT * FROM `#__jnews_lists` WHERE `id` IN (' . implode(',', $listidUnsubA) . ')';
                 $db->setQuery($query);
                 $listsO = $db->loadObjectList();
             }
             //check if we have subscription to any auto-responder
             $query = 'SELECT `id` FROM `#__jnews_lists` ';
             $query .= ' WHERE `list_type`= 2 ';
             $query .= ' AND `id` IN (' . implode(',', $listidUnsubA) . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $autoRespondListA = jnews::convertObjectList2Array($loadResultArray);
             if (!empty($autoRespondListA)) {
                 $query = 'DELETE FROM `#__jnews_queue` ';
                 $query .= ' WHERE `subscriber_id`= ' . $subscriberId;
                 $query .= ' AND `mailing_id` IN ( SELECT `mailing_id` FROM `#__jnews_listmailings` WHERE `list_id` IN (' . implode(',', $autoRespondListA) . ') )';
                 $db->setQuery($query);
                 $db->query();
             }
             foreach ($listsO as $key => $list) {
                 //we send the unsubscription notification to the subscriber if it is turn to yes
                 if ($list->unsubscribesend == 1) {
                     jNews_ProcessMail::sendUnsubcribeEmail($subscriber, $subscriberId, $list);
                 }
                 //we send the unsubscription notification to the list owner if it is turn to yes
                 if ($GLOBALS[JNEWS . 'level'] > 2 && $list->unsubscribenotifyadmin == 1 && !empty($list->notifyadminmsg) && !empty($list->owner)) {
                     $my = JFactory::getUser($list->owner);
                     if ($list->notifyadminmsg != "") {
                         $dom = new domDocument();
                         $dom->preserveWhiteSpace = false;
                         $dom->formatOutput = true;
                         if ($dom->loadHTML("<html><body>" . $list->notifyadminmsg . "</body></html>")) {
                             $xpath = new DOMXpath($dom);
                             $elements = $xpath->query("/html/descendant::*[contains(text(),'LISTNAME')]/..");
                             if (!is_null($elements)) {
                                 $feedback = _JNEWS_UNSUBSCRIBE_MESSAGE_TEXTAREA_TITLE;
                                 foreach ($elements as $element) {
                                     $item = $dom->createElement("span", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $feedback);
                                     $br = $dom->createElement('br');
                                     $item->insertBefore($br);
                                     $titlespace = $dom->createElement("span", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $textarea_msg);
                                     $item->appendChild($titlespace);
                                     if ($element->nextSibling != null) {
                                         $appen = $element->nextSibling;
                                     } else {
                                         $appen = $element;
                                     }
                                     if ($element->parentNode != null) {
                                         $inss = $element->parentNode;
                                     } else {
                                         $inss = $element;
                                     }
                                     $inss->insertBefore($item, $appen);
                                 }
                                 $dom->formatOutput = true;
                                 $lisnotifyadminmsg = $dom->saveHTML();
                             }
                             $res_search = preg_match("/(?:<body[^>]*>)(.*)<\\/body>/isU", $lisnotifyadminmsg, $matches);
                             if ($res_search > 0 && isset($matches[1]) && $matches[1] !== "") {
                                 $list->notifyadminmsg = $matches[1];
                             }
                         }
                     }
                 }
                 jNews_ProcessMail::sendNotification($list->notifyadminmsg, $subscriber, $my, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
             }
             if (!empty($GLOBALS[JNEWS . 'unsubscribe_notification'])) {
                 $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'unsubscribe_notification']);
                 if (!empty($listOfAdminA)) {
                     foreach ($listOfAdminA as $oneAdmin) {
                         if (empty($oneAdmin)) {
                             continue;
                         }
                         $owner = new stdClass();
                         $owner->name = $oneAdmin;
                         $owner->email = $oneAdmin;
                         jNews_ProcessMail::sendNotification(_JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION, $newSubscriber, $owner, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
                     }
                 }
             }
         }
     }
     return $result;
 }
Пример #5
0
 function _getTableQuery($query, $loadAction = 'loadResult')
 {
     // check parameters
     // return empty if invalid
     if (empty($query)) {
         return '';
     }
     // set database
     static $db = null;
     if (!isset($db)) {
         $db = JFactory::getDBO();
     }
     $db->setQuery($query);
     if ($loadAction == 'loadResultArray') {
         $loadResultArray = $db->loadObjectList();
         $resultsSubClA = jnews::convertObjectList2Array($loadResultArray);
         return $resultsSubClA;
     } else {
         // set and load query
         return $db->{$loadAction}();
     }
 }
Пример #6
0
/**
 * Installation of the extensions plugins and modules
 */
function installExtensions()
{
    $db = JFactory::getDBO();
    $errors = array();
    $path = JNEWSPATH_ADMIN . 'extensions';
    $dirs = JFolder::folders($path);
    $excludedExtensions = array();
    if (version_compare(JVERSION, '1.6.0') < '') {
        //j15
        $query = "DELETE FROM `#__modules` WHERE `module` LIKE '%jnewsletter%' ";
        $db->setQuery($query);
        $db->query();
        $query = "SELECT CONCAT(`folder`,`element`) FROM #__plugins WHERE `folder` = 'jnews' OR `element` LIKE '%jnews%'";
        $query .= " UNION SELECT `module` FROM #__modules WHERE `module` LIKE '%jnews%'";
        $db->setQuery($query);
        $loadResultArray = $db->loadObjectList();
        $existingExtensions = jnews::convertObjectList2Array($loadResultArray);
    } else {
        //j16
        $db->setQuery("SELECT CONCAT(`folder`,`element`) FROM #__extensions WHERE `folder` = 'jnews' OR `element` LIKE '%jnews%'");
        $loadResultArray = $db->loadObjectList();
        $existingExtensions = jnews::convertObjectList2Array($loadResultArray);
    }
    $plugins = array();
    $modules = array();
    $extensioninfo = array();
    //array('name','ordering','required table or published')
    $extensioninfo['mod_jnews'] = array('jNews Module');
    $extensioninfo['jnewssyncuser'] = array('jNews User Synchronization', 20, 1);
    $extensioninfo['vmjnewssubs'] = array('jNews-Virtuemart Newsletter Subscription', 15, '#__vm_order_user_info');
    $extensioninfo['forwardtofriend'] = array('jNews Forward to Friend', 5, 1);
    $extensioninfo['jnewsbot'] = array('jNews Content Plugin', 6, 1);
    $extensioninfo['jnewsbotk2'] = array('jNews K2 Plugin', 4, '#__k2_items');
    $extensioninfo['jnewsshare'] = array('jNews Social Share Plugin', 9, 1);
    //inclusion of module in newsletter
    $extensioninfo['jnewsflexicontent'] = array('jNews Flexicontent Bot', 7, '#__flexicontent_cats_item_relations');
    $extensioninfo['tagdatetime'] = array('jNews Tag: Date and Time', 2, 1);
    $extensioninfo['tagsite'] = array('jNews Tag: Site Links', 5, 1);
    $extensioninfo['tagsubscriber'] = array('jNews Tag: Subscriber', 3, 1);
    $extensioninfo['tagsubscription'] = array('jNews Tag: Subscriptions', 7);
    $extensioninfo['virtuemartproduct'] = array('VirtueMart Products', 8, '#__vm_product');
    $listTables = $db->getTableList();
    foreach ($dirs as $oneDir) {
        $arguments = explode('_', $oneDir);
        if ($arguments[0] == 'mod') {
            $newModule = new stdClass();
            $newModule->name = $oneDir;
            if (isset($extensioninfo[$oneDir][0])) {
                $newModule->name = $extensioninfo[$oneDir][0];
            }
            $newModule->type = 'module';
            $newModule->folder = '';
            $newModule->element = $oneDir;
            $newModule->enabled = 1;
            $newModule->params = '{}';
            $newModule->ordering = 0;
            if (isset($extensioninfo[$oneDir][1])) {
                $newModule->ordering = $extensioninfo[$oneDir][1];
            }
            $destinationFolder = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'modules' . DS . $oneDir;
            if (!jnews::createDirectory($destinationFolder)) {
                continue;
            }
            if (!jnews::copyFolder($path . DS . $oneDir, $destinationFolder)) {
                continue;
            }
            if (is_array($existingExtensions) && in_array($newModule->element, $existingExtensions)) {
                continue;
            }
            $modules[] = $newModule;
        } else {
            // it is a plugin
            $extensionKeys = array_keys($extensioninfo);
            $newPlugin = new stdClass();
            if (in_array($oneDir, $extensionKeys)) {
                if (isset($extensioninfo[$oneDir][2])) {
                    if (is_numeric($extensioninfo[$oneDir][2])) {
                        $newPlugin->enabled = $extensioninfo[$oneDir][2];
                    } else {
                        if (!in_array(str_replace('#__', $db->getPrefix(), $extensioninfo[$oneDir][2]), $listTables)) {
                            $excludedExtensions[] = $oneDir;
                        }
                    }
                }
                if (!in_array($oneDir, $excludedExtensions)) {
                    $newPlugin->name = $oneDir;
                    if (isset($extensioninfo[$oneDir][0])) {
                        $newPlugin->name = $extensioninfo[$oneDir][0];
                    }
                    $newPlugin->type = 'plugin';
                    if ($oneDir == 'jnewssyncuser') {
                        $newPlugin->folder = 'user';
                    } elseif ($oneDir == 'vmjnewssubs' || $oneDir == 'jnewscron') {
                        $newPlugin->folder = 'system';
                    } else {
                        $newPlugin->folder = 'jnews';
                    }
                    $newPlugin->element = $oneDir;
                    $newPlugin->enabled = 1;
                    $newPlugin->params = '{}';
                    $newPlugin->ordering = 0;
                    if (isset($extensioninfo[$oneDir][1])) {
                        $newPlugin->ordering = $extensioninfo[$oneDir][1];
                    }
                    if (!jnews::createDirectory(JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'plugins' . DS . $newPlugin->folder)) {
                        continue;
                    }
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        $destinationFolder = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'plugins' . DS . $newPlugin->folder;
                    } else {
                        //j16
                        $destinationFolder = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'plugins' . DS . $newPlugin->folder . DS . $newPlugin->element;
                        if (!jnews::createDirectory($destinationFolder)) {
                            continue;
                        }
                    }
                    if (!jnews::copyFolder($path . DS . $oneDir, $destinationFolder)) {
                        continue;
                    }
                    if (is_array($existingExtensions) && in_array($newPlugin->folder . $newPlugin->element, $existingExtensions)) {
                        continue;
                    }
                    $plugins[] = $newPlugin;
                }
            }
        }
    }
    if (!empty($errors)) {
        jnews::displayInfo($errors, 'error');
    }
    if (version_compare(JVERSION, '1.6.0', '<')) {
        $extensions = $plugins;
    } else {
        $extensions = array_merge($plugins, $modules);
    }
    $success = array();
    if (!empty($extensions)) {
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $queryExtensions = 'INSERT INTO `#__plugins` (`name`,`element`,`folder`,`published`,`ordering`) VALUES ';
        } else {
            $queryExtensions = 'INSERT INTO `#__extensions` (`name`,`element`,`folder`,`enabled`,`ordering`,`type`,`access`,`manifest_cache`) VALUES ';
        }
        foreach ($extensions as $oneExt) {
            $queryExtensions .= '(' . $db->Quote($oneExt->name) . ',' . $db->Quote($oneExt->element) . ',' . $db->Quote($oneExt->folder) . ',' . $oneExt->enabled . ',' . $oneExt->ordering;
            if (version_compare(JVERSION, '1.6.0', '>=')) {
                $manifest_cache = '{"legacy":false,"name":"' . $oneExt->name . '","type":"plugin","creationDate":"' . date("F Y") . '","author":"Joobi Limited","copyright":"Copyright (C) 2006 - 2012 Joobi Limited. All rights reserved.","authorEmail":"*****@*****.**","authorUrl":"www.joobi.co","version":"' . jnews::getVersion() . '","description":"","group":""}';
                $queryExtensions .= ',' . $db->Quote($oneExt->type) . ',1,' . $db->Quote($manifest_cache);
            }
            $queryExtensions .= '),';
            if ($oneExt->type != 'module') {
                $success[] = JText::sprintf(_JNEWS_PLUG_INSTALLED, $oneExt->name);
            }
        }
        $queryExtensions = trim($queryExtensions, ',');
        $db->setQuery($queryExtensions);
        $db->query();
    }
    if (!empty($modules)) {
        foreach ($modules as $oneModule) {
            if (version_compare(JVERSION, '1.6.0', '<')) {
                $queryModule = 'INSERT INTO `#__modules` (`title`,`position`,`published`,`module`) VALUES ';
                $queryModule .= '(' . $db->Quote($oneModule->name) . ",'left',0," . $db->Quote($oneModule->element) . ")";
            } else {
                $queryModule = 'INSERT INTO `#__modules` (`title`,`position`,`published`,`module`,`access`,`language`) VALUES ';
                $queryModule .= '(' . $db->Quote($oneModule->name) . ",'position-7',0," . $db->Quote($oneModule->element) . ",1,'*')";
            }
            $db->setQuery($queryModule);
            $db->query();
            $moduleId = $db->insertid();
            $db->setQuery('INSERT IGNORE INTO `#__modules_menu` (`moduleid`,`menuid`) VALUES (' . $moduleId . ',0)');
            $db->query();
            $success[] = JText::sprintf(_JNEWS_MODULE_INSTALLED, $oneModule->name);
        }
    }
    if (!empty($success)) {
        jnews::displayInfo($success, 'success');
    }
}
Пример #7
0
    /**
     * This public static function will generate a graph report of Mailing Report
     * Two Pie charts are generated,
     * @referenced files: open flash chart 2 library
     *
     * @param object $results query result
     */
    public static function mailingSpecificGraph($results, $queryfilters)
    {
        if (empty($results)) {
            echo '&nbsp;&nbsp;<b>' . _JNEWS_GRAPH_WARN_MESSAGE . '</b><br /><br />';
            return true;
        }
        ?>
		<div style="font-size:20px; font-weight:bold; color:#0B55C4;">
			<?php 
        echo _JNEWS_MAILING_SUBJECT_HEADER . ': ' . $results['subject'];
        ?>
		</div>
		<br />
		<?php 
        //remove the wizard text in the pop-up page of mailing report
        $doc = JFactory::getDocument();
        $doc->addStyleDeclaration('div#acawizard{display:none}');
        //Tabs
        $stats_tabs = new MosTabsjNews(0);
        $stats_tabs->startPane('acaMailingReports');
        //Graph of each Mailing
        $stats_tabs->startTab(_JNEWS_MAIL_GRAPH, "acaMailingReports.graph");
        outputReportGraph::mailingGooglePieChart($results);
        $stats_tabs->endTab();
        //Detailed info of each Mailing (read/unread/text)
        $stats_tabs->startTab(_JNEWS_MAIL_DETAILS, "acaMailingReports.details");
        ?>
		<br />
		<table class="<?php 
        echo jnews::myTheme();
        ?>
">
			<thead>
				<th ><?php 
        echo _JNEWS_MAIL_DETAILS_READ;
        ?>
</th>
				<th ><?php 
        echo _JNEWS_MAIL_DETAILS_UNREAD;
        ?>
</th>
				<th ><?php 
        echo _JNEWS_MAIL_DETAILS_TEXT;
        ?>
</th>
			</thead>
			<tr>
				<?php 
        $mailingId = $results['id'];
        $startDate = $queryfilters['startdate'];
        $endDate = $queryfilters['enddate'];
        $db = JFactory::getDBO();
        $sql = "SELECT B.`email` " . "FROM `#__jnews_stats_details` AS A " . "LEFT JOIN `#__jnews_subscribers` AS B ON B.`id` = A.`subscriber_id` " . "WHERE A.`mailing_id` = " . $mailingId . " AND A.sentdate BETWEEN {$startDate} AND {$endDate}";
        //html read
        $query = $sql . " AND A.`html` = 1 AND A.`read` = 1 LIMIT 10000";
        $db->setQuery($query);
        $loadResultArray = $db->loadObjectList();
        $resultHTMLRead = jnews::convertObjectList2Array($loadResultArray);
        //html unread
        $query = $sql . " AND A.`html` = 1 AND A.`read` = 0 LIMIT 10000";
        $db->setQuery($query);
        $loadResultArray = $db->loadObjectList();
        $resultHTMLUnread = jnews::convertObjectList2Array($loadResultArray);
        //text only
        $query = $sql . " AND A.`html` = 0 LIMIT 10000";
        $db->setQuery($query);
        $loadResultArray = $db->loadObjectList();
        $resultsText = jnews::convertObjectList2Array($loadResultArray);
        ?>
				<td valign="top"><?php 
        foreach ($resultHTMLRead as $data) {
            if (!empty($data)) {
                echo $data . "<br />";
            }
        }
        ?>
</td>
				<td valign="top"><?php 
        foreach ($resultHTMLUnread as $data) {
            if (!empty($data)) {
                echo $data . "<br />";
            }
        }
        ?>
</td>
				<td valign="top"><?php 
        foreach ($resultsText as $data) {
            if (!empty($data)) {
                echo $data . "<br />";
            }
        }
        ?>
</td>
			</tr>
		</table>
	<?php 
        $stats_tabs->endTab();
        $stats_tabs->endPane();
    }
Пример #8
0
 public static function getOwnedlists($id)
 {
     $db = JFactory::getDBO();
     $query = "SELECT `id` FROM `#__jnews_lists` WHERE `owner`=" . $id;
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $ownedlists = jnews::convertObjectList2Array($loadResultArray);
     return $ownedlists;
 }
Пример #9
0
 public static function getListMailingToDelete($listID)
 {
     if (empty($listID)) {
         return false;
     }
     $type = jNews_Lists::getListType($listID);
     $query = 'SELECT `mailing_id` FROM `#__jnews_listmailings` WHERE `list_id`=' . $listID;
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $resultA = jnews::convertObjectList2Array($loadResultArray);
     return $resultA;
 }
Пример #10
0
 /**
  * This public static function will save entries to listSubscibers
  * @param object $subsListInfo subcriberInfo
  * -> user_id
  * ->array sub_list_id  all lists IDs
  * ->array subscribed only subscribed
  * ->acc_level
  */
 public static function updateSubscriptionToLists($suscription)
 {
     if (empty($suscription->sub_list_id)) {
         return false;
     }
     $db = JFactory::getDBO();
     $listidSubsA = array();
     //subscribe lists
     $listidUnsubsA = array();
     //unsubscribe lists
     $mainframe = JFactory::getApplication();
     //cehck if one of the list is attached to an auto-responder
     //if so make sure we subscribe to it
     $query = 'SELECT `followup_id` FROM `#__jnews_followup`  ';
     $query .= ' WHERE `list_id` IN ( ' . implode($suscription->sub_list_id, ',') . ')';
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $attachedList2AutoResponderA = jnews::convertObjectList2Array($loadResultArray);
     if (!empty($attachedList2AutoResponderA)) {
         foreach ($attachedList2AutoResponderA as $oneAutoList) {
             if (!in_array($oneAutoList, $suscription->sub_list_id)) {
                 $suscription->sub_list_id[] = $oneAutoList;
                 $suscription->subscribed[] = 1;
             }
         }
     }
     //get the current state of subscriptions
     $query = 'SELECT `unsubscribe`,`list_id` FROM `#__jnews_listssubscribers`  ';
     $query .= ' WHERE `subscriber_id`= ' . $suscription->user_id;
     $db->setQuery($query);
     $existingSubcriptionsA = $db->loadObjectList('list_id');
     foreach ($suscription->subscribed as $oneID => $checked) {
         $listID2 = (int) $suscription->sub_list_id[$oneID];
         if (isset($existingSubcriptionsA[$listID2])) {
             if ($existingSubcriptionsA[$listID2]->unsubscribe) {
                 //currently unsubscribed
                 if ($checked) {
                     $listidSubsA[] = $listID2;
                 }
             } else {
                 //already subscribed
                 if (!$checked) {
                     $listidUnsubsA[] = $listID2;
                 }
             }
         } else {
             if ($checked) {
                 $listidSubsA[] = $listID2;
             }
         }
     }
     //endfroeach
     //we check if frontend or not
     if (!$mainframe->isAdmin()) {
         //we check if current subscription is not empty
         if (!empty($listidSubsA)) {
             if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
                 //we check if the social class file exists for the implementation of master lists
                 if (class_exists('jNews_Social')) {
                     //we check if configuration for master lists is enabled
                     if ($GLOBALS[JNEWS . 'use_masterlists']) {
                         if ($GLOBALS[JNEWS . 'level'] > 1) {
                             //we validate if the user can be subscribed to the list then we return the masterlistid
                             //1 - MasterLists for all Potential Users
                             $listidSubsA[] = jNews_Social::includeMasterListIds($suscription->user_id, 1, $listidSubsA);
                             //3 - MasterLists for all Registered Subscribers
                             $listidSubsA[] = jNews_Social::includeMasterListIds($suscription->user_id, 2, $listidSubsA);
                         }
                         if ($GLOBALS[JNEWS . 'level'] > 2) {
                             //we validate if the user can be subscribed to the list then we return the masterlistid
                             //3 - MasterLists for all Front-end Subscribers
                             $listidSubsA[] = jNews_Social::includeMasterListIds($suscription->user_id, 3, $listidSubsA);
                         }
                         //we remove here the masterlistids from the $listidUnsubsA
                         //so that masterlist entries won't get updated to unsubscribe
                         foreach ($listidUnsubsA as $key => $lsidunsub) {
                             if (in_array($lsidunsub, $listidSubsA)) {
                                 unset($listidUnsubsA[$key]);
                             }
                         }
                     }
                 }
             }
         }
     }
     //update
     jNews_ListsSubs::_applyChangedSubscription($suscription->user_id, $listidSubsA, $listidUnsubsA);
     $allListsForAR = array();
     if (!empty($listidSubsA)) {
         foreach ($listidSubsA as $id) {
             $allListsForAR[$id] = true;
         }
     }
     if (!empty($listidUnsubsA)) {
         foreach ($listidUnsubsA as $id) {
             $allListsForAR[$id] = false;
         }
     }
     if (empty($allListsForAR)) {
         return true;
     }
     $allListsForARkeysA = array_keys($allListsForAR);
     //we need to separate the ARs from the Lists (From the Subscriptions that were changed)
     $query = 'SELECT `id` FROM `#__jnews_lists` WHERE `list_type`=1 AND `id` IN (' . implode(',', $allListsForARkeysA) . ')';
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $listA = jnews::convertObjectList2Array($loadResultArray);
     if (!empty($listA)) {
         $changedARA = array_diff($allListsForARkeysA, $listA);
         //we get the records from  the followup table
         $query = 'SELECT * FROM `#__jnews_followup` WHERE `list_id` IN (' . implode(',', $listA) . ')';
         $db->setQuery($query);
         $followupLists = $db->loadObjectList();
         if (empty($followupLists)) {
             $query = 'SELECT `id` FROM `#__jnews_lists` WHERE `list_type`=2 AND `id` IN (' . implode(',', $allListsForARkeysA) . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $subscribeARA = jnews::convertObjectList2Array($loadResultArray);
             $query = 'SELECT `id` FROM `#__jnews_lists` WHERE `list_type`=2 AND `id` NOT IN (' . implode(',', $allListsForARkeysA) . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $unsubscribeARA = jnews::convertObjectList2Array($loadResultArray);
         } else {
             $subscribeARA = array();
             $unsubscribeARA = array();
             jNews_ListsSubs::_resolveListAndARConflicts($subscribeARA, $unsubscribeARA, $followupLists, $allListsForAR, $changedARA);
         }
     } else {
         $subscribeARA = $listidSubsA;
         $unsubscribeARA = $listidUnsubsA;
     }
     if (!empty($subscribeARA)) {
         jNews_ListsSubs::subscribeARtoQueue($suscription->user_id, $subscribeARA);
     }
     if (!empty($unsubscribeARA)) {
         jNews_ListsSubs::unsubscribeARtoQueue($suscription->user_id, $unsubscribeARA);
     }
     return true;
 }
Пример #11
0
 /**
  * <p>Function to count the total number of joomla modules</p>
  * @param $modAccess
  */
 function _countVMProducts()
 {
     static $db = null;
     if (!isset($db)) {
         $db = JFactory::getDBO();
     }
     $query = "SELECT count(`virtuemart_product_id`) FROM `#__virtuemart_products`";
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $result = jnews::convertObjectList2Array($loadResultArray);
     $count = !empty($result) ? $result[0] : 0;
     return $count;
 }
Пример #12
0
 /**
  * public static function to count the number of templates
  */
 public static function countTemplates($published = 0, $availability = -1)
 {
     static $count = null;
     if (isset($count)) {
         return $count;
     }
     $db = JFactory::getDBO();
     $query = "SELECT count(`template_id`) FROM `#__jnews_templates`";
     if ($published == 1) {
         $query .= ' WHERE `published` = 1';
     }
     if ($published == 1 && $availability == 1) {
         $query .= ' AND ';
     } elseif ($published == 0 && $availability == 1) {
         $query .= ' WHERE ';
     }
     if ($availability == 1) {
         $query .= ' `availability` = 1';
     }
     $db->setQuery($query);
     $loadResultArray = $db->loadObjectList();
     $result = jnews::convertObjectList2Array($loadResultArray);
     $count = !empty($result) ? $result[0] : 0;
     return $count;
 }