Version 4 > Content Model > Content date services

Content date services

Dates can be assigned to content objects. This can be used for a variety of purposes, including setting up scheduled tasks, placing things onto a calendar, or simply logging notes on the content. Dates can be date ranges, with a start and end. Dates have the following attributes:

  • type: task, todo, calendar, log, other
  • description: a text description or action
  • start, end: datetime values (start is required, end is not)
  • status: active dates will be selected by the system; inactive dates will be ignored; completed dates are tasks or todo items that have been marked as done

Tasks

Tasks are automatically scheduled actions that the system can take. To setup a task, add a content_date record with type “task”, and the start date/time set to when you want the task to execute. The description should be a task action that is recognized by that content type. By default, the following actions are known:

  • publish
  • unpublish
  • archive

Other content types can define their own actions to extend the set of permitted tasks. They can announce their allowed tasks using the method allowed_tasks(). The cron.pl script handles the scheduling; it runs hourly, so task execution times only have a granularity of 1 hour by default.

“Active” tasks will execute once; after execution completes, the system sets the end date of the task to the execution time, and changes the task status to “completed”. Tasks can also be set to “hourly”, “daily”, or “weekly”, in which case they will run periodically after the start date and before the end date.

To-do Lists

Tasks allow the system to perform certain preset automatic jobs for you. In cases where the job is too complicated to automate, you can use to-do lists to setup reminders and checklists for yourself to do them manually. To setup a to-do, add a content_date record with type “todo”, and the start date/time set to your desired reminder date. The description should be a message to yourself indicating the work that needs to be done. To-do items can be viewed using the ToDo plugin application, which also allows you to strike items off your to-do list.

You can quickly add items to a to-do list with the call:

$c->todo($description,$date);

Logbook

To log notes on a content object, set the type to “log”, and the description to the log message, or use the call:

$c->log($message);

The system will automatically log workflow if you set $config{log_workflow} = 1 in your configuration settings.

Calendars

Dates of type "calendar" are used to mark content as being pertinent to those dates. This is used by calendar and event content types to place the events onto the calendar.

Events can have more than one date associated with them. For example, an event that occurs every Tuesday evening will have one calendar date for each of those occurrences. Something like a course will have multiple classes (for example, 12 classes in total), and then the whole course will repeat as a new event with its own set of 12 dates. That way, each running of the course is handled as a separate event with its own registration.