本文整理汇总了PHP中Trace::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Trace::addItem方法的具体用法?PHP Trace::addItem怎么用?PHP Trace::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trace
的用法示例。
在下文中一共展示了Trace::addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replyAction
public function replyAction()
{
return;
try {
$globalContext = new \Sb\Context\Model\Context();
$messageId = ArrayHelper::getSafeFromArray($_GET, 'mid', null);
$redirect = false;
if ($messageId) {
$message = MessageDao::getInstance()->get($messageId);
$this->view->message = $message;
if ($message->getRecipient()->getId() != $globalContext->getConnectedUser()->getId()) {
Flash::addItem(__("Vous ne pouvez pas répondre à ce message car il ne vous est pas destiné.", "s1b"));
$redirect = true;
}
} else {
Flash::addItem(__("Le message auquel vous tentez de répondre n'existe pas.", "s1b"));
$redirect = true;
}
if ($_POST) {
$title = htmlspecialchars($_POST['Title']);
$messageContent = htmlspecialchars($_POST['Message']);
/* test if form is not empty */
if (!empty($title) && !empty($messageContent)) {
// create new message in db
$reply = new Message();
$reply->setRecipient($message->getSender());
$replySender = $globalContext->getConnectedUser();
$reply->setSender($replySender);
$reply->setDate(new \DateTime());
$reply->setTitle($title);
$reply->setMessage($messageContent);
$reply->setIs_read(false);
MessageDao::getInstance()->add($reply);
if ($message->getSender()->getSetting()->getEmailMe() == 'Yes') {
// send a email to warn the origianl sender of the email
$body = MailHelper::newMessageArrivedBody($replySender->getUserName());
MailSvc::getInstance()->send($message->getSender()->getEmail(), sprintf(__("Un message vous a été envoyé depuis le site %s", "s1b"), Constants::SITENAME), $body);
}
Flash::addItem(__("Message envoyé.", "s1b"));
$redirect = true;
} else {
Flash::addItem(__("Vous devez renseigné le titre et le contenu du message.", "s1b"));
}
}
if ($redirect) {
HTTPHelper::redirect(Urls::USER_MAILBOX);
}
} catch (\Exception $e) {
Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
$this->forward("error", "error", "default");
}
}
示例2: submitRecommandAction
public function submitRecommandAction()
{
try {
$globalContext = new \Sb\Context\Model\Context();
$user = $globalContext->getConnectedUser();
// Getting params
$id = $this->getParam("id");
$title = $this->getParam("title");
$message = $this->getParam("message");
$IdAddressee = $this->getParam("IdAddressee");
// Getting book
$book = $this->getBook($id);
if (!empty($title) && !empty($message) && !empty($IdAddressee)) {
$titleVal = trim($title);
$messageVal = trim($message);
$recipients = $IdAddressee;
$recipientsIds = explode(",", $recipients);
foreach ($recipientsIds as $recipientId) {
if (trim($recipientId) != "") {
$recipient = UserDao::getInstance()->get($recipientId);
if ($recipient) {
// adding message in db
$message = new Message();
$message->setSender($user);
$message->setRecipient($recipient);
$message->setIs_read(false);
$message->setTitle($titleVal);
$message->setMessage($messageVal);
MessageDao::getInstance()->add($message);
// Sending email if user authorized it
$userSetting = $recipient->getSetting();
if ($userSetting->getEmailMe() == 'Yes') {
$body = MailHelper::newMessageArrivedBody($user->getUserName());
MailSvc::getInstance()->send($recipient->getEmail(), sprintf(__("%s vous recommande %s ", "s1b"), $user->getUserName(), $book->getTitle()), $body);
}
}
}
}
Flash::addItem(__("Message envoyé.", "s1b"));
HTTPHelper::redirect(Urls::USER_HOME);
} else {
Flash::addItem(__("Au moins l'un des champs n'est pas rempli", "s1b"));
HTTPHelper::redirect(Urls::USER_MAILBOX_RECOMMAND, array("message" => $message, "id" => $id));
}
} catch (\Exception $e) {
Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
$this->forward("error", "error", "default");
}
}