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


PHP FabrikWorker::parseMessageForPlaceholder方法代码示例

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


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

示例1: 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

示例2: 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
  *
  * @throws Exception
  *
  * @return	bool
  */
 public function onAfterProcess()
 {
     $params = $this->getParams();
     $api_AUP = JPATH_SITE . '/components/com_alphauserpoints/helper.php';
     if (JFile::exists($api_AUP)) {
         $w = new FabrikWorker();
         $this->data = $this->getProcessData();
         require_once $api_AUP;
         $aup = new AlphaUserPointsHelper();
         // Define which user will receive the points.
         $userId = $params->get('user_id', '');
         $userId = (int) $w->parseMessageForPlaceholder($userId, $this->data, false);
         $aupId = $aup->getAnyUserReferreID($userId);
         // Replace these if you want to show a specific reference for the attributed points - doesn't seem to effect anything
         $keyReference = '';
         // Shown in the user details page - description of what the point is for
         $dataReference = $params->get('data_reference', '');
         $dataReference = $w->parseMessageForPlaceholder($dataReference, $this->data, false);
         // Override the plugin default points
         $randomPoints = $params->get('random_points', 0);
         if ($params->get('random_points_eval', '0') == '1') {
             if (!empty($randomPoints)) {
                 $randomPoints = $w->parseMessageForPlaceholder($randomPoints, $this->data, false);
                 $randomPoints = @eval($randomPoints);
                 FabrikWorker::logEval($randomPoints, 'Caught exception on eval in aup plugin : %s');
             }
             $randomPoints = (double) $randomPoints;
         } else {
             $randomPoints = (double) $w->parseMessageForPlaceholder($randomPoints, $this->data, false);
         }
         // If set to be greater than $randompoints then this is the # of points assigned (not sure when this would be used - commenting out for now)
         $referralUserPoints = 0;
         $aupPlugin = $params->get('aup_plugin', 'plgaup_fabrik');
         $aupPlugin = $w->parseMessageForPlaceholder($aupPlugin, $this->data, false);
         if (!$aup->checkRuleEnabled($aupPlugin, 0, $aupId)) {
             throw new Exception('Alpha User Points plugin not published');
         }
         $aup->userpoints($aupPlugin, $aupId, $referralUserPoints, $keyReference, $dataReference, $randomPoints);
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:48,代码来源:alphauserpoints.php

示例3: setAxisLabels

 /**
  * Set the axis label
  *
  * @return  void
  */
 protected function setAxisLabels()
 {
     $worker = new FabrikWorker();
     $params = $this->getParams();
     $this->axisLabels = (array) $params->get('fusionchart_axis_labels');
     foreach ($this->axisLabels as $axis_key => $axis_val) {
         $this->axisLabels[$axis_key] = $worker->parseMessageForPlaceholder($axis_val, null, false);
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:14,代码来源:fusionchart.php

示例4: _fromEmailName

 /**
  * Get the email to name and email address
  *
  * @param   array $data Placeholder replacement data
  *
  * @since 3.3.2
  *
  * @return array ($emailFrom, $fromName)
  */
 private function _fromEmailName($data = array())
 {
     $w = new FabrikWorker();
     $params = $this->getParams();
     $fromUser = $params->get('emailtable_from_user');
     if ($fromUser) {
         $emailFrom = $this->user->get('email');
         $fromName = $this->user->get('name');
     } else {
         $emailFrom = $params->get('email_from', $this->config->get('mailfrom'));
         @(list($emailFrom, $fromName) = explode(':', $w->parseMessageForPlaceholder($emailFrom, $data, false), 2));
     }
     return array($emailFrom, $fromName);
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:23,代码来源:email.php

示例5: log


//.........这里部分代码省略.........
                                 $csvMsg[] = "UserAgent";
                             }
                             if ($params->get('compare_data') == 1) {
                                 $csvMsg[] = "\"" . JText::_('COMPARE_DATA_LABEL_CSV') . "\"";
                             }
                         }
                         // Inserting data in CSV with actual line break as row separator
                         $csvMsg[] = "\n\"" . $date . "\"";
                         if ($params->get('logs_record_ip') == 1) {
                             $csvMsg[] = "\"" . $_SERVER['REMOTE_ADDR'] . "\"";
                         }
                         if ($params->get('logs_record_referer') == 1) {
                             $csvMsg[] = "\"" . $http_referrer . "\"";
                         }
                         if ($params->get('logs_record_useragent') == 1) {
                             $csvMsg[] = "\"" . $_SERVER['HTTP_USER_AGENT'] . "\"";
                         }
                         if ($params->get('compare_data') == 1) {
                             $csvMsg[] = "\"" . $result_compare . "\"";
                         }
                         $csvMsg = implode(",", $csvMsg);
                         if ($send_email) {
                             $email_msg = $csvMsg;
                         }
                         if ($make_file) {
                             if ($buffer !== '') {
                                 $csvMsg = $buffer . $csvMsg;
                             }
                             JFile::write($logs_file, $csvMsg);
                         }
                     }
                 }
             }
         }
     }
     if ($params->get('logs_record_in_db') == 1) {
         // In which table?
         if ($params->get('record_in') == '') {
             $rdb = '#__fabrik_log';
         } else {
             $db_suff = $params->get('record_in');
             $form = $formModel->getForm();
             $fid = $form->id;
             $db->setQuery("SELECT " . $db->quoteName('db_table_name') . " FROM " . $db->quoteName('#__fabrik_lists') . " WHERE " . $db->quoteName('form_id') . " = " . (int) $fid);
             $tname = $db->loadResult();
             $rdb = $db->quoteName($tname . $db_suff);
         }
         // Making the message to record
         if ($params->get('custom_msg') != '') {
             $message = preg_replace('/<br\\/>/', ' ', $custom_msg);
         } else {
             $message = $this->makeStandardMessage($params, $result_compare);
         }
         // $$$ hugh - FIXME - not sure about the option driven $create_custom_table stuff, as this won't work
         // if they add an option to an existing log table.  We should probably just create all the optional columns
         // regardless.
         if ($params->get('record_in') == '') {
             $in_db = "INSERT INTO {$rdb} (" . $db->quoteName('referring_url') . ", " . $db->quoteName('message_type') . ", " . $db->quoteName('message') . ") VALUES (" . $db->Quote($http_referrer) . ", " . $db->Quote($messageType) . ", " . $db->Quote($message) . ");";
             $db->setQuery($in_db);
             $db->query();
         } else {
             $create_custom_table = "CREATE TABLE IF NOT EXISTS {$rdb} (" . $db->quoteName('id') . " int(11) NOT NULL auto_increment PRIMARY KEY, {$clabels_createdb});";
             $db->setQuery($create_custom_table);
             $db->query();
             $in_db = "INSERT INTO {$rdb} ({$clabels_db}) VALUES ({$cdata_db});";
             $db->setQuery($in_db);
             if (!$db->query()) {
                 // $$$ changed to always use db fields even if not selected
                 // so logs already created may need optional fields added.
                 // try adding every field we should have, don't care if query fails.
                 foreach ($clabelsCreateDb as $insert) {
                     $db->setQuery("ALTER TABLE ADD {$insert} AFTER `id`");
                     $db->query();
                 }
                 // ... and try the insert query again
                 $db->setQuery($in_db);
                 $db->query();
             }
         }
     }
     if ($send_email) {
         jimport('joomla.mail.helper');
         $config =& JFactory::getConfig();
         $email_from = $config->getValue('mailfrom');
         $email_to = explode(',', $w->parseMessageForPlaceholder($params->get('log_send_email_to', '')));
         $subject = strip_tags($w->parseMessageForPlaceholder($params->get('log_send_email_subject', 'log event')));
         foreach ($email_to as $email) {
             $email = trim($email);
             if (empty($email)) {
                 continue;
             }
             if (JMailHelper::isEmailAddress($email)) {
                 $res = JUtility::sendMail($email_from, $email_from, $email, $subject, $email_msg, true);
             } else {
                 JError::raiseNotice(500, JText::sprintf('DID_NOT_SEND_EMAIL_INVALID_ADDRESS', $email));
             }
         }
     }
     return true;
 }
