Example #1
0
 function __construct()
 {
     $mes = e107::getMessage();
     $frm = e107::getForm();
     $tp = e107::getParser();
     //	$this->simulation();
     $mailoutPlugins = e107::getConfig()->get('e_mailout_list');
     if (empty($_GET['id'])) {
         return;
     }
     $tmp = base64_decode($_GET['id']);
     parse_str($tmp, $data);
     $data['plugin'] = $tp->filter($data['plugin'], 'str');
     $data['email'] = $tp->filter($data['email'], 'email');
     e107::getMessage()->addDebug(print_a($data, true));
     $plugin = vartrue($data['plugin'], false);
     if (empty($data) || !e107::isInstalled($plugin) || !in_array($plugin, $mailoutPlugins)) {
         $this->invalidURL();
         return;
     }
     $ml = e107::getAddon($plugin, 'e_mailout');
     if (!empty($data['userclass'])) {
         $data['userclass'] = intval($data['userclass']);
         $listName = e107::getUserClass()->getName($data['userclass']);
     } else {
         $listName = $ml->mailerName;
     }
     if (vartrue($_POST['remove']) && !empty($data)) {
         if ($ml->unsubscribe('process', $data) != false) {
             $text = "<p><b>" . $data['email'] . "</b> has been removed from " . $listName . ".</p>";
             $mes->addSuccess($text);
         } else {
             $text = "<p>There was a problem when attempting to remove <b>" . $data['email'] . "</b> from " . $listName . ".</p>";
             $mes->addError($text);
         }
         echo "<div class='container'>" . $mes->render() . "</div>";
         return;
     }
     if ($ml->unsubscribe('check', $data) != false) {
         $text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>" . $data['email'] . "</b> from <i>" . $listName . "</i>.</p>";
         $text .= $frm->open('unsub', 'post', e_REQUEST_URI);
         $text .= $frm->button('remove', 'Remove ', 'submit');
         $text .= $frm->close();
         $mes->setTitle('Unsubscribe', E_MESSAGE_INFO)->addInfo($text);
         echo "<div class='container'>" . $mes->render() . "</div>";
         return;
     } else {
         $this->invalidURL();
         return;
     }
 }
Example #2
0
 /**
  * Page Navigation
  * @example {PAGE_NAVIGATION: template=navdoc&auto=1} in your Theme template. 
  */
 function sc_page_navigation($parm = '')
 {
     //	$parm = eHelper::scParams($parm);
     $tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'], 'nav'), true, true);
     // always merge
     $template = $tmpl['showPage'];
     $request = $this->request;
     if ($request && is_array($request)) {
         switch ($request['action']) {
             case 'listBooks':
                 $parm['cbook'] = 'all';
                 $template = $tmpl['listBooks'];
                 if (e107::getPref('listBooks', false) == false) {
                     return false;
                 }
                 break;
             case 'listChapters':
                 $parm['cbook'] = $request['id'];
                 $template = $tmpl['listChapters'];
                 break;
             case 'listPages':
                 $parm['cchapter'] = $request['id'];
                 $template = $tmpl['listPages'];
                 break;
             case 'showPage':
                 $parm['cpage'] = $request['id'];
                 break;
         }
     }
     if ($parm) {
         $parm = http_build_query($parm, null, '&');
     } else {
         $parm = '';
     }
     $links = e107::getAddon('page', 'e_sitelink');
     $data = $links->pageNav($parm);
     if (isset($data['title']) && !vartrue($template['noAutoTitle'])) {
         // use chapter title
         $template['caption'] = $data['title'];
         $data = $data['body'];
     }
     if (empty($data)) {
         return;
     }
     return e107::getNav()->render($data, $template);
 }
