/** * This function will update the refresh token by the specific user */ public function refreshAndUpdateAccessToken() { $service_bgl360 = new ServiceBgl360($this->wpdb, $this->user_id); $time = new Time(); //Get specific access token $userCurrentAccessToken = $service_bgl360->getCurrentAccessTokenByUser($this->user_id); // $this->authentication_bgl360->clear(); // print_r( $userCurrentAccessToken ); // echo "Current logged in access token " . $userCurrentAccessToken[0]['access_token'] . '<br>'; // echo "Current logged in refresh token " . $userCurrentAccessToken[0]['refresh_token'] . '<br>'; // echo "Is access token expired?<br>" . $userCurrentAccessToken[0]['id'] . ' <BR>'; // @todo get access token by refresh token smsf database. // echo "Token is automatically refreshed <br>"; // echo "refresh token " . $userCurrentAccessToken[0]['refresh_token'] . '<br>'; // Set the refresh token $this->authentication_bgl360->setRefreshTokenUrl($userCurrentAccessToken[0]['refresh_token']); // Set the access token $this->authentication_bgl360->setAccessToken($userCurrentAccessToken[0]['access_token']); // Get the refresh token data composed by the set access and refresh tokens $response = $this->authentication_bgl360->getRefreshTokenData($this->authentication_bgl360->getRefreshTokenUrl()); // print_r($response); // echo "This is refresh url => " . $this->authentication_bgl360->getRefreshTokenUrl() . '<br>'; // If there is something wrong with the refresh token provided then response will include "invalid_token" if ($response['error'] == 'invalid_token') { echo "<span style='color:red' >Refresh token is already used to retrieved new access token </span><br>"; //delete the current user's access tokens if ($service_bgl360->deleteAccessToken($this->user_id)) { echo "user id: " . $this->user_id . " <-- deleted <br>"; } } else { echo "<span style='color:green' > New access token updated</span>"; // Update access token and refresh token by the user in SMSF database $service_bgl360->updateAccessToken(array('access_token' => $response['access_token'], 'refresh_token' => $response['refresh_token'], 'expired_at' => $time->getAccessTokenExpireDateTime(), 'updated_at' => $time->getCurrentDateTime())); } }
function save_instructor(Request $request) { $acam = Session::get('phaseterm'); $instructor = $request->instructor; $class_id = $request->cl_id; // no point if the instructor = 0 if ($instructor != 0) { $time = Time::getPeriod($class_id); $day = Day::getShortDay($class_id); $conflict = Api::checkInstructor($instructor, $time, $day); if ($conflict == false) { $class = Classallocation::find($class_id); $class->instructor = $instructor; $class->save(); if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Successfully Assigned', 'success')); return back(); } } else { if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Conflict')); return back(); } else { echo 'conflict'; } } } else { if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Please Select a instructor')); return back(); } else { echo 'no'; } } }
public function index() { $data['is_showzhiye'] = Zhiye::where('z_show', '=', '1')->get(); $data['allzhiye'] = Zhiye::all(); $data['is_showcompany'] = Company::where('c_show', '=', '1')->get(); $data['allcompany'] = Company::all(); $data['alltime'] = Time::all(); return view('contestRoom.index', $data); }
function testTag() { $now = strtotime('2016-12-03T12:03:56Z'); $result = Time::tag($now, false, Time::TAG_ALLOW_DYNTIME, $now); self::assertEquals("<time datetime='2016-12-03T12:03:56Z' title='3rd Dec 2016, 12:03:56 pm GMT'>a few seconds ago</time>", $result); $result = Time::tag($now, Time::TAG_EXTENDED, Time::TAG_ALLOW_DYNTIME, $now); self::assertEquals("<time datetime='2016-12-03T12:03:56Z'>3rd Dec 2016, 12:03:56 pm GMT</time><span class='dynt-el'>a few seconds ago</span>", $result); $result = Time::tag($now, Time::TAG_EXTENDED, Time::TAG_NO_DYNTIME, $now); self::assertEquals("<time datetime='2016-12-03T12:03:56Z' class='nodt'>3rd Dec 2016, 12:03:56 pm GMT</time>", $result); $result = Time::tag($now, Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME, $now); self::assertEquals("<time datetime='2016-12-03T12:03:56Z' class='no-dynt-el'>3rd Dec 2016, 12:03:56 pm GMT</time>", $result); }
function room($roomId) { $data['system'] = $this->system; $room = Classroom::findOrFail($roomId); $data['room_id'] = $roomId; $data['room_name'] = $room->legacycode; $data['location'] = $room->location; $data['days'] = Day::where('id', '!=', 8)->get(); $data['times'] = Time::all(); $schedCollection = new SchedCollection(); $data['table_day'] = $schedCollection->getSchedRoom($roomId, $this->system); return view('edp.room_sched', $data); }
public function show($id) { $inst = Party::find($id); if ($inst instanceof ModelNotFoundException) { return view('errors.404'); } $data['instructor'] = $inst; $data['classes'] = Classallocation::where('academicterm', $this->system->phaseterm)->where('instructor', $id); $data['days'] = Day::where('id', '!=', 8)->get(); $data['times'] = Time::all(); $schedCollection = new SchedCollection(); $data['table_day'] = $schedCollection->getSchedInstructor($id, $this->system); return view('instructor.sched', $data); }
function add_day_period(Request $request, $id) { if ($request->has('day')) { $valid = $this->assign($request); if ($valid) { return redirect('add_day_period/' . $id); } } elseif ($request->has('submit')) { $this->error = htmlAlert('Please select a day'); } $data['cid'] = $id; $data['error'] = $this->error; $data['cl'] = Classallocation::find($id); $data['days'] = Day::where('id', '!=', 8)->get(); $data['times'] = Time::where('id', '!=', 12)->get(); return view('dean.assigned_subj', $data); }
/** * Render log page <tbody> content * * @param $LogItems * * @return string */ static function getTbody($LogItems) { global $Database; $HTML = ''; if (count($LogItems) > 0) { foreach ($LogItems as $item) { if (!empty($item['initiator'])) { $inituser = Users::get($item['initiator'], 'id'); if (empty($inituser)) { $inituser = '******'; } else { $inituser = $inituser->getProfileLink(); } $ip = in_array($item['ip'], array('::1', '127.0.0.1')) ? "localhost" : $item['ip']; if ($item['ip'] === $_SERVER['REMOTE_ADDR']) { $ip .= ' <span class="self">(from your IP)</span>'; } } else { $inituser = null; $ip = '<a class="server-init" title="Search for all entries by Web server"><span class="typcn typcn-zoom"></span> Web server</a>'; } $event = Logs::$LOG_DESCRIPTION[$item['reftype']] ?? $item['reftype']; if (isset($item['refid'])) { $event = '<span class="expand-section typcn typcn-plus">' . $event . '</span>'; } $ts = Time::tag($item['timestamp'], Time::TAG_EXTENDED); if (!empty($inituser)) { $ip = "{$inituser}<br>{$ip}"; } $HTML .= <<<HTML \t\t<tr> \t\t\t<td class='entryid'>{$item['entryid']}</td> \t\t\t<td class='timestamp'>{$ts}</td> \t\t\t<td class='ip'>{$ip}</td> \t\t\t<td class='reftype'>{$event}</td> \t\t</tr> HTML; } } else { $HTML = '<tr><td colspan="4"><div class="notice info align-center"><label>No log items found</label></td></tr>'; } return $HTML; }
if ($reserved_by === $currentUser->id) { Response::fail("You've already reserved this {$type}"); } if ($Post->isOverdue()) { $message = "This post was reserved " . Time::tag($Post->reserved_at) . " so anyone's free to reserve it now."; $checkIfUserCanReserve($message, $data, 'overdue'); Response::fail($message, $data); } Users::reservationLimitExceeded(); if (!$Post->isTransferable()) { Response::fail("This {$type} was reserved recently, please allow up to 5 days before asking for a transfer"); } $ReserverLink = Users::get($reserved_by, 'id', 'name')->getProfileLink(); $PreviousAttempts = Posts::getTransferAttempts($Post, $type, $currentUser->id, $reserved_by); if (!empty($PreviousAttempts[0]) && empty($PreviousAttempts[0]['read_at'])) { Response::fail("You already expressed your interest in this post to {$ReserverLink} " . Time::tag($PreviousAttempts[0]['sent_at']) . ', please wait for them to respond.'); } $notifSent = Notifications::send($Post->reserved_by, 'post-passon', array('type' => $type, 'id' => $Post->id, 'user' => $currentUser->id)); Response::success("A notification has been sent to {$ReserverLink}, please wait for them to react.<br>If they don't visit the site often, it'd be a good idea to send them a note asking him to consider your inquiry."); } $isUserReserver = $Post->reserved_by === $currentUser->id; if (!empty($Post->reserved_by)) { switch ($action) { case 'reserve': if ($isUserReserver) { Response::fail("You've already reserved this {$type}", array('li' => Posts::getLi($Post))); } if ($Post->isOverdue()) { $overdue = array('reserved_by' => $Post->reserved_by, 'reserved_at' => $Post->reserved_at); $Post->reserved_by = null; break;
/** * Execute the command. * * @return void */ public function handle() { //set_time_limit( 600 ); //ini_set('memory_limit', '256M'); //bump up limits set_time_limit(600); ini_set('memory_limit', '256M'); return; //will we be checking entities $entityCheck = $this->validate_entities == 'on' ? false : true; //create new file $inputFileData = ['raw_data' => $this->data, 'fk_user_id' => $this->userId]; $inputFile = InputFile::create($inputFileData); $inputFileDataId = $inputFile->id; $multivariantDataset = $this->multivariant_dataset; $variables = $this->variables; if (!empty($variables)) { $entityData = []; //creating new datasource, if there is some $sourceName = $this->source_name; if (!empty($sourceName)) { $datasourceData = ['name' => $this->source_name, 'link' => $this->source_link, 'description' => $this->source_description]; $datasource = Datasource::create($datasourceData); } else { //fake datasoure $datasource = new \stdClass(); $datasource->id = null; } //create new dataset or pick existing one $datasetName = $this->new_dataset_name; $datasetData = ['name' => $datasetName, 'fk_dst_cat_id' => $this->category_id, 'fk_dst_subcat_id' => $this->subcategory_id, 'description' => $this->new_dataset_description, 'fk_dsr_id' => $datasource->id]; $dataset = Dataset::create($datasetData); $datasetId = $dataset->id; //process possible tags $tagsInput = $this->new_dataset_tags; if (!empty($tagsInput)) { $tagsArr = explode(',', $tagsInput); foreach ($tagsArr as $tag) { $tag = DatasetTag::create(['name' => $tag]); $tagId = $tag->id; $datasetTagLink = LinkDatasetsTags::create(['fk_dst_id' => $datasetId, 'fk_dst_tags_id' => $tagId]); } } //store inserted variables, for case of rolling back $inserted_variables = array(); foreach ($variables as $variableJsonString) { //convert back single out to actual single quote //$variableJsonString = str_replace( "'", "‘", $variableJsonString ); //setting json_decode second param to false, to try to save memory $variableObj = json_decode($variableJsonString, false); $variableData = ['name' => $variableObj->name, 'fk_var_type_id' => $this->variable_type, 'fk_dst_id' => $datasetId, 'unit' => $variableObj->unit, 'description' => $variableObj->description, 'fk_dsr_id' => $datasource->id]; //update of existing variable or new variable if (!isset($variableObj->id)) { //new variable $variable = Variable::create($variableData); } else { //update variable $variable = Variable::find($variableObj->id); $variable->fill($variableData); $variable->save(); } $variableId = $variable->id; $inserted_variables[] = $variable; $variableValues = $variableObj->values; foreach ($variableValues as $countryValue) { $entityData = ['name' => $countryValue->key, 'fk_ent_t_id' => 5, 'validated' => 0]; if ($entityCheck) { //entity validation (only if not multivariant dataset) //find corresponding iso code $entityIsoName = EntityIsoName::match($entityData['name'])->first(); if (!$entityIsoName) { //!haven't found corresponding country, throw an error! //rollback everything first foreach ($inserted_variables as $inserted_var) { $inserted_var->data()->delete(); $inserted_var->delete(); } //is new dataset if ($this->new_dataset === '1') { $dataset = Dataset::find($datasetId); //delete itself $dataset->delete(); } \Log::error('Error non-existing entity in dataset.'); \Log::error($entityData['name']); return redirect()->route('import')->with('message', 'Error non-existing entity in dataset.')->with('message-class', 'error'); } //enter standardized info $entityData['name'] = $entityIsoName->name; $entityData['code'] = $entityIsoName->code; $entityData['validated'] = 1; } //find try finding entity in db if (isset($entityIsoName)) { $entity = Entity::where('code', $entityIsoName->code)->first(); } else { //not standardized data $entity = Entity::where('code', $entityData['name'])->orWhere('name', $entityData['name'])->first(); } if (!$entity) { //entity haven't found in database, so insert it $entity = Entity::create($entityData); } //check to override validation if stored in db not validated and now is validate if ($entity->validated == 0 && $entityData['validated'] === 1) { $entity->validated = 1; $entity->save(); } $entityId = $entity->id; $countryValues = $countryValue->values; //prepare vars for mass insert $times = []; $values = []; //TODO - get latest time for base timeId $lastTime = Time::orderBy('id', 'desc')->first(); $timeId = !empty($lastTime) ? $lastTime->id : 0; foreach ($countryValues as $value) { if ($this->hasValue($value->x) && $this->hasValue($value->y)) { $timeId++; //create time $timeObj = $value->x; $timeValue = ['startDate' => isset($timeObj->sd) ? $timeObj->sd : "", 'endDate' => isset($timeObj->ed) ? $timeObj->ed : "", 'date' => isset($timeObj->d) ? $timeObj->d : "", 'label' => isset($timeObj->l) ? $timeObj->l : ""]; //convert timedomain $fk_ttype_id = 1; if (!empty($timeObj->td)) { $ttQuery = TimeType::query(); $fk_ttype_id = $ttQuery->whereRaw('LOWER(`name`) like ?', [$timeObj->td])->first()->id; } $timeValue['fk_ttype_id'] = $fk_ttype_id; //using mass insert instead //$time = Time::create( $timeValue ); //$timeId = $time->id; $times[] = $timeValue; //create value $dataValueData = ['value' => $value->y, 'fk_time_id' => $timeId, 'fk_input_files_id' => $inputFileDataId, 'fk_var_id' => $variableId, 'fk_ent_id' => $entityId, 'fk_dsr_id' => $datasource->id]; //using mass insert instead //$dataValue = DataValue::create( $dataValueData ); $values[] = $dataValueData; } } //mass insertion Time::insert($times); DataValue::insert($values); } } } }
*/ use App\ServiceBgl360; use App\AuthenticationBgl360; use App\ResourceRequestBgl360; use App\Time; /** * Declare local and global variables */ global $wpdb; /** * Instantiate classes */ $service_bgl360 = new ServiceBgl360($wpdb, $current_user->ID); $authentication_bgl360 = new AuthenticationBgl360(); $resource_request_bgl360 = new ResourceRequestBgl360(); $time = new Time(); /** * Set up authentication data */ //echo "this is authentication page <br>"; $clientId = 'f937a03e-db37-4213-9d37-9484e7eab33d'; $clientSecret = '9a88e4bc-ab1c-41b3-a8b3-a5f7b32502de'; $basicAuthorizationHeader = 'ZjkzN2EwM2UtZGIzNy00MjEzLTlkMzctOTQ4NGU3ZWFiMzNkOjlhODhlNGJjLWFiMWMtNDFiMy1hOGIzLWE1ZjdiMzI1MDJkZQ=='; $authentication_bgl360->setRedirectUrlToAuthorizationPage("https://api.bgl360.com.au/oauth/authorize?response_type=code&client_id={$clientId}&scope=investment&redirect_uri=https://app.thesmsfacademy.com.au/wp-bgl360-authenticate.php"); $authentication_bgl360->setMainUri('https://api.bgl360.com.au/oauth/token'); $authentication_bgl360->setAuthorizationCode($authentication_bgl360->getAuthorizationCode()); $authentication_bgl360->setGrantType('authorization_code'); $authentication_bgl360->setScope('investment'); $authentication_bgl360->setClientId($clientId); $authentication_bgl360->setClientSecret($clientSecret); $authentication_bgl360->setRedirectUri('https://app.thesmsfacademy.com.au/wp-bgl360-authenticate.php');
use App\AuthenticationBgl360; use App\ResourceRequestBgl360; use App\Time; use App\AccessToken; /** * Initialized global and local variables */ global $wpdb; $totalDaysRemaining = 0; /** * Instantiate classes */ $service_bgl360 = new ServiceBgl360($wpdb, $current_user->ID); $authentication_bgl360 = new AuthenticationBgl360(); $resource_request_bgl360 = new ResourceRequestBgl360(); $time = new Time(); /** * Get all access token saved to database */ $accessData = $service_bgl360->getAccessTokens(); foreach ($accessData as $accessToken) { echo "id = " . $accessToken['id'] . "<br>"; echo " current date " . $time->getCurrentDate() . '<br>'; echo " expired at date " . $time->toDate($accessToken['expired_at']) . '<br>'; echo " Total remaining days " . $time->getTotalRemainingDays($time->getCurrentDate(), $time->toDate($accessToken['expired_at'])) . '<br>'; /** * Get total days remaining */ if ($time->getTotalRemainingDays($time->getCurrentDate(), $time->toDate($accessToken['expired_at'])) == 0) { /** * Update access token because total days passed days is 6
</div> <div class="main"> <div> <h1><?php echo CoreUtils::escapeHTML($heading); ?> </h1> <p>Vector Requests & Reservations</p> <?php if (Permission::sufficient('staff')) { ?> <p class="addedby"><em><?php echo $CurrentEpisode->isMovie ? 'Movie' : 'Episode'; ?> added by <?php echo Users::get($CurrentEpisode->posted_by)->getProfileLink() . ' ' . Time::tag($CurrentEpisode->posted); ?> </em></p> <?php } ?> </div> </div> <div class="next-ep"><?php if (!empty($NextEpisode)) { $NextEpisodeTitle = $NextEpisode->formatTitle(AS_ARRAY, null, false); ?> <div> <a href="<?php echo $NextEpisode->formatURL(); ?>
/** * Save a new time entry to the database * * @param Request $request The incoming request. * * @return Response */ public function store(TimeRequest $request) { $time = new Time(); $time->project_id = (int) $request->project_id; $time->estimatedDuration = (int) $request->estimatedDuration; $time->start = $request->start; $time->minutes = $request->minutes; $time->summary = $request->summary; $time->user()->associate($request->user()); $time->save(); $userMessage = $this->successMessage('time entry'); return redirect()->route('time.index', [$time->id])->with('userMessage', $userMessage); }
/** * List ltem generator function for reservation suggestions * This function assumes that the post it's being used for is not reserved or it can be contested. * * @param Request $Request * * @return string */ static function getSuggestionLi(Request $Request) : string { $escapedLabel = CoreUtils::aposEncode($Request->label); $label = self::_getPostLabel($Request); $time_ago = Time::tag($Request->posted); $reserve = self::getPostReserveButton($Request, null, false); return <<<HTML <li id="request-{$Request->id}"> \t<div class="image screencap"> \t\t<a href="{$Request->fullsize}" target="_blank"> \t\t\t<img src="{$Request->fullsize}" alt="{$escapedLabel}"> \t\t</a> \t</div> \t{$label} \t<em class="post-date">Requested <a href="{$Request->toLink()}">{$time_ago}</a> under {$Request->toAnchor()}</em> \t{$reserve} </li> HTML; }
*/ use App\ServiceBgl360; use App\AuthenticationBgl360; use App\ResourceRequestBgl360; use App\Time; /** * Declare local and global variables */ global $wpdb; /** * Instantiate classes */ $service_bgl360 = new ServiceBgl360($wpdb, $current_user->ID); $authentication_bgl360 = new AuthenticationBgl360(); $resource_request_bgl360 = new ResourceRequestBgl360(); $time = new Time(); /** * Set up authentication data */ $authentication_bgl360->setRedirectUrlToAuthorizationPage("https://api-staging.bgl360.com.au/oauth/authorize?response_type=code&client_id=5dbf9b2c-981f-44e4-8212-d3b5c74795a1&scope=investment&redirect_uri=https://app.thesmsfacademy.com.au/bgl360-authenticate.php"); $authentication_bgl360->setMainUri('https://api-staging.bgl360.com.au/oauth/token'); $authentication_bgl360->setAuthorizationCode($authentication_bgl360->getAuthorizationCode()); $authentication_bgl360->setGrantType('authorization_code'); $authentication_bgl360->setScope('investment'); $authentication_bgl360->setClientId('5dbf9b2c-981f-44e4-8212-d3b5c74795a1'); $authentication_bgl360->setClientSecret('b5a0ff39-ef93-4bc7-b5de-e0ace2d7a6fc'); $authentication_bgl360->setRedirectUri('https://app.thesmsfacademy.com.au/bgl360-authenticate.php'); $authentication_bgl360->setAccessTokenUri($authentication_bgl360->getAccessTokenUri()); if ($service_bgl360->isExistAccessToken()) { // Get access token from database $userCurrentAccessToken = $service_bgl360->getCurrentAccessTokenByUser();
/** * Display a listing of the resource. * * @return Response */ public function index($page = '') { return view('home.time')->withTimes(Time::orderBy('created_at', 'DESC')->paginate(10)->setPath('time')); }
private static function _getNotifElem($html, $n) { if (empty(self::$ACTIONABLE_NOTIF_OPTIONS[$n['type']])) { $actions = "<span class='mark-read variant-green typcn typcn-tick' title='Mark read' data-id='{$n['id']}'></span>"; } else { $actions = ''; foreach (self::$ACTIONABLE_NOTIF_OPTIONS[$n['type']] as $value => $opt) { $actions .= "<span class='mark-read variant-{$opt['color']} typcn typcn-{$opt['icon']}' title='{$opt['label']}' data-id='{$n['id']}' data-value='{$value}'></span>"; } } return "<li>{$html} <span class='nobr'>– " . Time::tag(strtotime($n['sent_at'])) . "{$actions}</span></li>"; }
/** * Returns the HTML of the GIT informaiiton in the website's footer * * @param bool $appendSeparator * * @return string */ static function getFooterGitInfo(bool $appendSeparator = true) : string { $commit_info = "Running <strong><a href='" . GITHUB_URL . "' title='Visit the GitHub repository'>MLPVC-RR</a>"; $commit_id = rtrim(shell_exec('git rev-parse --short=4 HEAD')); if (!empty($commit_id)) { $commit_time = Time::tag(date('c', strtotime(shell_exec('git log -1 --date=short --pretty=format:%ci')))); $commit_info .= "@<a href='" . GITHUB_URL . "/commit/{$commit_id}' title='See exactly what was changed and why'>{$commit_id}</a></strong> created {$commit_time}"; } else { $commit_info .= "</strong> (version information unavailable)"; } if ($appendSeparator) { $commit_info .= ' | '; } return $commit_info; }
/** * Returns the markup for the time of last update displayed under an appaerance * * @param int $PonyID * @param bool $wrap * * @return string */ static function getUpdatesHTML($PonyID, $wrap = WRAP) { global $Database; $update = Updates::get($PonyID, MOST_RECENT); if (!empty($update)) { $update = "Last updated " . Time::tag($update['timestamp']); } else { if (!Permission::sufficient('staff')) { return ''; } $update = ''; } return $wrap ? "<div class='update'>{$update}</div>" : $update; }
/** * Display a project * * @param Request $request The incoming request. * @param integer $id A project primary key. * * @return Response */ public function show(Request $request, $id) { $project = $request->user()->projects()->with('client')->findOrFail($id); $numMonths = 6; $timeByMonth = Time::forProjectAndUserByMonth($project, $request->user(), $numMonths); $totalTime = $project->time()->sum('minutes'); $slice = array_slice($timeByMonth, 0, $numMonths); $sliceTotal = array_sum($slice); $viewVars = ['project' => $project, 'page_title' => $project->name, 'totalTime' => $totalTime, 'slice' => $slice, 'sliceTotal' => $sliceTotal, 'sliceRange' => $numMonths]; return view('projects.show', $viewVars); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $time = Time::find($id); if (file_exists(public_path() . '/uploads/' . $time->image && $time->image)) { unlink(public_path() . '/uploads/' . $time->image); } $time->delete(); return Redirect::to('Today/time'); }
if (!empty($Unbanishes)){ $Banishes = array_merge($Banishes,$Unbanishes); usort($Banishes, function($a, $b){ $a = strtotime($a['timestamp']); $b = strtotime($b['timestamp']); return $a > $b ? -1 : ($a < $b ? 1 : 0); }); unset($Unbanishes); } $displayInitiator = Permission::sufficient('staff'); foreach ($Banishes as $b){ $initiator = $displayInitiator ? Users::get($b['initiator']) : null; $b['reason'] = htmlspecialchars($b['reason']); echo "<li class=".strtolower($Actions[$b['action']])."><blockquote>{$b['reason']}</blockquote> - ".(isset($initiator)?$initiator->getProfileLink().' ':'').Time::tag($b['timestamp'])."</li>"; } } ?></ul> </section> </div> <div id="settings"><?php if ($sameUser || Permission::sufficient('staff')){ ?> <section class="guide-settings"> <h2><?=$sameUser? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff']:''?>Color Guide</h2> <form action="/preference/set/cg_itemsperpage"> <label> <span>Appearances per page</span> <input type="number" min="7" max="20" name="value" value="<?=UserPrefs::get('cg_itemsperpage', $User->id)?>" step="1"<?=!$sameUser?' disabled':''?>> <?php if ($sameUser){ ?> <button class="save typcn typcn-tick green" disabled>Save</button>
static function getPendingReservationsHTML($UserID, $sameUser, &$YouHave = null) { global $Database, $currentUser; $YouHave = $sameUser ? 'You have' : 'This user has'; $PrivateSection = $sameUser ? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff'] : ''; $cols = "id, season, episode, preview, label, posted, reserved_by"; $PendingReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('reservations', null, $cols); $PendingRequestReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('requests', null, "{$cols}, reserved_at, true as requested_by"); $TotalPending = count($PendingReservations) + count($PendingRequestReservations); $hasPending = $TotalPending > 0; $HTML = ''; if (Permission::sufficient('staff') || $sameUser) { $pendingCountReadable = $hasPending > 0 ? "<strong>{$TotalPending}</strong>" : 'no'; $posts = CoreUtils::makePlural('reservation', $TotalPending); $gamble = $TotalPending < 4 && $sameUser ? ' <button id="suggestion" class="btn orange typcn typcn-lightbulb">Suggestion</button>' : ''; $HTML .= <<<HTML <section class='pending-reservations'> <h2>{$PrivateSection}Pending reservations{$gamble}</h2> \t\t\t\t<span>{$YouHave} {$pendingCountReadable} pending {$posts} HTML; if ($hasPending) { $HTML .= " which ha" . ($TotalPending !== 1 ? 've' : 's') . "n't been marked as finished yet"; } $HTML .= "."; if ($sameUser) { $HTML .= " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your pending reservations."; } $HTML .= "</span>"; if ($hasPending) { /** @var $Posts Post[] */ $Posts = array_merge(Posts::getReservationsSection($PendingReservations, RETURN_ARRANGED)['unfinished'], array_filter(array_values(Posts::getRequestsSection($PendingRequestReservations, RETURN_ARRANGED)['unfinished']))); usort($Posts, function (Post $a, Post $b) { $a = strtotime($a->posted); $b = strtotime($b->posted); return -($a < $b ? -1 : ($a === $b ? 0 : 1)); }); $LIST = ''; foreach ($Posts as $Post) { unset($_); $postLink = $Post->toLink($_); $postAnchor = $Post->toAnchor(null, $_); $label = !empty($Post->label) ? "<span class='label'>{$Post->label}</span>" : ''; $is_request = isset($Post->rq); $reservation_time_known = !empty($Post->reserved_at); $posted = Time::tag($is_request && $reservation_time_known ? $Post->reserved_at : $Post->posted); $PostedAction = $is_request && !$reservation_time_known ? 'Posted' : 'Reserved'; $contestable = $Post->isOverdue() ? Posts::CONTESTABLE : ''; $LIST .= <<<HTML <li> <div class='image screencap'> \t<a href='{$postLink}'><img src='{$Post->preview}'></a> </div> {$label} <em>{$PostedAction} under {$postAnchor} {$posted}</em>{$contestable} <div> \t<a href='{$postLink}' class='btn blue typcn typcn-arrow-forward'>View</a> \t<button class='red typcn typcn-user-delete cancel'>Cancel</button> </div> </li> HTML; } $HTML .= "<ul>{$LIST}</ul>"; } $HTML .= "</section>"; } return $HTML; }
public static function checkInstructor($instructor, $time, $day) { $instructor_sched = Day_period::getInstructorsSched($instructor); $subject_time = explode(' / ', $time); $subject_day = explode(' / ', $day); foreach ($instructor_sched as $sched) { if (!in_array('TBA', $subject_day)) { $inst_day = Day::find($sched->day); if (!in_array($inst_day, $subject_day)) { $from = Time::find($sched->from_time); $to = Time::find($sched->to_time); foreach ($subject_time as $key) { $keys = explode('-', $key); $isConflict = intersectCheck($from->time, $keys[0], $to->time, $keys[1]); if ($isConflict) { return true; } } } } } return false; }
/** * Render episode voting HTML * * @param Episode $Episode * * @return string */ static function getSidebarVoting(Episode $Episode) : string { $thing = $Episode->isMovie ? 'movie' : 'episode'; if (!$Episode->aired) { return "<p>Voting will start " . Time::tag($Episode->willair) . ", after the {$thing} had aired.</p>"; } global $Database, $signedIn, $currentUser; $HTML = ''; if (empty($Episode->score)) { $Episode->updateScore(); } $Score = preg_replace(new RegExp('^(\\d+)\\.0+$'), '$1', number_format($Episode->score, 1)); $ScorePercent = round($Score / 5 * 1000) / 10; $HTML .= '<p>' . (!empty($Score) ? "This {$thing} is rated {$Score}/5 (<a class='detail'>Details</a>)" : 'Nopony voted yet.') . '</p>'; if ($Score > 0) { $HTML .= "<img src='/muffin-rating?w={$ScorePercent}' id='muffins' alt='muffin rating svg'>"; } $UserVote = Episodes::getUserVote($Episode); if (empty($UserVote)) { $HTML .= "<br><p>What did <em>you</em> think about the {$thing}?</p>"; if ($signedIn) { $HTML .= "<button class='blue rate typcn typcn-star'>Cast your vote</button>"; } else { $HTML .= "<p><em>Sign in above to cast your vote!</em></p>"; } } else { $HTML .= "<p>Your rating: " . CoreUtils::makePlural('muffin', $UserVote['vote'], PREPEND_NUMBER) . '</p>'; } return $HTML; }
public function stop($id) { $time = \App\Time::find($id); $time->touch(); return \Redirect::route('projects.tickets.show', ['project_id' => $time->ticket->project->id, 'ticket_id' => $time->ticket->id]); }
public function entity(Request $request) { try { $name = $request->get('name'); $entityCheck = $request->has('entityCheck') ? $request->get('entityCheck') : false; $inputFileDataId = $request->has('inputFileId') ? $request->get('inputFileId') : ''; $datasourceId = $request->has('datasourceId') ? $request->get('datasourceId') : ''; $variableId = $request->has('variableId') ? $request->get('variableId') : ''; $entityData = ['name' => $name, 'fk_ent_t_id' => 5, 'validated' => 0]; if ($entityCheck) { //entity validation (only if not multivariant dataset) //find corresponding iso code $entityIsoName = EntityIsoName::match($entityData['name'])->first(); if (!$entityIsoName) { return redirect()->route('import')->with('message', 'Error non-existing entity in dataset.')->with('message-class', 'error'); } //enter standardized info $entityData['name'] = $entityIsoName->name; $entityData['code'] = $entityIsoName->code; $entityData['validated'] = 1; } //find try finding entity in db if (isset($entityIsoName)) { $entity = Entity::where('code', $entityIsoName->code)->first(); } else { //not standardized data $entity = Entity::where('code', $entityData['name'])->orWhere('name', $entityData['name'])->first(); } if (!$entity) { //entity haven't found in database, so insert it $entity = Entity::create($entityData); } //check to override validation if stored in db not validated and now is validate if ($entity->validated == 0 && $entityData['validated'] === 1) { $entity->validated = 1; $entity->save(); } $entityId = $entity->id; $countryValues = $request->get("values"); //$countryValue->values; //prepare vars for mass insert $times = []; $values = []; //TODO - get latest time for base timeId $lastTime = Time::orderBy('id', 'desc')->first(); $timeId = !empty($lastTime) ? $lastTime->id : 0; foreach ($countryValues as $value) { if (isset($value['x']) && isset($value['y']) && $this->hasValue($value['x']) && $this->hasValue($value['y'])) { $timeId++; //create time $timeObj = $value['x']; $timeValue = ['startDate' => isset($timeObj['sd']) ? $timeObj['sd'] : "", 'endDate' => isset($timeObj['ed']) ? $timeObj['ed'] : "", 'date' => isset($timeObj['d']) ? $timeObj['d'] : "", 'label' => isset($timeObj['l']) ? $timeObj['l'] : ""]; //convert timedomain $fk_ttype_id = 1; if (!empty($timeObj['td'])) { $ttQuery = TimeType::query(); $fk_ttype_id = $ttQuery->whereRaw('LOWER(`name`) like ?', [$timeObj['td']])->first()->id; } $timeValue['fk_ttype_id'] = $fk_ttype_id; //using mass insert instead //$time = Time::create( $timeValue ); //$timeId = $time->id; $times[] = $timeValue; //create value $dataValueData = ['value' => $value['y'], 'fk_time_id' => $timeId, 'fk_input_files_id' => $inputFileDataId, 'fk_var_id' => $variableId, 'fk_ent_id' => $entityId, 'fk_dsr_id' => $datasourceId]; //using mass insert instead //$dataValue = DataValue::create( $dataValueData ); $values[] = $dataValueData; } } //mass insertion Time::insert($times); DataValue::insert($values); return ['success' => true]; } catch (Exception $e) { return ['success' => false]; } }