本文整理汇总了PHP中Tinebase_Translation::dateToStringInTzAndLocaleFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Translation::dateToStringInTzAndLocaleFormat方法的具体用法?PHP Tinebase_Translation::dateToStringInTzAndLocaleFormat怎么用?PHP Tinebase_Translation::dateToStringInTzAndLocaleFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Translation
的用法示例。
在下文中一共展示了Tinebase_Translation::dateToStringInTzAndLocaleFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($certificate, $dontSkip = FALSE)
{
$config = Tinebase_Config::getInstance()->get('modssl');
if (is_object($config)) {
$this->casfile = $config->casfile;
$this->crlspath = $config->crlspath;
}
$this->status = array('isValid' => true, 'errors' => array());
$this->certificate = self::_fixPemCertificate($certificate);
$c = openssl_x509_parse($this->certificate);
// define certificate properties
$this->serialNumber = $c['serialNumber'];
$this->version = $c['version'];
$this->subject = $c['subject'];
$this->cn = $c['subject']['CN'];
$this->issuer = $c['issuer'];
$this->issuerCn = $c['issuer']['CN'];
$this->hash = $this->_calcHash();
// $dateTimezone = new DateTimeZone(Tinebase_Core::getUserTimezone());
// $locale = new Zend_Locale($_translation->getAdapter()->getLocale());
// Date valid from
$this->validFrom = Tinebase_Translation::dateToStringInTzAndLocaleFormat(new Tinebase_DateTime($c['validFrom_time_t']));
// Date valid to
$this->validTo = Tinebase_Translation::dateToStringInTzAndLocaleFormat(new Tinebase_DateTime($c['validTo_time_t']));
$this->_parsePurpose($c['purposes']);
$this->_parseExtensions($c['extensions']);
if (strtolower($this->casfile) != 'skip') {
$this->_validityCheck();
// skip validation, we trust the server's result
}
if (strtolower($this->crlspath) != 'skip' | $dontSkip) {
$this->_testRevoked();
// skip test,
}
}
示例2: _onAfterExportRecords
/**
* do the rendering
*
* @param array $result
*/
protected function _onAfterExportRecords($result)
{
$templateProcessor = $this->getDocument();
// first step: generate layout
$dayblock = $templateProcessor->cloneBlock('DAYBLOCK', 1, false);
$seperator = $templateProcessor->cloneBlock('SEPARATOR', 1, false);
$dayCount = count($this->_daysEventMatrix);
$daysblock = $dayCount ? $dayblock : '';
for ($i = 1; $i < $dayCount; $i++) {
$daysblock .= $seperator;
$daysblock .= $dayblock;
}
$templateProcessor->replaceBlock('DAYBLOCK', $daysblock);
$templateProcessor->deleteBlock('SEPARATOR');
// second step: render events
foreach ($this->_daysEventMatrix as $dayString => $dayEvents) {
$this->processDay($dayString, $dayEvents);
}
// third step: render generics
if ($this->_from instanceof Tinebase_DateTime) {
$templateProcessor->setValue('from', Tinebase_Translation::dateToStringInTzAndLocaleFormat($this->_from, null, null, $this->_config->dateformat));
}
if ($this->_until instanceof Tinebase_DateTime) {
$templateProcessor->setValue('until', Tinebase_Translation::dateToStringInTzAndLocaleFormat($this->_until->getClone()->subSecond(1), null, null, $this->_config->dateformat));
}
parent::_onAfterExportRecords($result);
}
示例3: testExportCsv
/**
* test csv export
*
* @return void
*
* @see 0007242: add customer address fields to lead csv export
*/
public function testExportCsv()
{
$this->_filename = $this->_instance->generate();
$export = file_get_contents($this->_filename);
$translate = Tinebase_Translation::getTranslation('Crm');
$defaultContainerId = Tinebase_Container::getInstance()->getDefaultContainer('Crm')->getId();
$this->assertContains('"lead_name","leadstate_id","Leadstate","leadtype_id","Leadtype","leadsource_id","Leadsource","container_id","start"' . ',"description","end","turnover","probableTurnover","probability","end_scheduled","resubmission_date","tags","attachments","notes","seq","tags",' . '"CUSTOMER-org_name","CUSTOMER-n_family","CUSTOMER-n_given","CUSTOMER-adr_one_street","CUSTOMER-adr_one_postalcode","CUSTOMER-adr_one_locality",' . '"CUSTOMER-adr_one_countryname","CUSTOMER-tel_work","CUSTOMER-tel_cell","CUSTOMER-email",' . '"PARTNER","RESPONSIBLE","TASK"', $export, 'headline wrong: ' . substr($export, 0, 360));
$this->assertContains('"PHPUnit","1","' . $translate->_('open') . '","1","' . $translate->_('Customer') . '","1","' . $translate->_('Market') . '","' . $defaultContainerId . '"', $export, 'data #1 wrong');
$this->assertContains('"Metaways Infosystems GmbH","Kneschke","Lars","Pickhuben 4","24xxx","Hamburg","DE","+49TELWORK","+49TELCELL","unittests@tine20.org"' . ',"","","phpunit: crm test task"', $export, 'relations wrong');
$dateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat(NULL, NULL, NULL, 'date');
$this->assertContains($dateString, $export, 'note date wrong');
}
示例4: testExportCsv
/**
* test csv export
*
* @return void
*/
public function testExportCsv()
{
$csvFilename = $this->_instance->generate();
$export = file_get_contents($csvFilename);
$translate = Tinebase_Translation::getTranslation('Crm');
$defaultContainerId = Tinebase_Container::getInstance()->getDefaultContainer('Crm')->getId();
$this->assertContains('"lead_name","leadstate_id","Leadstate","leadtype_id","Leadtype","leadsource_id","Leadsource","container_id","start"' . ',"description","end","turnover","probableTurnover","probability","end_scheduled","tags","notes","tags","CUSTOMER","PARTNER","RESPONSIBLE","TASK"', $export, 'headline wrong');
$this->assertContains('"PHPUnit","1","' . $translate->_('open') . '","1","' . $translate->_('Customer') . '","1","' . $translate->_('Market') . '","' . $defaultContainerId . '"', $export, 'data #1 wrong');
$this->assertContains('"Kneschke, Lars","","phpunit: crm test task"', $export, 'relations wrong');
$dateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat(NULL, NULL, NULL, 'date');
$this->assertContains($dateString, $export, 'note date wrong');
unlink($csvFilename);
}
示例5: _addActivities
/**
* add notes and activities to pdf
*
* @param array $record
* @param Tinebase_Record_RecordSet $_notes
*/
protected function _addActivities($record, $_notes)
{
$translate = Tinebase_Translation::getTranslation('Tinebase');
if (!empty($_notes)) {
$noteTypes = Tinebase_Notes::getInstance()->getNoteTypes();
$record[] = array('label' => $translate->_('Activities'), 'type' => 'separator');
foreach ($_notes as $note) {
if ($note instanceof Tinebase_Model_Note) {
$noteArray = $note->toArray();
$noteText = strlen($note->note) > 100 ? substr($note->note, 0, 99) . '...' : $note->note;
$noteType = $noteTypes[$noteTypes->getIndexById($note->note_type_id)];
$time = Tinebase_Translation::dateToStringInTzAndLocaleFormat($note->creation_time);
$createdBy = '(' . $noteArray['created_by'] . ')';
$record[] = array('label' => $time, 'type' => 'multiRow', 'value' => array(array('icon' => '/' . $noteType->icon), $noteText, $createdBy));
}
}
}
return $record;
}
示例6: getTranslatedValue
/**
* gets translated value
*
* NOTE: This is needed for values like Yes/No, Datetimes, etc.
*
* @param string $_field
* @param mixed $_value
* @param Zend_Translate $_translation
* @param string $_timezone
* @return string
*/
public static function getTranslatedValue($_field, $_value, $_translation, $_timezone)
{
if ($_value instanceof Tinebase_DateTime) {
$locale = new Zend_Locale($_translation->getAdapter()->getLocale());
return Tinebase_Translation::dateToStringInTzAndLocaleFormat($_value, $_timezone, $locale, 'datetime', true);
}
switch ($_field) {
case 'transp':
return $_value && $_value == Calendar_Model_Event::TRANSP_TRANSP ? $_translation->_('No') : $_translation->_('Yes');
case 'organizer':
if (!$_value instanceof Addressbook_Model_Contact) {
$organizer = Addressbook_Controller_Contact::getInstance()->getMultiple($_value, TRUE)->getFirstRecord();
}
return $organizer instanceof Addressbook_Model_Contact ? $organizer->n_fileas : '';
case 'rrule':
if ($_value) {
$rrule = $_value instanceof Calendar_Model_Rrule ? $_value : new Calendar_Model_Rrule($_value);
return $rrule->getTranslatedRule($_translation);
}
default:
return $_value;
}
}
示例7: sendNotificationToAttender
/**
* send notification to a single attender
*
* @param Calendar_Model_Attender $_attender
* @param Calendar_Model_Event $_event
* @param Tinebase_Model_FullAccount $_updater
* @param Sting $_action
* @param String $_notificationLevel
* @param array $_updates
* @param array $attachs
* @return void
*/
public function sendNotificationToAttender($_attender, $_event, $_updater, $_action, $_notificationLevel, $_updates = NULL, $attachs = FALSE)
{
try {
// find organizer account
if ($_event->organizer && $_event->resolveOrganizer()->account_id) {
$organizer = Tinebase_User::getInstance()->getFullUserById($_event->resolveOrganizer()->account_id);
} else {
// use creator as organizer
$organizer = Tinebase_User::getInstance()->getFullUserById($_event->created_by);
}
// get prefered language, timezone and notification level
$prefUser = $_attender->getUserAccountId();
$locale = Tinebase_Translation::getLocale(Tinebase_Core::getPreference()->getValueForUser(Tinebase_Preference::LOCALE, $prefUser ? $prefUser : $organizer->getId()));
$timezone = Tinebase_Core::getPreference()->getValueForUser(Tinebase_Preference::TIMEZONE, $prefUser ? $prefUser : $organizer->getId());
$translate = Tinebase_Translation::getTranslation('Calendar', $locale);
// check if user wants this notification
$sendLevel = $prefUser ? Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::NOTIFICATION_LEVEL, $prefUser) : 100;
$sendOnOwnActions = $prefUser ? Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::SEND_NOTIFICATION_OF_OWN_ACTIONS, $prefUser) : 0;
// NOTE: organizer gets mails unless she set notificationlevel to NONE
if ($prefUser == $_updater->getId() && !$sendOnOwnActions || $sendLevel < $_notificationLevel && ($prefUser != $organizer->getId() || $sendLevel == self::NOTIFICATION_LEVEL_NONE)) {
return;
}
// get date strings
$startDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_event->dtstart, $timezone, $locale);
$endDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_event->dtend, $timezone, $locale);
switch ($_action) {
case 'alarm':
$messageSubject = sprintf($translate->_('Alarm for event "%1$s" at %2$s'), $_event->summary, $startDateString);
break;
case 'created':
$messageSubject = sprintf($translate->_('Event invitation "%1$s" at %2$s'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case 'deleted':
$messageSubject = sprintf($translate->_('Event "%1$s" at %2$s has been canceled'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_CANCEL;
break;
case 'changed':
switch ($_notificationLevel) {
case self::NOTIFICATION_LEVEL_EVENT_RESCHEDULE:
$messageSubject = sprintf($translate->_('Event "%1$s" at %2$s has been rescheduled'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case self::NOTIFICATION_LEVEL_EVENT_UPDATE:
$messageSubject = sprintf($translate->_('Event "%1$s" at %2$s has been updated'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case self::NOTIFICATION_LEVEL_ATTENDEE_STATUS_UPDATE:
if (!empty($_updates['attendee']) && !empty($_updates['attendee']['toUpdate']) && count($_updates['attendee']['toUpdate']) == 1) {
// single attendee status update
$attender = $_updates['attendee']['toUpdate'][0];
switch ($attender->status) {
case Calendar_Model_Attender::STATUS_ACCEPTED:
$messageSubject = sprintf($translate->_('%1$s accepted event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_DECLINED:
$messageSubject = sprintf($translate->_('%1$s declined event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_TENTATIVE:
$messageSubject = sprintf($translate->_('Tentative response from %1$s for event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_NEEDSACTION:
$messageSubject = sprintf($translate->_('No response from %1$s for event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
}
} else {
$messageSubject = sprintf($translate->_('Attendee changes for event "%1$s" at %2$s'), $_event->summary, $startDateString);
}
// we don't send iMIP parts to organizers with an account cause event is already up to date
if ($_event->organizer && !$_event->resolveOrganizer()->account_id) {
$method = Calendar_Model_iMIP::METHOD_REPLY;
}
break;
}
break;
default:
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " unknown action '{$_action}'");
}
break;
}
$view = new Zend_View();
$view->setScriptPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
$view->translate = $translate;
$view->timezone = $timezone;
$view->event = $_event;
$view->updater = $_updater;
$view->updates = $_updates;
//.........这里部分代码省略.........
示例8: generate
/**
* create contact pdf
*
* @param Addressbook_Model_Contact $_contact contact data
*
* @return string the contact pdf
*/
public function generate(Addressbook_Model_Contact $_contact)
{
$locale = Tinebase_Core::get('locale');
$translate = Tinebase_Translation::getTranslation('Addressbook');
// set user timezone
$_contact->setTimezone(Tinebase_Core::getUserTimezone());
$contactFields = array(array('label' => $translate->_('Business Contact Data'), 'type' => 'separator'), array('label' => $translate->_('Organisation / Unit'), 'type' => 'singleRow', 'value' => array(array('org_name', 'org_unit')), 'glue' => ' / '), array('label' => $translate->_('Business Address'), 'type' => 'multiRow', 'value' => array('adr_one_street', 'adr_one_street2', array('adr_one_postalcode', 'adr_one_locality'), array('adr_one_region', 'adr_one_countryname'))), array('label' => $translate->_('Email'), 'value' => array('email')), array('label' => $translate->_('Telephone Work'), 'value' => array('tel_work')), array('label' => $translate->_('Telephone Cellphone'), 'value' => array('tel_cell')), array('label' => $translate->_('Telephone Car'), 'value' => array('tel_car')), array('label' => $translate->_('Telephone Fax'), 'value' => array('tel_fax')), array('label' => $translate->_('Telephone Page'), 'value' => array('tel_pager')), array('label' => $translate->_('URL'), 'value' => array('url')), array('label' => $translate->_('Role'), 'value' => array('role')), array('label' => $translate->_('Room'), 'value' => array('room')), array('label' => $translate->_('Assistant'), 'value' => array('assistent')), array('label' => $translate->_('Assistant Telephone'), 'value' => array('tel_assistent')), array('label' => $translate->_('Private Contact Data'), 'type' => 'separator'), array('label' => $translate->_('Private Address'), 'type' => 'multiRow', 'value' => array('adr_two_street', 'adr_two_street2', array('adr_two_postalcode', 'adr_two_locality'), array('adr_two_region', 'adr_two_countryname'))), array('label' => $translate->_('Email Home'), 'value' => array('email_home')), array('label' => $translate->_('Telephone Home'), 'value' => array('tel_home')), array('label' => $translate->_('Telephone Cellphone Private'), 'value' => array('tel_cell_private')), array('label' => $translate->_('Telephone Fax Home'), 'value' => array('tel_fax_home')), array('label' => $translate->_('URL Home'), 'value' => array('url_home')), array('label' => $translate->_('Other Data'), 'type' => 'separator'), array('label' => $translate->_('Birthday'), 'value' => array('bday')), array('label' => $translate->_('Job Title'), 'value' => array('title')));
try {
$tineImage = Addressbook_Controller::getInstance()->getImage($_contact->getId());
Tinebase_ImageHelper::resize($tineImage, 160, 240, Tinebase_ImageHelper::RATIOMODE_PRESERVANDCROP);
$tmpPath = tempnam(Tinebase_Core::getTempDir(), 'tine20_tmp_gd');
$tmpPath .= $tineImage->getImageExtension();
file_put_contents($tmpPath, $tineImage->blob);
$contactPhoto = Zend_Pdf_Image::imageWithPath($tmpPath);
unlink($tmpPath);
} catch (Exception $e) {
// gif images are not supported yet by zf (or some other error)
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $e->__toString());
}
$contactPhoto = NULL;
}
// build title (name) + subtitle + icon
$nameFields = array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix');
$titleArray = array();
foreach ($nameFields as $nameField) {
if (!empty($_contact[$nameField])) {
$titleArray[] = $_contact[$nameField];
}
}
$title = implode(' ', $titleArray);
$subtitle = $_contact->org_name;
$titleIcon = "/images/oxygen/32x32/apps/system-users.png";
// add data to array
$record = array();
foreach ($contactFields as $fieldArray) {
if (!isset($fieldArray['type']) || $fieldArray['type'] !== 'separator') {
$values = array();
foreach ($fieldArray['value'] as $valueFields) {
$content = array();
if (is_array($valueFields)) {
$keys = $valueFields;
} else {
$keys = array($valueFields);
}
foreach ($keys as $key) {
if ($_contact->{$key} instanceof Tinebase_DateTime) {
$content[] = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_contact->{$key}, NULL, NULL, 'date');
} elseif (!empty($_contact->{$key})) {
if (preg_match("/countryname/", $key)) {
$content[] = Zend_Locale::getTranslation($_contact->{$key}, 'country', $locale);
} else {
$content[] = $_contact->{$key};
}
}
}
if (!empty($content)) {
$glue = isset($fieldArray['glue']) ? $fieldArray['glue'] : " ";
$values[] = implode($glue, $content);
}
}
if (!empty($values)) {
$record[] = array('label' => $fieldArray['label'], 'type' => isset($fieldArray['type']) ? $fieldArray['type'] : 'singleRow', 'value' => sizeof($values) === 1 ? $values[0] : $values);
}
} elseif (isset($fieldArray['type']) && $fieldArray['type'] === 'separator') {
$record[] = $fieldArray;
}
}
// add notes
$record = $this->_addActivities($record, $_contact->notes);
//print_r($record);
// tags
$tags = isset($_contact['tags']) ? $_contact['tags'] : array();
// generate pdf
$this->generatePdf($record, $title, $subtitle, $tags, $_contact->note, $titleIcon, $contactPhoto, array(), FALSE);
}
示例9: doSendNotifications
/**
* creates notification text and sends out notifications
*
* @todo:
* - add changes to mail body
* - find updater in addressbook to notify him
* - add products?
* - add notification levels
*
* @param Crm_Model_Lead $_lead
* @param Tinebase_Model_FullUser $_updater
* @param string $_action {created|changed}
* @param Crm_Model_Lead $_oldLead
* @return void
*/
protected function doSendNotifications(Crm_Model_Lead $_lead, Tinebase_Model_FullUser $_updater, $_action, $_oldLead = NULL)
{
$sendOnOwnActions = Tinebase_Core::getPreference('Crm')->getValue(Crm_Preference::SEND_NOTIFICATION_OF_OWN_ACTIONS);
if (!$sendOnOwnActions) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Sending of Lead notifications disabled by user.');
return;
}
$view = new Zend_View();
$view->setScriptPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
$translate = Tinebase_Translation::getTranslation('Crm');
$view->updater = $_updater;
$view->lead = $_lead;
$settings = Crm_Controller::getInstance()->getConfigSettings();
$view->leadState = $settings->getOptionById($_lead->leadstate_id, 'leadstates');
$view->leadType = $settings->getOptionById($_lead->leadtype_id, 'leadtypes');
$view->leadSource = $settings->getOptionById($_lead->leadsource_id, 'leadsources');
$view->container = Tinebase_Container::getInstance()->getContainerById($_lead->container_id);
if (isset($_lead->relations)) {
$customer = $_lead->relations->filter('type', 'CUSTOMER')->getFirstRecord();
if ($customer) {
$view->customer = $customer->related_record->n_fn;
if (isset($customer->related_record->org_name)) {
$view->customer .= ' (' . $customer->related_record->org_name . ')';
}
}
}
if ($_lead->start instanceof DateTime) {
$view->start = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_lead->start, NULL, NULL, 'date');
} else {
$view->start = '-';
}
if ($_lead->end instanceof DateTime) {
$view->leadEnd = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_lead->end, NULL, NULL, 'date');
} else {
$view->leadEnd = '-';
}
if ($_lead->end_scheduled instanceof DateTime) {
$view->ScheduledEnd = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_lead->end_scheduled, NULL, NULL, 'date');
} else {
$view->ScheduledEnd = '-';
}
$view->lang_customer = $translate->_('Customer');
$view->lang_state = $translate->_('State');
$view->lang_type = $translate->_('Role');
$view->lang_source = $translate->_('Source');
$view->lang_start = $translate->_('Start');
$view->lang_scheduledEnd = $translate->_('Scheduled end');
$view->lang_end = $translate->_('End');
$view->lang_turnover = $translate->_('Turnover');
$view->lang_probability = $translate->_('Probability');
$view->lang_folder = $translate->_('Folder');
$view->lang_updatedBy = $translate->_('Updated by');
$view->lang_updatedFields = $translate->_('Updated Fields:');
$view->lang_updatedFieldMsg = $translate->_('%s changed from %s to %s.');
$plain = $view->render('newLeadPlain.php');
$html = $view->render('newLeadHtml.php');
if ($_action == 'changed') {
$subject = sprintf($translate->_('Lead %s has been changed'), $_lead->lead_name);
} else {
if ($_action == 'deleted') {
$subject = sprintf($translate->_('Lead %s has been deleted'), $_lead->lead_name);
} else {
$subject = sprintf($translate->_('Lead %s has been created'), $_lead->lead_name);
}
}
// create pdf
try {
$pdfGenerator = new Crm_Export_Pdf();
$pdfGenerator->generate($_lead);
$attachment = array('rawdata' => $pdfGenerator->render(), 'filename' => $_lead->lead_name . '.pdf');
} catch (Zend_Pdf_Exception $e) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' error creating pdf: ' . $e->__toString());
$attachment = NULL;
}
$recipients = $this->_getNotificationRecipients($_lead);
// send notification to updater in any case!
if (!in_array($_updater->contact_id, $recipients->getArrayOfIds())) {
$updaterContact = Addressbook_Controller_Contact::getInstance()->get($_updater->contact_id);
$recipients->addRecord($updaterContact);
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . $plain);
}
try {
Tinebase_Notification::getInstance()->send(Tinebase_Core::getUser(), $recipients, $subject, $plain, $html, array($attachment));
//.........这里部分代码省略.........
示例10: _getSubject
/**
* get notification subject and method
*
* @param Calendar_Model_Event $_event
* @param string $_notificationLevel
* @param string $_action
* @param array $_updates
* @param string $timezone
* @param Zend_Locale $locale
* @param Zend_Translate $translate
* @param atring $method
* @param Calendar_Model_Attender
* @return string
* @throws Tinebase_Exception_UnexpectedValue
*/
protected function _getSubject($_event, $_notificationLevel, $_action, $_updates, $timezone, $locale, $translate, &$method, Calendar_Model_Attender $attender)
{
$startDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_event->dtstart, $timezone, $locale);
$endDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_event->dtend, $timezone, $locale);
switch ($_action) {
case 'alarm':
$messageSubject = sprintf($translate->_('Alarm for event "%1$s" at %2$s'), $_event->summary, $startDateString);
break;
case 'created':
$messageSubject = sprintf($translate->_('Event invitation "%1$s" at %2$s'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case 'booked':
if ($attender->user_type !== Calendar_Model_Attender::USERTYPE_RESOURCE) {
throw new Tinebase_Exception_UnexpectedValue('not a resource');
}
$resource = Calendar_Controller_Resource::getInstance()->get($attender->user_id);
$messageSubject = sprintf($translate->_('Resource "%1$s" was booked for "%2$s" at %3$s'), $resource->name, $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case 'deleted':
$messageSubject = sprintf($translate->_('Event "%1$s" at %2$s has been canceled'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_CANCEL;
break;
case 'changed':
switch ($_notificationLevel) {
case self::NOTIFICATION_LEVEL_EVENT_RESCHEDULE:
if (isset($_updates['dtstart']) || array_key_exists('dtstart', $_updates)) {
$oldStartDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_updates['dtstart'], $timezone, $locale);
$messageSubject = sprintf($translate->_('Event "%1$s" has been rescheduled from %2$s to %3$s'), $_event->summary, $oldStartDateString, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
}
// fallthrough if dtstart didn't change
// fallthrough if dtstart didn't change
case self::NOTIFICATION_LEVEL_EVENT_UPDATE:
$messageSubject = sprintf($translate->_('Event "%1$s" at %2$s has been updated'), $_event->summary, $startDateString);
$method = Calendar_Model_iMIP::METHOD_REQUEST;
break;
case self::NOTIFICATION_LEVEL_ATTENDEE_STATUS_UPDATE:
if (!empty($_updates['attendee']) && !empty($_updates['attendee']['toUpdate']) && count($_updates['attendee']['toUpdate']) == 1) {
// single attendee status update
$attender = $_updates['attendee']['toUpdate']->getFirstRecord();
switch ($attender->status) {
case Calendar_Model_Attender::STATUS_ACCEPTED:
$messageSubject = sprintf($translate->_('%1$s accepted event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_DECLINED:
$messageSubject = sprintf($translate->_('%1$s declined event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_TENTATIVE:
$messageSubject = sprintf($translate->_('Tentative response from %1$s for event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
case Calendar_Model_Attender::STATUS_NEEDSACTION:
$messageSubject = sprintf($translate->_('No response from %1$s for event "%2$s" at %3$s'), $attender->getName(), $_event->summary, $startDateString);
break;
}
} else {
$messageSubject = sprintf($translate->_('Attendee changes for event "%1$s" at %2$s'), $_event->summary, $startDateString);
}
// we don't send iMIP parts to organizers with an account cause event is already up to date
if ($_event->organizer && !$_event->resolveOrganizer()->account_id) {
$method = Calendar_Model_iMIP::METHOD_REPLY;
}
break;
}
break;
default:
$messageSubject = 'unknown action';
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " unknown action '{$_action}'");
}
break;
}
if ($attender->user_type === Calendar_Model_Attender::USERTYPE_RESOURCE) {
$messageSubject = '[' . $translate->_('Resource Management') . '] ' . $messageSubject;
}
return $messageSubject;
}
示例11: testImport
/**
* test import
*
* @see 0006226: Data truncated for column 'adr_two_lon'
*
* TODO move import test to separate test class
*/
public function testImport()
{
$this->_testNeedsTransaction();
$result = $this->_importHelper();
$this->assertEquals(2, $result['totalcount'], 'dryrun should detect 2 for import.' . print_r($result, TRUE));
$this->assertEquals(0, $result['failcount'], 'Import failed for one or more records.');
$this->assertEquals('Müller, Klaus', $result['results'][0]['n_fileas'], 'file as not found');
// import again without dryrun
$result = $this->_importHelper(array('dryrun' => 0));
$this->assertEquals(2, $result['totalcount'], 'Didn\'t import anything.');
$klaus = $result['results'][0];
$this->assertEquals('Import list (' . Tinebase_Translation::dateToStringInTzAndLocaleFormat(Tinebase_DateTime::now(), NULL, NULL, 'date') . ')', $klaus['tags'][0]['name']);
// import with duplicates
$result = $this->_importHelper(array('dryrun' => 0));
$this->assertEquals(0, $result['totalcount'], 'Do not import anything.');
$this->assertEquals(2, $result['duplicatecount'], 'Should find 2 dups.');
$this->assertEquals(1, count($result['exceptions'][0]['exception']['clientRecord']['tags']), '1 autotag expected');
// import again with clientRecords
$klaus['adr_one_locality'] = 'Hamburg';
// check that empty filter works correctly, db only accepts NULL for empty value here
$klaus['adr_two_lon'] = '';
$clientRecords = array(array('recordData' => $klaus, 'resolveStrategy' => 'mergeMine', 'index' => 0));
$result = $this->_importHelper(array('dryrun' => 0), $clientRecords);
$this->assertEquals(1, $result['totalcount'], 'Should merge Klaus: ' . print_r($result, TRUE));
$this->assertEquals(1, $result['duplicatecount'], 'Fritz is no duplicate.');
$this->assertEquals('Hamburg', $result['results'][0]['adr_one_locality'], 'locality should change');
}
示例12: _doMessageSubstitutions
/**
* do substitutions in vacation message
*
* @param Expressomail_Model_Sieve_Vacation $vacation
* @param string $message
* @return string
*
* @todo get locale from placeholder (i.e. endDate-_LOCALESTRING_)
* @todo get field from placeholder (i.e. representation-_FIELDNAME_)
* @todo use html templates?
* @todo use ZF templates / phplib tpl files?
*/
protected function _doMessageSubstitutions(Expressomail_Model_Sieve_Vacation $vacation, $message)
{
$timezone = Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
$representatives = $vacation->contact_ids ? Addressbook_Controller_Contact::getInstance()->getMultiple($vacation->contact_ids) : array();
if ($vacation->contact_ids && count($representatives) > 0) {
// sort representatives
$representativesArray = array();
foreach ($vacation->contact_ids as $id) {
$representativesArray[] = $representatives->getById($id);
}
}
try {
$ownContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId());
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $e);
}
$ownContact = NULL;
}
$search = array('{startDate-en_US}', '{endDate-en_US}', '{startDate-de_DE}', '{endDate-de_DE}', '{representation-n_fn-1}', '{representation-n_fn-2}', '{representation-email-1}', '{representation-email-2}', '{representation-tel_work-1}', '{representation-tel_work-2}', '{owncontact-n_fn}', '{signature}');
$replace = array(Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->start_date, $timezone, new Zend_Locale('en_US'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->end_date, $timezone, new Zend_Locale('en_US'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->start_date, $timezone, new Zend_Locale('de_DE'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->end_date, $timezone, new Zend_Locale('de_DE'), 'date'), isset($representativesArray[0]) ? $representativesArray[0]->n_fn : 'unknown person', isset($representativesArray[1]) ? $representativesArray[1]->n_fn : 'unknown person', isset($representativesArray[0]) ? $representativesArray[0]->email : 'unknown email', isset($representativesArray[1]) ? $representativesArray[1]->email : 'unknown email', isset($representativesArray[0]) ? $representativesArray[0]->tel_work : 'unknown phone', isset($representativesArray[1]) ? $representativesArray[1]->tel_work : 'unknown phone', $ownContact ? $ownContact->n_fn : '', $vacation->signature ? Expressomail_Model_Message::convertHTMLToPlainTextWithQuotes(preg_replace("/\\r|\\n/", '', $vacation->signature)) : '');
$result = str_replace($search, $replace, $message);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $result);
}
return $result;
}
示例13: getLinkedObjects
/**
* get linked objects for lead pdf (contacts, tasks, ...)
*
* @param Crm_Model_Lead $_lead lead data
* @param Zend_Locale $_locale the locale
* @param Zend_Translate $_translate
* @return array the linked objects
*/
protected function getLinkedObjects(Crm_Model_Lead $_lead, Zend_Locale $_locale, Zend_Translate $_translate)
{
$linkedObjects = array();
// check relations
if ($_lead->relations instanceof Tinebase_Record_RecordSet) {
$_lead->relations->addIndices(array('type'));
/********************** contacts ******************/
$linkedObjects[] = array($_translate->_('Contacts'), 'headline');
$types = array("customer" => "/images/oxygen/32x32/apps/system-users.png", "partner" => "/images/oxygen/32x32/actions/view-process-own.png", "responsible" => "/images/oxygen/32x32/apps/preferences-desktop-user.png");
foreach ($types as $type => $icon) {
$contactRelations = $_lead->relations->filter('type', strtoupper($type));
foreach ($contactRelations as $relation) {
try {
//$contact = Addressbook_Controller_Contact::getInstance()->getContact($relation->related_id);
$contact = $relation->related_record;
$contactNameAndCompany = $contact->n_fn;
if (!empty($contact->org_name)) {
$contactNameAndCompany .= " / " . $contact->org_name;
}
$linkedObjects[] = array($contactNameAndCompany, 'separator', $icon);
$postalcodeLocality = !empty($contact->adr_one_postalcode) ? $contact->adr_one_postalcode . " " . $contact->adr_one_locality : $contact->adr_one_locality;
$regionCountry = !empty($contact->adr_one_region) ? $contact->adr_one_region . " " : "";
if (!empty($contact->adr_one_countryname)) {
$regionCountry .= Zend_Locale::getTranslation($contact->adr_one_countryname, 'country', $_locale);
}
$linkedObjects[] = array($_translate->_('Address'), array($contact->adr_one_street, $postalcodeLocality, $regionCountry));
$linkedObjects[] = array($_translate->_('Telephone'), $contact->tel_work);
$linkedObjects[] = array($_translate->_('Email'), $contact->email);
} catch (Exception $e) {
// do nothing so far
}
}
}
/********************** tasks ******************/
$taskRelations = $_lead->relations->filter('type', strtoupper('task'));
if (!empty($taskRelations)) {
$linkedObjects[] = array($_translate->_('Tasks'), 'headline');
foreach ($taskRelations as $relation) {
try {
$task = $relation->related_record;
$taskTitle = $task->summary . " ( " . $task->percent . " % ) ";
// @todo add big icon to db or preg_replace?
if (!empty($task->status)) {
$status = Tasks_Config::getInstance()->get(Tasks_Config::TASK_STATUS)->records->getById($task->status);
$icon = "/" . $status['icon'];
$linkedObjects[] = array($taskTitle, 'separator', $icon);
} else {
$linkedObjects[] = array($taskTitle, 'separator');
}
// get due date
if (!empty($task->due)) {
$dueDate = new Tinebase_DateTime($task->due);
$linkedObjects[] = array($_translate->_('Due Date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($dueDate, NULL, NULL, 'date'));
}
// get task priority
$taskPriority = $this->getTaskPriority($task->priority, $_translate);
$linkedObjects[] = array($_translate->_('Priority'), $taskPriority);
} catch (Exception $e) {
// do nothing so far
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' exception caught: ' . $e->__toString());
}
}
}
/********************** products ******************/
$productRelations = $_lead->relations->filter('type', strtoupper('product'));
if (!empty($productRelations)) {
$linkedObjects[] = array($_translate->_('Products'), 'headline');
foreach ($productRelations as $relation) {
try {
$product = $relation->related_record;
$quantity = isset($relation['remark']['quantity']) ? $relation['remark']['quantity'] : 1;
$price = isset($relation['remark']['price']) ? $relation['remark']['price'] : $product->price;
// @todo set precision for the price ?
$price = Zend_Locale_Format::toNumber($price, array('locale' => $_locale)) . " €";
$description = isset($relation['remark']['description']) ? $relation['remark']['description'] : $product->description;
$linkedObjects[] = array($product->name . ' - ' . $description . ' (' . $price . ') x ' . $quantity, 'separator');
} catch (Exception $e) {
// do nothing so far
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' exception caught: ' . $e->__toString());
}
}
}
}
return $linkedObjects;
}
示例14: getNotificationMessage
/**
* create notification message for task alarm
*
* @return string
*
* @todo should we get the locale pref for each single user here instead of the default?
* @todo move lead stuff to Crm(_Model_Lead)?
* @todo add getSummary to Addressbook_Model_Contact for linked contacts?
*/
public function getNotificationMessage()
{
// get locale from prefs
$localePref = Tinebase_Core::getPreference()->getValue(Tinebase_Preference::LOCALE);
$locale = Tinebase_Translation::getLocale($localePref);
$translate = Tinebase_Translation::getTranslation($this->_application, $locale);
// get date strings
$timezone = $this->originator_tz ? $this->originator_tz : Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
$dueDateString = Tinebase_Translation::dateToStringInTzAndLocaleFormat($this->due, $timezone, $locale);
// resolve values
Tinebase_User::getInstance()->resolveUsers($this, 'organizer', true);
$status = Tasks_Config::getInstance()->get(Tasks_Config::TASK_STATUS)->records->getById($this->status);
$organizerName = $this->organizer ? $this->organizer->accountDisplayName : '';
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($this->toArray(), TRUE));
$text = $this->summary . "\n\n" . $translate->_('Due') . ': ' . $dueDateString . "\n" . $translate->_('Organizer') . ': ' . $organizerName . "\n" . $translate->_('Description') . ': ' . $this->description . "\n" . $translate->_('Priority') . ': ' . $this->priority . "\n" . $translate->_('Status') . ': ' . $translate->_($status['value']) . "\n" . $translate->_('Percent') . ': ' . $this->percent . "%\n\n";
// add relations (get with ignore acl)
$relations = Tinebase_Relations::getInstance()->getRelations(get_class($this), 'Sql', $this->getId(), NULL, array('TASK'), TRUE);
foreach ($relations as $relation) {
if ($relation->related_model == 'Crm_Model_Lead') {
$lead = $relation->related_record;
$text .= $translate->_('Lead') . ': ' . $lead->lead_name . "\n";
$leadRelations = Tinebase_Relations::getInstance()->getRelations(get_class($lead), 'Sql', $lead->getId());
foreach ($leadRelations as $leadRelation) {
if ($leadRelation->related_model == 'Addressbook_Model_Contact') {
$contact = $leadRelation->related_record;
$text .= $leadRelation->type . ': ' . $contact->n_fn . ' (' . $contact->org_name . ')' . "\n" . (!empty($contact->tel_work) ? "\t" . $translate->_('Telephone') . ': ' . $contact->tel_work . "\n" : '') . (!empty($contact->email) ? "\t" . $translate->_('Email') . ': ' . $contact->email . "\n" : '');
}
}
}
}
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $text);
return $text;
}
示例15: _doAutoTagReplacements
/**
* replace some strings in autotags (name + description)
*
* @param array $_tagData
* @return array
*/
protected function _doAutoTagReplacements($_tagData)
{
$result = $_tagData;
$search = array('###CURRENTDATE###', '###CURRENTTIME###', '###USERFULLNAME###');
$now = Tinebase_DateTime::now();
$replacements = array(Tinebase_Translation::dateToStringInTzAndLocaleFormat($now, NULL, NULL, 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($now, NULL, NULL, 'time'), Tinebase_Core::getUser()->accountDisplayName);
$fields = array('name', 'description');
foreach ($fields as $field) {
if (isset($result[$field])) {
$result[$field] = str_replace($search, $replacements, $result[$field]);
}
}
return $result;
}