Example #3
0
 /**
  * Render Related Items for the current page/news-item etc. 
  * @param string $type : comma separated list. ie. plugin folder names. 
  * @param string $tags : comma separated list of keywords to return related items of.
  * @param array $curVal. eg. array('page'=> current-page-id-value); 
  */
 function renderRelated($parm, $tags, $curVal)
 {
     if (empty($tags)) {
         return;
     }
     $tags = str_replace(', ', ',', $tags);
     //BC Fix, all tags should be comma separated without spaces ie. one,two NOT one, two
     if (!varset($parm['limit'])) {
         $parm = array('limit' => 5);
     }
     if (!varset($parm['types'])) {
         $parm['types'] = 'news';
     }
     $tp = e107::getParser();
     $types = explode(',', $parm['types']);
     $list = array();
     foreach ($types as $plug) {
         if (!($obj = e107::getAddon($plug, 'e_related'))) {
             continue;
         }
         $parm['current'] = intval(varset($curVal[$plug]));
         $tmp = $obj->compile($tags, $parm);
         if (count($tmp)) {
             foreach ($tmp as $val) {
                 $list[] = "<li><a href='" . $tp->replaceConstants($val['url'], 'full') . "'>" . $val['title'] . "</a></li>";
             }
         }
     }
     if (count($list)) {
         return "<div class='e-related clearfix'><hr><h4>" . defset('LAN_RELATED', 'Related') . "</h4><ul class='e-related'>" . implode("\n", $list) . "</ul></div>";
         //XXX Tablerender?
     }
 }
Example #4
0
 /**
  * Displays existing comments, and a comment entry form
  *
  * @param string $table - the source table for the associated item
  * @param string $action - usually 'comment' or 'reply'
  * @param integer $id - ID of item associated with comments (e.g. news ID)
  * @param unknown_type $width - appears to not be used
  * @param string $subject
  * @param boolean $rate
  */
 function compose_comment($table, $action, $id, $width, $subject, $rate = FALSE, $return = FALSE, $tablerender = TRUE)
 {
     //compose comment	: single call function will render the existing comments and show the form_comment
     //rate				: boolean, to show/hide rating system in comment, default FALSE
     global $totcc;
     $tp = e107::getParser();
     $ns = e107::getRender();
     $pref = e107::getPref();
     if ($this->getCommentPermissions() === FALSE) {
         return;
     }
     $params = array('method' => 'compose_comment', 'table' => $table, 'action' => $action, 'id' => $id, 'width' => $width, 'subject' => $subject, 'rate' => $rate, 'return' => $return, 'tablerender' => $tablerender);
     if ($this->engine != 'e107') {
         list($plugin, $method) = explode("::", $this->engine);
         $obj = e107::getAddon($plugin, 'e_comment');
         $text = e107::callMethod($obj, $method, $params);
         if (!$return) {
             if ($tablerender) {
                 echo $ns->tablerender(null, $text, 'comment', true);
             } else {
                 echo $text;
             }
         } else {
             $ret['comment'] = $text;
             $ret['comment_form'] = '';
             $ret['caption'] = '';
             return !$return ? "" : $ret;
         }
         return '';
     }
     if ($user_func = e107::getOverride()->check($this, 'compose_comment')) {
         return call_user_func($user_func, $params);
     }
     // ------------- TODO move the 'listing' into separate function so that ajax can access it easily.
     $options = array('action' => $action, 'subject' => $subject, 'rate' => $rate);
     $text = $lock = $modcomment = '';
     if ($action != 'reply') {
         $tmp = $this->getComments($table, $id, 0, $options);
         // render all comments;
         $text = $tmp['comments'];
         $lock = $tmp['lock'];
         unset($tmp);
     }
     // -------------------------------------------------------
     if ($text) {
         $modcomment = "<div class='comment-options'>";
         if ($this->totalComments && getperms("B")) {
             //	$modcomment .= "<a href='".e_ADMIN_ABS."modcomment.php?$table.$id'>".COMLAN_314."</a>";
             $modcomment .= "<a class='btn btn-default btn-mini btn-sm' href='" . e_ADMIN_ABS . "comment.php?searchquery={$id}&filter_options=comment_type__" . $this->getCommentType($table) . "'>" . COMLAN_314 . "</a>";
         }
         $modcomment .= $this->nextprev($table, $id, $from);
         $modcomment .= "</div>";
     }
     // ---------------------------
     if ($lock != '1') {
         $comment = $this->form_comment($action, $table, $id, $subject, "", TRUE, $rate, false);
         // tablerender turned off.
     } else {
         $comment = "<br /><div style='text-align:center'><b>" . COMLAN_328 . "</b></div>";
     }
     if ($text) {
         //XXX Do NOT add to template - too important to allow for modification.
         $text = "<ul class='media-list' id='comments-container'>\n" . $text . "\n</ul>";
     } else {
         $text = "<ul class='media-list' id='comments-container'><li><!-- --></li></ul>";
     }
     $search = array("{MODERATE}", "{COMMENTS}", "{COMMENTFORM}", "{COMMENTNAV}");
     $replace = array($modcomment, $text, $comment, $pagination);
     $TEMPL = str_replace($search, $replace, $this->template['layout']);
     if (!$return) {
         if ($tablerender) {
             echo $ns->tablerender("<span id='e-comment-total'>" . $this->totalComments . "</span> " . COMLAN_99, $TEMPL, 'comment', TRUE);
         } else {
             echo $TEMPL;
         }
     }
     //echo $modcomment.$comment;
     //echo $text;
     $ret['comment'] = $text;
     $ret['comment_form'] = $comment;
     $ret['caption'] = "<span id='e-comment-total'>" . $this->totalComments . "</span> " . COMLAN_99;
     return !$return ? "" : $ret;
 }
