/** * Adds raid to bbdkp * */ public function raidplan_push() { global $cache, $user, $config, $phpbb_root_path, $phpEx; $cache->destroy('sql', RP_RAIDS_TABLE); $this->roles = $this->_get_roles(); $this->raidroles = $this->_init_raidplan_roles(); $this->Get_Raidplan(); if (!class_exists('\\bbdkp\\controller\\raids\\RaidController')) { require "{$phpbb_root_path}includes/bbdkp/controller/raids/RaidController.{$phpEx}"; } // check if raid exists in bbdkp if ($this->raid_id > 0) { $RaidController = new RaidController(); $raidinfo = array('raid_id' => (int) $this->raid_id, 'event_id' => $this->event_type, 'raid_value' => (double) $this->eventlist[$this->event_type]['value'], 'time_bonus' => 0, 'raid_note' => $this->body, 'raid_start' => $this->start_time, 'raid_end' => $this->end_time); $RaidController->update_raid($raidinfo); //get all confirmed raiders $raid_attendees = array(); foreach ($this->raidroles as $key => $role) { foreach ($role['role_confirmations'] as $confirmation) { if (is_object($confirmation) && $confirmation instanceof \bbdkp\controller\raidplanner\RaidplanSignup) { $raid_attendees[] = $confirmation->getDkpmemberid(); } } } // now check if any of them are not registered in dkp, if they are not then add them $raiddetail = new Raiddetail($this->raid_id); $raiddetail->Get($this->raid_id); $registered = array(); foreach ($raiddetail->raid_details as $member_id => $attendee) { $registered[] = (int) $member_id; } // $to_add = array_diff($raid_attendees, $registered); if (count($to_add) > 0) { foreach ($to_add as $member_id) { $newraider = new Raiddetail($this->raid_id); $newraider->raid_value = (double) $this->eventlist[$this->event_type]['value']; $newraider->time_bonus = 0; $newraider->zerosum_bonus = 0; $newraider->raid_decay = 0; $newraider->dkpid = $this->eventlist[$this->event_type]['dkpid']; $newraider->member_id = $member_id; $newraider->create(); unset($newraider); } } } else { //new raid if ($config['rp_rppushmode'] == 0 && $this->signups['confirmed'] > 0) { // automatic mode, don't ask permisison $raid_attendees = array(); foreach ($this->raidroles as $key => $role) { foreach ($role['role_confirmations'] as $confirmation) { if (is_object($confirmation) && $confirmation instanceof \bbdkp\controller\raidplanner\RaidplanSignup) { $raid_attendees[] = $confirmation->getDkpmemberid(); } } } // timebonus is hardcoded to zero but could be changed later... $raid = array('raid_note' => $this->body, 'raid_value' => $this->eventlist[$this->event_type]['value'], 'raid_timebonus' => request_var('hidden_raid_timebonus', 0.0), 'zerosum_bonus' => 0, 'raid_decay' => 0, 'raid_start' => $this->start_time, 'raid_end' => $this->end_time, 'event_name' => $this->eventlist[$this->event_type]['event_name'], 'event_id' => $this->event_type, 'dkpid' => $this->eventlist[$this->event_type]['dkpid'], 'raid_attendees' => $raid_attendees); $this->exec_pushraid($raid); } else { //insert if (confirm_box(true)) { // recall hidden vars $raid = array('raid_note' => utf8_normalize_nfc(request_var('hidden_raid_note', ' ', true)), 'raid_value' => request_var('hidden_raid_value', 0.0), 'raid_timebonus' => request_var('hidden_raid_timebonus', 0.0), 'zerosum_bonus' => 0, 'raid_decay' => 0, 'raid_start' => request_var('hidden_startraid_date', 0), 'raid_end' => request_var('hidden_endraid_date', 0), 'event_name' => utf8_normalize_nfc(request_var('hidden_raid_name', ' ', true)), 'event_id' => request_var('hidden_event_id', 0), 'dkpid' => request_var('hidden_dkpid', 0), 'raid_attendees' => request_var('hidden_raid_attendees', array(0 => 0))); $this->exec_pushraid($raid); } else { // store raidinfo as hidden vars // this clears the $_POST array $raid_attendees = array(); foreach ($this->raidroles as $key => $role) { foreach ($role['role_confirmations'] as $confirmation) { if (is_object($confirmation) && $confirmation instanceof \bbdkp\controller\raidplanner\RaidplanSignup) { $raid_attendees[] = $confirmation->getDkpmemberid(); } } } // timebonus is hardcoded to zero but could be changed later... $s_hidden_fields = build_hidden_fields(array('hidden_raid_id' => $this->raid_id, 'hidden_raid_note' => $this->body, 'hidden_event_id' => $this->event_type, 'hidden_raid_name' => $this->eventlist[$this->event_type]['event_name'], 'hidden_raid_value' => $this->eventlist[$this->event_type]['value'], 'hidden_dkpid' => $this->eventlist[$this->event_type]['dkpid'], 'hidden_raid_timebonus' => 0, 'hidden_startraid_date' => $this->start_time, 'hidden_endraid_date' => $this->end_time, 'hidden_raid_attendees' => $raid_attendees, 'pushraidplan' => true)); confirm_box(false, sprintf($user->lang['CONFIRM_CREATE_RAID'], $this->eventlist[$this->event_type]['event_name']), $s_hidden_fields); } } } unset($RaidController); $cache->destroy('sql', RP_RAIDS_TABLE); $this->Get_Raidplan(); }