当前位置: 首页>>代码示例>>PHP>>正文


PHP FabrikWorker类代码示例

本文整理汇总了PHP中FabrikWorker的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker类的具体用法?PHP FabrikWorker怎么用?PHP FabrikWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FabrikWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onCanEdit

 /**
  * 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;
     }
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:44,代码来源:caneditrow.php

示例2: shouldValidate

 /**
  * 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;
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:40,代码来源:validation_rule.php

示例3: onAfterProcess

 /**
  * 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)
 {
     $w = new FabrikWorker();
     $config_userpass = $params->get('username') . ':' . $params->get('password');
     $endpoint = $params->get('endpoint');
     $headers = array('Content-Type: application/xml', 'Accept: application/xml');
     // Set where we should post the REST request to
     $endpoint = $w->parseMessageForPlaceholder($endpoint);
     $endpoint = $w->parseMessageForPlaceholder($endpoint);
     // What is the root node for the xml data we are sending
     $xmlParent = $params->get('xml_parent', 'ticket');
     $xmlParent = $w->parseMessageForPlaceholder($xmlParent);
     $xml = new SimpleXMLElement('<' . $xmlParent . '></' . $xmlParent . '>');
     // Set up CURL object
     $chandle = curl_init();
     // Set which fields should be included in the XML data.
     $include = $w->parseMessageForPlaceholder($params->get('include_list', 'milestone-id, status, summary'));
     $include = explode(',', $include);
     foreach ($include as $i) {
         if (array_key_exists($i, $formModel->_formData)) {
             $xml->addChild($i, $formModel->_formData[$i]);
         } elseif (array_key_exists($i, $formModel->_fullFormData, $i)) {
             $xml->addChild($i, $formModel->_fullFormData[$i]);
         }
     }
     $output = $xml->asXML();
     $curl_options = array(CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $output, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_USERPWD => $config_userpass, CURLOPT_CUSTOMREQUEST => 'POST');
     foreach ($curl_options as $key => $value) {
         curl_setopt($chandle, $key, $value);
     }
     $output = curl_exec($chandle);
     $httpCode = curl_getinfo($chandle, CURLINFO_HTTP_CODE);
     switch ($httpCode) {
         case '400':
             echo "Bad Request";
             break;
         case '401':
             echo "Unauthorized";
             break;
         case '404':
             echo "Not found";
             break;
         case '405':
             echo "Method Not Allowed";
             break;
         case '406':
             echo "Not Acceptable";
             break;
         case '415':
             echo "Unsupported Media Type";
             break;
         case '500':
             echo "Internal Server Error";
             break;
     }
     if (curl_errno($chandle)) {
         die("ERROR: " . curl_error($chandle));
     }
     curl_close($chandle);
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:69,代码来源:rest.php

示例4: onCanEdit

 /**
  * 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;
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:67,代码来源:caneditrow.php

示例5: getFabrikItem

 /**
  * 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];
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:41,代码来源:fabrikj2store.php

示例6: render

 /**
  * 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);
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:38,代码来源:fbcomment.php

示例7: shouldValidate

	/**
	 * 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;
	}
开发者ID:Jobar87,项目名称:fabrik,代码行数:39,代码来源:validation_rule.php

示例8: display

 /**
  * 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'));
             }
         }
     }
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:32,代码来源:view.html.php

示例9: onAfterProcess

 /**
  * 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&amp;view=form&amp;fabrik=" . $formModel->get('id') . "&amp;rowid=" . JRequest::getVar('rowid');
     $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&amp;view=details&amp;fabrik=" . $formModel->get('id') . "&amp;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);
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:66,代码来源:receipt.php

示例10: display

 /**
  * 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);
         }
     }
 }
开发者ID:LGBGit,项目名称:tierno,代码行数:37,代码来源:view.word.php

示例11: onLastProcess

 /**
  * 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;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:65,代码来源:redirect.php

示例12: onAfterProcess

 /**
  * 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;
     }
 }
开发者ID:rhotog,项目名称:fabrik,代码行数:63,代码来源:mailchimp.php

示例13: process

	/**
	 * 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);
	}
开发者ID:Jobar87,项目名称:fabrik,代码行数:62,代码来源:email.php

示例14: onAfterProcess

 /**
  * 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();
     $app = JFactory::getApplication();
     $input = $app->input;
     $formModel = $this->getModel();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     if ($params->get('ask-receipt')) {
         if (!array_key_exists('fabrik_email_copy', $_POST)) {
             return;
         }
     }
     $rowid = $input->get('rowid');
     $config = JFactory::getConfig();
     $w = new FabrikWorker();
     $form = $formModel->getForm();
     $data = $this->getProcessData();
     $message = $params->get('receipt_message');
     $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $package . "&amp;view=form&amp;fabrik=" . $formModel->get('id') . "&amp;rowid=" . $rowid;
     $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $package . "&amp;view=details&amp;fabrik=" . $formModel->get('id') . "&amp;rowid=" . $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, $data, false);
     $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $data, 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, $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);
     $mail = JFactory::getMailer();
     $res = $mail->sendMail($from, $fromname, $to, $subject, $message, true);
     if (!$res) {
         throw new RuntimeException('Couldn\'t send receipt', 500);
     }
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:60,代码来源:receipt.php

示例15: onLastProcess

 /**
  * 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;
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:60,代码来源:redirect.php


注:本文中的FabrikWorker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。