/** * Process the plugin, called after form is submitted * * @return bool */ public function onLastProcess() { $formModel = $this->getModel(); $params = $this->getParams(); $app = JFactory::getApplication(); $package = $app->getUserState('com_fabrik.package', 'fabrik'); $session = JFactory::getSession(); $context = $formModel->getRedirectContext(); // Get existing session params $surl = (array) $session->get($context . 'url', array()); $stitle = (array) $session->get($context . 'title', array()); $smsg = (array) $session->get($context . 'msg', array()); $sshowsystemmsg = (array) $session->get($context . 'showsystemmsg', array()); $this->formModel = $formModel; $w = new FabrikWorker(); $form = $formModel->getForm(); $this->data = $this->getProcessData(); $this->data['append_jump_url'] = $params->get('append_jump_url'); $this->data['save_in_session'] = $params->get('save_insession'); $this->data['jump_page'] = $w->parseMessageForPlaceHolder($params->get('jump_page'), $this->data); $this->data['thanks_message'] = $w->parseMessageForPlaceHolder($params->get('thanks_message'), $this->data); if (!$this->shouldRedirect($params)) { // Clear any session redirects unset($surl[$this->renderOrder]); unset($stitle[$this->renderOrder]); unset($smsg[$this->renderOrder]); unset($sshowsystemmsg[$this->renderOrder]); $session->set($context . 'url', $surl); $session->set($context . 'title', $stitle); $session->set($context . 'msg', $smsg); $session->set($context . 'showsystemmsg', $sshowsystemmsg); return true; } $this->_storeInSession(); $sshowsystemmsg[$this->renderOrder] = true; $session->set($context . 'showsystemmsg', $sshowsystemmsg); if ($this->data['jump_page'] != '') { $this->data['jump_page'] = $this->buildJumpPage(); // 3.0 ajax/module redirect logic handled in form controller not in plugin $surl[$this->renderOrder] = $this->data['jump_page']; $session->set($context . 'url', $surl); $session->set($context . 'redirect_content_how', $params->get('redirect_content_how', 'popup')); $session->set($context . 'redirect_content_popup_width', $params->get('redirect_content_popup_width', '300')); $session->set($context . 'redirect_content_popup_height', $params->get('redirect_content_popup_height', '300')); $session->set($context . 'redirect_content_popup_x_offset', $params->get('redirect_content_popup_x_offset', '0')); $session->set($context . 'redirect_content_popup_y_offset', $params->get('redirect_content_popup_y_offset', '0')); $session->set($context . 'redirect_content_popup_title', $params->get('redirect_content_popup_title', '')); $session->set($context . 'redirect_content_popup_reset_form', $params->get('redirect_content_popup_reset_form', '1')); } else { $sshowsystemmsg[$this->renderOrder] = false; $session->set($context . 'showsystemmsg', $sshowsystemmsg); $stitle[$this->renderOrder] = $form->label; $session->set($context . 'title', $stitle); $surl[$this->renderOrder] = 'index.php?option=com_' . $package . '&view=plugin&g=form&plugin=redirect&method=displayThanks&task=pluginAjax'; $session->set($context . 'url', $surl); } $smsg[$this->renderOrder] = $this->data['thanks_message']; $session->set($context . 'msg', $smsg); return true; }
/** * Decorate the J2Store product information with its related Fabrik record * * @param $product * * @return object */ private function getFabrikItem(&$product) { list($component, $listId) = explode('.', $product->product_source); $key = $listId . '.' . $product->product_source_id; static $sets; if (!is_array($sets)) { $sets = array(); } if (!isset($sets[$key])) { JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel'); /** @var FabrikFEModelList $listModel */ $listModel = JModelLegacy::getInstance('List', 'FabrikFEModel'); $listModel->setId($listId); $formModel = $listModel->getFormModel(); $formModel->setRowId($product->product_source_id); $row = $formModel->getData(); $params = $formModel->getParams(); $index = array_search('j2store', (array) $params->get('plugins', array(), 'array')); $w = new FabrikWorker(); $plugIn = FabrikWorker::getPluginManager()->loadPlugIn('j2store', 'form'); // Set params relative to plugin render order $plugInParams = $plugIn->setParams($params, $index); $context = new stdClass(); $context->title = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_product_name'), $row); $context->published = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_enabled'), $row); $objectRow = JArrayHelper::toObject($row); $context->viewLink = $listModel->viewDetailsLink($objectRow); $context->editLink = $listModel->editLink($objectRow); $context->id = $objectRow->__pk_val; $sets[$key] = $context; } //echo "<pre>";print_r($sets);echo "</pre>"; return $sets[$key]; }
/** * Main setup routine for displaying the form/detail view * * @param string $tpl template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { $this->output(); if (!$this->app->isAdmin()) { $this->state = $this->get('State'); $model = $this->getModel(); $this->params = $this->state->get('params'); $row = $model->getData(); $w = new FabrikWorker(); if ($this->params->get('menu-meta_description')) { $desc = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_description'), $row); $this->doc->setDescription($desc); } if ($this->params->get('menu-meta_keywords')) { $keywords = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_keywords'), $row); $this->doc->setMetadata('keywords', $keywords); } if ($this->params->get('robots')) { $this->doc->setMetadata('robots', $this->params->get('robots')); } // Set the response to indicate a file download $this->app->setHeader('Content-Type', 'application/vnd.ms-word'); $name = $this->getModel()->getTable()->label; $name = JStringNormalise::toDashSeparated($name); $this->app->setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\""); $this->doc->setMimeEncoding('text/html; charset=Windows-1252', false); } } }
/** * process the plugin, called when form is submitted * * @param object $params * @param object form */ function onAfterProcess($params, &$formModel) { if ($params->get('ask-receipt')) { $post = JRequest::get('post'); if (!array_key_exists('fabrik_email_copy', $post)) { return; } } $config =& JFactory::getConfig(); $w = new FabrikWorker(); $this->formModel =& $formModel; $form =& $formModel->getForm(); //getEmailData returns correctly formatted {tablename___elementname} keyed results //_formData is there for legacy and may allow you to use {elementname} only placeholders for simple forms $aData = array_merge($this->getEmailData(), $formModel->_formData); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $editlink = "<a href=\"{$editURL}\">" . JText::_('EDIT') . "</a>"; $viewlink = "<a href=\"{$viewURL}\">" . JText::_('VIEW') . "</a>"; $message = str_replace('{fabrik_editlink}', $editlink, $message); $message = str_replace('{fabrik_viewlink}', $viewlink, $message); $message = str_replace('{fabrik_editurl}', $editURL, $message); $message = str_replace('{fabrik_viewurl}', $viewURL, $message); $message = $w->parseMessageForPlaceHolder($message, $aData, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $aData, false); if (empty($to)) { // $$$ hugh - not much point trying to send if we don't have a To address // (happens frequently if folk don't properly validate their form inputs and are using placeholders) // @TODO - might want to add some feedback about email not being sent return; } /* // $$$ hugh - this code doesn't seem to be used? // it sets $email, which is then never referenced? $receipt_email = $params->get('receipt_to'); if (!$form->record_in_database) { foreach ($aData as $key=>$val) { $aBits = explode('___', $key); $newKey = array_pop( $aBits); if ($newKey == $receipt_email) { $email = $val; } } } */ $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = $w->parseMessageForPlaceHolder($subject, null, false); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); //darn silly hack for poor joomfish settings where lang parameters are set to overide joomla global config but not mail translations entered $rawconfig = new JConfig(); if ($from === '') { $from = $rawconfig->mailfrom; } if ($fromname === '') { $fromname = $rawconfig->fromname; } $res = JUTility::sendMail($from, $fromname, $to, $subject, $message, true); }
/** * Main setup routine for displaying the form/detail view * * @param string $tpl template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { $this->setCanonicalLink(); $this->output(); if (!$this->app->isAdmin()) { $this->state = $this->get('State'); $model = $this->getModel(); $this->params = $this->state->get('params'); $row = $model->getData(); $w = new FabrikWorker(); if ($this->params->get('menu-meta_description')) { $desc = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_description'), $row); $this->doc->setDescription($desc); } if ($this->params->get('menu-meta_keywords')) { $keywords = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_keywords'), $row); $this->doc->setMetadata('keywords', $keywords); } if ($this->params->get('robots')) { $this->doc->setMetadata('robots', $this->params->get('robots')); } } } }
/** * do the plugin action * @return number of records updated */ function process(&$data) { $app = JFactory::getApplication(); jimport('joomla.mail.helper'); $params = $this->getParams(); $msg = $params->get('message'); $to = $params->get('to'); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $subject = $params->get('subject', 'Fabrik cron job'); $eval = $params->get('cronemail-eval'); $condition = $params->get('cronemail_condition', ''); $updates = array(); foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { if (!empty($condition)) { $this_condition = $w->parseMessageForPlaceHolder($condition, $row); if (eval($this_condition === false)) { continue; } } $row = JArrayHelper::fromObject($row); $thisto = $w->parseMessageForPlaceHolder($to, $row); if (JMailHelper::isEmailAddress($thisto)) { $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $thissubject = $w->parseMessageForPlaceHolder($subject, $row); $res = JUTility::sendMail( $MailFrom, $FromName, $thisto, $thissubject, $thismsg, true); } $updates[] = $row['__pk_val']; } } } $field = $params->get('cronemail-updatefield'); if (!empty( $updates) && trim($field ) != '') { //do any update found $listModel = JModel::getInstance('list', 'FabrikFEModel'); $listModel->setId($params->get('table')); $table = $listModel->getTable(); $connection = $params->get('connection'); $field = $params->get('cronemail-updatefield'); $value = $params->get('cronemail-updatefield-value'); $field = str_replace("___", ".", $field); $query = "UPDATE $table->db_table_name set $field = " . $fabrikDb->Quote($value) . " WHERE $table->db_primary_key IN (" . implode(',', $updates) . ")"; $fabrikDb = $listModel->getDb(); $fabrikDb->setQuery($query); $fabrikDb->query(); } return count($updates); }
/** * process the plugin, called afer form is submitted * * @param object $params (with the current active plugin values in them) * @param object form */ function onLastProcess($params, &$formModel) { $session = JFactory::getSession(); $context = 'com_fabrik.form.' . $formModel->get('id') . '.redirect.'; //get existing session params $surl = (array) $session->get($context . 'url', array()); $stitle = (array) $session->get($context . 'title', array()); $smsg = (array) $session->get($context . 'msg', array()); $sshowsystemmsg = (array) $session->get($context . 'showsystemmsg', array()); $app = JFactory::getApplication(); $this->formModel =& $formModel; $w = new FabrikWorker(); $this->_data = new stdClass(); $this->_data->append_jump_url = $params->get('append_jump_url'); $this->_data->save_in_session = $params->get('save_insession'); $form =& $formModel->getForm(); $this->data = array_merge($this->getEmailData(), $formModel->_formData); $this->_data->jump_page = $w->parseMessageForPlaceHolder($params->get('jump_page'), $this->data); $this->_data->thanks_message = $w->parseMessageForPlaceHolder($params->get('thanks_message'), $this->data); if (!$this->shouldRedirect($params)) { //clear any sessoin redirects unset($surl[$this->renderOrder]); unset($stitle[$this->renderOrder]); unset($smsg[$this->renderOrder]); unset($sshowsystemmsg[$this->renderOrder]); $session->set($context . 'url', $surl); $session->set($context . 'title', $stitle); $session->set($context . 'msg', $smsg); $session->set($context . 'showsystemmsg', $sshowsystemmsg); /*$session->clear($context.'url'); $session->clear($context.'title'); $session->clear($context.'msg');*/ return true; } $this->_storeInSession($formModel); $sshowsystemmsg[$this->renderOrder] = true; $session->set($context . 'showsystemmsg', $sshowsystemmsg); if ($this->_data->jump_page != '') { $this->_data->jump_page = $this->_buildJumpPage($formModel); //3.0 ajax/module redirect logic handled in form controller not in plugin $surl[$this->renderOrder] = $this->_data->jump_page; $session->set($context . 'url', $surl); } else { $sshowsystemmsg[$this->renderOrder] = false; $session->set($context . 'showsystemmsg', $sshowsystemmsg); $stitle[$this->renderOrder] = $form->label; $session->set($context . 'title', $stitle); $surl[$this->renderOrder] = 'index.php?option=com_fabrik&view=plugin&g=form&plugin=redirect&method=displayThanks&task=pluginAjax'; $session->set($context . 'url', $surl); } $smsg[$this->renderOrder] = $this->_data->thanks_message; $session->set($context . 'msg', $smsg); return true; }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @return bool */ public function onAfterProcess() { $params = $this->getParams(); $input = $this->app->input; $formModel = $this->getModel(); if ($params->get('ask-receipt')) { if (!array_key_exists('fabrik_email_copy', $_POST)) { return; } } $rowId = $input->get('rowid'); $config = JFactory::getConfig(); $w = new FabrikWorker(); $data = $this->getProcessData(); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId; $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId; $editLink = "<a href=\"{$editURL}\">" . FText::_('EDIT') . "</a>"; $viewLink = "<a href=\"{$viewURL}\">" . FText::_('VIEW') . "</a>"; $message = str_replace('{fabrik_editlink}', $editLink, $message); $message = str_replace('{fabrik_viewlink}', $viewLink, $message); $message = str_replace('{fabrik_editurl}', $editURL, $message); $message = str_replace('{fabrik_viewurl}', $viewURL, $message); $message = $w->parseMessageForPlaceHolder($message, $data, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $data, false); $to = FabrikString::stripSpace($to); if (empty($to)) { /* $$$ hugh - not much point trying to send if we don't have a To address * (happens frequently if folk don't properly validate their form inputs and are using placeholders) * @TODO - might want to add some feedback about email not being sent */ return; } $to = explode(',', $to); $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = JText::_($w->parseMessageForPlaceHolder($subject, $data, false)); $from = $config->get('mailfrom', ''); $fromName = $config->get('fromname', ''); // Darn silly hack for poor joomfish settings where lang parameters are set to override joomla global config but not mail translations entered $rawConfig = new JConfig(); if ($from === '') { $from = $rawConfig->mailfrom; } if ($fromName === '') { $fromName = $rawConfig->fromname; } $from = $params->get('from_email', $from); $res = FabrikWorker::sendMail($from, $fromName, $to, $subject, $message, true); if (!$res) { throw new RuntimeException('Couldn\'t send receipt', 500); } }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @param object $params plugin params * @param object &$formModel form model * * @return bool */ public function onAfterProcess($params, &$formModel) { jimport('joomla.filesystem.file'); $files[] = COM_FABRIK_BASE . 'components/com_kunena/class.kunena.php'; $define = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php'; $files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.defines.php'; $files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.link.class.php'; $files[] = COM_FABRIK_BASE . 'components/com_kunena/lib/kunena.smile.class.php'; if (!JFile::exists($define)) { return JError::raiseError(500, 'could not find the Kunena component'); } require_once $define; foreach ($files as $file) { require_once $file; } if (JFile::exists(KUNENA_PATH_FUNCS . '/post.php')) { $postfile = KUNENA_PATH_FUNCS . '/post.php'; } else { $postfile = KUNENA_PATH_TEMPLATE_DEFAULT . '/post.php'; } $w = new FabrikWorker(); // $fbSession = CKunenaSession::getInstance(); // Don't need this, session is loaded in CKunenaPost $catid = $params->get('kunena_category', 0); $parentid = 0; $action = 'post'; // Added action in request JRequest::setVar('action', $action); $func = 'post'; $contentURL = 'empty'; JRequest::setVar('catid', $catid); $msg = $w->parseMessageForPlaceHolder($params->get('kunena_content'), $formModel->_fullFormData); $subject = $params->get('kunena_title'); JRequest::SetVar('message', $msg); $subject = $w->parseMessageForPlaceHolder($subject, $formModel->_fullFormData); // Added subject in request JRequest::SetVar('subject', $subject); $origId = JRequest::getVar('id'); JRequest::setVar('id', 0); /* ob_start(); include ($postfile); ob_end_clean(); */ ob_start(); include $postfile; $mypost = new CKunenaPost(); // Public CKunenaPost::display() will call protected method CKunenaPost::post() if JRequest action is 'post' $mypost->display(); ob_end_clean(); JRequest::setVar('id', $origId); }
/** * Draws the form element * * @param array $data to pre-populate element with * @param int $repeatCounter repeat group counter * * @return string returns element html */ public function render($data, $repeatCounter = 0) { $params = $this->getParams(); $displayData = new stdClass(); $displayData->num = $params->get('fbcomment_number_of_comments', 10); $displayData->width = $params->get('fbcomment_width', 300); $displayData->colour = $params->get('fb_comment_scheme') == '' ? '' : ' colorscheme="dark" '; $displayData->href = $params->get('fbcomment_href', ''); if (empty($data->href)) { $rowId = $this->app->input->getString('rowid', '', 'string'); if ($rowId != '') { $formModel = $this->getFormModel(); $formId = $formModel->getId(); $href = 'index.php?option=com_fabrik&view=form&formid=' . $formId . '&rowid=' . $rowId; $href = JRoute::_($href); $displayData->href = COM_FABRIK_LIVESITE_ROOT . $href; } } if (!empty($displayData->href)) { $w = new FabrikWorker(); $displayData->href = $w->parseMessageForPlaceHolder($data->href, $data); $locale = $params->get('fbcomment_locale', 'en_US'); if (empty($locale)) { $locale = 'en_US'; } $displayData->graphApi = FabrikHelperHTML::facebookGraphAPI($params->get('opengraph_applicationid'), $locale); } $layout = $this->getLayout('form'); return $layout->render($displayData); }
/** * Can the row be edited * * @param object $params plugin params * @param object $listModel list model * @param object $row current row to test * * @return boolean */ public function onCanEdit($params, $listModel, $row) { // If $row is null, we were called from the table's canEdit() in a per-table rather than per-row context, // and we don't have an opinion on per-table edit permissions, so just return true. if (is_null($row) || is_null($row[0])) { return true; } if (is_array($row[0])) { $data = JArrayHelper::toObject($row[0]); } else { $data = $row[0]; } $field = str_replace('.', '___', $params->get('caneditrow_field')); // If they provided some PHP to eval, we ignore the other settings and just run their code $caneditrow_eval = $params->get('caneditrow_eval', ''); // $$$ rob if no can edit field selected in admin return true if (trim($field) == '' && trim($caneditrow_eval) == '') { return true; } if (!empty($caneditrow_eval)) { $w = new FabrikWorker(); $data = JArrayHelper::fromObject($data); $caneditrow_eval = $w->parseMessageForPlaceHolder($caneditrow_eval, $data); $caneditrow_eval = @eval($caneditrow_eval); FabrikWorker::logEval($caneditrow_eval, 'Caught exception on eval in can edit row : %s'); return $caneditrow_eval; } else { // No PHP given, so just do a simple match on the specified element and value settings. if ($params->get('caneditrow_useraw', '0') == '1') { $field .= '_raw'; } $value = $params->get('caneditrow_value'); return $data->{$field} == $value; } }
/** * looks at the validation condition & evaulates it * if evaulation is true then the validation rule is applied *@return bol apply validation */ function shouldValidate($data, $c) { $params = $this->getParams(); $post = JRequest::get('post'); $v = (array)$params->get($this->_pluginName .'-validation_condition'); if (!array_key_exists($c, $v)) { return true; } $condition = $v[$c]; if ($condition == '') { return true; } $w = new FabrikWorker(); // $$$ rob merge join data into main array so we can access them in parseMessageForPlaceHolder() $joindata = JArrayHelper::getValue($post, 'join', array()); foreach ($joindata as $joinid => $joind) { foreach ($joind as $k => $v) { if ($k !== 'rowid') { $post[$k] = $v; } } } $condition = trim($w->parseMessageForPlaceHolder($condition, $post)); $res = @eval($condition); if (is_null($res)) { return true; } return $res; }
/** * looks at the validation condition & evaulates it * if evaulation is true then the validation rule is applied *@return bol apply validation */ function shouldValidate($data, $c) { $params =& $this->getParams(); $post = JRequest::get('post'); $v = $params->get($this->_pluginName . '-validation_condition', '', '_default', 'array', $c); if (!array_key_exists($c, $v)) { return true; } $condition = $v[$c]; if ($condition == '') { return true; } $w = new FabrikWorker(); // $$$ rob merge join data into main array so we can access them in parseMessageForPlaceHolder() $joindata = JArrayHelper::getValue($post, 'join', array()); foreach ($joindata as $joinid => $joind) { foreach ($joind as $k => $v) { if ($k !== 'rowid') { $post[$k] = $v; } } } $condition = trim($w->parseMessageForPlaceHolder($condition, $post)); // $$$ hugh - this screws things up if it's more than one line of code. /* if (substr(strtolower($condition ), 0, 6) !== 'return') { $condition = "return $condition"; } */ $res = @eval($condition); if (is_null($res)) { return true; } return $res; }
/** * Can the row be edited * * @param object $row Current row to test * * @return boolean */ public function onCanEdit($row) { $params = $this->getParams(); // If $row is null, we were called from the list's canEdit() in a per-table rather than per-row context, // and we don't have an opinion on per-table edit permissions, so just return true. if (is_null($row) || is_null($row[0])) { return true; } if (is_array($row[0])) { $data = ArrayHelper::toObject($row[0]); } else { $data = $row[0]; } /** * If __pk_val is not set or empty, then we've probably been called from somewhere in form processing, * and this is a new row. In which case this plugin cannot offer any opinion! */ if (!isset($data->__pk_val) || empty($data->__pk_val)) { return true; } $field = str_replace('.', '___', $params->get('caneditrow_field')); // If they provided some PHP to eval, we ignore the other settings and just run their code $caneditrow_eval = $params->get('caneditrow_eval', ''); // $$$ rob if no can edit field selected in admin return true if (trim($field) == '' && trim($caneditrow_eval) == '') { $this->acl[$data->__pk_val] = true; return true; } if (!empty($caneditrow_eval)) { $w = new FabrikWorker(); $data = ArrayHelper::fromObject($data); $caneditrow_eval = $w->parseMessageForPlaceHolder($caneditrow_eval, $data); FabrikWorker::clearEval(); $caneditrow_eval = @eval($caneditrow_eval); FabrikWorker::logEval($caneditrow_eval, 'Caught exception on eval in can edit row : %s'); $this->acl[$data['__pk_val']] = $caneditrow_eval; return $caneditrow_eval; } else { // No PHP given, so just do a simple match on the specified element and value settings. if ($params->get('caneditrow_useraw', '0') == '1') { $field .= '_raw'; } $value = $params->get('caneditrow_value'); $operator = $params->get('operator', '='); if (is_object($data->{$field})) { $data->{$field} = ArrayHelper::fromObject($data->{$field}); } switch ($operator) { case '=': default: $return = is_array($data->{$field}) ? in_array($value, $data->{$field}) : $data->{$field} == $value; break; case "!=": $return = is_array($data->{$field}) ? !in_array($value, $data->{$field}) : $data->{$field} != $value; break; } $this->acl[$data->__pk_val] = $return; return $return; } }
/** * process the plugin, called when form is submitted * * @param object $params * @param object form */ function onBeforeStore( &$params, &$formModel ) { return; jimport('joomla.filesystem.file'); $files[] = COM_FABRIK_BASE.'administrator'.DS.'components'.DS.'com_kunena'.DS.'language'.DS.'kunena.english.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'class.kunena.php'; $define = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'lib'.DS.'kunena.defines.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'lib'.DS.'kunena.defines.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'lib'.DS.'kunena.session.class.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'lib'.DS.'kunena.link.class.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'lib'.DS.'kunena.link.class.php'; $files[] = COM_FABRIK_BASE.'components'.DS.'com_kunena'.DS.'template'.DS.'default'.DS.'smile.class.php'; if (!JFile::exists($define)) { return JError::raiseError(500, 'could not find the Kunena component'); } require_once($define); foreach ($files as $file) { require_once($file); } if (JFile::exists(KUNENA_ABSTMPLTPATH . '/post.php')) { $postfile = KUNENA_ABSTMPLTPATH . '/post.php'; } else { $postfile = KUNENA_PATH_TEMPLATE_DEFAULT .DS. 'post.php'; } $w = new FabrikWorker(); $fbSession = CKunenaSession::getInstance(); $catid =$params->get('kunena_category', 0); $parentid = 0; $action = 'post'; $func = 'post'; $contentURL = 'empty'; JRequest::setVar('catid', $catid); $msg = $w->parseMessageForPlaceHolder($params->get('kunena_content'), $formModel->_fullFormData); $subject = $params->get('kunena_title'); JRequest::SetVar('message', $msg); $subject = $w->parseMessageForPlaceHolder($subject, $formModel->_fullFormData); $origId = JRequest::getVar('id'); JRequest::setVar('id', 0); ob_start(); include ($postfile); ob_end_clean(); JRequest::setVar('id', $origId); }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @param object $params plugin params * @param object &$formModel form model * * @return bool */ public function onAfterProcess($params, &$formModel) { if ($params->get('ask-receipt')) { $post = JRequest::get('post'); if (!array_key_exists('fabrik_email_copy', $post)) { return; } } $config = JFactory::getConfig(); $w = new FabrikWorker(); $this->formModel = $formModel; $form = $formModel->getForm(); $aData = array_merge($this->getEmailData(), $formModel->_formData); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $editlink = "<a href=\"{$editURL}\">" . JText::_('EDIT') . "</a>"; $viewlink = "<a href=\"{$viewURL}\">" . JText::_('VIEW') . "</a>"; $message = str_replace('{fabrik_editlink}', $editlink, $message); $message = str_replace('{fabrik_viewlink}', $viewlink, $message); $message = str_replace('{fabrik_editurl}', $editURL, $message); $message = str_replace('{fabrik_viewurl}', $viewURL, $message); $message = $w->parseMessageForPlaceHolder($message, $aData, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $aData, false); if (empty($to)) { /* $$$ hugh - not much point trying to send if we don't have a To address * (happens frequently if folk don't properly validate their form inputs and are using placeholders) * @TODO - might want to add some feedback about email not being sent */ return; } $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = $w->parseMessageForPlaceHolder($subject, null, false); $from = $config->get('mailfrom'); $fromname = $config->get('fromname'); // Darn silly hack for poor joomfish settings where lang parameters are set to overide joomla global config but not mail translations entered $rawconfig = new JConfig(); if ($from === '') { $from = $rawconfig->mailfrom; } if ($fromname === '') { $fromname = $rawconfig->fromname; } $res = JUTility::sendMail($from, $fromname, $to, $subject, $message, true); }
/** * process the plugin, called when form is submitted * * @param object $params * @param object form */ function onAfterProcess($params, &$formModel) { $this->formModel = $formModel; $emailData = $this->getEmailData(); $post = JRequest::get('post'); if (!array_key_exists('fabrik_mailchimp_signup', $post)) { return; } $listId = $params->get('mailchimp_listid'); $apiKey = $params->get('mailchimp_apikey'); if ($apiKey == '') { JError::raiseNotice(500, 'Mailchimp: no api key specified'); return; } if ($listId == '') { JError::raiseNotice(500, 'Mailchimp: no list id specified'); return; } $api = new MCAPI($params->get('mailchimp_apikey')); $opts = array(); $emailKey = $formModel->getElement($params->get('mailchimp_email'), true)->getFullName(); $firstNameKey = $formModel->getElement($params->get('mailchimp_firstname'), true)->getFullName(); if ($params->get('mailchimp_lastname') !== '') { $lastNameKey = $formModel->getElement($params->get('mailchimp_lastname'), true)->getFullName(); $lname = $formModel->_formDataWithTableName[$lastNameKey]; $opts['LNAME'] = $lname; } $email = $formModel->_formDataWithTableName[$emailKey]; $fname = $formModel->_formDataWithTableName[$firstNameKey]; $opts['FNAME'] = $fname; $w = new FabrikWorker(); $groupOpts = json_decode($params->get('mailchimp_groupopts', "[]")); if (!empty($groupOpts)) { foreach ($groupOpts as $groupOpt) { $groups = array(); if (isset($groupOpt->groups)) { $groupOpt->groups = $w->parseMessageForPlaceHolder($groupOpt->groups, $emailData); $groups[] = JArrayHelper::fromObject($groupOpt); //array('name'=>'Your Interests:', 'groups'=>'Bananas,Apples') } } $opts['GROUPINGS'] = $groups; } // By default this sends a confirmation email - you will not see new members // until the link contained in it is clicked! $emailType = $params->get('mailchimp_email_type', 'html'); $doubleOptin = (bool) $params->get('mailchimp_double_optin', true); $updateExisting = (bool) $params->get('mailchimp_update_existing'); $retval = $api->listSubscribe($listId, $email, $opts, $emailType, $doubleOptin, $updateExisting); if ($api->errorCode) { $formModel->_arErrors['mailchimp_error'] = true; JError::raiseNotice(500, $api->errorCode . ':' . $api->errorMessage); return false; } else { return true; } }
protected function parse($match) { $match = $match[0]; require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'parent.php'; $w = new FabrikWorker(); $w->replaceRequest($match); $match = $w->parseMessageForPlaceHolder($match); return $match; }
function parse($match) { $match = $match[0]; require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'json.php'; require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'parent.php'; $w = new FabrikWorker(); $w->replaceRequest($match); // stop [] for ranged filters from being removed $match = str_replace('{}', '[]', $match); $match = $w->parseMessageForPlaceHolder($match); return $match; }
/** * process the plugin, called when form is submitted * * @param object $params * @param object form */ function shouldProcess(&$params) { $condition = $params->get('confirmation_condition'); if ($condition == '') { return true; } $w = new FabrikWorker(); $condition = trim($w->parseMessageForPlaceHolder($condition, $this->data)); $res = @eval($condition); if (is_null($res)) { return true; } return $res; }
/** * @access private * run sql query * @param array data * @return string result of query */ function _runSQL($data) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $params = $this->_params; $sql = $params->get('sql'); $w = new FabrikWorker(); $sql = $w->parseMessageForPlaceHolder($sql, $data); $sql = str_replace(array("\n", "\r", "\n\r", "\r\n", "<br>", "<br/>", "<br />"), "", $sql); $db->setQuery($sql); $res = $db->loadResult(); echo $db->getErrorMsg(); return $res; }
function repeat_emails($params, &$formModel) { jimport('joomla.mail.helper'); $article_id = '70'; $email_element_name = 'fab_sponsors___sponsor_email'; $sponsorship_prefix = 'fab_sponsorship___'; $sponsorship_pk = $sponsorship_prefix . 'id'; $sponsors_join_id = 58; $email_from_addr = "*****@*****.**"; $email_from_name = "Hugh Messenger"; $email_subject = "Hi {fab_sponsors___sponsor_name}"; $user = JFactory::getUser(); $config = JFactory::getConfig(); $db = JFactory::getDbo(); $w = new FabrikWorker(); $content = repeat_emails_get_article($article_id); $sponsorship_data = array(); foreach ($formModel->_formDataWithTableName as $key => $value) { if (strstr($key, $sponsorship_prefix)) { $sponsorship_data[$key] = $value; } } $sponsorship_data[$sponsorship_pk] = $formModel->_formData[$sponsorship_pk]; $sponsorship_data[$sponsorship_pk_raw] = $formModel->_formData[$sponsorship_pk]; foreach ($formModel->_formData['join'][$sponsors_join_id][$email_element_name] as $key => $email) { $sponsor_data = array(); foreach ($formModel->_formData['join'][$sponsors_join_id] as $sponsor_key => $sponsor_val) { $sponsor_data[$sponsor_key] = $formModel->_formData['join'][$sponsors_join_id][$sponsor_key][$key]; } $email_data = array_merge($sponsorship_data, $sponsor_data); $this_content = $w->parseMessageForPlaceHolder($content, $email_data); $this_subject = $w->parseMessageForPlaceHolder($email_subject, $email_data); if (JMailHelper::isEmailAddress($email)) { $res = JUtility::sendMail($email_from_addr, $email_from_name, $email, $this_subject, $this_content, true); } } }
/** * this really does get just the default value (as defined in the element's settings) * @return unknown_type */ function getDefaultValue($data = array()) { if (!isset($this->_default)) { $w = new FabrikWorker(); $element =& $this->getElement(); if ($element->eval) { //strip html tags $element->label = preg_replace('/<[^>]+>/i', '', $element->label); //change htmlencoded chars back $element->label = htmlspecialchars_decode($element->label); $this->_default = @eval($this->_default); FabrikWorker::logEval($this->_default, 'Caught exception on eval in ' . $element->name . '::getDefaultValue() : %s'); } else { $this->_default = $element->label; } $this->_default = $w->parseMessageForPlaceHolder($this->_default, $data); } return $this->_default; }
/** * this really does get just the default value (as defined in the element's settings) * @return unknown_type */ function getDefaultValue($data = array()) { if (!isset($this->_default)) { $params =& $this->getParams(); $element = $this->getElement(); $w = new FabrikWorker(); $this->_default = $params->get('imagefile'); // $$$ hugh - this gets us the default image, with the root folder prepended. // But ... if the root folder option is set, we need to strip it. $rootFolder = $params->get('selectImage_root_folder', '/'); $rootFolder = ltrim($rootFolder, '/'); $this->_default = preg_replace("#^{$rootFolder}#", '', $this->_default); $this->_default = $w->parseMessageForPlaceHolder($this->_default, $data); if ($element->eval == "1") { $this->_default = @eval(stripslashes($this->_default)); FabrikWorker::logEval($this->_default, 'Caught exception on eval in ' . $element->name . '::getDefaultValue() : %s'); } } return $this->_default; }
/** * Run eval * * @param string $data Original data * @param int $repeatCounter Repeat group counter * * @return string Evaluated PHP function */ private function _eval($data, $repeatCounter = 0) { $params = $this->getParams(); $elementModel = $this->elementModel; $formModel = $elementModel->getFormModel(); $formData = $formModel->formData; $w = new FabrikWorker(); $phpCode = $params->get('php-code'); $phpCode = $w->parseMessageForPlaceHolder($phpCode, $formData, true, true); /** * $$$ hugh - added trigger_error(""), which will "clear" any existing errors, * otherwise logEval will pick up and report notices and warnings generated * by the rest of our code, which can be VERY confusing. Note that this required a tweak * to logEval, as error_get_last won't be null after doing this, but $error['message'] will * be empty. * $$$ hugh - moved the $trigger_error() into a helper func */ FabrikWorker::clearEval(); $return = @eval($phpCode); FabrikWorker::logEval($return, 'Caught exception on php validation of ' . $elementModel->getFullName(true, false) . ': %s'); return $return; }
/** * Parse the {fabrik} tag * * @param array $match {fabrik} preg match * * @return string */ protected function parse($match) { $match = $match[0]; // $$$ hugh - see if we can remove formatting added by WYSIWYG editors $match = strip_tags($match); require_once COM_FABRIK_FRONTEND . '/helpers/parent.php'; $w = new FabrikWorker(); $match = preg_replace('/\\s+/', ' ', $match); /* $$$ hugh - only replace []'s in value, not key, so we handle * ranged filters and 'complex' filters */ $match2 = array(); foreach (explode(" ", $match) as $m) { if (strstr($m, '=')) { list($key, $val) = explode('=', $m); $val = str_replace('[', '{', $val); $val = str_replace(']', '}', $val); $match2[] = $key . '=' . $val; } else { $match2[] = $m; } } $match = implode(' ', $match2); $w->replaceRequest($match); // Stop [] for ranged filters from being removed // $match = str_replace('{}', '[]', $match); $match = $w->parseMessageForPlaceHolder($match); return $match; }
/** * Trigger called when a row is stored. * If toggle_others on then set other records yesno value to 0 * * @param array &$data Data to store * @param int $repeatCounter Repeat group index * * @return void */ public function onStoreRow(&$data, $repeatCounter = 0) { if (!parent::onStoreRow($data, $repeatCounter)) { return false; } $value = $this->getValue($data, $repeatCounter); if ($value == '1') { $params = $this->getParams(); $toggle = (bool) $params->get('toggle_others', false); if ($toggle === false) { return; } $listModel = $this->getListModel(); $name = $this->getElement()->name; $db = $listModel->getDb(); $query = $db->getQuery(true); if ($this->isJoin()) { $joinModel = $this->getJoinModel(); $pk = $joinModel->getJoinedToTablePk('.'); } else { $pk = $listModel->getPrimaryKey(); } $shortPk = FabrikString::shortColName($pk); $rowId = FArrayHelper::getValue($data, $shortPk, null); $query->update($this->actualTableName())->set($name . ' = 0'); if (!empty($rowId)) { $query->where($pk . ' <> ' . $rowId); } $toggle_where = $params->get('toggle_where', ''); FabrikString::ltrimiword($toggle_where, 'where'); if (!empty($toggle_where)) { $w = new FabrikWorker(); $toggle_where = $w->parseMessageForPlaceHolder($toggle_where); $query->where($toggle_where); } $db->setQuery($query); $db->execute(); } }
/** * Map web service data to Fabrik fields * * @param array $datas web service data * @param string $fk foreign key * * @return array mapped data */ public function map($datas, $fk) { $return = array(); $w = new FabrikWorker(); foreach ($datas as $data) { $row = array(); foreach ($this->map as $map) { $to = $map['to']; $map['from'] = $w->parseMessageForPlaceHolder($map['from'], $data, false); if (JArrayHelper::getValue($map, 'match', '') !== '') { if (JArrayHelper::getValue($map, 'eval') == 1) { $res = eval($map['match']); if ($res !== false) { $row[$to] = $res; } } else { if ($map['match'] == $map['from']) { $row[$to] = $map['value']; } } } else { $row[$to] = $map['from']; } } $return[] = $row; } return $return; }
function getJSIcons() { $icons = array(); $w = new FabrikWorker(); $uri = JURI::getInstance(); $params = $this->getParams(); $templates = (array) $params->get('fb_gm_detailtemplate'); $listids = (array) $params->get('googlemap_table'); //images for file system $aIconImgs = (array) $params->get('fb_gm_iconimage'); //image from marker data $markerImages = (array) $params->get('fb_gm_iconimage2'); //specifed letter $letters = (array) $params->get('fb_gm_icon_letter'); $aFirstIcons = (array) $params->get('fb_gm_first_iconimage'); $aLastIcons = (array) $params->get('fb_gm_last_iconimage'); $titleElements = (array) $params->get('fb_gm_title_element'); $groupClass = (array) $params->get('fb_gm_group_class'); $c = 0; $this->recordCount = 0; $maxMarkers = $params->get('fb_gm_markermax', 0); if (count($listids) == 1) { $recLimit = $maxMarkers; } else { $recLimit = 0; } $limitMessageShown = false; $limitMessage = $params->get('fb_gm_markermax_message'); $groupedIcons = array(); $k = 0; foreach ($listids as $listid) { $template = JArrayHelper::getValue($templates, $c, ''); $listModel = $this->getlistModel($listid); $table = $listModel->getTable(); $mapsElements = $listModel->getElementsOfType('googlemap'); if (empty($mapsElements)) { JError::raiseError(500, JText::_('No google map element present in this list')); continue; } $coordColumn = $mapsElements[0]->getFullName(false, true, false) . "_raw"; //are we using random start location for icons? $listModel->_randomRecords = $params->get('fb_gm_random_marker') == 1 && $recLimit != 0 ? true : false; //used in table model setLimits JRequest::setVar('limit' . $listid, $recLimit); $listModel->setLimits(); $nav = $listModel->getPagination(0, 0, $recLimit); $data = $listModel->getData(); $this->txt = array(); $k = 0; foreach ($data as $groupKey => $group) { foreach ($group as $row) { $customimagefound = false; $iconImg = JArrayHelper::getValue($aIconImgs, $c, ''); if ($k == 0) { $firstIcon = JArrayHelper::getValue($aFirstIcons, $c, $iconImg); if ($firstIcon !== '') { $iconImg = $firstIcon; } } $v = $this->getCordsFromData($row->{$coordColumn}); if ($v == array(0, 0)) { continue; //dont show icons with no data } $rowdata = JArrayHelper::fromObject($row); $rowdata['rowid'] = $rowdata['__pk_val']; $html = $w->parseMessageForPlaceHolder($template, $rowdata); $titleElement = JArrayHelper::getValue($titleElements, $c, ''); $title = $titleElement == '' ? '' : strip_tags($row->{$titleElement}); // $$$ hugh - if they provided a template, lets assume they will handle the link themselves. // http://fabrikar.com/forums/showthread.php?p=41550#post41550 // $$$ hugh - at some point the fabrik_view / fabrik_edit links became optional if (empty($html) && (array_key_exists('fabrik_view', $rowdata) || array_key_exists('fabrik_edit', $rowdata))) { $html .= "<br />"; // use edit link by preference if (array_key_exists('fabrik_edit', $rowdata)) { $html .= $rowdata['fabrik_edit']; } else { $html .= $rowdata['fabrik_view']; } } $html = str_replace(array("\n\r"), "<br />", $html); $html = str_replace(array("\n", "\r"), "<br />", $html); $html = str_replace("'", '"', $html); $this->txt[] = $html; if ($iconImg == '') { $iconImg = JArrayHelper::getValue($markerImages, $c, ''); if ($iconImg != '') { $iconImg = JArrayHelper::getValue($rowdata, $iconImg, ''); //get the src preg_match('/src=["|\'](.*?)["|\']/', $iconImg, $matches); if (array_key_exists(1, $matches)) { $iconImg = $matches[1]; //check file exists $path = str_replace(COM_FABRIK_LIVESITE, '', $iconImg); if (JFile::exists(JPATH_BASE . $path)) { $customimagefound = true; } } } if ($iconImg != '') { list($width, $height) = $this->markerSize($iconImg); } else { //standard google map icon size $width = 20; $height = 34; } } else { //standard google map icon size list($width, $height) = $this->markerSize(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $iconImg); } //just for moosehunt! $radomize = $_SERVER['HTTP_HOST'] == 'moosehunt.mobi' ? true : false; $groupKey = strip_tags($groupKey); $gClass = JArrayHelper::getValue($groupClass, 0, ''); if (!empty($gClass)) { $gClass .= '_raw'; $gClass = isset($row->{$gClass}) ? $row->{$gClass} : ''; } if (array_key_exists($v[0] . $v[1], $icons)) { $existingIcon = $icons[$v[0] . $v[1]]; if ($existingIcon['groupkey'] == $groupKey) { // $$$ hugh - this inserts label between multiple record $html, but not at the top. // If they want to insert label, they can do it themselves in the template. // $icons[$v[0].$v[1]][2] = $icons[$v[0].$v[1]][2] . "<h6>$table->label</h6>" . $html; $icons[$v[0] . $v[1]][2] = $icons[$v[0] . $v[1]][2] . "<br />" . $html; if ($customimagefound) { //$icons[$v[0].$v[1]][3] = "<br />" . $iconImg; $icons[$v[0] . $v[1]][3] = $iconImg; } } else { $groupedIcons[] = array($v[0], $v[1], $html, $iconImg, $width, $height, 'groupkey' => $groupKey, 'listid' => $listid, 'title' => $title, 'groupClass' => 'type' . $gClass); } } else { //default icon - lets see if we need to use a letterd icon instead if (JArrayHelper::getValue($letters, $c, '') != '') { $iconImg = $uri->getScheme() . '://www.google.com/mapfiles/marker' . strtoupper($letters[$c]) . '.png'; } $icons[$v[0] . $v[1]] = array($v[0], $v[1], $html, $iconImg, $width, $height, 'groupkey' => $groupKey, 'listid' => $listid, 'title' => $title, 'groupClass' => 'type' . $gClass); } $this->recordCount++; $k++; } } //replace last icon? $iconImg = JArrayHelper::getValue($aLastIcons, $c, ''); if ($iconImg != '') { list($width, $height) = $this->markerSize(JPATH_SITE . '/media/com_fabrik/images/' . $iconImg); $icons[$v[0] . $v[1]][3] = $iconImg; $icons[$v[0] . $v[1]][4] = $width; $icons[$v[0] . $v[1]][5] = $height; } $c++; } $icons = array_values($icons); //replace coord keys with numeric keys $icons = array_merge($icons, $groupedIcons); if ($maxMarkers != 0 && $maxMarkers < count($icons)) { $icons = array_slice($icons, -$maxMarkers); } $limitMessageShown = !($k >= $recLimit); if (!$limitMessageShown && $recLimit !== 0 && $limitMessage != '') { $app->enqueueMessage($limitMessage); } FabrikHelperHTML::debug($icons, 'map'); return $icons; }
/** * do the plugin action * @return number of records updated */ function process(&$data) { $app =& JFactory::getApplication(); jimport('joomla.mail.helper'); $params =& $this->getParams(); $msg = $params->get('message'); $to = $params->get('to'); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $subject = $params->get('subject', 'Fabrik cron job'); $eval = $params->get('cronemail-eval'); $condition = trim($params->get('cronemail_condition', '')); $merge_emails = (int) $params->get('cronemail_mergemessages', 0); $merged_msg = ''; $updates = array(); $first_row = array(); foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { $row = JArrayHelper::fromObject($row); if (empty($first_row)) { $first_row = $row; // used for placeholders in subject when merging mail } if (!empty($condition)) { $this_condition = $w->parseMessageForPlaceHolder($condition, $row); if (eval($this_condition) === false) { $this->logMsg .= "\n condition returned false: {$this_condition}\n"; continue; } } if (!$merge_emails) { $thistos = explode(',', $w->parseMessageForPlaceHolder($to, $row)); $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $thissubject = $w->parseMessageForPlaceHolder($subject, $row); foreach ($thistos as $thisto) { if (JMailHelper::isEmailAddress($thisto)) { $res = JUTility::sendMail($MailFrom, $FromName, $thisto, $thissubject, $thismsg, true); $this->logMsg .= "\n {$thisto}: "; $this->logMsg .= $res ? ' sent ' : ' not sent \\n'; } else { $this->logMsg .= "\n {$thisto} not an email\n"; } } } else { $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $merged_msg .= $thismsg; } $updates[] = $row['__pk_val']; } } } if ($merge_emails) { // arbitrarily use first row for placeholders $thistos = explode(',', $w->parseMessageForPlaceHolder($to, $first_row)); $thissubject = $w->parseMessageForPlaceHolder($subject, $first_row); $merged_msg = $params->get('cronemail_message_preamble', '') . $merged_msg . $params->get('cronemail_message_postamble', ''); foreach ($thistos as $thisto) { if (JMailHelper::isEmailAddress($thisto)) { $res = JUTility::sendMail($MailFrom, $FromName, $thisto, $thissubject, $merged_msg, true); $this->logMsg .= "\n {$thisto}: "; $this->logMsg .= $res ? ' sent ' : ' not sent \\n'; } else { $this->logMsg .= "\n {$thisto} not an email\n"; } } } $field = $params->get('cronemail-updatefield'); if (!empty($updates) && trim($field) != '') { //do any update found $tableModel =& JModel::getInstance('table', 'FabrikModel'); $tableModel->setId($params->get('table')); $table =& $tableModel->getTable(); $connection = $params->get('connection'); $field = $params->get('cronemail-updatefield'); $value = $params->get('cronemail-updatefield-value'); $noquotes = $params->get('cronemail-updatefield-no-quotes'); $field = str_replace("___", ".", $field); $fabrikDb =& $tableModel->getDb(); $query = "UPDATE {$table->db_table_name} set {$field} = " . ($noquotes ? $value : $fabrikDb->Quote($value)) . " WHERE {$table->db_primary_key} IN (" . implode(',', $updates) . ")"; $fabrikDb->setQuery($query); $fabrikDb->query(); } return count($updates); }