add to Google calendar option cut some description content off - google-calendar-api

We have coded a PHP page building the content of a calendar event. It is a mix of static and dynamic content for different parts of the email including the Description. When I receive the email in Gmail, the Add Calendar is displayed in the email header. An .ICS file is also attached. If I click on Add to calendar, the content of the description is incomplete, the length of content is OK, the problem is not coming from that point. When I open the attached ICS file in Outlook or Hotmail, the content is ok. If I'm adding the event into Google calendar importing the ICS, the content is ok too. But this method is too complicated for my end users.
Any suggestion? Is someone has already met this issue?
Regards

A solution for your issue might be to use the Google Calendar API so you can create calendar events and afterwards add them to the users' calendars.
You should follow the steps from the PHP Quickstart and here a couple of code snippets that create a calendar and then an event with Google Calendar API:
Create a calendar
$calendar = new Google_Service_Calendar_Calendar();
$calendar->setSummary('your_calendar_summary');
$calendar->setTimeZone('your_time_zone');
$createdCalendar = $service->calendars->insert($calendar);
Create an event (you can customize the parameters to your liking)
$event = new Google_Service_Calendar_Event(array(
'summary' => 'your_event_summary',
'location' => 'your_event_location',
'description' => 'your_event_description',
'start' => array(
'dateTime' => 'your_start_date',
'timeZone' => 'your_time_zone',
),
'end' => array(
'dateTime' => 'your_date_time',
'timeZone' => 'your_time_zone',
),
'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2'
),
'attendees' => array(
array('email' => 'atendee1#example.com'),
array('email' => 'atendee2#example.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
),
),
));
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);
If you want to integrate the Google Calendar service with Gmail you can check these links that might help you:
Email Markup;
Gmail API Reference;
Furthermore, you can read more about the Calendar API here:
Google Calendar PHP Quickstart;
Google Calendar Add Events.

Related

How to use file upload option in WooCommerce payment gateway admin options?

I am developing a plugin to integrate a payment gateway in WooCommerce. I have done one before.
But in this one, I need to upload a key file in gateway settings and that is used to hash the data before making payment request to related portal.
I have following code which allows to choose file, but I doubt this is working in the back end.
'sandbox_pvt_key' => array(
'title' => __( 'Test Private Key', 'woocommerce-custom-gateway' ),
'type' => 'file',
'desc_tip' => true,
'description' => __( 'Please upload the test private key file; this is needed in order to test payment.', 'woocommerce-custom-gateway' ),
'default' => '',
),
The output looks like the following:
Can anybody lemme know if this is supported option in the gateway settings? If not, can anybody guide me on how I can customize it via some hook/filters or any other way.
This can be achieved in the process_admin_options()
public function process_admin_options() {
$this->upload_key_files();
$saved = parent::process_admin_options();
return $saved;
}
private function upload_key_files() {
//handle uploads here
}

Different reminders for each attendee

I'd like to know if is possible to send different notification for each attendee of the event.
here is my code:
'attendees' => array(
array('email' => $event["email"], 'displayName' => $event["displayname"]),
array('email' => $event["email2"], 'displayName' => $event["displayname2"]),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
'overrides' => array(
//array('method' => 'email', 'minutes' => 60),
array('method' => 'popup', 'minutes' => 1440),
array('method' => 'popup', 'minutes' => 10),
),
),
),
There seems to be no mention of customized calendar notifications mentioned Reminders and Notifications. As far as the docs go:
Notifications
Calendar support the following notification types:
Event creation: a new event has been added to one of the user's calendars.
Event change: an event the user is invited to has been modified by the organizer.
Event cancellation: an event the user was invited to has been cancelled.
Attendee response: an attendee to an event created by the user has changed their response status.
Agenda: a list of all the events in the user’s calendar, sent at the start of the day.
The user can decide what notifications to enable per calendar and the delivery method for each notification type. These settings are not shared with other users. Similar to default reminders, they’re accessible through the CalendarList collection.
Delivery mechanisms
The delivery methods offered by Google Calendar are:
Pop-up. These are supported on mobile platforms and on web clients.
Email sent by the server.
SMS. These are only available for Google
Apps for Work, Education, and Government customers.

Bundle for notifications in Symfony2