Example #5
0
File: links.php Project: gitye/e107
 function link_sefurl($curVal, $mode)
 {
     if ($mode == 'read') {
         $plugin = $this->getController()->getModel()->get('link_owner');
         return $curVal;
         //  $this->linkFunctions[$curVal];
     }
     if ($mode == 'write') {
         $plugin = $this->getController()->getModel()->get('link_owner');
         $obj = e107::getAddon($plugin, 'e_url');
         $config = e107::callMethod($obj, 'config');
         $opts = array();
         if (empty($config)) {
             return $this->hidden('link_sefurl', '') . "<span class='label label-warning'>" . LAN_NOT_AVAILABLE . "</span>";
         }
         foreach ($config as $k => $v) {
             if (strpos($v['regex'], ')') === false) {
                 $opts[] = $k;
             }
         }
         return $this->select('link_sefurl', $opts, $curVal, array('useValues' => true, 'defaultValue' => '', 'default' => '(' . LAN_DISABLED . ')'));
     }
 }
Example #6
0
            $parm['cchapter'] = $request['id'];
            $template = $tmpl['listPages'];
            break;
        case 'showPage':
            $parm['cpage'] = $request['id'];
            break;
    }
}
$expandable = vartrue($parm['expandable']);
if ($parm) {
    $parm = http_build_query($parm, null, '&');
} else {
    $parm = '';
}
### Retrieve
$links = e107::getAddon('page', 'e_sitelink');
$data = $links->pageNav($parm);
if (isset($data['title']) && !vartrue($template['noAutoTitle'])) {
    // use chapter title
    $template['caption'] = $data['title'];
    $data = $data['body'];
}
if (empty($data)) {
    return;
}
$text = e107::getNav()->render($data, $template);
/**
 * Expandable menu support. 
 * @see jquery.page.navigation.js . activate with expandable=1 in the page-navigation menu. 
 * For best results include: e107::css('page', 'css/page.navigation.css', 'jquery'); in theme.php 
 */
