/** * Log the notification messages in db * * @param string $message * @param string $messageType * @param $user: 0=Guest || 1-n=afGuardUser with id 1-n || instanceof afGuardUser class, 0 is default * @author radu */ public static function log($message, $messageType = 'notification', $user = 0) { if (afStudioUser::getInstance()->isAuthenticated()) { $user = afStudioUser::getInstance()->getUsername(); } else { // Seems like method called not from studio, or user not authenticated $user = '******'; } $afsNotification = new afsNotification(); $afsNotification->setMessage($message); $afsNotification->setMessageType($messageType); $afsNotification->setUser($user); $afsNotification->setIp(afsToolkit::getIP()); $afsNotification->save(); }
/** * Exclude object from result * * @param afsNotification $afsNotification Object to remove from the list of results * * @return afsNotificationQuery The current query, for fluid interface */ public function prune($afsNotification = null) { if ($afsNotification) { $this->addUsingAlias(afsNotificationPeer::ID, $afsNotification->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Render notification * * @param afsNotification $notification * @return string * @author Sergey Startsev */ public static function render(afsNotification $notification) { $row = "{$notification->getCreatedAt('d/m/Y H:i')} {$notification->getUser()}" . " [{$notification->getMessageType()}] {{$notification->getIp()}} {$notification->getMessage()}"; return self::renderAsTag($row); }