diff --git a/main/admin/promotions.php b/main/admin/promotions.php index c38cfde4d4..ecfa905254 100644 --- a/main/admin/promotions.php +++ b/main/admin/promotions.php @@ -162,7 +162,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 = $promotion->copy($_GET['id']); + $res = $promotion->copy($_GET['id'], null, true); 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 bb0f20d9d1..78cfb4dae9 100644 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -104,6 +104,7 @@ class Career extends Model { /** * Copies the career to a new one * @param integer Career ID + * @param boolean Whether or not to copy the promotions inside * @return integer New career ID on success, false on failure */ public function copy($id, $copy_promotions = false) { diff --git a/main/inc/lib/promotion.lib.php b/main/inc/lib/promotion.lib.php index 273ef75284..09be6dfe1d 100644 --- a/main/inc/lib/promotion.lib.php +++ b/main/inc/lib/promotion.lib.php @@ -114,9 +114,10 @@ class Promotion extends Model { * Copies the promotion to a new one * @param integer Promotion ID * @param integer Career ID, in case we want to change it + * @param boolean Whether or not to copy the sessions inside * @return integer New promotion ID on success, false on failure */ - public function copy($id, $career_id = null) { + public function copy($id, $career_id = null, $copy_sessions = false) { $promotion = $this->get($id); $new = array(); foreach ($promotion as $key => $val) { @@ -143,14 +144,16 @@ class Promotion extends Model { } } $pid = $this->save($new); - //Now also copy each session of the promotion as a new session and register it inside the promotion - require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; - $session_list = SessionManager::get_all_sessions_by_promotion($id); - if (!empty($session_list)) { - foreach($session_list as $item) { - $sid = SessionManager::copy_session($item['id'], true, true); - if ($sid != 0) { - SessionManager::suscribe_sessions_to_promotion($pid,array($sid)); + if ($copy_sessions) { + //Now also copy each session of the promotion as a new session and register it inside the promotion + require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; + $session_list = SessionManager::get_all_sessions_by_promotion($id); + if (!empty($session_list)) { + foreach($session_list as $item) { + $sid = SessionManager::copy_session($item['id'], true, true); + if ($sid != 0) { + SessionManager::suscribe_sessions_to_promotion($pid,array($sid)); + } } } }