Roxen.git / server / etc / modules / Variable.pmod / Schedule.pike

version» Context lines:

Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:139:      #endif      #define VALS_SORT 0   #define VALS_REPEAT_HOURS 1   #define VALS_REPEAT_COUNT 2   #define VALS_DAY 3   #define VALS_HOUR 4   #define VALS_MINUTE 5    + protected multiset(int(0..2)) valid_sorts = (< 0, 1, 2 >); +    //! Transforms the form variables given in the @[vl] attribute   //! to the internal time representation as follows.   //!   //! @array   //! @elem int(0..2) sort   //! @int   //! @value 0   //! Never   //! @value 1   //! Every x hour   //! @value 2   //! Every x y at z   //! @endint -  + //!   //! @elem int(1..23) hour   //! Number of hours between restarts.   //!   //! @elem int(1..9) everynth   //! Number of days or weeks to skip between restarts.   //!   //! @elem int(0..7) day   //! @int   //! @value 0   //! Day   //! @value 1   //! Sunday   //! @value 2..7   //! Rest of weekdays   //! @endint -  + //!   //! @elem int(0..23) time_hour   //! Time at which to restart (hour). -  + //!   //! @elem int(0..59)|void time_min   //! Time at which to restart (minute).   //! If not present at minute 0 (compat).   //! @endarray   array transform_from_form( string what, mapping vl )   {    array res = query() + ({});    if(sizeof(res) <= VALS_HOUR) {    res = ({ 0, 2, 1, 6, 3, -1 });    } else if (sizeof(res) <= VALS_MINUTE) {
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:198:    }       if (!res[VALS_MINUTE]) {    // Compat.    res = res[..VALS_HOUR];    }       return res;   }    + array verify_set_from_form(array val) + { +  if ((sizeof(val) >= VALS_SORT) && +  !valid_sorts[val[VALS_SORT]]) { +  throw("Invalid operation mode.\n"); +  } +  return ::verify_set_from_form(val); + } +    protected int mktime(mapping m)   {    int t = predef::mktime(m);    if (m->timezone) {    // Compensate for cases where predef::mktime() is broken.    // Cf [WS-469].    t += t - predef::mktime(localtime(t));    }    return t;   }
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:352: Inside #if constant(roxenp)
  }      string render_form( RequestID id, void|mapping additional_args )   {    string res, inp1, inp2, inp3, inp4;    array vals = query();    if (sizeof(vals) == VALS_MINUTE) {    vals += ({ 0 });    }    -  res = "<table>" +  res = "<table>"; +  +  if (valid_sorts[0]) { +  res +=    "<tr valign='top'><td><input name='" + path() + "' value='0' type='radio' " +    checked(0,0) + " /></td><td>" + LOCALE(482, "Never") + "</td></tr>\n"; -  +  }    -  +  if (valid_sorts[1]) {    inp1 = HTML.select(path()+"1", "123456789"/1 + "1011121314151617181920212223"/2, (string)vals[VALS_REPEAT_HOURS]);       res += "<tr valign='top'><td><input name='" + path() + "' value='1' type='radio' " +    checked(0,1) + " /></td><td>" + sprintf( LOCALE(483, "Every %s hour(s)."), inp1) +    "</td></tr>\n"; -  +  }    -  +  if (valid_sorts[2]) {    inp1 = HTML.select(path()+"2", "123456789"/1, (string)vals[VALS_REPEAT_COUNT]);    inp2 = HTML.select(path()+"3", ({    ({ "0", LOCALE(484, "Day") }),    ({ "1", LOCALE(485, "Sunday") }),    ({ "2", LOCALE(486, "Monday") }), -  ({ "3", LOCALE(487, "Tuesday") }), +  ({ "3", LOCALE(487, "Tuesday") }),    ({ "4", LOCALE(488, "Wednesday") }),    ({ "5", LOCALE(489, "Thursday") }),    ({ "6", LOCALE(490, "Friday") }),    ({ "7", LOCALE(491, "Saturday") }) }), (string)vals[VALS_DAY]);    inp3 = HTML.select(path()+"4",    "000102030405060708091011121314151617181920212223"/2,    sprintf("%02d", vals[VALS_HOUR]));    inp4 = HTML.select(path()+"5",    "00153045"/2,    sprintf("%02d", vals[VALS_MINUTE]));       res += "<tr valign='top'><td><input name='" + path() + "' value='2' type='radio' " +    checked(0,2) + " /></td>\n<td>" +    sprintf(LOCALE(492, "Every %s %s at %s:%s o'clock."),    inp1, inp2, inp3, inp4) + -  "</td></tr>\n</table>"; +  "</td></tr>\n"; +  }    -  +  res += "</table>"; +     return res;   }      string render_view( RequestID id, void|mapping additional_args )   {    array res = query();    if (sizeof(res) == VALS_MINUTE) {    res += ({ 0 });    }    switch(res[VALS_SORT]) {
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:419: Inside #if constant(roxenp)
   })[res[VALS_DAY]];       return sprintf(LOCALE(494, "Every %d %s at %02d:%02d"),    res[VALS_REPEAT_COUNT], period,    res[VALS_HOUR], res[VALS_MINUTE]);    default:    return LOCALE(495, "Error in stored value.");    }   }    + protected void create(array(int) default_value, void|int flags, +  void|LocaleString std_name, void|LocaleString std_doc, +  multiset(int(0..2))|void valid_sorts) + { +  if (valid_sorts) { +  this_program::valid_sorts &= valid_sorts; +  if (!sizeof(this_program::valid_sorts)) { +  error("Invalid set of operation modes for Schedule: %O\n", valid_sorts); +  } +  } +  if (sizeof(default_value||({})) && +  !this_program::valid_sorts[default_value[VALS_SORT]]) { +  error("Invalid default mode for Schedule: %O\n", default_value[VALS_SORT]); +  } +  ::create(default_value, flags, std_name, std_doc); + } +    #endif