Code Duplication    Length = 14-16 lines in 2 locations

calendar/inc/class.calendar_so.inc.php 2 locations

@@ 2408-2421 (lines=14) @@
2405
	 * @param int $cal_id Id of the calendar-entry
2406
	 * @return int number of alarms deleted
2407
	 */
2408
	private function delete_alarms($cal_id)
2409
	{
2410
		//error_log(__METHOD__."($cal_id) ".function_backtrace());
2411
		if (($alarms = $this->read_alarms($cal_id)))
2412
		{
2413
			foreach(array_keys($alarms) as $id)
2414
			{
2415
				$this->async->cancel_timer($id);
2416
			}
2417
			// update cache, if used
2418
			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2419
		}
2420
		return count($alarms);
2421
	}
2422
2423
	/**
2424
	 * delete one alarms identified by its id
@@ 2429-2444 (lines=16) @@
2426
	 * @param string $id alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is used as the job-id too
2427
	 * @return int number of alarms deleted
2428
	 */
2429
	function delete_alarm($id)
2430
	{
2431
		//error_log(__METHOD__."('$id') ".function_backtrace());
2432
		// update the modification information of the related event
2433
		list(,$cal_id) = explode(':',$id);
2434
		if ($cal_id)
2435
		{
2436
			$this->updateModified($cal_id, true);
2437
		}
2438
		$ret = $this->async->cancel_timer($id);
2439
2440
		// update cache, if used
2441
		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2442
2443
		return $ret;
2444
	}
2445
2446
	/**
2447
	 * Delete account hook