Hi Richard
We seem to have identified what’s causing the problem. It seems that the misbehaviour is in one of the EE core files.
We’re triggering the error based on the categories posted in one of our hooks and are showing it by using the new_entry_form function:
$EE->new_entry_form('preview', '<ul><li>'.implode('</li><li>',array_filter($errors)).'</li></ul>');
$EXT->end_script = TRUE;
At around the line 2876 in cp.publish.php, the following code handles EE date fields:
if ($dtwhich != 'preview' OR $submission_error != '')
{
$localize = TRUE;
print_r($field_data);
if ($field_data != '' AND isset($result))
{
if (isset($result->row['field_dt_'.$row['field_id']]) AND $result->row['field_dt_'.$row['field_id']] != '')
{
$field_data = $LOC->offset_entry_dst($field_data, $dst_enabled);
$field_data = $LOC->simpl_offset($field_data, $result->row['field_dt_'.$row['field_id']]);
$localize = FALSE;
}
}
if ($field_data != '')
$custom_date = $LOC->set_human_time($field_data, $localize);
$cal_date = ($LOC->set_localized_time($field_data) * 1000);
}
else
{
$custom_date = $_POST[$date_field];
$cal_date = ($custom_date != '') ? ($LOC->set_localized_time($LOC->convert_human_date_to_gmt($custom_date)) * 1000) : ($LOC->set_localized_time() * 1000);
}
Now, the date from your custom date field is passed along to this functon corretly, it’s correclty in the $_POST var and also in this function, the troublemaker now are the following lines:
if ($field_data != '')
$custom_date = $LOC->set_human_time($field_data, $localize);
$field_data contains the correnct date (something like 2008-10-23 05:19 PM for example), the function $LOC->set_human_time being called with the $field_data value for the date field however returns always 1970-01-01 03:33 AM which is also the value being shown in the date’s text field.
Seems that $custom_date is always 1970-01-01 03:33 AM in that case.
Changing those lines to
if ($field_data != '')
$custom_date = $field_data;
correctly renders the date in the date’s text field as now the value of $custom_date is the actual posted value.
However, we should definitely get a word from the core developers on this as it seems that the set_human_time function renders the wrong date? Are we missing something?
Thanks very much Peter for looking into the problem. It seems like you have made a lot of progress in identifying the problem. Just a shame that it appears to be a problem that you personally can’t solve. So, I too look forward to some feedback from the folks at EE with regards to this!
Thanks again
Hi Peter, I thought I would point you to a thread in Tech Support relating to some other time bugs I have been having with Custom Date fields. As it turns out they appear to have been ironed out but only after completely removing the Required Category extension from my site.
Take a look: http://ellislab.com/forums/viewthread/94734/
Hi Peter,
There is a problem experienced when Required Category extension is used with nested categories.
Let me describe it in general terms.
Suppose:
1) the weblog “My Weblog” has category group such as this:
Category A (level 1) Category B (level 2) Category C (level 2) Category d (level 2)
2) the weblog “My Weblog” has following Required Category settings:
Posts in this weblog require at least one category? - No. Maximum number of categories - 1. Number of categories has to equal the maximum - Yes.
3) the entry “My Entry” was posted into the weblog “My Weblog” and assigned to Category C which is subcategory of Category A.
4) the entry “My Entry” was opened, some corrections was made and the button “Submit” was pressed.
The result is two error warnings:
Posts in this weblog cannot have more than one category associated with them. Posts in this weblog must have exactly one category associated with them.
These error warnings are being displayed because the entry “My Entry” was automatically assigned to Category A which is parent category of Category C.
In this case the content author must open Categories tab and assign entry only to Category C. This is quite confusing to content authors. It would be better if Required Category Extension took account of parent category/subcategory relationship in such cases. That is, it seems to me that if an entry is assigned to two categories and one category is the parent of the other category, the Required Category extension should treat such assignment as assignment to one category.
I made necessary changes enabling such functionality. If you like them, feel free to include into official version.
I have two category[] fields in my SAEF, so initially the extension did not work for me - even though both fields were empty.
To fix that, I’ve added following code in function _check_errors
for ($j=0; $j<=count($_POST['category']); $j++) {
if ($_POST['category'][$j]=="") {
unset($_POST['category'][$j]);
}
}
just before
// category required
if ($this->require_cat && empty($_POST['category']))
Greetings, After a harrowing experience with an entirely blank EE site, and subsequent re-installation of the build, I received the following error when attempting to log in: Warning: Missing argument 1 for edit_weblog_prefs() in …/extensions/ext.dc_required_category.php on line 261 Is there anything I can do about this? I think I’d ultimately like to remove the extension altogether since now the members have gotten used to selecting a category with their entry. Thank you! Brian M.
EDIT: Solved my issue by searching the database in phpMyAdmin and deleting all occurrences of dc_required.
Hi
Yes, there will be an EE2 version of the extension. We’re also going to try to incorporate the additional features added already by Laisvunas in this thread. What I cannot say yet, is when the EE2 version is going to be ready, just had some busy times, getting better now.
Try to hang in there!
I’ve updated the extension to the version 1.0.6 incorporating the changes from Laisvunas. Feel free to update and get back in case something does not work as advertised.
http://github.com/designchuchi/dc.template_manager.ee_addon/archives/master
Starting to port the extension to EE2.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.