*/ require_once AWP_LIB_DIR . '/Plugin.php'; class AWP_Cases extends AWP_Base { function &instance() { static $instances = array(); if (!isset($instances[0])) { $class = __CLASS__; $instances[0] = & new $class(); } return $instances[0]; } function __construct() { $this->_plugin_activated = false; $settings=array(); $this->_plugin_activated=false; $settings=get_option("awp_plugins"); if(get_option("awp_plugins")!=="false"){ if($settings["cases"]) $this->_plugin_activated=true; } $this->fields = array( array('fieldid' => 'subject','fieldname' => 'Subject','defaulttext' => 'Subject','must_require'=>1,'must'=>1,'showorder' => '1','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'description','fieldname' => 'Description','defaulttext' => 'Description','must_require'=>0,'must'=>0,'showorder' => '2','validation' => 'textarea','fieldtype' => 'textarea'), array('fieldid' => 'priority','fieldname' => 'Priority','defaulttext' => 'Priority','must_require'=>1,'must'=>1,'showorder' => '3','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'firstname','fieldname' => 'First Name','defaulttext' => 'First Name','must_require'=>1,'must'=>1,'showorder' => '4','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'lastname','fieldname' => 'Last Name','defaulttext' => 'Last Name','must_require'=>1,'must'=>1,'showorder' => '5','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'email','fieldname' => 'Email','defaulttext' => 'Email','showorder' => '6','must_require'=>1,'must'=>1,'validation' => 'email','fieldtype' => 'text'), array('fieldid' => 'phone','fieldname' => 'Telephone Number','defaulttext' => 'Telephone Number','must_require'=>0,'must'=>0,'showorder' => '7','validation' => 'phonenumber','fieldtype' => 'text'), array('fieldid' => 'type','fieldname' => 'Type','defaulttext' => 'Type','must_require'=>1,'must'=>1,'showorder' => '8','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'captcha','fieldname' => 'Captcha','defaulttext' => 'Captcha','must_require'=>1,'showorder' => '9','validation' => 'text','fieldtype' => 'captcha'), array('fieldid' => 'customfield1','fieldname' => 'Custom Field 1','defaulttext' => 'Custom Field1','showorder' => '10','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield2','fieldname' => 'Custom Field 2','defaulttext' => 'Custom Field2','showorder' => '11','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield3','fieldname' => 'Custom Field 3','defaulttext' => 'Custom Field3','showorder' => '12','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield4','fieldname' => 'Custom Field 4','defaulttext' => 'Custom Field4','showorder' => '13','validation' => '','fieldtype' => 'radio'), array('fieldid' => 'customfield5','fieldname' => 'Custom Field 5','defaulttext' => 'Custom Field5','showorder' => '14','validation' => '','fieldtype' => 'checkbox') ); $this->validations = array( array('validationLabel' => 'None','validation' => 'none'), array('validationLabel' => 'Email ID','validation' => 'email'), array('validationLabel' => 'Number','validation' => 'number') ); $this->fieldtypes = array( array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'), array('fieldtypeLabel' => 'Radio Option','fieldtype' => 'radio'), array('fieldtypeLabel' => 'Select','fieldtype' => 'select'), array('fieldtypeLabel' => 'Textbox','fieldtype' => 'text'), array('fieldtypeLabel' => 'Textarea','fieldtype' => 'textarea') ); } /** * Runs plugin */ function run() { if($this->_plugin_activated){ add_shortcode('apptivo_cases','apptivo_business_cases'); } } function settings(){ //Theme Templates $themetemplates = get_awpTemplates(TEMPLATEPATH.'/cases','Plugin'); $plugintemplates=$this->get_plugin_templates(); arsort($plugintemplates); if(isset($_POST['awp_cases_settings'])): //Cases Form Propertieds. //template Type& Template Layout if($_POST['awp_cases_templatetype']=="awp_plugin_template"): $templatelayout=$_POST['awp_cases_plugintemplatelayout']; else: $templatelayout=$_POST['awp_cases_themetemplatelayout']; endif; $casesform_properties=array( 'tmpltype' =>$_POST['awp_cases_templatetype'], 'layout' =>$templatelayout, 'confmsg' => stripslashes($_POST['awp_cases_confirmationmsg']), 'confirm_msg_page' => $_POST['awp_cases_confirm_msg_page'], 'confirm_msg_pageid' => $_POST['awp_cases_confirmmsg_pageid'], 'css' => stripslashes($_POST['awp_cases_customcss']), 'submit_button_type' => $_POST['awp_cases_submit_type'], 'submit_button_val' => $_POST['awp_cases_submit_value'] ); //New Custom fields $stack = array(); $addtional_custom = array(); $addtional_order = 15; for($i=6;$i<20;$i++) { if(isset($_POST['customfield'.$i.'_newest']) ) { $addtional_custom = array('fieldid' => 'customfield'.$i.'','fieldname' => 'Custom Field '.$i.'', 'defaulttext' => 'Custom Field'.$i.'','showorder' => $addtional_order,'validation' => '', 'fieldtype' => 'select'); $addtional_order++; array_push($stack, $addtional_custom); }else { break; } } if(!empty($stack)) : update_option('awp_addtional_custom_cases',$stack); endif; //General Cases form fields //For Additional custom fields. $addtional_custom = get_option('awp_addtional_custom_cases'); $master_field = array(); if(!empty($addtional_custom)): $master_field = array_merge($this->fields,$addtional_custom); else: $master_field = $this->fields; endif; $casesformfields=array(); foreach( $master_field as $fieldsmasterproperties ) { $enabled=0; $contactformfield=array(); $fieldid=$fieldsmasterproperties['fieldid']; if(!empty ($_POST[$fieldid.'_order'])){ $displayorder = $_POST[$fieldid.'_order']; } else{ $displayorder = $fieldsmasterproperties['showorder']; } if(!empty ($_POST[$fieldid.'_text'])){ $displaytext = $_POST[$fieldid.'_text']; } else{ $displaytext = $fieldsmasterproperties['defaulttext']; } if($fieldsmasterproperties['must']) { $enabled = 1; $required = 1; } else if($fieldid=='captcha') { $enabled = $_POST[$fieldid.'_show']; $required = 1; } else { $enabled = $_POST[$fieldid.'_show']; $required = $_POST[$fieldid.'_require']; } if($enabled){ $casefield=$this->createformfield_array($fieldid,$displaytext,$required,$_POST[$fieldid.'_type'],$_POST[$fieldid.'_validation'],$_POST[$fieldid.'_options'],$displayorder); array_push($casesformfields, $casefield); } } $cases_fields_properties = array('properties'=>$casesform_properties,'fields'=>$casesformfields); update_option('absp_cases_form_fields',$cases_fields_properties); endif; $absp_cases_fields_properties = get_option('absp_cases_form_fields'); $fields=$absp_cases_fields_properties['fields']; //Cases Fields $formproperties=$absp_cases_fields_properties['properties'];//Case Properties echo '