public function execute()
 {
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $etSID = SJB_Array::get($passed_parameters_via_uri, 0);
     }
     $field_id = SJB_Request::getVar('field_id', null);
     $etInfo = SJB_EmailTemplateEditor::getEmailTemplateInfoBySID($etSID);
     if (is_null($etSID) || is_null($field_id)) {
         $errors['PARAMETERS_MISSED'] = 1;
     } elseif (is_null($etInfo) || !isset($etInfo[$field_id])) {
         $errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
     } else {
         $uploaded_file_id = $etInfo[$field_id];
         SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id);
         $etInfo[$field_id] = '';
         $emailTemplate = new SJB_EmailTemplate($etInfo);
         $emailTemplate->setSID($etSID);
         SJB_EmailTemplateEditor::saveEmailTemplate($emailTemplate);
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-email-templates/' . $emailTemplate->getPropertyValue('group') . '/' . $etSID);
     }
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('errors', isset($errors) ? $errors : null);
     $tp->display('delete_uploaded_file.tpl');
 }
Example #2
0
 /**
  * @static
  * @param SJB_EmailTemplate $emailTpl
  * @return array
  */
 public static function createTemplateStructureForEmailTpl(SJB_EmailTemplate $emailTpl)
 {
     if (!$emailTpl) {
         return array();
     }
     $structure = array();
     foreach ($emailTpl->getProperties() as $property) {
         if ($property->getType() == 'list') {
             $value = $property->getValue();
             $listValues = isset($property->type->property_info['list_values']) ? $property->type->property_info['list_values'] : array();
             foreach ($listValues as $listValue) {
                 if ($listValue['id'] == $value) {
                     $structure[$property->getID()] = $listValue['caption'];
                 }
             }
         } else {
             $structure[$property->getID()] = $property->getValue();
         }
     }
     $structure['id'] = $emailTpl->getID();
     return $structure;
 }
Example #3
0
 /**
  * add new template process
  * @return bool
  */
 protected function addNewTemplateForm($etGroup = '')
 {
     $errors = null;
     $form_is_submitted = SJB_Request::getVar('et_submit', false);
     $tplInfo = array_merge(array('group' => $etGroup), $_REQUEST);
     $emailTemplate = new SJB_EmailTemplate($tplInfo);
     $emailTemplate_edit_form = new SJB_Form($emailTemplate);
     $emailTemplate_edit_form->registerTags($this->tp);
     if ($form_is_submitted) {
         if ($emailTemplate_edit_form->isDataValid($errors)) {
             $etGroupExists = SJB_Array::get($this->etGroups, $emailTemplate->getPropertyValue('group'));
             if ($etGroupExists) {
                 $emailTemplate->setPropertyValue('user_defined', true);
                 SJB_EmailTemplateEditor::saveEmailTemplate($emailTemplate);
                 $this->successMessage = 'Email template is successfully added';
                 $emailTemplate = new SJB_EmailTemplate(array('group' => $etGroup));
                 $emailTemplate_edit_form = new SJB_Form($emailTemplate);
                 $emailTemplate_edit_form->registerTags($this->tp);
             } else {
                 $this->error = 'WRONG_GROUP';
             }
         }
     }
     $this->errors = $errors;
     $this->tp->assign('form_fields', $emailTemplate_edit_form->getFormFieldsInfo());
 }