开发者ID:rhotog,项目名称:fabrik,代码行数:101,代码来源:logs.php

示例6: getFusionchart

 function getFusionchart()
 {
     $document =& JFactory::getDocument();
     $params =& $this->getParams();
     $worker = new FabrikWorker();
     $fc_version = $params->get('fusionchart_version', 'free_old');
     if ($fc_version == 'free_22') {
         require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionChartsFree' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
         $document->addScript($this->srcBase . "fusionchart/lib/FusionChartsFree/JSClass/FusionCharts.js");
         $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionChartsFree/Charts/";
     } else {
         if ($fc_version == 'pro_30') {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionCharts' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FusionCharts/Charts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionCharts/Charts/";
         } else {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FCclass' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FCcharts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FCcharts/";
         }
     }
     $calc_prefixes = array('sum___', 'avg___', 'med___', 'cnt___');
     $calc_prefixmap = array('sum___' => 'sums', 'avg___' => 'avgs', 'med___' => 'medians', 'cnt___' => 'count');
     $w = $params->get('fusionchart_width');
     $h = $params->get('fusionchart_height');
     $chartType = $params->get('fusionchart_type');
     // Create new chart
     $FC = new FusionCharts("{$chartType}", "{$w}", "{$h}");
     //$FC->JSC["debugmode"]=true;
     // Define path to FC's SWF
     $FC->setSWFPath($fc_swf_path);
     $this->setChartMessages($FC);
     // Setting Param string
     $strParam = $this->getChartParams();
     $label_step_ratios = (array) $params->get('fusion_label_step_ratio');
     $x_axis_label = (array) $params->get('fusion_x_axis_label');
     $chartElements = (array) $params->get('fusionchart_elementList');
     $chartColours = (array) $params->get('fusionchart_colours');
     $listid = (array) $params->get('fusionchart_table');
     $axisLabels = (array) $params->get('fusionchart_axis_labels');
     foreach ($axisLabels as $axis_key => $axis_val) {
         //$worker->replaceRequest($axis_val);
         $axisLabels[$axis_key] = $worker->parseMessageForPlaceholder($axis_val, null, false);
     }
     $dual_y_parents = $params->get('fusionchart_dual_y_parent');
     $measurement_units = (array) $params->get('fusion_x_axis_measurement_unit');
     $legends = $params->get('fusiongraph_show_legend', '');
     $chartWheres = (array) $params->get('fusionchart_where');
     $c = 0;
     $gdata = array();
     $glabels = array();
     $gcolours = array();
     $gfills = array();
     $max = array();
     $min = array();
     $calculationLabels = array();
     $calculationData = array();
     $calcfound = false;
     $tmodels = array();
     $labelStep = 0;
     foreach ($listid as $tid) {
         $min[$c] = 0;
         $max[$c] = 0;
         if (!array_key_exists($tid, $tmodels)) {
             $listModel = null;
             $listModel = JModel::getInstance('list', 'FabrikFEModel');
             $listModel->setId($tid);
             $tmodels[$tid] = $listModel;
         } else {
             $listModel = $tmodels[$tid];
         }
         $table = $listModel->getTable();
         $form = $listModel->getForm();
         // $$$ hugh - adding plugin query, 2012-02-08
         if (array_key_exists($c, $chartWheres) && !empty($chartWheres[$c])) {
             $chartWhere = $this->_replaceRequest($chartWheres[$c]);
             $listModel->setPluginQueryWhere('fusionchart', $chartWhere);
         } else {
             // if no where clause, explicitly clear any previously set clause
             $listModel->unsetPluginQueryWhere('fusionchart');
         }
         // $$$ hugh - remove pagination BEFORE calling render().  Otherwise render() applies
         // session state/defaults when it calls getPagination, which is then returned as a cached
         // object if we call getPagination after render().  So call it first, then render() will
         // get our cached pagination, rather than vice versa.
         $nav = $listModel->getPagination(0, 0, 0);
         $listModel->render();
         //$listModel->doCalculations();
         $alldata = $listModel->getData();
         $cals = $listModel->getCalculations();
         $column = $chartElements[$c];
         //$measurement_unit = $measurement_units[$c];
         $measurement_unit = JArrayHelper::getValue($measurement_units, $c, '');
         $pref = substr($column, 0, 6);
         $label = JArrayHelper::getValue($x_axis_label, $c, '');
         $tmpgdata = array();
         $tmpglabels = array();
         $colour = array_key_exists($c, $chartColours) ? str_replace("#", '', $chartColours[$c]) : '';
         $gcolours[] = $colour;
         if (in_array($pref, $calc_prefixes)) {
//.........这里部分代码省略.........
开发者ID:rhotog,项目名称:fabrik,代码行数:101,代码来源:fusionchart.php

示例7: process

 /**
  * Do the plug-in action
  *
  * @param   object  $params  plugin parameters
  * @param   object  &$model  list model
  * @param   array   $opts    custom options
  *
  * @return  bool
  */
 public function process($params, &$model, $opts = array())
 {
     $db = $model->getDb();
     $user = JFactory::getUser();
     $update = json_decode($params->get('update_col_updates'));
     if (!$update) {
         return false;
     }
     // $$$ rob moved here from bottom of func see http://fabrikar.com/forums/showthread.php?t=15920&page=7
     $dateCol = $params->get('update_date_element');
     $userCol = $params->get('update_user_element');
     $item = $model->getTable();
     // Array_unique for left joined table data
     $ids = array_unique(JRequest::getVar('ids', array(), 'method', 'array'));
     JArrayHelper::toInteger($ids);
     $this->_row_count = count($ids);
     $ids = implode(',', $ids);
     $model->reset();
     $model->_pluginQueryWhere[] = $item->db_primary_key . ' IN ( ' . $ids . ')';
     $data = $model->getData();
     // $$$servantek reordered the update process in case the email routine wants to kill the updates
     $emailColID = $params->get('update_email_element', '');
     if (!empty($emailColID)) {
         $w = new FabrikWorker();
         jimport('joomla.mail.helper');
         $message = $params->get('update_email_msg');
         $subject = $params->get('update_email_subject');
         $eval = $params->get('eval', 0);
         $config = JFactory::getConfig();
         $from = $config->getValue('mailfrom');
         $fromname = $config->getValue('fromname');
         $elementModel = FabrikWorker::getPluginManager()->getElementPlugin($emailColID);
         $emailElement = $elementModel->getElement(true);
         $emailField = $elementModel->getFullName(false, true, false);
         $emailColumn = $elementModel->getFullName(false, false, false);
         $emailFieldRaw = $emailField . '_raw';
         $emailWhich = $emailElement->plugin == 'user' ? 'user' : 'field';
         $tbl = array_shift(explode('.', $emailColumn));
         $db = JFactory::getDBO();
         $aids = explode(',', $ids);
         // If using a user element, build a lookup list of emails from #__users,
         // so we're only doing one query to grab all involved emails.
         if ($emailWhich == 'user') {
             $userids_emails = array();
             $query = $db->getQuery();
             $query->select('#__users.id AS id, #__users.email AS email')->from('#__users')->join('LEFT', $tbl . ' ON #__users.id = ' . $emailColumn)->where(_primary_key . ' IN (' . $ids . ')');
             $db->setQuery($query);
             $results = $db->loadObjectList();
             foreach ($results as $result) {
                 $userids_emails[(int) $result->id] = $result->email;
             }
         }
         foreach ($aids as $id) {
             $row = $model->getRow($id);
             if ($emailWhich == 'user') {
                 $userid = (int) $row->{$emailFieldRaw};
                 $to = JArrayHelper::getValue($userids_emails, $userid);
             } else {
                 $to = $row->{$emailField};
             }
             if (JMailHelper::cleanAddress($to) && JMailHelper::isEmailAddress($to)) {
                 // $tofull = '"' . JMailHelper::cleanLine($toname) . '" <' . $to . '>';
                 // $$$servantek added an eval option and rearranged placeholder call
                 $thissubject = $w->parseMessageForPlaceholder($subject, $row);
                 $thismessage = $w->parseMessageForPlaceholder($message, $row);
                 if ($eval) {
                     $thismessage = @eval($thismessage);
                     FabrikWorker::logEval($thismessage, 'Caught exception on eval in updatecol::process() : %s');
                 }
                 $res = JUtility::sendMail($from, $fromname, $to, $thissubject, $thismessage, true);
                 if ($res) {
                     $this->_sent++;
                 } else {
                     ${$this}->_notsent++;
                 }
             } else {
                 $this->_notsent++;
             }
         }
     }
     // $$$servantek reordered the update process in case the email routine wants to kill the updates
     if (!empty($dateCol)) {
         $date = JFactory::getDate();
         $this->_process($model, $dateCol, $date->toSql());
     }
     if (!empty($userCol)) {
         $this->_process($model, $userCol, (int) $user->get('id'));
     }
     foreach ($update->coltoupdate as $i => $col) {
         $this->_process($model, $col, $update->update_value[$i]);
     }
//.........这里部分代码省略.........
开发者ID:rogeriocc,项目名称:fabrik,代码行数:101,代码来源:update_col.php

示例8: process

 /**
  * do the plugin action
  * @param object parameters
  * @param object table model
  */
 function process(&$params, &$model, $opts = array())
 {
     $db =& $model->getDb();
     $user =& JFactory::getUser();
     $updateTo = $params->get('update_value');
     $updateCol = $params->get('coltoupdate');
     $updateTo_2 = $params->get('update_value_2');
     $updateCol_2 = $params->get('coltoupdate_2');
     // $$$ rob moved here from bottom of func see http://fabrikar.com/forums/showthread.php?t=15920&page=7
     $tbl = array_shift(explode('.', $updateCol));
     $dateCol = $params->get('update_date_element');
     $userCol = $params->get('update_user_element');
     $table =& $model->getTable();
     // array_unique for left joined table data
     $ids = array_unique(JRequest::getVar('ids', array(), 'method', 'array'));
     JArrayHelper::toInteger($ids);
     $this->_row_count = count($ids);
     $ids = implode(',', $ids);
     $model->_pluginQueryWhere[] = $table->db_primary_key . ' IN ( ' . $ids . ')';
     $data =& $model->getData();
     //$$$servantek reordered the update process in case the email routine wants to kill the updates
     $emailColID = $params->get('update_email_element', '');
     if (!empty($emailColID)) {
         $w = new FabrikWorker();
         jimport('joomla.mail.helper');
         $message = $params->get('update_email_msg');
         $subject = $params->get('update_email_subject');
         $eval = $params->get('eval', 0);
         $config =& JFactory::getConfig();
         $from = $config->getValue('mailfrom');
         $fromname = $config->getValue('fromname');
         $elementModel =& JModel::getInstance('element', 'FabrikModel');
         $elementModel->setId($emailColID);
         $emailElement =& $elementModel->getElement(true);
         $emailField = $elementModel->getFullName(false, true, false);
         $emailColumn = $elementModel->getFullName(false, false, false);
         $emailFieldRaw = $emailField . '_raw';
         $emailWhich = $emailElement->plugin == 'fabrikuser' ? 'user' : 'field';
         $db =& JFactory::getDBO();
         $aids = explode(',', $ids);
         // if using a user element, build a lookup list of emails from jos_users,
         // so we're only doing one query to grab all involved emails.
         if ($emailWhich == 'user') {
             $userids_emails = array();
             $query = 'SELECT #__users.id AS id, #__users.email AS email FROM #__users LEFT JOIN ' . $tbl . ' ON #__users.id = ' . $emailColumn . ' WHERE ' . $table->db_primary_key . ' IN (' . $ids . ')';
             $db->setQuery($query);
             $results = $db->loadObjectList();
             foreach ($results as $result) {
                 $userids_emails[(int) $result->id] = $result->email;
             }
         }
         foreach ($aids as $id) {
             $row = $model->getRow($id);
             if ($emailWhich == 'user') {
                 $userid = (int) $row->{$emailFieldRaw};
                 $to = $userids_emails[$userid];
             } else {
                 $to = $row->{$emailField};
             }
             if (JMailHelper::cleanAddress($to) && JMailHelper::isEmailAddress($to)) {
                 //$tofull = '"' . JMailHelper::cleanLine($toname) . '" <' . $to . '>';
                 //$$$servantek added an eval option and rearranged placeholder call
                 $thissubject = $w->parseMessageForPlaceholder($subject, $row);
                 $thismessage = $w->parseMessageForPlaceholder($message, $row);
                 if ($eval) {
                     $thismessage = @eval($thismessage);
                     FabrikWorker::logEval($thismessage, 'Caught exception on eval in updatecol::process() : %s');
                 }
                 $res = JUtility::sendMail($from, $fromname, $to, $thissubject, $thismessage, true);
                 if ($res) {
                     $this->_sent++;
                 } else {
                     ${$this}->_notsent++;
                 }
             } else {
                 $this->_notsent++;
             }
         }
     }
     //$$$servantek reordered the update process in case the email routine wants to kill the updates
     if (!empty($dateCol)) {
         $date =& JFactory::getDate();
         $this->_process($model, $dateCol, $date->toMySQL());
     }
     if (!empty($userCol)) {
         $this->_process($model, $userCol, (int) $user->get('id'));
     }
     $this->_process($model, $updateCol, $updateTo);
     if (!empty($updateCol_2)) {
         $this->_process($model, $updateCol_2, $updateTo_2);
     }
     // $$$ hugh - this stuff has to go in process_result()
     //$msg = $params->get( 'update_message' );
     //return JText::sprintf( $msg, count($ids));
     $this->msg = $params->get('update_message', '');
//.........这里部分代码省略.........
开发者ID:nikshade,项目名称:fabrik21,代码行数:101,代码来源:update_col.php

示例9: updateFormModelData

 /**
  * Update the form models data with data from CURL request
  *
  * @param   Joomla\Registry\Registry $params       Parameters
  * @param   array                    $responseBody Response body
  * @param   array                    $data         Data returned from CURL request
  *
  * @return  void
  */
 protected function updateFormModelData($params, $responseBody, $data)
 {
     $w = new FabrikWorker();
     $dataMap = $params->get('put_include_list', '');
     $include = $w->parseMessageForPlaceholder($dataMap, $responseBody, true);
     $formModel = $this->getModel();
     if (FabrikWorker::isJSON($include)) {
         $include = json_decode($include);
         $keys = $include->put_key;
         $values = $include->put_value;
         $defaults = $include->put_value;
         for ($i = 0; $i < count($keys); $i++) {
             $key = $keys[$i];
             $default = $defaults[$i];
             $localKey = FabrikString::safeColNameToArrayKey($values[$i]);
             $remoteData = FArrayHelper::getNestedValue($data, $key, $default, true);
             if (!is_null($remoteData)) {
                 $formModel->_data[$localKey] = $remoteData;
             }
         }
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:31,代码来源:rest.php

示例10: onAfterProcess

 /**
  * process the plugin, called when form is submitted
  *
  * @param object $params
  * @param object form model
  * @returns bol
  */
 function onAfterProcess($params, &$formModel)
 {
     jimport('joomla.mail.helper');
     $user =& JFactory::getUser();
     $config =& JFactory::getConfig();
     $db =& JFactory::getDBO();
     $this->formModel =& $formModel;
     $formParams = $formModel->getParams();
     $ftpTemplate = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_fabrik' . DS . 'plugins' . DS . 'form' . DS . 'fabrikftp' . DS . 'tmpl' . DS . $params->get('ftp_template', ''));
     $this->data = array_merge($formModel->_formData, $this->getEmailData());
     if (!$this->shouldProcess('ftp_conditon')) {
         return;
     }
     $contentTemplate = $params->get('ftp_template_content');
     if ($contentTemplate != '') {
         $content = $this->_getConentTemplate($contentTemplate);
     } else {
         $content = '';
     }
     if (JFile::exists($ftpTemplate)) {
         if (JFile::getExt($ftpTemplate) == 'php') {
             $message = $this->_getPHPTemplateFtp($ftpTemplate);
         } else {
             $message = $this->_getTemplateFtp($ftpTemplate);
         }
         $message = str_replace('{content}', $content, $message);
     } else {
         if ($contentTemplate != '') {
             $message = $content;
         } else {
             $message = $this->_getTextFtp();
         }
     }
     $cc = null;
     $bcc = null;
     $w = new FabrikWorker();
     // $$$ hugh - test stripslashes(), should be safe enough.
     $message = stripslashes($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);
     $ftp_filename = $params->get('ftp_filename', '');
     $ftp_filename = $w->parseMessageForPlaceholder($ftp_filename, $this->data, false);
     $ftp_eval_filename = (int) $params->get('ftp_eval_filename', '0');
     if ($ftp_eval_filename) {
         $ftp_filename = @eval($ftp_filename);
         FabrikWorker::logEval($email_to_eval, 'Caught exception on eval in ftp filename eval : %s');
     }
     if (empty($ftp_filename)) {
         JError::raiseNotice(500, JText::sprintf('PLG_FTP_NO_FILENAME', $email));
     }
     $ftp_host = $w->parseMessageForPlaceholder($params->get('ftp_host', ''), $this->data, false);
     $ftp_port = $w->parseMessageForPlaceholder($params->get('ftp_port', '21'), $this->data, false);
     $ftp_chdir = $w->parseMessageForPlaceholder($params->get('ftp_chdir', ''), $this->data, false);
     $ftp_user = $w->parseMessageForPlaceholder($params->get('ftp_user', ''), $this->data, false);
     $ftp_password = $w->parseMessageForPlaceholder($params->get('ftp_password', ''), $this->data, false);
     $config =& JFactory::getConfig();
     $tmp_dir = rtrim($config->getValue('config.tmp_path'), DS);
     if (empty($tmp_dir) || !JFolder::exists($tmp_dir)) {
         JError::raiseError(500, 'PLG_FORM_FTP_NO_JOOMLA_TEMP_DIR');
         return false;
     }
     $tmp_file = $tmp_dir . DS . 'fabrik_ftp_' . md5(uniqid());
     $message = $w->parseMessageForPlaceholder($message, $this->data, true, false);
     if (JFile::write($tmp_file, $message)) {
         $conn_id = ftp_connect($ftp_host, $ftp_port);
         if ($conn_id) {
             if (@ftp_login($conn_id, $ftp_user, $ftp_password)) {
                 if (!empty($ftp_chdir)) {
                     if (!ftp_chdir($conn_id, $ftp_chdir)) {
                         JError::raiseNotice(500, JText::_('PLG_FORM_FTP_COULD_NOT_CHDIR'));
                         JFile::delete($tmp_file);
                         return false;
                     }
                 }
                 if (!ftp_put($conn_id, $ftp_filename, $tmp_file, FTP_ASCII)) {
                     JError::raiseNotice(500, JText::_('PLG_FORM_FTP_COULD_NOT_SEND_FILE'));
                     JFile::delete($tmp_file);
                     return false;
                 }
             } else {
                 JError::raiseNotice(500, JText::_('PLG_FORM_FTP_COULD_NOT_LOGIN'));
                 JFile::delete($tmp_file);
                 return false;
             }
         } else {
             JError::raiseError(500, 'PLG_FORM_FTP_COULD_NOT_CONNECT');
             JFile::delete($tmp_file);
//.........这里部分代码省略.........
开发者ID:nikshade,项目名称:fabrik21,代码行数:101,代码来源:fabrikftp.php

示例11: addAttachments

 /**
  * Add attachments to the email
  *
  * @return  void
  */
 protected function addAttachments()
 {
     $params = $this->getParams();
     $data = $this->getProcessData();
     /** @var FabrikFEModelForm $formModel */
     $formModel = $this->getModel();
     $groups = $formModel->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $elName = $elementModel->getFullName(true, false);
             if (array_key_exists($elName, $this->data)) {
                 if (method_exists($elementModel, 'addEmailAttachement')) {
                     if (array_key_exists($elName . '_raw', $data)) {
                         $val = $data[$elName . '_raw'];
                     } else {
                         $val = $data[$elName];
                     }
                     if (is_array($val)) {
                         if (is_array(current($val))) {
                             // Can't implode multi dimensional arrays
                             $val = json_encode($val);
                             $val = FabrikWorker::JSONtoData($val, true);
                         }
                     } else {
                         $val = array($val);
                     }
                     foreach ($val as $v) {
                         $file = $elementModel->addEmailAttachement($v);
                         if ($file !== false) {
                             $this->attachments[] = $file;
                             if ($elementModel->shouldDeleteEmailAttachment($v)) {
                                 $this->deleteAttachments[] = $file;
                             }
                         }
                     }
                 }
             }
         }
     }
     // $$$ hugh - added an optional eval for adding attachments.
     // Eval'd code should just return an array of file paths which we merge with $this->attachments[]
     $w = new FabrikWorker();
     $emailAttachEval = $w->parseMessageForPlaceholder($params->get('email_attach_eval', ''), $this->data, false);
     if (!empty($emailAttachEval)) {
         $email_attach_array = @eval($emailAttachEval);
         FabrikWorker::logEval($email_attach_array, 'Caught exception on eval in email email_attach_eval : %s');
         if (!empty($email_attach_array)) {
             $this->attachments = array_merge($this->attachments, $email_attach_array);
         }
     }
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:57,代码来源:email.php

示例12: sendEmails

 /**
  * Send notification emails
  *
  * @param   string  $ids  csv list of row ids.
  *
  * @return  void
  */
 protected function sendEmails($ids)
 {
     $params = $this->getParams();
     $model = $this->getModel();
     // Ensure that yesno exports text and not bootstrap icon.
     $model->setOutputFormat('csv');
     $emailColID = $params->get('update_email_element', '');
     $emailTo = $params->get('update_email_to', '');
     if (!empty($emailColID) || !empty($emailTo)) {
         $w = new FabrikWorker();
         jimport('joomla.mail.helper');
         $aids = explode(',', $ids);
         $message = $params->get('update_email_msg');
         $subject = $params->get('update_email_subject');
         $eval = $params->get('eval', 0);
         $from = $this->config->get('mailfrom');
         $fromName = $this->config->get('fromname');
         $emailWhich = $this->emailWhich();
         foreach ($aids as $id) {
             $row = $model->getRow($id, true);
             /**
              * hugh - hack to work around this issue:
              * https://github.com/Fabrik/fabrik/issues/1499
              */
             $this->params = $params;
             $to = trim($this->emailTo($row, $emailWhich));
             $tos = explode(',', $to);
             $cleanTo = true;
             foreach ($tos as &$email) {
                 $email = trim($email);
                 if (!(JMailHelper::cleanAddress($email) && FabrikWorker::isEmail($email))) {
                     $cleanTo = false;
                 }
             }
             if ($cleanTo) {
                 if (count($tos) > 1) {
                     $to = $tos;
                 }
                 $thisSubject = $w->parseMessageForPlaceholder($subject, $row);
                 $thisMessage = $w->parseMessageForPlaceholder($message, $row);
                 if ($eval) {
                     $thisMessage = @eval($thisMessage);
                     FabrikWorker::logEval($thisMessage, 'Caught exception on eval in updatecol::process() : %s');
                 }
                 $mail = JFactory::getMailer();
                 $res = $mail->sendMail($from, $fromName, $to, $thisSubject, $thisMessage, true);
                 if ($res) {
                     $this->sent++;
                 } else {
                     $this->notsent++;
                 }
             } else {
                 $this->notsent++;
             }
         }
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:64,代码来源:update_col.php

示例13: onAfterProcess

 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');
     $endpoint = $params->get('endpoint');
     $endpoint = $w->parseMessageForPlaceholder($endpoint);
     // Here we set up CURL to grab the data from Unfuddle
     $chandle = curl_init();
     $ticket = new SimpleXMLElement("<ticket></ticket>");
     $ignore = array('trkr_tickets___id');
     if ($formModel->_origRowId == 0) {
         $ingore[] = 'id';
     }
     /*foreach($formModel->_formData as $key => $val){
     			if ($formModel->hasElement($key) && !in_array($key, $ignore)) {
     				if (is_array($val)) {
     					$val = implode(',', $val);
     				}
     				$ticket->addChild($key, $val);
     			}
     		}
     */
     /*
     * $ticket = new SimpleXMLElement("<ticket></ticket>");
     		//$ticket->addChild('assignee-id',  $this->config['default_assignee']);
     		//$ticket->addChild('component-id', $data['component']);
     		//$ticket->addChild('description',  $data['description']);
     		$ticket->addChild('milestone-id', 47420);
     		//$ticket->addChild('priority',     $data['priority']);
     		//$ticket->addChild('severity-id',  $data['severity']);
     		$ticket->addChild('status',       'new');
     		$ticket->addChild('summary',      'test REST API from fabrik');
     */
     $include = array('milestone-id', 'status', 'summary');
     foreach ($include as $i) {
         echo "{$i} = " . $formModel->_formData[$i] . "<br>";
         $ticket->addChild($i, $formModel->_formData[$i]);
     }
     $output = $ticket->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);
     echo $httpCode . " : ";
     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);
     exit;
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:77,代码来源:rest.php

示例14: upsertData

 /**
  * Get fields to update/insert
  *
  * @param   bool  $upsertRowExists
  *
  * @return  array
  */
 protected function upsertData($upsertRowExists = false)
 {
     $params = $this->getParams();
     $w = new FabrikWorker();
     $upsertDb = $this->getDb();
     $upsert = json_decode($params->get('upsert_fields'));
     $fields = array();
     /** @var FabrikFEModelForm $formModel */
     $formModel = $this->getModel();
     if ($formModel->isNewRecord() || !$upsertRowExists) {
         if ($params->get('upsert_pk_or_fk', 'pk') == 'fk') {
             $row_value = $params->get('row_value', '');
             if ($row_value == '{origid}') {
                 $fk = FabrikString::safeColName($params->get('primary_key'));
                 $rowId = $formModel->getInsertId();
                 $fields[] = $fk . ' = ' . $upsertDb->q($rowId);
             }
         }
     }
     for ($i = 0; $i < count($upsert->upsert_key); $i++) {
         $k = FabrikString::shortColName($upsert->upsert_key[$i]);
         $k = $upsertDb->qn($k);
         $v = $upsert->upsert_value[$i];
         $v = $w->parseMessageForPlaceholder($v, $this->data);
         if ($upsert->upsert_eval_value[$i] === '1') {
             $res = FabrikHelperHTML::isDebug() ? eval($v) : @eval($v);
             FabrikWorker::logEval($res, 'Eval exception : upsert : ' . $v . ' : %s');
             $v = $res;
         }
         if ($v == '') {
             $v = $w->parseMessageForPlaceholder($upsert->upsert_default[$i], $this->data);
         }
         /*
          * $$$ hugh - permit the use of expressions, by putting the value in parens, with option use
          * of double :: to provide a default for new row (rowid is empty).  This default is seperate from
          * the simple default used above, which is predicated on value being empty.  So simple usage
          * might be ..
          *
          * (counter+1::0)
          *
          * ... if you want to increment a 'counter' field.  Or you might use a subquery, like ...
          *
          * ((SELECT foo FROM other_table WHERE fk_id = {rowid})::'foo default')
          */
         if (!preg_match('#^\\((.*)\\)$#', $v)) {
             $v = $upsertDb->q($v);
         } else {
             $matches = array();
             preg_match('#^\\((.*)\\)$#', $v, $matches);
             $v = $matches[1];
             $v = explode('::', $v);
             if (count($v) == 1) {
                 $v = $v[0];
             } else {
                 if ($formModel->isNewRecord()) {
                     $v = $v[1];
                 } else {
                     $v = $v[0];
                 }
             }
         }
         $fields[] = $k . ' = ' . $v;
     }
     return $fields;
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:72,代码来源:upsert.php

示例15: doEmail


//.........这里部分代码省略.........
     $first_row = array();
     foreach ($data as $group) {
         foreach ($group as $row) {
             if ($merge_emails) {
                 if (empty($first_row)) {
                     $first_row = $row;
                     // used for placeholders in subject when merging mail
                 }
                 $thismsg = '';
                 if ($old_style) {
                     $thismsg = $w->parseMessageForPlaceHolder($cover_message, $row);
                 } else {
                     if ($php_msg) {
                         $thismsg = $this->_getPHPTemplateEmail($emailTemplate, $row, $tableModel);
                     } else {
                         $thismsg = $w->parseMessageForPlaceHolder($message, $row);
                     }
                 }
                 $merged_msg .= $thismsg;
                 $updated[] = $row->__pk_val;
             } else {
                 if ($toType == 'list') {
                     $process = isset($row->{$to});
                     $mailto = $row->{$to};
                 } else {
                     $process = true;
                     $mailto = $to;
                 }
                 if ($process) {
                     $res = false;
                     $mailtos = explode(',', $mailto);
                     if ($toHow == 'single') {
                         foreach ($mailtos as $tokey => $thisto) {
                             $thisto = $w->parseMessageForPlaceholder($thisto, $row);
                             if (!JMailHelper::isEmailAddress($thisto)) {
                                 unset($mailtos[$tokey]);
                                 $notsent++;
                             } else {
                                 $mailtos[$tokey] = $thisto;
                             }
                         }
                         if ($notsent > 0) {
                             $mailtos = array_values($mailtos);
                         }
                         $sent = sizeof($mailtos);
                         if ($sent > 0) {
                             $thissubject = $w->parseMessageForPlaceholder($subject, $row);
                             $thismsg = '';
                             $thismsg = $cover_message;
                             if (!$old_style) {
                                 if ($php_msg) {
                                     $thismsg .= $this->_getPHPTemplateEmail($emailTemplate, $row, $tableModel);
                                 } else {
                                     $thismsg .= $message;
                                 }
                             }
                             $thismsg = $w->parseMessageForPlaceholder($thismsg, $row);
                             $res = JUtility::sendMail($email_from, $fromname, $mailtos, $thissubject, $thismsg, 1, $cc, $bcc, $this->filepath);
                         }
                     } else {
                         foreach ($mailtos as $mailto) {
                             $mailto = $w->parseMessageForPlaceholder($mailto, $row);
                             if (JMailHelper::isEmailAddress($mailto)) {
                                 $thissubject = $w->parseMessageForPlaceholder($subject, $row);
                                 $thismsg = '';
                                 $thismsg = $cover_message;
开发者ID:nikshade,项目名称:fabrik21,代码行数:67,代码来源:emailtable.php


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