Example #7
0
 /**
  * Handle a bounce report. 
  * @param string $bounceString - the string from header X-e107-id
  * @param string $emailAddress - optional email address string for checks
  * @return boolean - TRUE on success, FALSE on failure
  */
 public function markBounce($bounceString, $emailAddress = '')
 {
     $bounceString = trim($bounceString);
     $bounceInfo = array('mail_bounce_string' => $bounceString, 'mail_recipient_email' => $emailAddress);
     // Ready for event data
     $errors = array();
     // Log all errors, at least until proven
     $vals = explode('/', $bounceString);
     // Should get one or four fields
     if ($this->debugMode) {
         echo "<h4>Bounce String</h4>";
         print_a($bounceString);
         echo "<h4>Vals</h4>";
         print_a($vals);
     }
     if (!is_numeric($vals[0])) {
         $errors[] = 'Bad user ID: ' . $vals[0];
     }
     $uid = intval($vals[0]);
     // User ID (zero is valid)
     if (count($vals) == 4) {
         if (!is_numeric($vals[1])) {
             $errors[] = 'Bad body record: ' . $vals[1];
         }
         if (!is_numeric($vals[2])) {
             $errors[] = 'Bad recipient record: ' . $vals[2];
         }
         $vals[0] = intval($vals[0]);
         $vals[1] = intval($vals[1]);
         $vals[2] = intval($vals[2]);
         $vals[3] = trim($vals[3]);
         $hash = $vals[0] . '/' . $vals[1] . '/' . $vals[2] . '/';
         if (md5($hash) != $vals[3]) {
             $errors[] = 'Bad md5';
             $errors[] = print_r($vals, true);
             $errors[] = 'hash:' . md5($hash);
         }
         if (empty($errors)) {
             $this->checkDB(1);
             // Look up in mailer DB if no errors so far
             if (false === $this->db->gen("SELECT mr.`mail_recipient_id`, mr.`mail_recipient_email`, mr.`mail_recipient_name`, mr.mail_target_info, \n\t\t\t\t\tmc.mail_create_date, mc.mail_start_send, mc.mail_end_send, mc.`mail_title`, mc.`mail_subject`, mc.`mail_creator`, mc.`mail_other` FROM `#mail_recipients` AS mr \n\t\t\t\t\tLEFT JOIN `#mail_content` as mc ON mr.`mail_detail_id` = mc.`mail_source_id`\n\t\t\t\t\t\tWHERE mr.`mail_target_id` = {$vals[2]} AND mc.`mail_source_id` = {$vals[1]}")) {
                 // Invalid mailer record
                 $errors[] = 'Not found in DB: ' . $vals[1] . '/' . $vals[2];
             }
             $row = $this->db->fetch(MYSQL_ASSOC);
             $row = $this->dbToBoth($row);
             $bounceInfo = $row;
             if ($emailAddress && $emailAddress != $row['mail_recipient_email']) {
                 $errors[] = 'Email address mismatch: ' . $emailAddress . '/' . $row['mail_recipient_email'];
             }
             if ($uid != $row['mail_recipient_id']) {
                 $errors[] = 'User ID mismatch: ' . $uid . '/' . $row['mail_recipient_id'];
             }
             if (count($errors) == 0) {
                 $bounceInfo['mail_source_id'] = $vals[1];
                 $bounceInfo['mail_target_id'] = $vals[2];
                 $bounceInfo['mail_recipient_id'] = $uid;
                 $bounceInfo['mail_recipient_name'] = $row['mail_recipient_name'];
                 if (!$this->db->update('mail_content', '`mail_bounce_count` = `mail_bounce_count` + 1 WHERE `mail_source_id` = ' . $vals[1])) {
                     e107::getAdminLog()->add('Unable to increment bounce-count on mail_source_id=' . $vals[1], $bounceInfo, E_LOG_FATAL, 'BOUNCE', LOG_TO_ROLLING);
                 }
                 if (!$this->db->update('mail_recipients', '`mail_status` = ' . MAIL_STATUS_BOUNCED . ' WHERE `mail_target_id` = ' . $vals[2])) {
                     e107::getAdminLog()->add('Unable to update recipient mail_status to bounce on mail_target_id = ' . $vals[2], $bounceInfo, E_LOG_FATAL, 'BOUNCE', LOG_TO_ROLLING);
                 }
                 $addons = array_keys($row['mail_selectors']);
                 // trigger e_mailout.php addons. 'bounce' method.
                 foreach ($addons as $plug) {
                     if ($plug == 'core') {
                         require_once e_HANDLER . 'user_handler.php';
                         if ($err = userHandler::userStatusUpdate('bounce', $uid, $emailAddress)) {
                         }
                         $errors[] = $err;
                     } else {
                         if ($cls = e107::getAddon($plug, 'e_mailout')) {
                             if (e107::callMethod($cls, 'bounce', $bounceInfo) === false) {
                                 e107::getAdminLog()->add($plug . ' bounce process failed', $bounceInfo, E_LOG_FATAL, 'BOUNCE', LOG_TO_ROLLING);
                             }
                         }
                     }
                 }
             }
             //	echo e107::getMessage()->render();
             //	print_a($bounceInfo);
         }
     } elseif (count($vals) != 1 && count($vals) != 4) {
         $errors[] = 'Bad element count: ' . count($vals);
     } elseif (!empty($uid) || !empty($emailAddress)) {
         // require_once(e_HANDLER.'user_handler.php');
         $err = e107::getUserSession()->userStatusUpdate('bounce', $uid, $emailAddress);
         if ($err) {
             $errors[] = $err;
         }
     }
     if (!empty($errors)) {
         $logErrors = $bounceInfo;
         $logErrors['user_id'] = $uid;
         $logErrors['mailshot'] = $vals[1];
         $logErrors['mailshot_recipient'] = $vals[2];
         $logErrors['errors'] = $errors;
         $logErrors['email'] = $emailAddress;
         $logErrors['bounceString'] = $bounceString;
         $logString = $bounceString . ' (' . $emailAddress . ')[!br!]' . implode('[!br!]', $errors) . implode('[!br!]', $bounceInfo);
         //	e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce receive error',$logString, FALSE,LOG_TO_ROLLING);
         e107::getAdminLog()->add('Bounce receive error', $logErrors, E_LOG_WARNING, 'BOUNCE', LOG_TO_ROLLING);
         return $errors;
     } else {
         //	e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceInfo, FALSE,LOG_TO_ROLLING);
         e107::getAdminLog()->add('Bounce received/logged', $bounceInfo, E_LOG_INFORMATIVE, 'BOUNCE', LOG_TO_ROLLING);
     }
     e107::getEvent()->trigger('mailbounce', $bounceInfo);
     return false;
 }
