Linux mail.vriendennsm.nl 6.1.0-51-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.177-1 (2026-07-16) x86_64
Apache/2.4.68 (Debian)
Server IP : 217.154.75.17 & Your IP : 216.73.216.195
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
vnsm /
plugins /
system /
rsfpgooglecalendar /
Delete
Unzip
Name
Size
Permission
Date
Action
forms
[ DIR ]
drwxr-xr-x
2025-02-08 22:29
sql
[ DIR ]
drwxr-xr-x
2025-02-08 22:29
index.html
44
B
-rwxr-xr-x
2022-06-02 19:40
rsfpgooglecalendar.php
28.34
KB
-rwxr-xr-x
2022-06-02 19:40
rsfpgooglecalendar.xml
1.41
KB
-rwxr-xr-x
2022-06-02 19:40
script.php
3.01
KB
-rwxr-xr-x
2022-06-02 19:40
Save
Rename
<?php /** * @package RSform!Pro * @copyright (C) www.rsjoomla.com * @license GPL, http://www.gnu.org/copyleft/gpl.html */ // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); class plgSystemRsfpgooglecalendar extends JPlugin { protected $autoloadLanguage = true; public function __construct(&$subject, $config) { parent::__construct( $subject, $config ); if (file_exists(JPATH_ADMINISTRATOR.'/components/com_rsform/helpers/google_calendar_class.php')) { require_once JPATH_ADMINISTRATOR.'/components/com_rsform/helpers/google_calendar_class.php'; } } public function onRsformFormSave($form) { $app = JFactory::getApplication(); $data = $app->input->post->get('gc', array(), 'array'); $data['gc_mappings'] = $app->input->post->get('gc_mappings', array(), 'array'); $data['form_id'] = $form->FormId; $row = $this->getTable(); if (!$row) { return false; } if (!$row->save($data)) { $app->enqueueMessage($row->getError(), 'error'); } } protected function getTable() { return JTable::getInstance('RSForm_Google_Calendar', 'Table'); } public function onRsformBackendFormCopy($args) { $formId = $args['formId']; $newFormId = $args['newFormId']; /* @var $row TableRSForm_Google_Calendar */ if ($row = $this->getTable()) { if ($row->load($formId)) { $row->form_id = $newFormId; if ($row->check()) { $row->store(); } } } } public function onRsformFormDelete($formId) { $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($row = $this->getTable()) { $row->delete($formId); } // remove the error log for this specific form $query->delete('#__rsform_google_calendar_error_log') ->where($db->qn('form_id').'='.$db->q($formId)); $db->setQuery($query)->execute(); } public function onRsformBackendAfterShowConfigurationTabs($tabs) { $tabs->addTitle(JText::_('RSFP_GOOGLE_CALENDAR_LABEL'), 'page-googlecalendar'); $tabs->addContent($this->configurationScreen()); } public function onRsformBackendAfterShowFormEditTabsTab() { ?> <li><a href="javascript: void(0);" id="googlecalendar"><span class="rsficon rsficon-calendar"></span><span class="inner-text"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_SETTINGS'); ?></span></a></li> <?php } public function onRsformBackendAfterShowFormEditTabs() { $formId = JFactory::getApplication()->input->getInt('formId'); $db = JFactory::getDbo(); $row = $this->getTable(); if (!$row) { return; } $row->load($formId); // Fields $lists = array(); // Boolean inputs $gc_published = empty($row->gc_published) ? 0 : 1; $gc_use_recurrence = empty($row->gc_use_recurrence) ? 0 : 1; $gc_debug = empty($row->gc_debug) ? 0 : 1; $lists['published'] = RSFormProHelper::renderHTML('select.booleanlist', 'gc[gc_published]', '', $gc_published); $lists['debug'] = RSFormProHelper::renderHTML('select.booleanlist', 'gc[gc_debug]', '', $gc_debug); $lists['recurrence'] = RSFormProHelper::renderHTML('select.booleanlist', 'gc[gc_use_recurrence]', 'onclick="toggleRecurrence(this.value)"', $gc_use_recurrence); $lists['trigger_on_payment'] = RSFormProHelper::renderHTML('select.booleanlist', 'gc[gc_trigger_on_payment]', '', $row->gc_trigger_on_payment); $hasPayment = JPluginHelper::isEnabled('system', 'rsfppayment'); // check if the credentials are present $client_id = RSFormProHelper::getConfig('google.calendar.clientid'); $secret = RSFormProHelper::getConfig('google.calendar.secret'); $api = RSFormGoogleCalendar::getInstance(); $logColumns = true; // Do not show these errors always, only when the "use" is set to yes if ($gc_published) { // check the credentials if they are present if (empty($client_id) || empty($secret)) { JFactory::getApplication()->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_ERROR_NO_CREDENTIALS'), 'error'); $logColumns = false; } else { // if the credentials are present then check the access token if (!$api->getAccessToken()) { JFactory::getApplication()->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_ERROR_NO_ACCESSTOKEN_GENERATED'), 'error'); $logColumns = false; } } } $mappings = array(); $calendars = false; if ($gc_published) { $calendars = $api->getCalendarsIds(($logColumns ? $formId : null)); } if (!empty($row->gc_mappings)) { $mappings = unserialize($row->gc_mappings); } $query = $db->getQuery(true); $query->select($db->qn('code')) ->select($db->qn('message')) ->select($db->qn('date')) ->from($db->qn('#__rsform_google_calendar_error_log')) ->where($db->qn('form_id') . ' = ' . $db->q($formId)) ->order($db->qn('date') . ' ' . $db->escape('DESC')); $db->setQuery($query, 0, 15); $errors = $db->loadObjectList(); ?> <div id="googlecalendardiv"> <div> <div> <fieldset> <h3 class="rsfp-legend"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_SETTINGS_DESC'); ?></h3> <table width="100%" class="table table-bordered"> <tr> <td width="80" align="right" nowrap="nowrap" class="key"> <span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_USE_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_USE'); ?></span> </td> <td nowrap="nowrap" colspan="2"><?php echo $lists['published']; ?></td> </tr> <?php if ($hasPayment) { ?> <tr> <td width="80" align="right" nowrap="nowrap" class="key"> <span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_TRIGGER_ON_PAYMENT_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_TRIGGER_ON_PAYMENT'); ?></span> </td> <td nowrap="nowrap" colspan="2"><?php echo $lists['trigger_on_payment']; ?></td> </tr> <?php } ?> <tr> <td width="80" align="right" nowrap="nowrap" class="key"> <span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_DEBUG_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_DEBUG'); ?></span> </td> <td nowrap="nowrap" colspan="2"><?php echo $lists['debug']; ?></td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"> <span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_USE_RECURRENCE_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_USE_RECURRENCE'); ?></span> </td> <td nowrap="nowrap" colspan="2"><?php echo $lists['recurrence']; ?></td> </tr> <?php if ($calendars) { $select_calendars = array(); foreach($calendars as $cal_id => $info) { $select_calendars[$cal_id] = $info->title; } ?> <tr> <td width="80" align="right" nowrap="nowrap" class="key"> <span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_ID_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_ID'); ?></span> </td> <td nowrap="nowrap" colspan="2"> <?php echo JHtml::_('select.genericlist', $select_calendars, 'gc[gc_calendar_id]', null, 'value', 'text', isset($row->gc_calendar_id) ? $row->gc_calendar_id : null); ?> </td> </tr> <tr> <td colspan="2"> <small><?php echo JText::_('RSFP_GOOGLE_CALENDAR_ID_LONG_DESC'); ?></small> </td> </tr> <?php } ?> </table> </fieldset> <table class="table table-bordered"> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_SUMMARY_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_SUMMARY'); ?></span></td> <td> <input type="text" name="gc_mappings[summary]" style="width: 80%;" id="gc_mappings_summary" value="<?php echo (isset($mappings['summary']) ? RSFormProHelper::htmlEscape($mappings['summary']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_LOCATION_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_LOCATION'); ?></span></td> <td> <input type="text" name="gc_mappings[location]" style="width: 80%;" id="gc_mappings_location" value="<?php echo (isset($mappings['location']) ? RSFormProHelper::htmlEscape($mappings['location']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_DESCRIPTION_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_DESCRIPTION'); ?></span></td> <td> <textarea name="gc_mappings[description]" style="width: 80%;" id="gc_mappings_description" rows="10" cols="60" class="rs_inp rs_80"><?php echo (isset($mappings['description']) ? RSFormProHelper::htmlEscape($mappings['description']) : ''); ?></textarea> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_START_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_START'); ?><br/> <?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_START_LONG_DESC');?> </td> <td> <input type="text" name="gc_mappings[start]" style="width: 80%;" id="gc_mappings_start" value="<?php echo (isset($mappings['start']) ? RSFormProHelper::htmlEscape($mappings['start']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_END_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_END'); ?><br/> <?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_END_LONG_DESC');?> </td> <td> <input type="text" name="gc_mappings[end]" style="width: 80%;" id="gc_mappings_end" value="<?php echo (isset($mappings['end'])? RSFormProHelper::htmlEscape($mappings['end']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_TIMEZONE_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_TIMEZONE'); ?> </td> <td> <input type="text" name="gc_mappings[timeZone]" style="width: 80%;" id="gc_mappings_timeZone" value="<?php echo ($calendars ? $calendars[$row->gc_calendar_id]->timezone : '');?>" readonly /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_STATUS_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_STATUS'); ?></span><br/> <?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_STATUS_LONG_DESC');?> </td> <td> <input type="text" name="gc_mappings[status]" style="width: 80%;" id="gc_mappings_status" value="<?php echo (isset($mappings['status']) ? RSFormProHelper::htmlEscape($mappings['status']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ALLDAY_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ALLDAY'); ?></span><br/> <?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ALLDAY_LONG_DESC');?></td> <td> <input type="text" name="gc_mappings[allday]" style="width: 80%;" id="gc_mappings_allday" value="<?php echo (isset($mappings['allday']) ? RSFormProHelper::htmlEscape($mappings['allday']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ATTENDEES_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ATTENDEES'); ?></span><br/><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_ATTENDEES_LONG_DESC');?></td> <td> <input type="text" name="gc_mappings[attendees]" style="width: 80%;" id="gc_mappings_attendees" value="<?php echo (isset($mappings['attendees']) ? RSFormProHelper::htmlEscape($mappings['attendees']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> </td> </tr> <tr class="use_recurrence"> <td colspan="2"> <h4 style="text-align:center"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_RECURRENCE_RULES'); ?></h4> </td> </tr> <tr class="use_recurrence"> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_FREQUENCY_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_FREQUENCY'); ?></span></td> <td> <input type="text" name="gc_mappings[frequency]" style="width: 80%;" id="gc_mappings_frequency" value="<?php echo (isset($mappings['frequency']) ? RSFormProHelper::htmlEscape($mappings['frequency']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> <p><small><?php echo JText::sprintf('RSFP_GOOGLE_CALENDAR_POSSIBLE_VALUES', '');?></small></p> <ul> <li><small>DAILY</small></li> <li><small>WEEKLY</small></li> <li><small>MONTHLY</small></li> <li><small>YEARLY</small></li> </ul> </td> </tr> <tr class="use_recurrence"> <td width="80" align="right" nowrap="nowrap" class="key"><span class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_COUNT_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_COUNT'); ?></span><br/><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MAPPING_COUNT_LONG_DESC');?></td> <td> <input type="text" name="gc_mappings[count]" style="width: 80%;" id="gc_mappings_count" value="<?php echo (isset($mappings['count']) ? RSFormProHelper::htmlEscape($mappings['count']) : ''); ?>" class="rs_inp rs_80" data-delimiter=" " data-placeholders="display" /> <p><small><?php echo JText::_('RSFP_GOOGLE_CALENDAR_ONLY_INTEGER_VALUES');?></small></p> </td> </tr> </table> </div> <div> <fieldset> <legend><?php echo JText::_('RSFP_GOOGLE_CALENDAR_FORM_ERROR_LOG'); ?></legend> <?php if (empty($errors)) { ?> <div class="alert alert-error"> <?php echo JText::_('RSFP_GOOGLE_CALENDAR_NO_ERRORS_SO_FAR'); ?> </div> <?php } else { ?> <table class="table table-responsive table-condensed table-bordered"> <thead> <tr> <th><?php echo JText::_('RSFP_GOOGLE_CALENDAR_CODE'); ?></th> <th><?php echo JText::_('RSFP_GOOGLE_CALENDAR_MESSAGE'); ?></th> <th><?php echo JText::_('RSFP_GOOGLE_CALENDAR_DATETIME'); ?></th> </tr> </thead> <?php foreach ($errors as $error) { ?> <tr> <td><?php echo (empty($error->code) ? ' -- ' : $error->code); ?></td> <td><?php echo RSFormProHelper::htmlEscape($error->message); ?></td> <td><?php echo RSFormProHelper::getDate($error->date); ?></td> </tr> <?php } ?> </table> <?php } ?> </fieldset> </div> </div> </div> <?php $value = $gc_use_recurrence ? 1 : 0; JFactory::getDocument()->addScriptDeclaration("jQuery(function() { toggleRecurrence('{$value}'); });"); JFactory::getDocument()->addScriptDeclaration("function toggleRecurrence(value) { (value === '1') ? jQuery('.use_recurrence').show() : jQuery('.use_recurrence').hide(); }"); } private function configurationScreen() { ob_start(); JForm::addFormPath(__DIR__ . '/forms'); $form = JForm::getInstance( 'plg_system_rsfpgooglecalendar.configuration', 'configuration', array('control' => 'rsformConfig'), false, false ); $form->bind($this->loadFormData()); $clientId = $form->getValue('google.calendar.clientid'); $secret = $form->getValue('google.calendar.secret'); ?> <div id="page-googlecalendar" class="form-horizontal"> <?php foreach ($form->getFieldsets() as $fieldset) { if ($fields = $form->getFieldset($fieldset->name)) { foreach ($fields as $field) { echo $field->renderField(); } } } ?> <div class="alert alert-info"> <h4><?php echo JText::_('RSFP_GOOGLE_CALENDAR_REDIRECT_URI'); ?></h4> <p><?php echo JText::_('RSFP_GOOGLE_CALENDAR_REDIRECT_URI_DESC'); ?></p> <p><strong><?php echo JUri::root().'administrator/index.php?option=com_rsform&task=plugin&plugin_task=store_google_calendar_access_token'; ?></strong></p> </div> <?php if (!empty($clientId) && !empty($secret)) { $api = RSFormGoogleCalendar::getInstance(); $accesstoken = $api->getAccessToken(); $status = $this->accessTokenStatus($api, $accesstoken); if ($status) { foreach ($status as $key => $value) { ?> <div class="control-group"> <div class="control-label"> <label class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_'.strtoupper($key).'_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_'.strtoupper($key)); ?></label> </div> <div class="controls"> <?php if (is_bool($value)) { echo $value ? JText::_('RSFP_GOOGLE_CALENDAR_EXPIRED') : JText::_('RSFP_GOOGLE_CALENDAR_VALID'); } else { echo $value; } ?> </div> </div> <?php } if ($status->is_invalid) { ?> <div class="control-group"> <div class="control-label"> <label class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_RENEW_ACCESS_TOKEN_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_RENEW_ACCESS_TOKEN'); ?></label> </div> <div class="controls"> <a href="<?php echo $api->getAuthURL(JUri::root().'administrator/index.php?option=com_rsform&task=plugin&plugin_task=store_google_calendar_access_token'); ?>" class="btn btn-success"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_RENEW'); ?></a> </div> </div> <?php } else { ?> <div class="control-group"> <div class="control-label"> <label class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_REVOKE_ACCESS_TOKEN_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_REVOKE_ACCESS_TOKEN'); ?></label> </div> <div class="controls"> <a href="<?php echo JUri::root().'administrator/index.php?option=com_rsform&task=plugin&plugin_task=revoke_google_calendar_access_token'; ?>" class="btn btn-danger"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_REVOKE'); ?></a> </div> </div> <?php } } else { ?> <div class="control-group"> <div class="control-label"> <label class="hasTooltip" title="<?php echo JText::_('RSFP_GOOGLE_CALENDAR_GET_ACCESS_TOKEN_DESC'); ?>"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_GET_ACCESS_TOKEN'); ?></label> </div> <div class="controls"> <a href="<?php echo $api->getAuthURL(JUri::root().'administrator/index.php?option=com_rsform&task=plugin&plugin_task=store_google_calendar_access_token'); ?>" class="btn btn-primary"><?php echo JText::_('RSFP_GOOGLE_CALENDAR_AUTHENTICATE'); ?></a> </div> </div> <?php } } ?> </div> <?php $contents = ob_get_contents(); ob_end_clean(); return $contents; } private function loadFormData() { $data = array(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from($db->qn('#__rsform_config')) ->where($db->qn('SettingName') . ' LIKE ' . $db->q('google.calendar.%', false)); if ($results = $db->setQuery($query)->loadObjectList()) { foreach ($results as $result) { $data[$result->SettingName] = $result->SettingValue; } } return $data; } public function onRsformBackendSwitchTasks() { $app = JFactory::getApplication(); $input = $app->input; $plugin_task = $input->getCmd('plugin_task',''); switch ($plugin_task) { // store the access token that we receive from the google OAuth case 'store_google_calendar_access_token': $code = $input->getString('code', ''); $redirectUri = JUri::root().'administrator/index.php?option=com_rsform&task=plugin&plugin_task=store_google_calendar_access_token'; try { $api = RSFormGoogleCalendar::getInstance(); $accessToken = $api->retrieveAccessToken($code, $redirectUri); $api->storeAccessToken($accessToken); $app->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_STORED_ACCESS_TOKEN_SUCCESSFUL'), 'success'); } catch (Exception $e) { $app->enqueueMessage(JText::sprintf('RSFP_GOOGLE_CALENDAR_ERROR_NO_CALENDAR', $e->getMessage()), 'error'); } $app->redirect(JRoute::_('index.php?option=com_rsform&view=configuration', false)); break; // revoke the access token that exists case 'revoke_google_calendar_access_token': $api = RSFormGoogleCalendar::getInstance(); if ($api->revokeToken()) { $app->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_REVOKE_ACCESS_TOKEN_SUCCESSFUL'), 'success'); } else { $app->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_REVOKE_ACCESS_TOKEN_UNSUCCESSFUL'), 'error'); } $app->redirect(JRoute::_('index.php?option=com_rsform&view=configuration', false)); break; } } // parse the access token and out the current data protected function accessTokenStatus($api, $accesstoken) { $status = false; if ($accesstoken) { $status = json_decode($accesstoken); $config = JFactory::getConfig(); $tz = $config->get('offset'); $createdDate = JFactory::getDate($status->created); $createdDate->setTimezone(new DateTimeZone($tz)); $createdDate->format(RSFormProHelper::getConfig('global.date_mask')); $expires = $status->created + $status->expires_in; $expiresAt = JFactory::getDate($expires); $expiresAt->setTimezone(new DateTimeZone($tz)); $expiresAt->format(RSFormProHelper::getConfig('global.date_mask')); $status->created = $createdDate; $status->expires_at = $expiresAt; // we do not need this anymore unset($status->expires_in); $status->is_invalid = $api->isInvalidToken(); } return $status; } private function getSettings($formId) { static $cache = array(); if (!isset($cache[$formId])) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*') ->from($db->qn('#__rsform_google_calendar')) ->where($db->qn('form_id') . ' = ' . $db->q($formId)) ->where($db->qn('gc_published') . ' = ' . $db->q(1)); $db->setQuery($query); $cache[$formId] = $db->loadObject(); } if (!empty($cache[$formId])) { return clone $cache[$formId]; } return false; } public function onRsformAfterConfirmPayment($SubmissionId) { require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/submissions.php'; $submission = RSFormProSubmissionsHelper::getSubmission($SubmissionId, false); if ($submission) { if ($row = $this->getSettings($submission->FormId)) { if ($row->gc_trigger_on_payment) { $this->createEvent($submission->FormId, $SubmissionId, $row); } } } } /* * Functions used only inside this class */ public function onRsformFrontendAfterFormProcess($args) { $formId = (int) $args['formId']; $SubmissionId = (int) $args['SubmissionId']; if ($row = $this->getSettings($formId)) { if (empty($row->gc_trigger_on_payment)) { $this->createEvent($formId, $SubmissionId, $row); } } } private function createEvent($formId, $SubmissionId, $row) { list($replace, $with) = RSFormProHelper::getReplacements($SubmissionId); $replace[] = '\n'; $with[] = "\n"; if (empty($row->gc_mappings)) { return; } if (empty($row->gc_calendar_id)) { return; } $data = unserialize($row->gc_mappings); $required_data = array('start', 'end'); $required_error = false; foreach ($data as $colname => $value) { if ($colname === 'description') { if (strpos($value, '{/if}') !== false) { require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/scripting.php'; RSFormProScripting::compile($value, $replace, $with); } } $data[$colname] = str_replace($replace, $with, $value); if (in_array($colname, $required_data) && empty($data[$colname])) { $required_error = true; break; } } if ($required_error) { // if debug is active if ($row->gc_debug) { JFactory::getApplication()->enqueueMessage(JText::_('RSFP_GOOGLE_CALENDAR_ERROR_DATES_EMPTY'), 'warning'); } return; } $api = RSFormGoogleCalendar::getInstance(); $added = $api->addEvent($row->gc_calendar_id, $data, $row->gc_use_recurrence); if (!$added->status) { $dataLog = new stdClass(); $dataLog->form_id = $formId; $dataLog->message = $added->msg; if (isset($added->code)) { $dataLog->code = $added->code; } // if debug is active if ($row->gc_debug) { JFactory::getApplication()->enqueueMessage(JText::sprintf('RSFP_GOOGLE_CALENDAR_ERROR_NO_CALENDAR', $dataLog->message), 'warning'); } $api->storeErrorLog($dataLog); } } /* * End Functions used only inside this class */ public function onRsformFormBackup($form, $xml, $fields) { $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($row = $this->getTable()) { if ($row->load($form->FormId)) { $row->check(); $data = $row->getProperties(); unset($data['form_id']); $xml->add('googlecalendar'); foreach ($data as $property => $value) { $xml->add($property, $value); } $xml->add('/googlecalendar'); } } // export the error log $query->select('*') ->from($db->qn('#__rsform_google_calendar_error_log')) ->where($db->qn('form_id').'='.$db->q($form->FormId)); $db->setQuery($query); if ($errors = $db->loadObjectList()) { $xml->add('googlecalendarlog'); foreach ($errors as $error) { // No need for a form_id unset($error->form_id); unset($error->id); $xml->add('error'); foreach ($error as $property => $value) { $xml->add($property, $value); } $xml->add('/error'); } $xml->add('/googlecalendarlog'); } } public function onRsformFormRestore($form, $xml, $fields) { if (isset($xml->googlecalendar)) { $data = array( 'form_id' => $form->FormId ); foreach ($xml->googlecalendar->children() as $property => $value) { $data[$property] = (string) $value; } $row = $this->getTable(); $row->save($data); } // the error log if (isset($xml->googlecalendarlog)) { $db = JFactory::getDbo(); foreach ($xml->googlecalendarlog->error as $error) { $data = array( $db->qn('form_id') .'='. $db->q($form->FormId) ); foreach ($error->children() as $property => $value) { $value = (string) $value; $data[] = $db->qn($property) .'='. $db->q($value); } $query = $db->getQuery(true); $query ->insert('#__rsform_google_calendar_error_log') ->set($data); $db->setQuery($query)->execute(); } } } }