MyBB Community Forums
[F] [ACP] Weekdays select box in task manager [R] [C-Chris] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] [ACP] Weekdays select box in task manager [R] [C-Chris] (/thread-43773.html)



[F] [ACP] Weekdays select box in task manager [R] [C-Chris] - Michael S. - 01-19-2009

If you add a task and select to run it every weekday the options "Every Weekday" and "Sunday" are shown as selected.

Steps to reproduce:
1. Add or edit a task and select to run it every day. Save the task.
2. Edit the task again. Now the options "Every Weekday" and "Sunday" are highlighted.
<option value="*" selected="selected">Every Weekday</option>
<option value="0" selected="selected">Sunday</option>



RE: [ACP] Weekdays select box in task manager - Ryan Gordon - 01-29-2009

in admin/inc/class_form.php find:

if(!empty($selected) && ((string)$value == (string)$selected || (is_array($selected) && in_array($value, $selected))))
			{
				$select_add = " selected=\"selected\"";
			}

replace with

if(!empty($selected))
			{
				if(is_array($selected) && in_array($value, $selected))
				{
					$select_add = " selected=\"selected\"";
				}
				else if((is_string($value) || is_int($value)) && (string)$value == (string)$selected))
				{
					$select_add = " selected=\"selected\"";
				}
			}



RE: [ACP] Weekdays select box in task manager - Michael S. - 01-29-2009

else if((is_string($value) || is_int($value)) && (string)$value == (string)$selected))
I had to remove the last bracket because I got a parsing error. The new code isn't working - the issue still exists.

It seems to be an issue with * and 0. If I replace
if(is_array($selected) && in_array($value, $selected))
with
if(is_array($selected) && in_array("{$value}", $selected))
it's working fine.

Edit:
http://www.php.net/manual/de/function.in-array.php#86695
http://www.php.net/manual/de/function.in-array.php#78524
http://www.php.net/manual/de/function.in-array.php#76857


RE: [ACP] Weekdays select box in task manager - Ryan Gordon - 01-29-2009

Ah. Just change in_array($value, $selected) to in_array($value, $selected, true) then


RE: [ACP] Weekdays select box in task manager - Michael S. - 01-29-2009

That's not working. It shows up fine if you selected "Every Weekday". If you select another day no day is selected if you edit the settings again. I see no problem if I change the code like I posted before.


RE: [ACP] Weekdays select box in task manager - Ryan Gordon - 01-30-2009

Ah that's right, nevermind. It's trying to compare a string to an integer. So instead we simply have to typecast it to a string. Try this, and this one should definately work: in_array((string)$value, $selected)


RE: [ACP] Weekdays select box in task manager - Michael S. - 01-30-2009

Yes, this is working.


RE: [ACP] Weekdays select box in task manager - x_Stricken_x - 01-30-2009

I can confirm it works as wellSmile


[F] [ACP] Weekdays select box in task manager [R] - Ryan Gordon - 01-30-2009

Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group