Esempio n. 1
0
 public function formatStoreRecord($record, $model, $store)
 {
     $r = new \GO\Base\Mail\EmailRecipients();
     $r->addRecipient($model->email, $model->name);
     $record['from'] = (string) $r;
     $record['html_signature'] = \GO\Base\Util\String::text_to_html($model->signature);
     $record['plain_signature'] = $model->signature;
     $record['signature_below_reply'] = $model->account->signature_below_reply;
     $record['template_id'] = 0;
     if (\GO::modules()->addressbook) {
         $defaultAccountTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->account_id);
         if ($defaultAccountTemplateModel) {
             $record['template_id'] = $defaultAccountTemplateModel->template_id;
         } else {
             $defaultUserTemplateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id);
             if (!$defaultUserTemplateModel) {
                 $defaultUserTemplateModel = new \GO\Addressbook\Model\DefaultTemplateForAccount();
                 $defaultUserTemplateModel->account_id = $model->account_id;
                 $defaultUserTemplateModel->save();
             }
             $record['template_id'] = $defaultUserTemplateModel->template_id;
         }
     }
     unset($record['signature']);
     return parent::formatStoreRecord($record, $model, $store);
 }
Esempio n. 2
0
 public function formatAttribute($attributeName, $value, $html = false)
 {
     if (!isset($this->columns[$attributeName]['gotype'])) {
         if ($this->customfieldsModel() && substr($attributeName, 0, 4) == 'col_') {
             //if it's a custom field then we create a dummy customfields model.
             $cfModel = $this->_createCustomFieldsRecordFromAttributes();
             //	debug_print_backtrace();
             return $cfModel->formatAttribute($attributeName, $value, $html);
         } else {
             return $value;
         }
     }
     switch ($this->columns[$attributeName]['gotype']) {
         case 'unixdate':
             return \GO\Base\Util\Date::get_timestamp($value, false);
             break;
         case 'unixtimestamp':
             return \GO\Base\Util\Date::get_timestamp($value);
             break;
         case 'textarea':
             if ($html) {
                 return \GO\Base\Util\String::text_to_html($value);
             } else {
                 return $value;
             }
             break;
         case 'date':
             //strtotime hangs a while on parsing 0000-00-00 from the database. There shouldn't be such a date in it but
             //the old system stored dates like this.
             if ($value == "0000-00-00" || empty($value)) {
                 return "";
             }
             $date = new \DateTime($value);
             return $date->format(GO::user() ? GO::user()->completeDateFormat : GO::config()->getCompleteDateFormat());
             //return $value != '0000-00-00' ? \GO\Base\Util\Date::get_timestamp(strtotime($value),false) : '';
             break;
         case 'number':
             $decimals = isset($this->columns[$attributeName]['decimals']) ? $this->columns[$attributeName]['decimals'] : 2;
             return \GO\Base\Util\Number::localize($value, $decimals);
             break;
         case 'boolean':
             //				Formatting as yes no breaks many functions
             //				if($html)
             //					return !empty($value) ? GO::t('yes') : GO::t('no');
             //				else
             return !empty($value);
             break;
         case 'html':
             return $value;
             break;
         case 'phone':
             if ($html) {
                 if (!preg_match('/[a-z]+/i', $value)) {
                     if (preg_match('/^(\\+\\d{2})(\\d{2})(\\d{3})(\\d{4})$/', $value, $matches)) {
                         return $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
                     } elseif (preg_match('/^(\\d*)(\\d{3})(\\d{4})$/', $value, $matches)) {
                         return '(' . $matches[1] . ') ' . $matches[2] . ' ' . $matches[3];
                     }
                 }
             }
             return $value;
             break;
         default:
             if (substr($this->columns[$attributeName]['dbtype'], -3) == 'int') {
                 return $value;
             } else {
                 return $html ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value;
             }
             break;
     }
 }
Esempio n. 3
0
 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;
         }
     }
 }
