예제 #1
0
 case 'create':
     // Record new goal
 // Record new goal
 case 'create_new':
     // Record goal and create new
 // Record goal and create new
 case 'create_copy':
     // Record goal and create similar
     // Insert new file type...:
     $edited_Goal = new Goal();
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('goal');
     // Check permission:
     $current_User->check_perm('stats', 'edit', true);
     // load data from request
     if ($edited_Goal->load_from_Request()) {
         // We could load data from form without errors:
         // Insert in DB:
         $DB->begin();
         $q = $edited_Goal->dbexists();
         if ($q) {
             // We have a duplicate entry:
             param_error('goal_key', sprintf(T_('This goal already exists. Do you want to <a %s>edit the existing goal</a>?'), 'href="?ctrl=goals&amp;action=edit&amp;goal_ID=' . $q . '"'));
         } else {
             $edited_Goal->dbinsert();
             $Messages->add(T_('New goal created.'), 'success');
         }
         $DB->commit();
         if (empty($q)) {
             // What next?
             switch ($action) {