If you want to execute a script after changing properties of file or folder you can doe this by adding implementation  to tabsextension in siteprofile.

In this case we want to schedule republish of site depending on start/enddate of event

  <contenttype namespace="http://www.example.nl/xmlns/site" cloneoncopy="true">
    <member type="datetime" name="startdate" />
    <member type="datetime" name="enddate" />
  </contenttype>
  <tabsextension xmlns="http://www.webhare.net/xmlns/tollium/screens"
                 name="sitesettings"
                 gid="webdesigns.mysite.sitesettings"
                 implementation="lib"
                 library="sitesettings.whlib"
                 >
    <newtab tid=".dates">
      <datetime composition="contentdata" type="datetime" name="startdate" cellname="startdate" required="true" />
      <datetime composition="contentdata" type="datetime" name="enddate" cellname="enddate" required="true" />
    </newtab>
  </tabsextension>
  <apply>
    <to type="folder" pathmask="/" />
    <extendproperties extension=".sitesettings" contenttype="http://www.example.nl/xmlns/site" />
  </apply>


<?wh
LOADLIB "mod::system/lib/database.whlib";
LOADLIB "mod::tollium/lib/screenbase.whlib";

PUBLIC STATIC OBJECTTYPE sitesettings EXTEND TolliumTabsExtensionBase
<
  UPDATE PUBLIC MACRO SubmitExtension(OBJECT work)
  {
    IF (^enddate->value != DEFAULT DATETIME AND ^enddate->value < ^startdate->value)
      work->AddErrorFor(^enddate, GetTid("modulename:webdesigns.mysite.errors.enddatebeforestartdate"));

    GetPrimary()->RegisterCommitHandler("modulename:schedulenexttask", PTR this->ScheduleNextTask);
  }

  MACRO ScheduleNextTask(BOOLEAN iscommit)
  {
    IF (iscommit)
    {
      OBJECT obj := this->owner->GetAppContext("publisher:applytester");
      DATETIME scheduledate := GetNextScheduleDate( obj->objsite );

      IF( scheduledate != DEFAULT DATETIME )
      {
        GetPrimary()->BeginWork();
        GetPrimary()->ScheduleTask("modulename:taskname", scheduledate );
        GetPrimary()->CommitWork();
      }
    }
  }
>;

Note: NextScheduledate is a custom function which reads given start/enddate settings and returns schedule date depending on current date

Comments