cloneCalendar() static public method

Duplicate all holidays from a calendar to its clone
static public cloneCalendar ( $oldid, $newid )
$oldid
$newid
コード例 #1
0
 /** Clone a calendar to another entity : name is updated
  *
  * @param $options array of new values to set
  **/
 function duplicate($options = array())
 {
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             if (isset($this->fields[$key])) {
                 $this->fields[$key] = $val;
             }
         }
     }
     $input = $this->fields;
     $oldID = $input['id'];
     unset($input['id']);
     if ($newID = $this->add($input)) {
         Calendar_Holiday::cloneCalendar($oldID, $newID);
         CalendarSegment::cloneCalendar($oldID, $newID);
         $this->updateDurationCache($newID);
         return true;
     }
     return false;
 }
コード例 #2
0
 /** Clone a calendar to another entity : name is updated
  * @param $options array of new values to set
  **/
 function duplicate($options = array())
 {
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             if (isset($this->fields[$key])) {
                 $this->fields[$key] = $val;
             }
         }
     }
     $input = $this->fields;
     $oldID = $input['id'];
     unset($input['id']);
     $newID = $this->add($input);
     $calhol = new Calendar_Holiday();
     $calhol->cloneCalendar($oldID, $newID);
     $calseg = new CalendarSegment();
     $calseg->cloneCalendar($oldID, $newID);
     $this->updateDurationCache($newID);
 }