Esempio n. 4
0
 /**
  * Get the event in HTML markup
  * 
  * @todo Add recurrence info
  * @return string 
  */
 public function toHtml()
 {
     $html = '<table id="event-' . $this->uuid . '">' . '<tr><td>' . \GO::t('subject', 'calendar') . ':</td>' . '<td>' . $this->name . '</td></tr>';
     if ($this->calendar) {
         $html .= '<tr><td>' . \GO::t('calendar', 'calendar') . ':</td>' . '<td>' . $this->calendar->name . '</td></tr>';
     }
     $html .= '<tr><td>' . \GO::t('startsAt', 'calendar') . ':</td>' . '<td>' . \GO\Base\Util\Date::get_timestamp($this->start_time, empty($this->all_day_event)) . '</td></tr>' . '<tr><td>' . \GO::t('endsAt', 'calendar') . ':</td>' . '<td>' . \GO\Base\Util\Date::get_timestamp($this->end_time, empty($this->all_day_event)) . '</td></tr>';
     $html .= '<tr><td>' . \GO::t('status', 'calendar') . ':</td>' . '<td>' . $this->getLocalizedStatus() . '</td></tr>';
     if (!empty($this->location)) {
         $html .= '<tr><td style="vertical-align:top">' . \GO::t('location', 'calendar') . ':</td>' . '<td>' . \GO\Base\Util\String::text_to_html($this->location) . '</td></tr>';
     }
     if (!empty($this->description)) {
         $html .= '<tr><td style="vertical-align:top">' . \GO::t('strDescription') . ':</td>' . '<td>' . \GO\Base\Util\String::text_to_html($this->description) . '</td></tr>';
     }
     if ($this->isRecurring()) {
         $html .= '<tr><td colspan="2">' . $this->getRecurrencePattern()->getAsText() . '</td></tr>';
     }
     //don't calculate timezone offset for all day events
     //		$timezone_offset_string = \GO\Base\Util\Date::get_timezone_offset($this->start_time);
     //
     //		if ($timezone_offset_string > 0) {
     //			$gmt_string = '(\G\M\T +' . $timezone_offset_string . ')';
     //		} elseif ($timezone_offset_string < 0) {
     //			$gmt_string = '(\G\M\T -' . $timezone_offset_string . ')';
     //		} else {
     //			$gmt_string = '(\G\M\T)';
     //		}
     //$html .= '<tr><td colspan="2">&nbsp;</td></tr>';
     $cfRecord = $this->getCustomfieldsRecord();
     if (!empty($cfRecord)) {
         $columns = $cfRecord->getColumns();
         foreach ($columns as $column) {
             if (isset($column['customfield'])) {
                 $colId = $column['customfield']->id;
                 $colId = 'col_' . $colId;
                 $recordAttributes = $cfRecord->getAttributes();
                 if (!empty($recordAttributes[$colId])) {
                     $colValue = $cfRecord->getAttribute($column['customfield']->name);
                     $html .= '<tr><td style="vertical-align:top">' . $column['customfield']->name . '</td>' . '<td>' . $recordAttributes[$colId] . '</td></tr>';
                 }
             }
         }
     }
     $html .= '</table>';
     $stmt = $this->participants();
     if ($stmt->rowCount()) {
         $html .= '<table>';
         $html .= '<tr><td colspan="3"><br /></td></tr>';
         $html .= '<tr><td><b>' . \GO::t('participant', 'calendar') . '</b></td><td><b>' . \GO::t('status', 'calendar') . '</b></td><td><b>' . \GO::t('organizer', 'calendar') . '</b></td></tr>';
         while ($participant = $stmt->fetch()) {
             $html .= '<tr><td>' . $participant->name . '&nbsp;</td><td>' . $participant->statusName . '&nbsp;</td><td>' . ($participant->is_organizer ? \GO::t('yes') : '') . '</td></tr>';
         }
         $html .= '</table>';
     }
     return $html;
 }
