/** * Register new task for plugin (called by plugin during install) * * @param $itemtype : itemtype of the plugin object * @param $name : of the task * @param $frequency : of execution * @param $options array of optional options * (state, mode, allowmode, hourmin, hourmax, logs_lifetime, param, comment) * * @return bool for success **/ public static function Register($itemtype, $name, $frequency, $options = array()) { // Check that hook exists if (!isPluginItemType($itemtype)) { return false; } $input = array('itemtype' => $itemtype, 'name' => $name, 'frequency' => $frequency); foreach (array('allowmode', 'comment', 'hourmax', 'hourmin', 'logs_lifetime', 'mode', 'param', 'state') as $key) { if (isset($options[$key])) { $input[$key] = $options[$key]; } } $temp = new CronTask(); return $temp->add($input); }