* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Job', $id, 'is_active', $is_active);
CRM_Core_DAO::executeQuery($query);
}
+ /**
+ * Make a copy of a Job.
+ *
+ * @param int $id The job id to copy.
+ *
+ * @return CRM_Core_DAO
+ */
+ public static function copy($id, $params = array()) {
+ $fieldsFix = array(
+ 'suffix' => array(
+ 'name' => ' - ' . ts('Copy'),
+ ),
+ 'replace' => $params,
+ );
+ $copy = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_Job', array('id' => $id), NULL, $fieldsFix);
+ $copy->save();
+ CRM_Utils_Hook::copy('Job', $copy);
+
+ return $copy;
+ }
+
}