Esempio n. 1
0
 /**
  * This function is used in the integration of jLinks to jNews. jNews
  * categories are checked and jLinks entries are categorized. This is also
  * where the mail content is scanned for url links and replaced with
  * jLinks generated links with the namekeys of the original links.
  *
  * @param int $mailingType list type whether Newsletter, Auto-Responder,
  *                     or Smart Newsletter
  * @param object contains the mailer
  * @param int $mailID email ID to be used as suffix of the mail category namekey
  * @param string $mailSubject title or subject of the email
  * @param int $mailCatID determines if the mail category is created or not
  * @param array $convertedLinks container of the content converted links
  * @param int $subsid subscriber id
  *
  **/
 function _linkReplacement($mailingType, $mailID, $mailSubject, $mail, &$mailCatID, &$convertedLinks, $subsid)
 {
     if (empty($GLOBALS[JNEWS . 'show_jlinks'])) {
         return true;
     }
     $acajLinkey = 'jnewslink5wroot';
     $acajNewsKey = 'jnewsKa2f6gpw';
     $acajAutoKey = 'jnewsK9dfn7lws';
     $acajSmartKey = 'jnewsK8kd92hf';
     $acajMailKey = 'jnewsKo02j6d4u5aco';
     static $loaded = false;
     //TODO put priority if easylinks and jlinks exist or add checking if easylinks is installed instead of jlinks
     if (!$loaded) {
         if (!defined('JOOBI_SECURE')) {
             define('JOOBI_SECURE', true);
         }
         $joobiEntryPoint = __FILE__;
         if (defined('JPATH_ROOT')) {
             $path = JPATH_ROOT;
         } elseif (isset($mosConfig_absolute_path)) {
             $path = $mosConfig_absolute_path;
         }
         $status = false;
         //if jLinks is not installed on the website there is no need to proceed
         if (!file_exists($path . DS . 'joobi' . DS . 'entry.php')) {
             return true;
         }
         $status = @(include $path . DS . 'joobi' . DS . 'entry.php');
         if (!$status && !defined('INSTALLER_FOLDER')) {
             echo "We were unable to load Joobi library.";
         }
         //file include trials failed
         if (!$status) {
             return true;
         }
         $loaded = true;
     }
     //jLinks API class
     static $redirectC = null;
     if (empty($redirectC) && class_exists('WClass')) {
         $redirectC = WClass::get('redirect.api', null, 'class', false);
     }
     if (empty($redirectC) && class_exists('WGet')) {
         if (!method_exists('WGet', 'file')) {
             //mean none static
             $newClass = new WGet();
             if (method_exists($newClass, 'classes')) {
                 $redirectC = WGet::classes('redirect.api', null, 'class', false);
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     if (!method_exists($redirectC, 'getCatID')) {
         echo "We were unable to load the Redirect API";
         return true;
     }
     //check if new function exist
     static $updated = null;
     if (empty($updated)) {
         if (!method_exists($redirectC, 'newsletterReplacement')) {
             $updated = false;
         } else {
             $updated = true;
         }
     }
     //jLinks Newsletter Integration class
     static $newsletterC = null;
     $contentLinks = array();
     if ($updated) {
         $redirectC->getContentLinks($mail, $contentLinks);
     } else {
         if (empty($newsletterC) && class_exists('WClass')) {
             $newsletterC = WClass::get('redirect.newsletter', null, 'class', false);
         }
         if (empty($newsletterC) && class_exists('WGet')) {
             if (!method_exists('WGet', 'file')) {
                 //mean none static
                 $newClass = new WGet();
                 if (method_exists($newClass, 'classes')) {
                     $newsletterC = WGet::classes('redirect.newsletter', null, 'class', false);
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!method_exists($newsletterC, 'getContentLinks')) {
             echo "We were unable to load the Redirect Newsletter API";
             return true;
         }
         $newsletterC->getContentLinks($mail, $contentLinks);
     }
     //check if mail content have links to be replace else no need for replacement
     if (empty($contentLinks)) {
         return true;
     }
     //new codes as of ver 4.0.x --glenn
     static $newsO = null;
     //initialize newsletter object
     if (empty($newsO)) {
         $newsO = new stdClass();
         $newsO->name = $mailSubject;
         $newsO->namekey = '';
         $newsO->catid = $mailCatID;
         $newsO->app = 'jnews';
     }
     if (empty($newsO->catid)) {
         //determine the type of list
         $mailSuffix = '';
         $mailParentCat = '';
         $mailParentName = '';
         //Newsletter List type
         if ($mailingType == 1) {
             $mailSuffix = 'n' . $mailID;
             $mailParentCat = $acajNewsKey;
             $mailParentName = 'Newsletter';
             //Auto-Responder List type
         } elseif ($mailingType == 2) {
             $mailSuffix = 'ar' . $mailID;
             $mailParentCat = $acajAutoKey;
             $mailParentName = 'Auto-Responder';
             //Smart-Newsletter List type
         } elseif ($mailingType == 7) {
             $mailSuffix = 'sn' . $mailID;
             $mailParentCat = $acajSmartKey;
             $mailParentName = 'Smart Newsletter';
         }
         $newsO->namekey = $acajMailKey . $mailSuffix;
         $newsO->parent = new stdClass();
         $newsO->parent->name = $mailParentName;
         $newsO->parent->namekey = $mailParentCat;
         $newsO->parent->parent = new stdClass();
         $newsO->parent->parent->name = 'jNews';
         $newsO->parent->parent->namekey = $acajLinkey;
         $newsO->parent->parent->parent = 1;
         //old codes
         if (!$updated) {
             //check if mail category exist else create it
             $mailCatID = $redirectC->getCatID($acajMailKey . $mailSuffix);
             if (empty($mailCatID)) {
                 //check if jNews category is created else create it
                 $acajID = $redirectC->getCatID($acajLinkey);
                 if (empty($acajID)) {
                     $acajID = $redirectC->createCategory('jNews', 1, null, $acajLinkey);
                 }
                 //check if the List type category exists else create it
                 $mailParentCatID = $redirectC->getCatID($mailParentCat);
                 if (empty($mailParentCatID)) {
                     //create category parameters [ name, parent id, parent namekey, namekey, namekey prefix, namekey suffix ]
                     $mailParentCatID = $redirectC->createCategory($mailParentName, $acajID, null, $mailParentCat);
                 }
                 $mailCatID = $redirectC->createCategory($mailSubject, $mailParentCatID, null, $acajMailKey . $mailSuffix);
             }
         }
         //end of old codes
     }
     //new code in API
     if ($updated) {
         $redirectC->newsletterReplacement($newsO, $mail->Body, $subsid);
     } else {
         //jLinks Newsletter Integration class
         if (empty($newsletterC)) {
             if (class_exists('WClass')) {
                 $newsletterC = WClass::get('redirect.newsletter', null, 'class', false);
             }
             if (empty($newsletterC) && class_exists('WGet')) {
                 if (!method_exists('WGet', 'file')) {
                     //mean none static
                     $newClass = new WGet();
                     if (method_exists($newClass, 'classes')) {
                         $newsletterC = WGet::classes('redirect.newsletter', null, 'class', false);
                     } else {
                         return false;
                     }
                 } else {
                     return false;
                 }
             }
         }
         if (!method_exists($newsletterC, 'getContentLinks')) {
             echo "We were unable to load the Redirect Newsletter API";
             return true;
         }
         // if converting of content links are done or not
         if (empty($convertedLinks)) {
             //find link in the content and store them
             $newsletterC->convertContentLinks($contentLinks, $convertedLinks, $mailCatID, 'jnews');
         }
         //the replacing of the content links occurs here
         $newsletterC->replaceContentLinks($mail, $convertedLinks, $subsid, 'jnews');
     }
     //end of old codes
     return true;
 }
Esempio n. 2
0
 /**
  * To populate list of apps when we install the new JOOBI_MAIN_APP
  */
 private function _refreshApps()
 {
     $this->_joobiInfoLog("_refreshApps()");
     try {
         $refresh = WClass::get('apps.refresh');
         $refresh->getDataAndRefresh();
     } catch (Exception $e) {
         throw new Exception("Problem while refreshing the apps");
     }
     //trycatch block ends
 }