private function _quoteText($text) { $text = \GO\Base\Util\String::normalizeCrlf($text, "\n"); return '> ' . str_replace("\n", "\n> ", $text); }
/** * A function that checks the consistency with the database. * Generally this is called by r=maintenance/checkDabase */ public function checkDatabase() { //$this->save(); echo "Checking " . (is_array($this->pk) ? implode(',', $this->pk) : $this->pk) . " " . $this->className() . "\n"; flush(); if ($this->aclField() && !$this->isJoinedAclField) { $acl = $this->acl; if (!$acl) { $this->setNewAcl(); } else { $user_id = empty($this->user_id) ? 1 : $this->user_id; $acl->user_id = $user_id; $acl->description = $this->tableName() . '.' . $this->aclField(); $acl->save(); } } if ($this->hasFiles() && GO::modules()->isInstalled('files')) { //ACL must be generated here. $fc = new \GO\Files\Controller\FolderController(); $this->files_folder_id = $fc->checkModelFolder($this); } //normalize crlf foreach ($this->columns as $field => $attr) { if (($attr['gotype'] == 'textfield' || $attr['gotype'] == 'textarea') && !empty($this->_attributes[$field])) { $this->{$field} = \GO\Base\Util\String::normalizeCrlf($this->_attributes[$field], "\n"); } } //fill in empty required attributes that have defaults $defaults = $this->getDefaultAttributes(); foreach ($this->columns as $field => $attr) { if ($attr['required'] && empty($this->{$field}) && isset($defaults[$field])) { $this->{$field} = $defaults[$field]; echo "Setting default value " . $this->className() . ":" . $this->id . " {$field}=" . $defaults[$field] . "\n"; } } if ($this->isModified()) { $this->save(); } }
public function getPlainBody($asHtml = false, $noMaxBodySize = false) { $inlineImages = array(); if (!isset($this->_plainBody)) { $imap = $this->getImapConnection(); $this->_loadBodyParts(); $this->_plainBody = ''; if ($this->_plainParts['text_found']) { //check if we found a plain body foreach ($this->_plainParts['parts'] as $plainPart) { if ($plainPart['type'] == 'text') { if (!empty($this->_plainBody)) { $this->_plainBody .= "\n"; } $maxBodySize = $noMaxBodySize ? false : $this->maxBodySize; $this->_plainBody .= $imap->get_message_part_decoded($this->uid, $plainPart['number'], $plainPart['encoding'], $plainPart['charset'], $this->peek, $maxBodySize); $this->_bodyTruncated = $imap->max_read; } else { if ($asHtml) { //we have to put in this tag and replace it after we convert the text to html. Otherwise this html get's convert into htmlspecialchars. $this->_plainBody .= '{inline_' . count($inlineImages) . '}'; $attachment = $this->getAttachment($plainPart['number']); if ($attachment) { $attachment->content_id = 'go-autogen-' . $plainPart['number']; $inlineImages[] = '<img alt="' . $plainPart['name'] . '" src="cid:' . $attachment->content_id . '" style="display:block;margin:10px 0;" />'; } } } } } } else { foreach ($this->_plainParts['parts'] as $plainPart) { if ($plainPart['type'] != 'text') { if ($asHtml) { $attachment = $this->getAttachment($plainPart['number']); if ($attachment) { $attachment->content_id = 'go-autogen-' . $plainPart['number']; $inlineImages[] = '<img alt="' . $plainPart['name'] . '" src="cid:' . $attachment->content_id . '" style="display:block;margin:10px 0;" />'; } } } } } $this->_plainBody = \GO\Base\Util\String::normalizeCrlf($this->_plainBody); $this->extractUuencodedAttachments($this->_plainBody); if ($asHtml) { $body = $this->_plainBody; $body = \GO\Base\Util\String::text_to_html($body); for ($i = 0, $max = count($inlineImages); $i < $max; $i++) { $body = str_replace('{inline_' . $i . '}', $inlineImages[$i], $body); } return $body; } else { if (empty($this->_plainBody)) { return $this->getHtmlBody(true, $noMaxBodySize); } else { return $this->_plainBody; } } }
public static function read($data, $options = 0) { //parsing of rrule is done by GO. SabreDAV fails on vcalendar 1.0 rrules // if (strpos($data, "VERSION:1.0")) { Sabre\VObject\Component\VCalendar::$propertyMap['RRULE'] = 'Sabre\\VObject\\Property\\Text'; //Workaround funambol bug $data = str_replace("RRULE;ENCODING=QUOTED-PRINTABLE", "RRULE;", $data); } //remove quoted printable line breaks $data = \GO\Base\Util\String::normalizeCrlf($data, "\n"); if (strpos($data, 'QUOTED-PRINTABLE')) { $data = str_replace("=\n", "", $data); } //workaround for funambol bug $data = str_replace('EXDATE: ', 'EXDATE:', $data); $options = \Sabre\VObject\Reader::OPTION_FORGIVING + \Sabre\VObject\Reader::OPTION_IGNORE_INVALID_LINES; return parent::read($data, $options); }
/** * Write this message to a {@link \Swift_InputByteStream}. * @param \Swift_InputByteStream $is */ public function toByteStream(\Swift_InputByteStream $is) { if (empty($this->pkcs12_data) && empty($this->recipcerts)) { //no sign or encrypt parameters. Do parent method. return parent::toByteStream($is); } $this->_saveHeaders(); if (!empty($this->pkcs12_data)) { $this->_doSign(); } if (!empty($this->recipcerts)) { $this->_doEncrypt(); } //$is->write($this->saved_headers); $fp = fopen($this->tempout, 'r'); if (!$fp) { trigger_error('Could not read tempout file', E_USER_ERROR); } while ($line = fgets($fp)) { $line = \GO\Base\Util\String::normalizeCrlf($line); $is->write($line); } fclose($fp); return; }
private function _splitAddress($attributes) { if (isset($attributes['address'])) { $attributes['address_no'] = ''; $attributes['address'] = \GO\Base\Util\String::normalizeCrlf($attributes['address'], "\n"); $lines = explode("\n", $attributes['address']); if (count($lines) > 1) { $attributes['address'] = $lines[0]; $attributes['address_no'] = $lines[1]; } else { $attributes['address'] = $this->_getAddress($lines[0]); $attributes['address_no'] = $this->_getAddressNo($lines[0]); } } return $attributes; }