Inserts a new page's internal message

@param $imess
@return bool|int
979286
public function insert($imess){
    $cfg =& $this->class_cfg;
    // Get default page if it isn't set
    if ( empty($imess['id_option']) ){
      $perm = new \bbn\user\permissions();
      $imess['id_option'] = $perm->is(self::BBN_DEFAULT_PERM);
    }
    if (
      !empty($imess['id_option']) &&
      !empty($imess['title']) &&
      !empty($imess['content']) &&
      !empty($this->_id_type()) &&
      // Insert the new note
      ($id_note = $this->notes->insert($imess['title'], $imess['content'], $this->_id_type())) &&
      // Insert the new internal message
      $this->db->insert($cfg['table'], [
        $cfg['arch']['imessages']['id_note'] => $id_note,
        $cfg['arch']['imessages']['id_option'] => $imess['id_option'],
        $cfg['arch']['imessages']['id_user'] => $imess['id_user'] ?: NULL,
        $cfg['arch']['imessages']['id_group'] => $imess['id_group'] ?: NULL,
        $cfg['arch']['imessages']['start'] => $imess['start'] ?: NULL,
        $cfg['arch']['imessages']['end'] => $imess['end'] ?: NULL
      ])
    ){
      return $this->db->last_id();
    }
    return false;
  }
1315440
public function addWarning($strMessage)
    {
        $index = count($this->_arrErrorList) + 1;
        $this->_arrErrorList[$index]['command'] = "WARN";
        $this->_arrErrorList[$index]['message'] = $strMessage;
    }
631998
public function add(ApnsPHP_Message $message)
	{
		$sMessagePayload = $message->getPayload();
		$nRecipients = $message->getRecipientsNumber();

		$nMessageQueueLen = count($this->_aMessageQueue);
		for ($i = 0; $i < $nRecipients; $i++) {
			$nMessageID = $nMessageQueueLen + $i + 1;
			$this->_aMessageQueue[$nMessageID] = array(
				'MESSAGE' => $message,
				'BINARY_NOTIFICATION' => $this->_getBinaryNotification(
					$message->getRecipient($i),
					$sMessagePayload,
					$nMessageID,
					$message->getExpiry()
				),
				'ERRORS' => array()
			);
		}
	}
288482
private function sendEmail($to = '', $subject = '', $messageText = '')
    {
        $transport = $this->getServiceLocator()->get('mail.transport');
        $message = new Message();
            
        $message->addTo($to)
                ->addFrom($this->getOptions()->getSenderEmailAdress())
                ->setSubject($subject)
                ->setBody($messageText);

        $transport->send($message);
    }
530884
protected function send($text)
    {
        $this->logger->debug('Sending: ' . $text);
        $this->lastCommandId = uniqid(__CLASS__);
        $action = new \PAMI\Message\Action\AGIAction($this->channel, $text, $this->lastCommandId);
        $this->lastAgiResult = false;
        $response = $this->pamiClient->send($action);
        if (!$response->isSuccess()) {
            throw new \PAGI\Exception\ChannelDownException($response->getMessage());
        }
        while ($this->lastAgiResult === false) {
            $this->pamiClient->process();
            usleep(1000);
        }
        return $this->getResultFromResultString($this->lastAgiResult);
    }
428472
public int add(final Message msg, boolean resize) {
        if(msg == null) return 0;
        if(index >= messages.length) {
            if(!resize)
                return 0;
            resize();
        }
        messages[index++]=msg;
        return 1;
    }
422272
public static function __($message, $textdomain=false) {
        global $CFG, $PDOX, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD, $TSUGI_TRANSLATE;
    
        // If we have been asked to do some translation
        if ( isset($CFG->checktranslation) && $CFG->checktranslation && isset($PDOX) ) 
        {
            $string_sha = U::lti_sha256($message);
            $domain = $textdomain;
            if ( ! $domain ) $domain = textdomain(NULL);
            if ( $domain ) {
                $stmt = $PDOX->queryReturnError("INSERT INTO {$CFG->dbprefix}tsugi_string
                        (domain, string_text, string_sha256) VALUES ( :DOM, :TEXT, :SHA)
                        ON DUPLICATE KEY UPDATE updated_at = NOW()",
                    array(
                        ':DOM' => $domain,
                        ':TEXT' => $message,
                        ':SHA' => $string_sha
                    )
                );
            }
        }

        // Setup Text domain late...
        if ( $TSUGI_LOCALE_RELOAD ) {
            self::setupTextDomain();
        }

        if ( isset($TSUGI_TRANSLATE) && $TSUGI_TRANSLATE ) {
            $retval = $TSUGI_TRANSLATE->trans($message);
            // error_log("DOM=$TSUGI_LOCALE msg=$message trans=$retval");
            return $retval;
        }

        if ( ! function_exists('gettext')) return $message;
        if ( $textdomain === false ) {
            return gettext($message);
        } else {
            return dgettext($textdomain, $message);
        }
    }
1344096
public function put($message)
    {
        if (!\msg_send($this->queue, $this->msg_type, $message, $this->serialize_needed, $this->block_send, $err) === true) {
            throw new \RuntimeException($err);
        }

        return true;
    }