Esempio n. 5
0
 /**
  * Returns MIME fields contained in this class's instance as an associative
  * array.
  *
  * @param boolean $html Whether or not to return the HTML body. The alternative is
  * plain text. Defaults to true.
  *
  * @return Array
  */
 public function toOutputArray($html = true, $recipientsAsString = false, $noMaxBodySize = false, $useHtmlSpecialChars = true)
 {
     $from = $this->from->getAddresses();
     $response['notification'] = $this->disposition_notification_to;
     //seen is expensive because it can't be recovered from cache.
     // We'll use the grid to check if a message was seen or not.
     //$response['seen']=$this->seen;
     $from = $this->from->getAddress();
     $response['seen'] = $this->seen;
     $response['forwarded'] = $this->forwarded;
     $response['flagged'] = $this->flagged;
     $response['answered'] = $this->answered;
     $response['from'] = $from['personal'];
     $response['sender'] = $from['email'];
     $response['to'] = $recipientsAsString ? (string) $this->to : $this->_convertRecipientArray($this->to->getAddresses());
     $response['cc'] = $recipientsAsString ? (string) $this->cc : $this->_convertRecipientArray($this->cc->getAddresses());
     $response['bcc'] = $recipientsAsString ? (string) $this->bcc : $this->_convertRecipientArray($this->bcc->getAddresses());
     $response['reply_to'] = (string) $this->reply_to;
     $response['message_id'] = $this->message_id;
     $response['date'] = $this->date;
     $response['to_string'] = (string) $this->to;
     if (!$recipientsAsString && empty($response['to'])) {
         $response['to'][] = array('email' => '', 'personal' => \GO::t('no_recipients', 'email'));
     }
     $response['full_from'] = (string) $this->from;
     $response['priority'] = intval($this->x_priority);
     $response['udate'] = $this->udate;
     $response['date'] = \GO\Base\Util\Date::get_timestamp($this->udate);
     $response['size'] = $this->size;
     $labels = array();
     if (property_exists($this, 'account')) {
         $labels = \GO\Email\Model\Label::model()->getAccountLabels($this->account->id);
     }
     $response['labels'] = array();
     if (!empty($this->labels)) {
         foreach ($this->labels as $label) {
             if (isset($labels[$label])) {
                 $response['labels'][] = array('name' => $labels[$label]->name, 'color' => $labels[$label]->color);
             }
         }
     }
     $response['attachments'] = array();
     $response['zip_of_attachments_url'] = $this->getZipOfAttachmentsUrl();
     $response['inlineAttachments'] = array();
     if ($html) {
         $response['htmlbody'] = $this->getHtmlBody(false, $noMaxBodySize);
     } else {
         $response['plainbody'] = $this->getPlainBody(false, $noMaxBodySize);
     }
     if ($useHtmlSpecialChars) {
         $response['subject'] = htmlspecialchars($this->subject, ENT_COMPAT, 'UTF-8');
     } else {
         $response['subject'] = $this->subject;
     }
     $response['body_truncated'] = $this->bodyIsTruncated();
     $response['smime_signed'] = isset($this->content_type_attributes['smime-type']) && $this->content_type_attributes['smime-type'] == 'signed-data';
     $attachments = $this->getAttachments();
     foreach ($attachments as $att) {
         if ($html && $att->disposition != 'attachment') {
             if ($att->mime == 'text/html') {
                 $htmlPartStr = $att->getData();
                 $htmlPartStr = \GO\Base\Util\String::convertLinks($htmlPartStr);
                 $htmlPartStr = \GO\Base\Util\String::sanitizeHtml($htmlPartStr);
                 $response['htmlbody'] .= '<hr />' . $htmlPartStr;
                 continue;
             } else {
                 if ($att->mime == 'text/plain') {
                     $htmlPartStr = $att->getData();
                     $htmlPartStr = \GO\Base\Util\String::text_to_html($htmlPartStr);
                     $response['htmlbody'] .= '<hr />' . $htmlPartStr;
                     continue;
                 }
             }
         }
         $replaceCount = 0;
         $a = $att->getAttributes();
         //add unique token for detecting precense of inline attachment when we submit the message in handleFormInput
         $a['token'] = md5($a['tmp_file']);
         $a['url'] .= '&amp;token=' . $a['token'];
         if ($html && !empty($a['content_id'])) {
             $response['htmlbody'] = str_replace('cid:' . $a['content_id'], $a['url'], $response['htmlbody'], $replaceCount);
         }
         if ($a['name'] == 'smime.p7s') {
             $response['smime_signed'] = true;
             continue;
         }
         if (!$replaceCount) {
             $response['attachments'][] = $a;
         } else {
             $response['inlineAttachments'][] = $a;
         }
     }
     $response['contact_name'] = "";
     $response['contact_thumb_url'] = GO::config()->host . 'modules/addressbook/themes/Default/images/unknown-person.png';
     $response['blocked_images'] = 0;
     $response['xssDetected'] = false;
     $this->fireEvent('tooutputarray', array(&$response, $this));
     return $response;
 }
