Index: branches/5.2.x/core/units/forms/forms/forms_eh.php =================================================================== diff -u -N -r13840 -r14095 --- branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 13840) +++ branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 14095) @@ -1,6 +1,6 @@ Application->getUnitOption($event->Prefix, 'Sections'); - $forms = $this->Conn->GetCol('SELECT Title, FormId FROM '.TABLE_PREFIX.'Forms ORDER BY Title ASC', 'FormId'); - if (!$forms || count($forms) == 0) { - return; + $forms = $this->getForms(); + + if (!$forms) { + return ; } $form_subsection = Array( @@ -55,6 +55,8 @@ ); $priority = 1; + $sections = $this->Application->getUnitOption($event->Prefix, 'Sections'); + foreach ($forms as $form_id => $form_name) { $this->Application->Phrases->AddCachedPhrase('form_sub_label_'.$form_id, $form_name); $this->Application->Phrases->AddCachedPhrase('la_description_in-portal:submissions:'.$form_id, $form_name.' Submissions'); @@ -67,11 +69,29 @@ $this->Application->setUnitOption($event->Prefix, 'Sections', $sections); } + function getForms() + { + $cache_key = 'forms[%FormSerial%]'; + $forms = $this->Application->getCache($cache_key); + + if ($forms === false) { + $this->Conn->nextQueryCachable = true; + $sql = 'SELECT Title, FormId + FROM ' . TABLE_PREFIX . 'Forms + ORDER BY Title ASC'; + $forms = $this->Conn->GetCol($sql, 'FormId'); + + $this->Application->setCache($cache_key, $forms); + } + + return $forms; + } + function OnSave(&$event) { parent::OnSave($event); - if ($event->status == erSUCCESS) { + if ($event->status == kEvent::erSUCCESS) { $this->OnCreateFormFields($event); $this->_deleteSectionCache(); @@ -82,7 +102,7 @@ { parent::OnMassDelete($event); - if ($event->status == erSUCCESS) { + if ($event->status == kEvent::erSUCCESS) { $this->_deleteSectionCache(); } } @@ -195,7 +215,7 @@ } } else { - $event->status = erFAIL; + $event->status = kEvent::erFAIL; } } @@ -266,7 +286,7 @@ $connection_info[ strtolower($field) ] = $object->GetDBField($mode . $field); } - $pop3_helper =& $this->Application->makeClass('POP3Helper', $connection_info, 10); + $pop3_helper =& $this->Application->makeClass('POP3Helper', Array ($connection_info, 10)); /* @var $pop3_helper POP3Helper */ switch ( $pop3_helper->initMailbox(true) ) { @@ -484,10 +504,10 @@ // what roles are filled from what fields $role_mapping = Array ( - EMAIL_COMMUNICATION_ROLE_EMAIL => 'FromEmail', - EMAIL_COMMUNICATION_ROLE_NAME => 'FromName', - EMAIL_COMMUNICATION_ROLE_SUBJECT => 'Subject', - EMAIL_COMMUNICATION_ROLE_BODY => 'Message', + SubmissionFormField::COMMUNICATION_ROLE_EMAIL => 'FromEmail', + SubmissionFormField::COMMUNICATION_ROLE_NAME => 'FromName', + SubmissionFormField::COMMUNICATION_ROLE_SUBJECT => 'Subject', + SubmissionFormField::COMMUNICATION_ROLE_BODY => 'Message', ); $submission_fields = Array ();