Example #8
0
 /**
  * This one will be greatly extended, allowing menus to offer UI and us 
  * settings per instance later ($parm variable available for menus - same as shortcode's $parm)
  */
 function menuInstanceParameters()
 {
     if (!vartrue($_GET['parmsId'])) {
         return;
     }
     $id = intval($_GET['parmsId']);
     $frm = e107::getForm();
     $sql = e107::getDb();
     if (!$sql->select("menus", "*", "menu_id=" . $id)) {
         $this->menuAddMessage("Couldn't Load Menu", E_MESSAGE_ERROR);
         return;
     }
     $row = $sql->fetch();
     $text = "<div style='text-align:center;'>\n\t\t<form  id='e-save-form' method='post' action='" . e_SELF . "?lay=" . $this->curLayout . "'>\n        <fieldset id='core-menus-parametersform'>\n\t\t<legend>" . MENLAN_44 . " " . $row['menu_name'] . "</legend>\n        <table class='table '>\n        <colgroup>\n            <col class='col-label' />\n            <col class='col-control' />\n        </colgroup>\n\n\t\t";
     if (file_exists(e_PLUGIN . $row['menu_path'] . "e_menu.php")) {
         $plug = rtrim($row['menu_path'], '/');
         $obj = e107::getAddon($plug, 'e_menu');
         if (!is_object($obj)) {
             $text .= "<tr><td colspan='2' class='alert alert-danger'>{$plug} object not found. Try re-scanning plugin directories in Tools > Database. </td></tr>";
         } else {
             $menuName = substr($row['menu_name'], 0, -5);
         }
         $fields = e107::callMethod($obj, 'config', $menuName);
         if (!($form = e107::getAddon($plug, 'e_menu', $plug . "_menu_form"))) {
             $form = $frm;
         }
         $value = e107::unserialize($row['menu_parms']);
         if (!empty($fields)) {
             foreach ($fields as $k => $v) {
                 $text .= "<tr><td class='text-left'>" . $v['title'] . "</td>";
                 $v['writeParms']['class'] = 'e-save';
                 $i = $k;
                 if (!empty($v['multilan'])) {
                     $i = $k . '[' . e_LANGUAGE . ']';
                     if (isset($value[$k][e_LANGUAGE])) {
                         $value[$k] = varset($value[$k][e_LANGUAGE], '');
                     }
                 }
                 $text .= "<td class='text-left'>" . $form->renderElement($i, $value[$k], $v) . "</td></tr>";
             }
         } else {
             $text .= "<tr><td colspan='2' class='alert alert-danger'>No Fields Set in " . $row['menu_path'] . "e_menu.php</td></tr>";
         }
     } else {
         $text .= "<tr>\n\t\t\t<td>\n\t\t\t" . MENLAN_45 . "</td>\n\t\t\t<td>\n\t\t\t" . $frm->text('menu_parms', $row['menu_parms'], 900, 'class=e-save&size=xxlarge') . "\n\t\t\t</td>\n\t\t\t</tr>";
     }
     $text .= "</table>";
     /*
     		
     			$text .= "
     			<div class='buttons-bar center'>";
     			$text .= $frm->admin_button('parms_submit', LAN_SAVE, 'update');
     			$text .= "<input type='hidden' name='menu_id' value='".$id."' />
     			</div>";
     */
     $text .= $frm->hidden('mode', 'parms');
     $text .= $frm->hidden('menu_id', $id);
     $text .= "\n\t\t</fieldset>\n\t\t</form>\n\t\t</div>";
     return $text;
 }
