/** * Handles creating new default templates. * * @param string $template_pack This corresponds to a template pack class reference * which will contain information about where to obtain the templates. * @return mixed (array|bool) success array or false. */ protected function _create_new_templates($template_pack) { $this->_set_templates($template_pack); //necessary properties are set, let's save the default templates if (empty($this->_GRP_ID)) { $main_template_data = array('MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_override' => 0, 'MTP_deleted' => 0, 'MTP_is_global' => 1, 'MTP_user_id' => EEH_Activation::get_default_creator_id(), 'MTP_is_active' => 1); //let's insert the above and get our GRP_ID, then reset the template data array to just include the GRP_ID $grp_id = $this->_message_template_group_model->insert($main_template_data); if (empty($grp_id)) { return $grp_id; } $this->_GRP_ID = $grp_id; } $template_data = array('GRP_ID' => $this->_GRP_ID); foreach ($this->_contexts as $context => $details) { foreach ($this->_fields as $field => $field_type) { if ($field != 'extra') { $template_data['MTP_context'] = $context; $template_data['MTP_template_field'] = $field; $template_data['MTP_content'] = $this->_templates[$context][$field]; $MTP = $this->_message_template_model->insert($template_data); if (!$MTP) { EE_Error::add_error(sprintf(__('There was an error in saving new template data for %1$s messenger, %2$s message type, %3$s context and %4$s template field.', 'event_espresso'), $this->_messenger->name, $this->_message_type->name, $context, $field), __FILE__, __FUNCTION__, __LINE__); return false; } } } } return array('GRP_ID' => $this->_GRP_ID, 'MTP_context' => key($this->_contexts)); }