コード例 #1
0
 /**
  * collect data from POST after submit or update in showadd
  *
  * @param $raidplan
  */
 public function SetRaidplan(Raidplan $raidplan, $action)
 {
     global $user, $template;
     $error = array();
     // read subjectline
     $raidplan->setSubject(utf8_normalize_nfc(request_var('subject', '', true)));
     //read comment section
     $body = utf8_normalize_nfc(request_var('message', '', true));
     $bitfield = $uid = $options = '';
     $allow_bbcode = $allow_urls = $allow_smilies = true;
     generate_text_for_storage($body, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
     $raidplan->setBbcode(array('uid' => $uid, 'bitfield' => $bitfield));
     $raidplan->setBody($body);
     $raidplan->setPoster($user->data['user_id']);
     // set access level
     $raidplan->setAccesslevel(request_var('accesslevel', 0));
     // set member group id
     $raidplan->setGroupId(0);
     $raidplan->setGroupIdList(',');
     $group_id_array = request_var('calGroupId', array(0));
     $num_group_ids = sizeof($group_id_array);
     if ($num_group_ids == 1) {
         // if only one group pass the groupid
         $raidplan->setGroupId($group_id_array[0]);
     } elseif ($num_group_ids > 1) {
         // if we want multiple groups then pass the array
         for ($group_index = 0; $group_index < $num_group_ids; $group_index++) {
             if ($group_id_array[$group_index] == "") {
                 continue;
             }
             $raidplan->setGroupIdList($group_id_array[$group_index] . ",");
         }
     }
     //assign raid team
     switch ($raidplan->getAccesslevel()) {
         case 0:
             //non raid, manual event.
             $raidplan->setSignupsAllowed(0);
             $raidplan->setRaidteam(0);
             break;
         case 1:
             // if we selected group access but didn't actually choose a group then throw error
             if ($num_group_ids < 1) {
                 $error[] = $user->lang['NO_GROUP_SELECTED'];
             }
             //no break!
         //no break!
         case 2:
             //everyone invited
             $raidplan->setRaidteam(request_var('teamselect', request_var('team_id', 0)));
             $raidplan->setSignupsAllowed(1);
             $raidplan->init_raidplan_roles();
             $raidroles = request_var('role_needed', array(0 => 0));
             foreach ($raidroles as $role_id => $needed) {
                 $raidplan->setRaidroles($role_id, (int) $needed);
             }
     }
     //set event type
     $raidplan->setEventType(request_var('bbdkp_events', 0));
     // invite/start date values from pulldown click
     $end_m = request_var('calMEnd', 0);
     $end_d = request_var('calDEnd', 0);
     $end_y = request_var('calYEnd', 0);
     $inv_hr = request_var('calinvHr', 0);
     $inv_mn = request_var('calinvMn', 0);
     $raidplan->setInviteTime(gmmktime($inv_hr, $inv_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst);
     $start_hr = request_var('calHr', 0);
     $start_mn = request_var('calMn', 0);
     $raidplan->setStartTime(gmmktime($start_hr, $start_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst);
     $end_hr = request_var('calEndHr', 0);
     $end_mn = request_var('calEndMn', 0);
     $raidplan->setEndTime(gmmktime($end_hr, $end_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst);
     if ($raidplan->getEndTime() < $raidplan->getStartTime()) {
         //check for enddate before begindate
         // if the end hour is earlier than start hour then roll over a day
         $temp = $raidplan->getEndTime();
         $raidplan->setEndTime($temp += 3600 * 24);
     }
     //if this is not an "all day event"
     $raidplan->setAllDay(0);
     $raidplan->setday(sprintf('%2d-%2d-%4d', $end_d, $end_m, $end_y));
     $raidplan->Check_auth();
     if (count($error) > 0) {
         trigger_error(implode($error, "<br /> "), E_USER_WARNING);
     }
     $str = serialize($raidplan);
     $str1 = base64_encode($str);
     switch ($action) {
         case 'addraid':
             if (!$raidplan->getAuthCanadd()) {
                 trigger_error('USER_CANNOT_POST_RAIDPLAN');
             }
             $s_hidden_fields = build_hidden_fields(array('addraid' => true, 'raidobject' => $str1));
             $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
             confirm_box(false, $user->lang['CONFIRM_ADDRAID'], $s_hidden_fields);
             break;
         case 'updateraid':
             if (!$raidplan->getAuthCanedit()) {
                 trigger_error('USER_CANNOT_EDIT_RAIDPLAN');
             }
             $s_hidden_fields = build_hidden_fields(array('updateraid' => true, 'raidobject' => $str1, 'raidplan_id' => $raidplan->getId()));
             $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
             confirm_box(false, $user->lang['CONFIRM_UPDATERAID'], $s_hidden_fields);
             break;
     }
 }