/** * Run the database seeds. * * @return void */ public function run() { $entry = new Logs(); $entry->user = 1; $entry->action = "Deployed accounting system."; $entry->ip = "127.0.0.1"; $entry->save(); }
/** * parse xml * * @param Request $request * @return \BladeView|bool|\Illuminate\View\View */ public function loadXml(Request $request) { if ($file = $request->file('xml')) { if ($file->getMimeType() == 'application/xml') { $this->url = $file->move('xml/' . file::_get_path(), $file->getFilename()); $this->_parce($this->url); Logs::_create('User parse XML ' . $this->url); $this->data->file_name = $file->getFilename(); return view('admin.xml.view', ['data' => $this->data]); } else { return view('admin.xml.loadxml')->with(['error' => 'No type file']); } } else { return view('admin.xml.loadxml'); } }
Response::dbError('Episode tag creation failed'); } } } } } if ($editing) { $logentry = array('target' => $Episode->formatTitle(AS_ARRAY, 'id')); $changes = 0; if (!empty($Episode->airs)) { $Episode->airs = date('c', strtotime($Episode->airs)); } foreach (array('season', 'episode', 'twoparter', 'title', 'airs') as $k) { if (isset($insert[$k]) && $insert[$k] != $Episode->{$k}) { $logentry["old{$k}"] = $Episode->{$k}; $logentry["new{$k}"] = $insert[$k]; $changes++; } } if ($changes > 0) { Logs::action('episode_modify', $logentry); } } else { Logs::action('episodes', array('action' => 'add', 'season' => $insert['season'], 'episode' => $insert['episode'], 'twoparter' => isset($insert['twoparter']) ? $insert['twoparter'] : 0, 'title' => $insert['title'], 'airs' => $insert['airs'])); } if ($editing) { Response::done(); } Response::done(array('url' => (new Episode($insert))->formatURL())); break; }
public function listCheck($day, $room, $page) { $pagelen = 20; $day = Carbon::parse($day)->format('Y-m-d'); $startDate = date("Y-m-d H:i:s", strtotime($day)); $stopDate = date("Y-m-d H:i:s", strtotime($day . " 23:59:59")); $total_row = Cards::select(DB::raw('COUNT(*) as count'))->where('room_id', '=', $room)->get(); $total_page = ceil((int) $total_row[0]->count / $pagelen); $start = ($page - 1) * $pagelen; $cards = Cards::with("room")->where('room_id', '=', $room)->skip($start)->take($pagelen)->get(); $shows = Logs::with("card")->where('room_id', '=', $room)->whereBetween('access', array($startDate, $stopDate))->groupBy('card_id')->get(); $status = true; return compact("shows", "day", "cards", "status", "total_page"); }
$q[] = "by={$by}"; $title .= (!isset($type) ? 'Entries ' : '') . "by {$by} "; } } else { if (isset($q)) { $q[] = 'by=' . CoreUtils::FIXPATH_EMPTY; } } } $q = array(); if (isset($_GET['js'])) { $q[] = 'js=' . $_GET['js']; } process_filter($q); $Pagination = new Pagination('admin/logs', 20, $Database->count('log')); $heading = 'Global logs'; if (!empty($title)) { $title .= '- '; } $title .= "Page {$Pagination->page} - {$heading}"; CoreUtils::fixPath("/admin/logs/{$Pagination->page}" . (!empty($q) ? '?' . implode('&', $q) : '')); process_filter(); $LogItems = $Database->orderBy('timestamp')->orderBy('entryid')->get('log', $Pagination->getLimit()); if (isset($_GET['js'])) { $Pagination->respond(Logs::getTbody($LogItems), '#logs tbody'); } CoreUtils::loadPage(array('title' => $title, 'view' => "{$do}-logs", 'css' => "{$do}-logs", 'js' => array("{$do}-logs", 'paginate'))); break; default: CoreUtils::notFound(); }
if ($data['label'] !== $Group['label']) { $logdata['oldlabel'] = $Group['label']; $logdata['newlabel'] = $data['label']; } } $origColors = ColorGroups::stringifyColors($origColors); $recvColors = ColorGroups::stringifyColors($recvColors); $colorsChanged = $origColors !== $recvColors; if ($colorsChanged) { $logdata['oldcolors'] = $origColors; $logdata['newcolors'] = $recvColors; } if (!empty($logdata)) { $logdata['groupid'] = $Group['groupid']; $logdata['ponyid'] = $AppearanceID; Logs::action('cg_modify', $logdata); } Response::done($response); } else { CoreUtils::notFound(); } } } } // Tag list if (preg_match(new RegExp('^tags'), $data)) { $Pagination = new Pagination("cg/tags", 20, $CGDb->count('tags')); CoreUtils::fixPath("/cg/tags/{$Pagination->page}"); $heading = "Tags"; $title = "Page {$Pagination->page} - {$heading} - {$Color} Guide"; $Tags = Tags::getFor(null, $Pagination->getLimit(), true);
/** * Remove the specified resource from storage. * * @param $user * @return Response */ public function delete(User $user) { Logs::_create('User deleted ' . $user->name); $user->delete(); return redirect()->back(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $logs = Logs::all(); return $logs; }
/** * Format log entry details * * @param array $MainEntry Main log entry * @param array $data Data to process (sub-log entry) * * @return array */ static function formatEntryDetails($MainEntry, $data) { global $Database, $CGDb; $details = array(); $reftype = $MainEntry['reftype']; switch ($reftype) { case "rolechange": /** @var $target User */ $target = $Database->where('id', $data['target'])->getOne('users'); $details = array(array('Target user', $target->getProfileLink()), array('Old group', Permission::ROLES_ASSOC[$data['oldrole']]), array('New group', Permission::ROLES_ASSOC[$data['newrole']])); break; case "episodes": $details[] = array('Action', self::$ACTIONS[$data['action']]); $details[] = array('Name', (new Episode($data))->formatTitle()); if ($data['season'] === 0) { $details[] = array('Overall', "#{$data['episode']}"); } if (!empty($data['airs'])) { $details[] = array('Air date', Time::tag($data['airs'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME)); } $details[] = array('Two parts', !empty($data['twoparter'])); break; case "episode_modify": $link = $data['target']; $EpData = Episodes::parseID($data['target']); if (!empty($EpData)) { $Episode = Episodes::getActual($EpData['season'], $EpData['episode'], Episodes::ALLOW_MOVIES); if (!empty($Episode)) { $link = "<a href='" . $Episode->formatURL() . "'>" . $Episode->formatTitle(AS_ARRAY, 'id') . "</a>"; } } $details[] = array('Episode', $link); if (empty($Episode)) { $details[] = array('Still exists', false); } unset($data['entryid'], $data['target']); $newOld = self::_arrangeNewOld($data); if (!empty($newOld['airs'])) { $newOld['airs']['old'] = Time::tag($newOld['airs']['old'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME); $newOld['airs']['new'] = Time::tag($newOld['airs']['new'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME); } if (isset($newOld['title']['old']) && isset($newOld['title']['new'])) { $details[] = array('Title', self::charDiff($newOld['title']['old'], $newOld['title']['new'])); unset($newOld['title']); } foreach ($newOld as $thing => $ver) { $details[] = array("Old {$thing}", $ver['old']); $details[] = array("New {$thing}", $ver['new']); } break; case "userfetch": $details[] = array('User', Users::get($data['userid'])->getProfileLink()); break; case "banish": case "un-banish": $details[] = array('User', Users::get($data['target'])->getProfileLink()); $details[] = array('Reason', CoreUtils::escapeHTML($data['reason'])); break; case "post_lock": $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s"); self::_genericPostInfo($Post, $data, $details); break; case "color_modify": $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid'])); $details[] = array('Reason', CoreUtils::escapeHTML($data['reason'])); break; case "req_delete": $details[] = array('Request ID', $data['id']); $typeNames = array('chr' => 'Character', 'obj' => 'Object', 'bg' => 'Background'); $details[] = array('Description', CoreUtils::escapeHTML($data['label'])); $details[] = array('Type', $typeNames[$data['type']]); $IDstr = "S{$data['season']}E{$data['episode']}"; $details[] = array('Episode', "<a href='/episode/{$IDstr}'>{$IDstr}</a>"); $details[] = array('Posted', Time::tag($data['posted'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME)); if (!empty($data['requested_by'])) { $details[] = array('Requested by', Users::get($data['requested_by'])->getProfileLink()); } if (!empty($data['reserved_by'])) { $details[] = array('Reserved by', Users::get($data['reserved_by'])->getProfileLink()); } $details[] = array('Finished', !empty($data['deviation_id'])); if (!empty($data['deviation_id'])) { $details[] = array('Deviation', self::_link("http://fav.me/{$data['deviation_id']}")); $details[] = array('Approved', $data['lock']); } break; case "img_update": $Post = $Database->where('id', $data['id'])->getOne("{$data['thing']}s"); $data['type'] = $data['thing']; self::_genericPostInfo($Post, $data, $details); $details[] = array('Old image', "<a href='{$data['oldfullsize']}' target='_blank'>Full size</a><div><img src='{$data['oldpreview']}'></div>"); $details[] = array('New image', "<a href='{$data['newfullsize']}' target='_blank'>Full size</a><div><img src='{$data['newpreview']}'></div>"); break; case "res_overtake": $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s"); self::_genericPostInfo($Post, $data, $details); $details[] = array('Previous reserver', Users::get($data['reserved_by'])->getProfileLink()); $details[] = array('Previously reserved at', Time::tag($data['reserved_at'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME)); $diff_text = ''; $diff = Time::difference(strtotime($MainEntry['timestamp']), strtotime($data['reserved_at'])); foreach (array_keys(Time::$IN_SECONDS) as $unit) { if (empty($diff[$unit])) { continue; } $diff_text .= CoreUtils::makePlural($unit, $diff[$unit], PREPEND_NUMBER) . ' '; } $details[] = array('In progress for', rtrim($diff_text)); break; case "appearances": $details[] = array('Action', self::$ACTIONS[$data['action']]); $PonyGuide = empty($data['ishuman']); $details[] = array('Guide', $PonyGuide ? 'Pony' : 'EQG'); $details[] = array('ID', self::_getAppearanceLink($data['id'])); $details[] = array('Label', $data['label']); if (!empty($data['order'])) { $details[] = array('Ordering index', $data['order']); } if (!empty($data['notes'])) { $details[] = array('Notes', '<div>' . nl2br($data['notes']) . '</div>'); } if (!empty($data['cm_favme'])) { $details[] = array('CM Submission', self::_link("http://fav.me/{$data['cm_favme']}")); $details[] = array('CM Orientation', CGUtils::$CM_DIR[$data['cm_dir']]); if (!empty($data['cm_preview'])) { $details[] = array('Custom CM Preview', "<img src='" . CoreUtils::aposEncode($data['cm_preview']) . "'>"); } } if (!empty($data['usetemplate'])) { $details[] = array('Template applied', true); } $details[] = array('Private', !empty($data['private'])); if (!empty($data['added'])) { $details[] = array('Added', Time::tag($data['added'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME)); } break; case "res_transfer": $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s"); self::_genericPostInfo($Post, $data, $details); $details[] = array('New reserver', Users::get($data['to'])->getProfileLink()); break; case "cg_modify": $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid'])); $CG = $CGDb->where('groupid', $data['groupid'])->getOne('colorgroups'); if (empty($CG)) { $details[] = array('Color group ID', '#' . $data['groupid']); $details[] = array('Still exists', false); } else { $details[] = array('Group', "{$CG['label']} (#{$data['groupid']})"); } if (isset($data['newlabel'])) { $details[] = array('Label', self::charDiff($data['oldlabel'] ?? '', $data['newlabel'])); } if (isset($data['newcolors'])) { $details[] = array('Colors', self::charDiff($data['oldcolors'] ?? '', $data['newcolors'], 'block')); } break; case "cgs": $details[] = array('Action', self::$ACTIONS[$data['action']]); $details[] = array('Color group ID', '#' . $data['groupid']); $details[] = array('Label', $data['label']); $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid'])); if (isset($data['order'])) { $details[] = array('Ordering index', $data['order']); } break; case "cg_order": $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid'])); $details[] = array('Order', self::charDiff($data['oldgroups'], $data['newgroups'], 'block')); break; case "appearance_modify": $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid'])); $changes = JSON::decode($data['changes']); $newOld = self::_arrangeNewOld($changes); if (isset($newOld['label']['new'])) { $details[] = array('Label', self::charDiff($newOld['label']['old'], $newOld['label']['new'], 'block')); } if (isset($newOld['notes']['new']) || isset($newOld['notes']['old'])) { $details[] = array('Notes', self::charDiff($newOld['notes']['old'] ?? '', $newOld['notes']['new'] ?? '', 'block smaller')); } if (isset($newOld['cm_favme']['old'])) { $details[] = array('Old CM Submission', self::_link('http://fav.me/' . $newOld['cm_favme']['old'])); } else { if (isset($newOld['cm_favme']['new'])) { $details[] = array('Old CM Submission', null); } } if (isset($newOld['cm_favme']['new'])) { $details[] = array('New CM Submission', self::_link('http://fav.me/' . $newOld['cm_favme']['new'])); } else { if (isset($newOld['cm_favme']['old'])) { $details[] = array('New CM Submission', null); } } $olddir = isset($newOld['cm_dir']['old']) ? CGUtils::$CM_DIR[$newOld['cm_dir']['old']] : ''; $newdir = isset($newOld['cm_dir']['new']) ? CGUtils::$CM_DIR[$newOld['cm_dir']['new']] : ''; if ($olddir || $newdir) { $details[] = array('CM Orientation', self::charDiff($olddir, $newdir, 'inline', new FineDiff\Granularity\Paragraph())); } if (isset($newOld['private']['new'])) { $details[] = array('<span class="typcn typcn-lock-' . ($newOld['private']['new'] ? 'closed' : 'open') . '"></span> ' . ($newOld['private']['new'] ? 'Marked private' : 'No longer private'), self::SKIP_VALUE, self::KEYCOLOR_INFO); } if (isset($newOld['cm_preview']['new'])) { $details[] = array('New Custom CM Preview', "<img src='" . CoreUtils::aposEncode($newOld['cm_preview']['new']) . "'>"); } else { if (isset($newOld['cm_preview']['old'])) { $details[] = array('New Custom CM Preview', null); } } break; case "da_namechange": $User = Users::get($data['id'], 'id', 'name'); $newIsCurrent = $User->name === $data['new']; $details[] = array('User', $User->getProfileLink()); if ($newIsCurrent) { $details[] = array('Old name', $data['old']); } else { $details[] = array('Name', Logs::charDiff($data['old'], $data['new'])); } break; case "video_broken": $IDstr = "S{$data['season']}E{$data['episode']}"; $details[] = array('Episode', "<a href='/episode/{$IDstr}'>{$IDstr}</a>"); $url = VideoProvider::getEmbed(new EpisodeVideo(array('provider' => $data['provider'], 'id' => $data['id'])), VideoProvider::URL_ONLY); $details[] = array('Link', "<a href='{$url}'>{$url}</a>"); break; default: $details[] = array('<span class="typcn typcn-warning"></span> Couldn\'t process details', 'No data processor defined for this entry type', self::KEYCOLOR_ERROR); $details[] = array('Raw details', '<pre>' . var_export($data, true) . '</pre>'); break; } return array('details' => $details); }
if (empty($targetUser)) { Response::fail('User not found'); } if ($targetUser->id === $currentUser->id) { Response::fail("You cannot {$action} yourself"); } if (Permission::sufficient('staff', $targetUser->role)) { Response::fail("You cannot {$action} people within the assistant or any higher group"); } if ($action == 'banish' && $targetUser->role === 'ban' || $action == 'un-banish' && $targetUser->role !== 'ban') { Response::fail("This user has already been {$action}ed"); } $reason = (new Input('reason', 'string', array(Input::IN_RANGE => [5, 255], Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Please specify a reason', Input::ERROR_RANGE => 'Reason length must be between @min and @max characters'))))->out(); $changes = array('role' => $action == 'banish' ? 'ban' : 'user'); $Database->where('id', $targetUser->id)->update('users', $changes); Logs::action($action, array('target' => $targetUser->id, 'reason' => $reason)); $changes['role'] = Permission::ROLES_ASSOC[$changes['role']]; $changes['badge'] = Permission::labelInitials($changes['role']); if ($action == 'banish') { Response::done($changes); } Response::success("We welcome {$targetUser->name} back with open hooves!", $changes); } else { CoreUtils::notFound(); } } } if (strtolower($data) === 'immortalsexgod') { $data = 'DJDavid98'; } if (empty($data)) {
/** * Remove the specified resource from storage. * * @param $id * @return Response */ public function delete(Language $language) { Logs::_create('User deleted language ' . $language->name); $language->delete(); return redirect()->back(); }
/** * Approves a specific post and optionally notifies it's author * * @param string $type request/reservation * @param int $id post id * @param string $notifyUserID id of user to notify * * @return array */ static function approve($type, $id, $notifyUserID = null) { global $Database; if (!$Database->where('id', $id)->update("{$type}s", array('lock' => true))) { Response::dbError(); } $postdata = array('type' => $type, 'id' => $id); Logs::action('post_lock', $postdata); if (!empty($notifyUserID)) { Notifications::send($notifyUserID, 'post-approved', $postdata); } return $postdata; }
echo isset($by) || isset($type) ? '' : ' disabled'; ?> ></button> <datalist id="from_values"> <option>Web server</option> <option>you</option> </datalist> </form> <?php echo $Pagination->HTML; ?> <table id="logs"> <thead> <tr> <th class="entryid">#</th> <th class="timestamp">Timestamp</th> <th class="ip">Initiator</th> <th class="reftype">Event</th> </tr> </thead> <tbody><?php echo Logs::getTbody($LogItems); ?> </tbody> </table> <?php echo $Pagination->HTML; } ?> </div>
static function _create($title) { Logs::create(['user_id' => Auth::user()->id, 'title' => $title]); }
public function store_log(Request $request) { $valid = Validator::make($request->all(), ['file' => 'required|mimes:txt']); if ($valid->fails()) { $error = $valid->errors()->all(); return $error; } if ($request->hasFile('file')) { $files = $request->file('file'); $mime = $files->getClientMimeType(); $path = $files->getRealPath(); $room = $request->input('room'); if ($room == 1) { if ($mime == "text/plain") { $contents = file($files->getRealPath()); for ($i = 1; $i < count($contents); $i++) { $tmp = preg_split("/\\s+/", $contents[$i]); $date = $tmp[3] . " " . $tmp[4]; $date = str_replace('/', '-', $date); $date = date("Y-m-d H:i:s", strtotime($date)); $log = Logs::where('access', '=', $date)->get(); if ($log->isEmpty()) { $query = Cards::where('card_id', '=', $tmp[2])->where('room_id', '=', $room)->get(); $log = new Logs(); $log->card_id = $query[0]->id; $log->room_id = $room; $log->date = date("d-m-Y", strtotime($date)); $log->access = $date; $log->save(); } } return "true"; } else { if ($mime == "text/csv") { $open = fopen($path, "r"); $tmp = 0; while (!empty($data = fgetcsv($open))) { if ($tmp != 0) { $data[3] = str_replace('/', '-', $data[3]); $date = date("Y-m-d H:i:s", strtotime($data[3])); $log = Logs::where('access', '=', $date)->get(); if ($log->isEmpty()) { $query = Cards::where('card_id', '=', $data[2])->where('room_id', '=', $room)->get(); $log = new Logs(); $log->card_id = $query[0]->id; $log->room_id = $room; $log->date = date("d-m-Y", strtotime($data[3])); $log->access = $date; $log->save(); } } $tmp = 1; } fclose($open); return "true"; } } } else { if ($room == 2) { $contents = file($files->getRealPath()); for ($i = 1; $i < count($contents); $i++) { $tmp = explode("\t", $contents[$i]); $log = Logs::where('access', '=', $tmp[9])->get(); if ($log->isEmpty()) { if ($tmp[2] != '00000000') { $query = Cards::where('card_id', '=', $tmp[2])->where('room_id', '=', $room)->get(); $log = new Logs(); $log->card_id = $query[0]->id; $log->room_id = $room; $log->date = date("d-m-Y", strtotime($tmp[9])); $log->access = $tmp[9]; $log->save(); } } } return "true"; } } } return "Error"; }
if ($Post->reserved_by !== $currentUser->id) { Response::fail(); } break; } } $image_url = (new Input('image_url', 'string', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Image URL is missing'))))->out(); $Image = Posts::checkImage($image_url, $Post); // Check image availability if (!DeviantArt::isImageAvailable($Image->preview)) { Response::fail("<p class='align-center'>The specified image doesn't seem to exist. Please verify that you can reach the URL below and try again.<br><a href='{$Image->preview}' target='_blank'>{$Image->preview}</a></p>"); } if (!$Database->where('id', $Post->id)->update("{$thing}s", array('preview' => $Image->preview, 'fullsize' => $Image->fullsize))) { Response::dbError(); } Logs::action('img_update', array('id' => $Post->id, 'thing' => $thing, 'oldpreview' => $Post->preview, 'oldfullsize' => $Post->fullsize, 'newpreview' => $Image->preview, 'newfullsize' => $Image->fullsize)); Response::done(array('preview' => $Image->preview)); } else { if (preg_match(new RegExp('^fix-(request|reservation)-stash/(\\d+)$'), $data, $_match)) { if (!Permission::sufficient('staff')) { Response::fail(); } $thing = $_match[1]; $Post = $Database->where('id', $_match[2])->getOne("{$thing}s"); if (empty($Post)) { Response::fail("The specified {$thing} does not exist"); } // Link is already full size, we're done if (preg_match($FULLSIZE_MATCH_REGEX, $Post->fullsize)) { Response::done(array('fullsize' => $Post->fullsize)); }
/** * User Information Fetching * ------------------------- * Fetch user info from dA upon request to nonexistant user * * @param string $username * @param string $dbcols * * @return User|null|false */ function fetch($username, $dbcols = null) { global $Database, $USERNAME_REGEX; if (!$USERNAME_REGEX->match($username)) { return null; } $oldName = $Database->where('old', $username)->getOne('log__da_namechange', 'id'); if (!empty($oldName)) { return self::get($oldName['id'], 'id', $dbcols); } try { $userdata = DeviantArt::request('user/whois', null, array('usernames[0]' => $username)); } catch (CURLRequestException $e) { return null; } if (empty($userdata['results'][0])) { return false; } $userdata = $userdata['results'][0]; $ID = strtolower($userdata['userid']); /** @var $DBUser User */ $DBUser = $Database->where('id', $ID)->getOne('users', 'name'); $userExists = !empty($DBUser); $insert = array('name' => $userdata['username'], 'avatar_url' => URL::makeHttps($userdata['usericon'])); if (!$userExists) { $insert['id'] = $ID; } if (!($userExists ? $Database->where('id', $ID)->update('users', $insert) : $Database->insert('users', $insert))) { throw new \Exception('Saving user data failed' . (Permission::sufficient('developer') ? ': ' . $Database->getLastError() : '')); } if (!$userExists) { Logs::action('userfetch', array('userid' => $insert['id'])); } $names = array($username); if ($userExists && $DBUser->name !== $username) { $names[] = $DBUser->name; } foreach ($names as $name) { if (strcasecmp($name, $insert['name']) !== 0) { if (UserPrefs::get('discord_token', $ID) === 'true') { UserPrefs::set('discord_token', '', $ID); } Logs::action('da_namechange', array('old' => $name, 'new' => $insert['name'], 'id' => $ID), Logs::FORCE_INITIATOR_WEBSERVER); } } return self::get($insert['name'], 'name', $dbcols); }
/** * Update a user's role * * @param string $newgroup * * @return bool */ function updateRole(string $newgroup) : bool { global $Database; $response = $Database->where('id', $this->id)->update('users', array('role' => $newgroup)); if ($response) { Logs::action('rolechange', array('target' => $this->id, 'oldrole' => $this->role, 'newrole' => $newgroup)); } return (bool) $response; }
switch ($Notif['type']) { case "post-passon": $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s"); if (empty($Post)) { Posts::clearTransferAttempts($Post, $data['type'], 'del'); Response::fail("The {$data['type']} doesn't exist or has been deleted"); } if ($read_action === 'true') { if ($Post['reserved_by'] !== $currentUser->id) { Posts::clearTransferAttempts($Post, $data['type'], 'perm', null, $currentUser->id); Response::fail('You are not allowed to transfer this reservation'); } Notifications::safeMarkRead($Notif['id'], $read_action); Notifications::send($data['user'], "post-passallow", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id)); $Database->where('id', $data['id'])->update("{$data['type']}s", array('reserved_by' => $data['user'], 'reserved_at' => date('c'))); Posts::clearTransferAttempts($Post, $data['type'], 'deny'); Logs::action('res_transfer', array('id' => $data['id'], 'type' => $data['type'], 'to' => $data['user'])); } else { Notifications::safeMarkRead($Notif['id'], $read_action); Notifications::send($data['user'], "post-passdeny", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id)); } Response::done(); break; default: Notifications::safeMarkRead($Notif['id'], $read_action); } } else { Notifications::safeMarkRead($Notif['id']); } Response::done(); }