diff --git a/main/admin/careers.php b/main/admin/careers.php index c702999241..5b05eae816 100644 --- a/main/admin/careers.php +++ b/main/admin/careers.php @@ -148,7 +148,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } - $res = $career->copy($_GET['id']); + $res = $career->copy($_GET['id'], true); //copy career and promotions inside if ($res) { Display::display_confirmation_message(get_lang('Copied')); } diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index 75b616c0d7..bb0f20d9d1 100644 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -106,7 +106,7 @@ class Career extends Model { * @param integer Career ID * @return integer New career ID on success, false on failure */ - public function copy($id) { + public function copy($id, $copy_promotions = false) { $career = $this->get($id); $new = array(); foreach ($career as $key => $val) { @@ -128,12 +128,14 @@ class Career extends Model { } } $cid = $this->save($new); - //Now also copy each session of the promotion as a new session and register it inside the promotion - $promotion = new Promotion(); - $promo_list = $promotion->get_all_promotions_by_career_id($id); - if (!empty($promo_list)) { - foreach($promo_list as $item) { - $pid = $promotion->copy($item['id'], $cid); + if ($copy_promotions) { + //Now also copy each session of the promotion as a new session and register it inside the promotion + $promotion = new Promotion(); + $promo_list = $promotion->get_all_promotions_by_career_id($id); + if (!empty($promo_list)) { + foreach($promo_list as $item) { + $pid = $promotion->copy($item['id'], $cid); + } } } return $cid;