本文整理汇总了PHP中Message::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::add方法的具体用法?PHP Message::add怎么用?PHP Message::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processOrderStep
function processOrderStep($params)
{
global $cart, $smarty, $errors;
if (!isset($_POST['id_address_delivery']) or !Address::isCountryActiveById(intval($_POST['id_address_delivery']))) {
$errors[] = 'this address is not in a valid area';
} else {
$cart->id_address_delivery = intval($_POST['id_address_delivery']);
$cart->id_address_invoice = isset($_POST['same']) ? intval($_POST['id_address_delivery']) : intval($_POST['id_address_invoice']);
if (!$cart->update()) {
$errors[] = Tools::displayError('an error occured while updating your cart');
}
Module::hookExec('orderAddressVerification', array());
if (isset($_POST['message']) and !empty($_POST['message'])) {
if (!Validate::isMessage($_POST['message'])) {
$errors[] = Tools::displayError('invalid message');
} elseif ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$message = new Message(intval($oldMessage['id_message']));
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->update();
} else {
$message = new Message();
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->id_cart = intval($cart->id);
$message->id_customer = intval($cart->id_customer);
$message->add();
}
}
}
}
示例2: addMessageToOrder
public static function addMessageToOrder($id_order, $message)
{
$msg = new Message();
$msg->message = $message;
$msg->id_order = (int) $id_order;
$msg->private = 1;
$msg->add();
}
示例3: preUpdate
public function preUpdate($eventArgs)
{
global $_CONFIG, $_ARRAYLANG;
try {
$objSetting = $eventArgs->getEntity();
$value = $objSetting->getValue();
switch ($objSetting->getName()) {
case 'timezone':
if (!in_array($value, timezone_identifiers_list())) {
\Message::add($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID'], \Message::CLASS_ERROR);
throw new YamlSettingEventListenerException($_ARRAYLANG['TXT_CORE_TIMEZONE_INVALID']);
}
break;
case 'domainUrl':
$arrMatch = array();
if (preg_match('#^https?://(.*)$#', $value, $arrMatch)) {
$value = $arrMatch[1];
}
$value = htmlspecialchars($value, ENT_QUOTES, CONTREXX_CHARSET);
$objSetting->setValue($value);
break;
case 'forceProtocolFrontend':
if ($_CONFIG['forceProtocolFrontend'] != $value) {
if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) {
$value = 'none';
}
$objSetting->setValue($value);
}
break;
case 'forceProtocolBackend':
if ($_CONFIG['forceProtocolBackend'] != $value) {
if (!\Cx\Core\Config\Controller\Config::checkAccessibility($value)) {
$value = 'none';
}
$objSetting->setValue($value);
}
break;
case 'forceDomainUrl':
$useHttps = $_CONFIG['forceProtocolBackend'] == 'https';
$protocol = 'http';
if ($useHttps == 'https') {
$protocol = 'https';
}
$value = \Cx\Core\Config\Controller\Config::checkAccessibility($protocol) ? $value : 'off';
$objSetting->setValue($value);
break;
}
} catch (YamlSettingEventListenerException $e) {
\DBG::msg($e->getMessage());
}
}
示例4: ajouter
public function ajouter($nom)
{
$nom = trim($nom);
if (empty($nom)) {
throw new TheliaAdminException("Empty message name", TheliaAdminException::MESSAGE_NAME_EMPTY);
}
if (Message::exist_nom($nom)) {
throw new TheliaAdminException("Message already exists", TheliaAdminException::MESSAGE_ALREADY_EXISTS);
}
$message = new Message();
$message->nom = $nom;
$message->id = $message->add();
redirige("message_modifier.php?id=" . $message->id);
}
示例5: syncSwatchbookColors
/**
* write SystemMessageHook if update necessary
*/
public function syncSwatchbookColors()
{
// Count DataSet
$sql = \Database::getInstance()->prepare("SELECT id FROM tl_swatchbookColors")->execute();
// Load File
$file = new \File('src/CtEye/swatchbook-bundle/src/Resources/public/css/divElements.css');
/**
* Dataset rows are not equal File rows
* @return SystemMessage => Sync
*/
if ($sql->numRows !== count($file->getContentAsArray())) {
\Message::add($GLOBALS['TL_LANG']['swatchbook']['syncSystemMessage'], 'TL_ERROR');
$this->isUpdate = true;
}
return '';
}
示例6: webhook
/**
* Assign summary template
*/
public function webhook()
{
$stripe = new StripeJs();
if ($stripe->active) {
if (Tools::getIsset('token') && Configuration::get('STRIPE_WEBHOOK_TOKEN') == Tools::getValue('token')) {
include $this->module->getLocalPath() . 'lib/Stripe.php';
Stripe::setApiKey(Configuration::get('STRIPE_MODE') ? Configuration::get('STRIPE_PRIVATE_KEY_LIVE') : Configuration::get('STRIPE_PRIVATE_KEY_TEST'));
$event_json = Tools::jsonDecode(@Tools::file_get_contents('php://input'));
if (isset($event_json->id)) {
/* In case there is an issue with the event, Stripe throw an exception, just ignore it. */
try {
/* To double-check and for more security, we retrieve the original event directly from Stripe */
$event = Stripe_Event::retrieve($event_json->id);
/* We are only handling chargebacks, other events are ignored */
if ($event->type == 'charge.dispute.created') {
$id_order = (int) Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'stripe_transaction WHERE id_stripe_transaction = \'' . pSQL($event->id) . '\' AND `charge_back` = 0');
if ($id_order) {
$order = new Order((int) $id_order);
if (Validate::isLoadedObject($order)) {
if (Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS') != -1) {
if ($order->getCurrentState() != Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS')) {
$order->changeIdOrderState((int) Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS'), (int) $id_order);
Db::getInstance()->getValue('UPDATE `' . _DB_PREFIX_ . 'stipe_transaction` SET `charge_back` = 1 WHERE `id_stripe_transaction` = \'' . pSQL($event->id) . '\' AND `charge_back` = 0');
}
}
$message = new Message();
$message->message = $stripe->l('A chargeback occured on this order and was reported by Stripe on') . ' ' . date('Y-m-d H:i:s');
$message->id_order = (int) $order->id;
$message->id_employee = 1;
$message->private = 1;
$message->date_add = date('Y-m-d H:i:s');
$message->add();
}
}
}
} catch (Exception $e) {
header('HTTP/1.1 200 OK');
exit;
}
header('HTTP/1.1 200 OK');
exit;
}
}
}
header('HTTP/1.1 200 OK');
exit;
}
示例7: action_add_gift
public function action_add_gift()
{
$view = View::factory('bookmarklet/add_gift');
$view->url = @$_GET['u'];
$view->categories = ORM::factory('category')->order_by('name', 'asc')->find_all()->as_array('id', 'name');
$view->lists = $this->me('owner')->lists->order_by('updated', 'desc')->find_all()->as_array('id', 'name');
$view->errors = array();
if ($_POST) {
if (!arr::get($_POST, 'list_id')) {
$view->errors = 'Please select a list';
} else {
$list = new Model_List((int) arr::get($_POST, 'list_id'));
if ($list->owner->id != $this->me()->id) {
Request::current()->redirect('user/noaccess');
}
if (arr::get($_POST, 'name') && arr::get($_POST, 'category_id')) {
$gift = new Model_Gift();
$gift->list_id = $list->id;
$gift->name = arr::get($_POST, 'name');
$gift->price = arr::get($_POST, 'price');
$gift->url = arr::get($_POST, 'url');
$gift->category_id = arr::get($_POST, 'category_id');
$gift->details = arr::get($_POST, 'details');
$gift->save();
Message::add('success', 'Your gift has been added');
Request::current()->redirect('bookmarklet/added/' . $gift->id);
}
if (!arr::get($_POST, 'name')) {
$view->errors['name'] = Kohana::message('gift', 'title-required');
}
if (!arr::get($_POST, 'category_id')) {
$view->errors['cat'] = 'Please select a category';
}
}
}
$this->template->content = $view;
}
示例8: addMessage
/**
* Add order private message.
*
* @param $text
* @return bool
*/
public function addMessage($text)
{
$message = new Message();
$text = strip_tags($text, '<br>');
if (!Validate::isCleanHtml($text)) {
$text = 'Invalid payment message.';
}
$message->message = $text;
$message->id_order = (int) $this->getOrderId();
$message->private = 1;
return $message->add();
}
示例9: validateForm
/**
* This function checks if a form is valid
*
* @access protected
* @global array $_ARRAYLANG array containing the language variables
* @return boolean true if form is valid
*/
protected function validateForm()
{
global $_ARRAYLANG;
if ($this->formGenerator === false) {
// cannot save, no such entry
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_NO_SUCH_ENTRY'], \Message::CLASS_ERROR);
return false;
} else {
if (!$this->formGenerator->isValid() || isset($this->options['validate']) && !$this->options['validate']($this->formGenerator)) {
// data validation failed
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_VALIDATION_FAILED'], \Message::CLASS_ERROR);
return false;
}
}
return true;
}
示例10: _updateMessage
protected function _updateMessage($messageContent)
{
if ($messageContent) {
if (!Validate::isMessage($messageContent)) {
$this->errors[] = Tools::displayError('Invalid message');
} else {
if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) {
$message = new Message((int) $oldMessage['id_message']);
$message->message = $messageContent;
$message->update();
} else {
$message = new Message();
$message->message = $messageContent;
$message->id_cart = (int) $this->context->cart->id;
$message->id_customer = (int) $this->context->cart->id_customer;
$message->add();
}
}
} else {
if ($oldMessage = Message::getMessageByCartId($this->context->cart->id)) {
$message = new Message($oldMessage['id_message']);
$message->delete();
}
}
return true;
}
示例11: addMessage
/**
* Add a message
*
* @param string $strMessage The message
* @param string $strType The message type
*
* @deprecated Use Message::add() instead
*/
protected function addMessage($strMessage, $strType)
{
\Message::add($strMessage, $strType);
}
示例12: cronTask
/**
* Check statut of last applications
* saved with TSBuyerProtection::_requestForProtectionV2()
*
* Negative value means an error occurred.
* Error code are managed in TSBPException.
* @see (exception) TSBPException::_getFrontEndMessage() method
*
* Trusted Shops recommends that the request
* should be automated by a cronjob with an interval of 10 minutes.
* @see /../cron_garantee.php
*
* A message is added to the sheet order in Back-office,
* @see Message class
*
* @uses TSBuyerProtection::_getRequestState()
* @uses Message class
* @return void
*/
public function cronTask()
{
// get the last 20min to get the api number (to be sure)
$mktime = mktime(date('H'), date('i') - 20, date('s'), date('m'), date('d'), date('Y'));
$date = date('Y-m-d H:i:s', $mktime);
$db_name = _DB_PREFIX_ . TSBuyerProtection::DB_APPLI;
$sql = '
SELECT *
FROM `' . $db_name . '`
WHERE `last_update` >= "' . $date . '" OR `statut_number` <= 0
';
$to_check = Db::getInstance()->ExecuteS($sql);
foreach ($to_check as $application) {
$code = $this->_getRequestState(array('tsID' => $application['ts_id'], 'applicationID' => $application['id_application']));
if (!empty($this->errors)) {
$return_message = '<p style="color:red;">' . $this->l('Trusted Shops API returns an error concerning the application #') . $application['id_application'] . ': <br />' . implode(', <br />', $this->errors) . '</p>';
$this->errors = array();
} elseif ($code > 0) {
$return_message = sprintf($this->l('Trusted Shops application number %1$d was successfully processed. The guarantee number is: %2$d'), $application['id_application'], $code);
}
$sql = '
UPDATE `' . $db_name . '`
SET `statut_number` = "' . $code . '"
WHERE `id_application` >= "' . $application['id_application'] . '"
';
Db::getInstance()->Execute($sql);
$msg = new Message();
$msg->message = $return_message;
$msg->id_order = (int) $application['id_order'];
$msg->private = 1;
$msg->add();
}
}
示例13: addNewPrivateMessage
/**
* Adds a new private message for the Admin
*/
public function addNewPrivateMessage($order_id, $message)
{
if (!(bool) $order_id) {
return false;
}
$new_message = new Message();
$message = strip_tags($message, '<br>');
if (!Validate::isCleanHtml($message)) {
$message = $this->l('Payment message is not valid, please check your module.');
}
$new_message->message = $message;
$new_message->id_order = $order_id;
$new_message->private = 1;
return $new_message->add();
}
示例14: isset
$order_state_name = 'PS_OS_ERROR';
$message = $module->l('Unknown transaction status notification.');
break;
}
if ($order_state_name == 'PS_OS_PAYMENT' && $api->paymentType == 'rechnungskauf') {
$order_state_name = 'MASTERPAYMENT_INVOICE_APPROVED';
}
//Get order state id
$id_order_state = Configuration::get($order_state_name);
//Update order state
if ($order && $order->getCurrentState() != $id_order_state) {
$order->setCurrentState($id_order_state);
}
//Creates new order
if (!$order && in_array($status, array('SUCCESS', 'SCHEDULED', 'PENDING', 'FAILED', 'UNKNOWN'))) {
$paymentMethods = $module->getPaymentMethods();
$paymentName = isset($paymentMethods[$api->paymentType]) ? $paymentMethods[$api->paymentType] : $paymentMethods['none'];
$module->registerPaymentInfo($cart->id, $api->paymentType);
//create order
$module->validateOrder($cart->id, $id_order_state, $totalAmount, $paymentName, $message, array(), $currency->id, false, $cart->secure_key);
}
//Add message to order
if ($order && $message) {
$msg = new Message();
$msg->message = $message;
$msg->id_order = $order->id;
$msg->id_customer = $cart->id_customer;
$msg->private = true;
$msg->add();
}
exit;
示例15: array
<?php
Database::update(array('table' => 'bad_player', 'row' => array('id' => intval($_POST['id']), 'first_name' => "'" . Database::escape($_POST['first_name']) . "'", 'last_name' => "'" . Database::escape($_POST['last_name']) . "'")));
Message::add(array('type' => 'success', 'text' => 'Joueur modifié avec succès.'));
Routing::redirect(array('module' => $g_current_module, 'action' => 'list'));