Esempio n. 6
0
 public function formatDisplay($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     $prefix = !empty($this->field->prefix) ? $this->field->prefix . ' ' : '';
     $suffix = !empty($this->field->suffix) ? ' ' . $this->field->suffix : '';
     return $prefix . \GO\Base\Util\String::text_to_html($attributes[$key]) . $suffix;
 }
Esempio n. 7
0
<?php

require 'header.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (\GO\Base\Html\Error::checkRequired()) {
        redirect("configFile.php");
    }
}
printHead();
?>
<h1>License terms</h1>
<p>The following license applies to this product:</p>
<div class="cmd">
<?php 
echo \GO\Base\Util\String::text_to_html(file_get_contents('../LICENSE.TXT'));
?>
</div>

<?php 
\GO\Base\Html\Checkbox::render(array('required' => true, 'name' => 'agree', 'value' => 1, 'label' => 'I agree to the terms of the above license.'));
continueButton();
printFoot();
Esempio n. 8
0
 public function render()
 {
     require_once \GO::modules()->site->path . 'widget/twitter/codebird.php';
     $cacheKey = $this->consumerKey . ':' . $this->accessToken . ':' . $this->userTimeLine . ':' . $this->retweets;
     if (!$this->cacheLifeTime || !($tweets = \GO::cache()->get($cacheKey))) {
         //Get authenticated
         \Codebird\Codebird::setConsumerKey($this->consumerKey, $this->consumerSecret);
         $cb = \Codebird\Codebird::getInstance();
         $cb->setToken($this->accessToken, $this->accessTokenSecret);
         //These are our params passed in
         $params = array('screen_name' => $this->screenName, 'count' => $this->limit, 'include_rts' => $this->retweets, 'exclude_replies' => $this->exclude_replies);
         //tweets returned by Twitter
         $tweets = $this->userTimeLine ? (array) $cb->statuses_userTimeline($params) : (array) $cb->statuses_homeTimeline($params);
         \GO::cache()->set($cacheKey, $tweets, $this->cacheLifeTime);
     }
     $html = '';
     foreach ($tweets as $tweet) {
         if (is_object($tweet)) {
             $str = $this->template;
             foreach ($tweet as $key => $value) {
                 if (!is_object($value)) {
                     if ($key == 'text') {
                         $value = \GO\Base\Util\String::text_to_html($value);
                     }
                     if ($key == 'created_at') {
                         $value = strtotime($value);
                         if ($value) {
                             $value = date('Y-m-d G:i', $value);
                         }
                     }
                     $str = str_replace('{' . $key . '}', $value, $str);
                 } else {
                     $value = (array) $value;
                     foreach ($value as $subKey => $subValue) {
                         if (is_string($subValue)) {
                             $str = str_replace('{' . $key . ':' . $subKey . '}', $subValue, $str);
                         }
                     }
                 }
             }
             $html .= $str;
         }
     }
     return $html;
 }
Esempio n. 9
0
 /**
  * This function is used to format the database value for the interface display
  * panel (HTML).
  * 
  * @param string $key Database column 'col_x'
  * @param array $attributes Customfield model attributes
  * @return Mixed 
  */
 public function formatDisplay($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     return \GO\Base\Util\String::text_to_html($attributes[$key]);
 }
Esempio n. 10
0
 /**
  * Render the task row in the PDF
  * 
  * @param \GO\Tasks\Model\Task $task
  */
 private function _renderTaskRow($task)
 {
     $html = '';
     $html .= '<tcpdf method="renderLine" />';
     $html .= '<b><font style="font-size:' . $this->_nameFontSize . 'px">' . \GO\Base\Util\String::text_to_html($task->getAttribute('name', 'html'), true) . '</font></b>';
     if (!empty($task->description)) {
         $html .= '<br /><font style="font-size:' . $this->_descriptionFontSize . 'px">' . $task->getAttribute('description', 'html') . '</font>';
     }
     $this->writeHTML($html, true, false, false, false, 'L');
 }