685661
public function postMessage($sender, $recipient, $message)
    {
        if ($this->maxMessages) {
            $statement = $this->connection->prepare(
                'SELECT COUNT(*) FROM "phergie-plugin-tell"
                    WHERE "recipient" = ?;'
            );
            $statement->execute([ $recipient ]);

            if ($statement->fetchColumn(0) >= $this->maxMessages) {
                return false;
            }
        }

        $this->connection->prepare(
            'INSERT INTO "phergie-plugin-tell"
                ("sender", "recipient", "message")
                VALUES (?, ?, ?);'
        )->execute([ $sender, $recipient, $message ]);

        return true;
    }
705219
public function add_message($message, $class="notifyproblem", $align='center') {
        global $SESSION;

        if (empty($SESSION->lesson_messages) || !is_array($SESSION->lesson_messages)) {
            $SESSION->lesson_messages = array();
            $SESSION->lesson_messages[$this->properties->id] = array();
        } else if (!array_key_exists($this->properties->id, $SESSION->lesson_messages)) {
            $SESSION->lesson_messages[$this->properties->id] = array();
        }

        $SESSION->lesson_messages[$this->properties->id][] = array($message, $class, $align);

        return true;
    }
1009665
public function write($message)
    {
        $written = false;

        if ($this->output_allowed) {
            $written = error_log($message);
        }

        return $written;
    }
878922
public function getInsertString($includeText = true)
    {
        $statement = "";

        if (!$this->insert) {
            return $statement;
        }

        if ($this->isInto) {
            $statement .= $this->getOptionsString(true) . 'INTO ';
        } else {
            $statement .= $this->getOptionsString(true);
        }

        $statement .= $this->getInsert();

        if ($includeText && $statement) {
            $statement = "INSERT " . $statement;
        }

        return $statement;
    }
789445
public static function mail($text, $subject = null, $to = null)
    {
        if (!self::isDebug()) {
            return false;
        }

        $_this = self::i();

        if (empty($subject)) {
            $subject = self::$_config['mail']['subject'];
        }

        if (empty($to)) {
            $to = isset(self::$_config['mail']['to'])
                ? self::$_config['mail']['to']
                : 'jbdump@' . $_SERVER['HTTP_HOST'];
        }

        if (is_array($to)) {
            $to = implode(', ', $to);
        }

        // message
        $message   = array();
        $message[] = '<html><body>';
        $message[] = '<p><b>JBDump mail from '
            . '<a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>'
            . '</b></p>';

        $message[] = '<p><b>Date</b>: ' . date(DATE_RFC822, time()) . '</p>';
        $message[] = '<p><b>IP</b>: ' . self::getClientIP() . '</p>';
        $message[] = '<b>Debug message</b>: <pre>' . print_r($text, true) . '</pre>';
        $message[] = '</body></html>';
        $message   = wordwrap(implode(PHP_EOL, $message), 70);

        // To send HTML mail, the Content-type header must be set
        $headers   = array();
        $headers[] = 'MIME-Version: 1.0';
        $headers[] = 'Content-type: text/html; charset=utf-8';
        $headers[] = 'To: ' . $to;
        $headers[] = 'From: JBDump debug <jbdump@' . $_SERVER['HTTP_HOST'] . '>';
        $headers[] = 'X-Mailer: JBDump v' . self::VERSION;
        $headers   = implode("\r\n", $headers);

        $result = mail($to, $subject, $message, $headers);
        if (self::$_config['mail']['log']) {
            $_this->log(
                array(
                    'email'   => $to,
                    'subject' => $subject,
                    'message' => $message,
                    'headers' => $headers,
                    'result'  => $result
                ),
                'JBDump::mail'
            );
        }

        return $result;
    }
151539
public function insert(?IBinaryNode $node) {
        if (!$node instanceof BinarySearchNode) {
            return false;
        }
        if (null === $this->getRoot()) {
            $this->setRoot($node);
            $this->size++;
            return true;
        }
        /** @var BinarySearchNode $current */
        $current = $this->getRoot();
        if (Comparator::lessThan($node->getValue(), $current->getValue())) {
            while (null !== $current->getLeft()) {
                $current = $current->getLeft();
            }
            $current->setLeft($node);
            $this->size++;
            return true;
        } else if (Comparator::greaterThan($node->getValue(), $current->getValue())) {
            while (null !== $current->getRight()) {
                $current = $current->getRight();
            }
            $current->setRight($node);
            $this->size++;
            return true;
        }
        return false;
    }
1220824
private function checkHeadersForInjection(\sb\Email $email)
    {

        if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) {
            return true;
        }

        return false;
    }
926498
public function reply ($message) {
		// Make sure we actually have a text to reply to
		if (!$this->inbound_message) {
			return false;
		}

		return $this->sendText($this->from, $this->to, $message);
	}
1110434
public function addMessage( $message, $instance = null )
	{
		$sql = <<<SQL
INSERT INTO
	i18n_messages
SET
	message 	= ?,
	instance	= ?
SQL;

		return $this->Execute( $sql, array(
		                                  'tag' => 'Add message',
		                                  $message,
		                                  $instance
		                             ) );
	}