Example #9
0
 function search_info($id, $type, $plug_require = null, $info = '')
 {
     $tp = e107::getParser();
     if (check_class($this->search_prefs[$type . '_handlers'][$id]['class'])) {
         //		echo "<br />type = ".$this->search_prefs[$type.'_handlers'][$id]['class'];
         //		print_a($this->search_prefs);
         if ($plug_require) {
             require_once $plug_require;
             $ret = $search_info[0];
         } else {
             $ret = $info;
         }
         if ($obj = e107::getAddon($id, 'e_search')) {
             if (!($ret = $obj->config())) {
                 return false;
             }
             $ret['qtype'] = $ret['name'];
             if (!isset($ret['id'])) {
                 $ret['id'] = $ret['name'];
             }
             $ret['weights'] = array_values($ret['search_fields']);
             $ret['search_fields'] = array_keys($ret['search_fields']);
         }
         $ret['chars'] = $this->search_prefs[$type . '_handlers'][$id]['chars'];
         $ret['results'] = $this->search_prefs[$type . '_handlers'][$id]['results'];
         $ret['pre_title'] = $this->search_prefs[$type . '_handlers'][$id]['pre_title'];
         $ret['pre_title_alt'] = $tp->toHtml($this->search_prefs[$type . '_handlers'][$id]['pre_title_alt']);
         $ret['order'] = isset($this->search_prefs[$type . '_handlers'][$id]['order']) && $this->search_prefs[$type . '_handlers'][$id]['order'] ? $this->search_prefs[$type . '_handlers'][$id]['order'] : $this->auto_order;
         $this->auto_order++;
         return $ret;
     } else {
         return false;
     }
 }