AAAAchrono_connectivity_task.php000066600000014106151376101340012374 0ustar00 'Chrono Connectivity Task', 'tooltip' => 'Run a Chrono Connectivity Task.'); var $group = array('id' => 'x_chronoforms_apps', 'title' => 'ChronoForms Apps'); var $events = array('success' => 0, 'fail' => 0); var $params = null; function run($form, $actiondata){ $mainframe = JFactory::getApplication(); $this->params = $params = new JParameter($actiondata->params); if(trim($params->get('connection_name', '')) != '' && trim($params->get('task', '')) != ''){ $received_data = array( 'connection_name' => $params->get('connection_name', ''), 'task' => $params->get('task', ''), 'field_name' => $params->get('field_name', ''), ); if(trim($params->get('data', '')) != '' && isset($form->data[$params->get('data', '')])){ $received_data['data'] = $form->data[$params->get('data', '')]; } $this->processData($form, $actiondata, $received_data); }else if(isset($form->data['apps_data']['ChronoConnectivity']['action_'.$actiondata->order])){ $received_data = $form->data['apps_data']['ChronoConnectivity']['action_'.$actiondata->order]; //print_r2($session_data); if(isset($received_data['task']) && !empty($received_data['task'])){ $this->processData($form, $actiondata, $received_data); }else{ $this->events['fail'] = 1; if((bool)$params->get('show_returned_errors', 0) === true){ $form->validation_errors[] = "Error occurred, session data couldn't be found."; }else{ $form->validation_errors[] = $params->get('error_message', ''); $form->debug['Chrono Connectivity Task'][$actiondata->order] = "Error occurred, session data couldn't be found."; } } } } function processData($form, $actiondata, $received_data = array()){ $params = $this->params; require_once(JPATH_SITE.DS.'components'.DS.'com_chronoconnectivity'.DS.'libraries'.DS.'chronoconnection.php'); $task = $received_data['task']; $connection_name = $received_data['connection_name']; //get the data $data = array(); if(isset($received_data['data'])){ $data = $received_data['data']; } $return = true; //connection instance $MyConnection = CFChronoConnection::getInstance($connection_name); //print_r2(array('task' => $task, 'name' => $connection_name, 'data' => $data)); switch($task){ case 'delete_data': //check permissions $acl_result = $MyConnection->check_permissions('delete', $data); if($acl_result === false){ $MyConnection->permission_deny(); $return = false; break; }else if(is_array($acl_result)){ $data = $acl_result; } //delete records code here $return = $MyConnection->delete_record_data($data); break; case 'save_data': //check permissions $r_id = null; if(is_array($data)){ $form->data = array_merge($form->data, $data); } if(strlen($MyConnection->connection_model_id) > 0){ if(isset($form->data[$MyConnection->connection_model_id][$MyConnection->connection_table_primary]) && !empty($form->data[$MyConnection->connection_model_id][$MyConnection->connection_table_primary])){ $r_id = $form->data[$MyConnection->connection_model_id][$MyConnection->connection_table_primary]; } }else{ if(isset($form->data[$MyConnection->connection_table_primary]) && !empty($form->data[$MyConnection->connection_table_primary])){ $r_id = $form->data[$MyConnection->connection_table_primary]; } } $acl_result = $MyConnection->check_permissions('save', $r_id); if($acl_result === false){ $MyConnection->permission_deny(); $return = false; break; }else if(is_array($acl_result)){ $r_id = $acl_result[0]; } //save/update data $return = $MyConnection->save_action($data); break; case 'edit_data': //check permissions $acl_result = $MyConnection->check_permissions('edit', $data); if($acl_result === false){ $MyConnection->permission_deny(); $return = false; break; }else if(is_array($acl_result)){ $data = $acl_result[0]; } //edit/load record here $row_data = $MyConnection->read_record_data($data); if(is_array($row_data)){ $form->data = array_merge($row_data, $form->data); } $form = $MyConnection->addFormExtension($form, 'edit'); break; /*case 'binary_data': //check permissions $acl_result = $MyConnection->check_permissions('binary', $data); if($acl_result === false){ $MyConnection->permission_deny(); $return = false; break; }else if(is_array($acl_result)){ $data = $acl_result; } //binary records code here $field_name = $received_data['field_name']; $return = $MyConnection->binary_record_data($field_name, $data); break;*/ case 'list_data': default: //check permissions if($MyConnection->check_permissions('list', $data) === false){ $this->permission_deny(); $return = false; break; } //list records code here $actiondata->content1 = $MyConnection->get_list_output(); break; } //check events if($return === true){ $this->events['success'] = 1; }else{ $this->events['fail'] = 1; if(is_string($return)){ if((bool)$params->get('show_returned_errors', 0) === true){ $form->validation_errors[] = $return; }else{ $form->validation_errors[] = $params->get('error_message', ''); $form->debug['Chrono Connectivity Task'][$actiondata->order] = $return; } } } } function load($clear){ if($clear){ $action_params = array( 'task' => '', 'field_name' => '', 'data' => '', 'connection_name' => '', 'error_message' => 'An error has occurred.', 'show_returned_errors' => 0, 'purge_old_data' => 1, 'purge_data_lifetime' => 15 ); } return array('action_params' => $action_params); } } ?>.htaccess000066600000000177151376101340006354 0ustar00 Order allow,deny Deny from all chrono_connectivity_task.ctp000066600000013122151376101340012370 0ustar00
Chrono Connectivity Task
Header(array('settings' => 'Settings', 'help' => 'Help'), 'chrono_connectivity_task_config_{n}'); ?> tabStart('settings'); ?> input('action_chrono_connectivity_task_{n}_connection_name_config', array('type' => 'text', 'label' => "Connection Name", 'class' => 'medium_input', 'smalldesc' => 'Leave empty for auto integration, if no connection name is passed for this action then this will be used.')); ?> input('action_chrono_connectivity_task_{n}_task_config', array('type' => 'select', 'label' => "Task", 'options' => array('list_data' => 'List Data', 'edit_data' => 'Edit/Read Data', 'delete_data' => 'Delete Data', 'save_data' => 'Save Data', 'binary_data' => 'Binary Data'), 'smalldesc' => 'Leave empty for auto integration, if no task is passed for this action then this will be used.')); ?> input('action_chrono_connectivity_task_{n}_data_config', array('type' => 'text', 'label' => "Data field name", 'class' => 'medium_input', 'smalldesc' => 'Leave empty for auto integration, if no data is passed for this action then the value of this field will be used.')); ?> input('action_chrono_connectivity_task_{n}_field_name_config', array('type' => 'text', 'label' => "Field Name", 'class' => 'medium_input', 'smalldesc' => 'Leave empty for auto integration, if no field name is passed for this action then this will be used, useful for "binary" tasks only.')); ?> input('action_chrono_connectivity_task_{n}_error_message_config', array('type' => 'text', 'label' => "Error Message", 'class' => 'medium_input', 'smalldesc' => 'The error message which will be added to the errors/debug (see below) array in case some problem occurred.')); ?> input('action_chrono_connectivity_task_{n}_show_returned_errors_config', array('type' => 'select', 'label' => "Show errors", 'options' => array(0 => 'No (Add to debug only!)', 1 => 'Yes'), 'smalldesc' => 'Should the errors be added to the Errors array (visible to user) or to the Debug messages array ?')); ?> input('action_chrono_connectivity_task_{n}_purge_old_data_config', array('type' => 'select', 'label' => "Purge Old Data", 'options' => array(0 => 'No', 1 => 'Yes'), 'smalldesc' => 'Should the action check and remove any old session data ?')); ?> input('action_chrono_connectivity_task_{n}_purge_data_lifetime_config', array('type' => 'text', 'label' => "Session Data Lifetime", 'class' => 'medium_input', 'smalldesc' => 'The session data life time which will be used to decide if the data is old enough or not.')); ?> tabEnd(); ?> tabStart('help'); ?>

tabEnd(); ?>
cfaction_chrono_connectivity_task.ctp000066600000000245151376101340014240 0ustar00runCode($form, $actiondata); ?>cfaction_chrono_connectivity_task.php000066600000000727151376101340014246 0ustar00params); echo $actiondata->content1; } } ?>index.html000066600000000035151376101340006544 0ustar00