I want to include notifications, e.g. for forum threads. A user shall retrieve notifications if there are any new posts to a forum thread. Another example would be the notifications on Facebook, e.g. where you're notified of new comments on your posts or pictures.
Is there a notification bundle for Symfony2 that you can recommend for implementing such a function?
I came up with the Sonata NotificationBundle but I am unsure if this is what I really need. When I look at the usage examples it looks as if this would provide a email notification function
// retrieve the notification backend
$backend = $container->get('sonata.notification.backend');
// create and publish a message
$backend->createAndPublish('mailer', array(
'from' => array(
'email' => 'no-reply#sonata-project.org',
'name' => 'No Reply'
),
'to' => array(
'myuser#example.org' => 'My User',
'myuser1#example.org' => 'My User 1',
),
'message' => array(
'html' => '<b>hello</b>',
'text' => 'hello'
),
'subject' => 'Contact form',
));
or a logging function
$this->get('sonata.notification.backend')->createAndPublish('logger', array(
'level' => 'debug',
'message' => 'Hello world!'
));
Can you confirm/recommend the usage of that bundle? Or can you recommend any other?
Good news:
NotificationBundle from GeniusesOfSymfony
https://github.com/GeniusesOfSymfony/NotificationBundle
Proper documentation will probably be published soon.
(on-going discussion here: https://github.com/GeniusesOfSymfony/WebSocketBundle/issues/4#issuecomment-81829513)
I've already tested a similar bundle created by them (WebSocketBundle) which also provides real-time-interaction and it works really great. The documentation is also very good.
I recommend that you "star" the project on github. You can also create an issue to ask about the current status of the project.
I'm searching for the same library now, and also found https://github.com/namshi/notificator
Didn't use it yet, but it has 130 stars today, so probably will try it.
You can achieve this with sonata notification bundle.
You will need to create custom consumer class as described here
https://sonata-project.org/bundles/notification/3-x/doc/reference/usage.html#custom-consumer
You can try this Bundle: NotificationsBundle
It's a simple implementation for Pusher that provides a real time data proadcast.

Drupal login form customize

Hi i have used this code
<?php
$elements = drupal_get_form("user_login");
$form = drupal_render($elements);
echo $form;
?>
to get the default Drupal login form for my site but I need to customize the HTML, I have found some pages in module/users but did not understand how to customize the structure.
The user login form for Drupal is built by the user_login function in user.module using Drupal Form API. If you need to customize it, you should do it using hook_form_alter() in your module
function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
if ($form_id=='user_login') {
// YOUR CUSTOM CODE FOR THE FORM GOES HERE
}
}
** EDIT, AFTER YOUR COMMENT **
You don't need to call the YOUR_MODULE_NAME_form_alter() function: Drupal does that for you via the hook mechanism everytime it needs to build a form, and, when $form_id=='user_login', it modifies the login form to allow your customization. The way Drupal does that is discussed in detail in drupal.org, just follow the link I wrote at the beginning of this answer.
The user login form is declared this way in user.module:
// Display login form:
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#required' => TRUE,
);
$form['name']['#description'] = t('Enter your #s username.', array('#s' => variable_get('site_name', 'Drupal')));
$form['pass'] = array('#type' => 'password',
'#title' => t('Password'),
'#description' => t('Enter the password that accompanies your username.'),
'#required' => TRUE,
);
$form['#validate'] = user_login_default_validators();
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
The $form array is passed by reference to your hook_form_alter() before being rendered, allowing for customization. So, let's say that you want to change the label of the textfield for the user name from "Username" to "Name of the User", you write
$form['name']['#title'] = t("Name of the User");
in your custom code. If you want to add another field to the form (a textarea, for example), you do
$form['otherfield'] = array(
'#title' => t('My new custom textarea'),
'#type' => 'textarea',
'#description' => t("A description of what this area is for"),
'#cols' => 10,
'#rows' => 3,
'#weight' => 20,
);
and Drupal will add the field to the user login form.
There are many different kind of fields and properties that you can customize this way: I encourage you to fully read the Form API documentation. This way you let Drupal take care of form generation, translation, rendering, validation and submission, also permitting to other modules to manipulate your form if needed.
I hope it's clear, have a good day.
use this in template.php
function themename_theme() {
$items = array();
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'corporateclean') . '/templates',
'template' => 'user-login',
);
and create a template folder and within that create a file user-login.tpl.php and in this file you can put your html and could customize drupal login

Wysiwyg mo editor for Drupal 5 forms (Form API): How to enable it for several textareas?

I am trying to create a form with the Drupal 5 form API that has two textareas, both of which should have have a wysiwyg editor enabled to allow HTML formatted input. However, only the second textarea has the editor enabled, the other one displays the "Input format selector", but not the editor controls. I have tried this with TinyMCE 3.3.9.3 and 3.3.9.4b and CKEditor 3.5.1.6398 both using the wysiwyg module integration, the result in both cases is the same.
In this related question it is mentioned that there might be a problem of identical IDs. I have no clue how to transfer this solution to the Drupal Form API, since I gave the two fields different names. In the generated HTML, they have separate HTML ids based on the Drupal names I assigned.
The code I used to create the text areas is the following:
$form['oos'] = array(
'#tree' => false,
);
$form['oos']['oosmessage'] = array(
'#description' => t('Something'),
'#title' => t('Generic out of stock message'),
'#type' => 'textarea',
);
$form['oos']['format'] = filter_form(1, 20, array('format'));
$form['oosmd'] = array(
'#tree' => false,
);
$form['oosmd']['oosmessage_date'] = array(
'#type' => 'textarea',
'#title' => t('Out of stock message until a specific date'),
'#description' =>t('Something else.'),
);
$form['oosmd']['format'] = filter_form(1, 20, array('format'));
Thanks!
Ellen
Try to give the two textareas different ids and see if that works.

Resources