Пример #1
0
            $form->setConstants(array('sec_token' => $token));
            $form->display();
        }
        break;
    case 'delete':
        if ($check) {
            // Action handling: deleting an obj
            $res = $promotion->delete($_GET['id']);
            if ($res) {
                Display::display_confirmation_message(get_lang('ItemDeleted'));
            }
        }
        $promotion->display();
        break;
    case 'copy':
        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
            api_not_allowed();
        }
        if ($check) {
            $res = $promotion->copy($_GET['id'], null, true);
            if ($res) {
                Display::display_confirmation_message(get_lang('ItemCopied') . ' - ' . get_lang('ExerciseAndLPsAreInvisibleInTheNewCourse'));
            }
        }
        $promotion->display();
        break;
    default:
        $promotion->display();
        break;
}
Display::display_footer();
Пример #2
0
 /**
  * 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)
 {
     $career = $this->get($id);
     $new = array();
     foreach ($career as $key => $val) {
         switch ($key) {
             case 'id':
             case 'updated_at':
                 break;
             case 'name':
                 $val .= ' ' . get_lang('CopyLabelSuffix');
                 $new[$key] = $val;
                 break;
             case 'created_at':
                 $val = api_get_utc_datetime();
                 $new[$key] = $val;
                 break;
             default:
                 $new[$key] = $val;
                 break;
         }
     }
     $cid = $this->save($new);
     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;
 }