public static function SetTimeUnit($p_unit, $p_languageId, $p_name) { $timeUnit = new TimeUnit($p_unit, $p_languageId); if ($timeUnit->exists()) { $timeUnit->setProperty('Name', $p_name); } else { $timeUnit->create(array('Name' => $p_name)); } }
/** * Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted. * * @param int $timeout * @param TimeUnit|null $unit the timeunit of the given timeout * @return bool true if the count reached zero and false if the waiting time elapsed before the count reached zero */ public function await($timeout = 0, TimeUnit $unit = null) { if (null !== $unit) { $timeout = $unit->toMicros($timeout); } $timeoutAt = microtime(true) + $timeout / 1000000; while (0 != $this->count) { if ($timeout > 0 && microtime(true) > $timeoutAt) { return false; } time_nanosleep(0, 1); } return true; }
public function getLength() { $begin = $this->begin->toDateTime(); $end = $this->end->toDateTime(); $diff = $begin->diff($end); return new Duration($diff->format('%H'), TimeUnit::hour()); }
/** * * @param string $ruleId * @param RuleCriteriaType $criteriaType */ function buildNewInstance($ruleId, $criteriaType) { $criteria = parent::buildNewInstance($ruleId, $criteriaType); $criteria->interval = 1; $criteria->intervalType = TimeUnit::from(TimeUnit::Month); return $criteria; }
/** * @param RuleCriteriaType $ruleCriteriaType * @return RuleCriteria */ function build($ruleCriteriaType, $value, $methodDetail) { $method = $ruleCriteriaType->method; $criteria = new RuleCriteriaAge($method == 'age_max' ? 'max' : 'min', $value, TimeUnit::from($methodDetail)); $criteria->value = $value; return $criteria; }
function _action_submit_intervals() { // parse results from response $ruleId = _post('id'); $rule = $this->getRuleManager()->getRule($ruleId); // new intervals object $intervals = new ReminderIntervals(); $change = false; foreach (ReminderIntervalType::values() as $type) { foreach (ReminderIntervalRange::values() as $range) { $amtKey = $type->code . "-" . $range->code; $timeKey = $amtKey . "-timeunit"; $amt = _post($amtKey); $timeUnit = TimeUnit::from(_post($timeKey)); if ($amt && $timeUnit) { $detail = new ReminderIntervalDetail($type, $range, $amt, $timeUnit); $intervals->addDetail($detail); $change = true; } } } if ($change) { $this->getRuleManager()->updateIntervals($rule, $intervals); } $this->redirect("index.php?action=detail!view&id={$ruleId}"); }
function updateFromRequest() { parent::updateFromRequest(); $age = _post("fld_value"); $timeUnit = TimeUnit::from(_post("fld_timeunit")); $this->value = $age; $this->timeUnit = $timeUnit; }
function updateFromRequest() { parent::updateFromRequest(); $age = _post("fld_value"); $timeUnit = TimeUnit::from(_post("fld_timeunit")); if ($timeUnit == null) { $timeUnit = TimeUnit::from(_post("fld_target_interval_type")); } $this->value = $age; $this->timeUnit = $timeUnit; }
<?php require_once $base_path . 'classes/checkframework.php'; $clone_court = $_POST['clone_court']; $clone_from = $_POST['clone_from']; $clone_to = $_POST['clone_to']; $success = TimeUnit::myclone($clone_court, $clone_from, $clone_to, $selected_date); echo $success;
function updateFromRequest() { $inclusion = "yes" == _post("fld_inclusion"); $optional = "yes" == _post("fld_optional"); $groupId = _post("group_id"); $interval = _post("fld_target_interval"); $intervalType = TimeUnit::from(_post("fld_target_interval_type")); $this->groupId = $groupId; $this->optional = $optional; $this->inclusion = $inclusion; $this->interval = $interval; $this->intervalType = $intervalType; }
<?php require_once $base_path . 'classes/checkframework.php'; $clone_court = $_POST['clone_court']; $clone_from = $_POST['clone_from']; $clone_to = $_POST['clone_to']; $success = TimeUnit::deleteday($clone_court, $selected_date); echo $success;
camp_html_display_error(getGS("You do not have the right to manage publications.")); exit; } $Pub = Input::Get('Pub', 'int'); $Language = Input::Get('Language', 'int', 1, true); if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']); exit; } $publicationObj = new Publication($Pub); $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), $publicationObj->getLanguageId()); if (!$pubTimeUnit->exists()) { $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), 1); } $countries = Country::GetCountries($Language); include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); $crumbs = array(getGS("Subscriptions") => "deftime.php?Pub=$Pub&Language=$Language"); camp_html_content_top(getGS("Set subscription settings for a country"), array("Pub" => $publicationObj), true, false, $crumbs); ?> <P> <FORM METHOD="POST" ACTION="do_countryadd.php" onsubmit="return <?php camp_html_fvalidate(); ?>;"> <?php echo SecurityToken::FormParameter(); ?> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="box_table"> <INPUT TYPE="HIDDEN" NAME="cPub" VALUE="<?php p($Pub); ?>">
<?php require_once 'classes/_loader.php'; require_once 'classes/init.php'; $date = $_GET['date']; $date = str_replace(' (Central Europe Daylight Time)', '', $date); $date = strtotime($date); if ($date === false) { $ret = array('error' => 'Invalid date'); } else { $date_formatted = date('Y-m-d', $date); $login = new Login('users'); $logined_user = $login->doLogin() == 1 ? $login->obj : null; $timeunits = TimeUnit::get_day_timeunits($date_formatted, $logined_user); $ret = $timeunits; } echo json_encode($ret); require_once 'classes/close.php';
public function previous() { return $this->minus(new Duration(1, TimeUnit::day())); }
require_once $GLOBALS['g_campsiteDir'] . "/classes/TimeUnit.php"; // Check permissions if (!$g_user->hasPermission('ManagePub')) { camp_html_display_error(getGS("You do not have the right to manage publications.")); exit; } $Pub = Input::Get('Pub', 'int'); $Language = Input::Get('Language', 'int', 1); if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']); exit; } $publicationObj = new Publication($Pub); $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), $publicationObj->getLanguageId()); if (!$pubTimeUnit->exists()) { $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), 1); } $defaultTimes = SubscriptionDefaultTime::GetSubscriptionDefaultTimes(null, $Pub); include_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/javascript_common.php"; camp_html_content_top(getGS("Subscription Settings by Country"), array("Pub" => $publicationObj)); ?> <p> <TABLE class="action_buttons"> <TR> <TD><A HREF="/<?php echo $ADMIN; ?> /pub/countryadd.php?Pub=<?php p($Pub); ?> &Language=<?php
<?php require_once $base_path . 'classes/checkframework.php'; $clone_court = $_POST['clone_court']; $competition_name = $_POST['competition_name']; $competition_from = $_POST['competition_from']; $competition_to = $_POST['competition_to']; $competition_fromt = $_POST['competition_fromt']; $competition_tot = $_POST['competition_tot']; $confirm = $_POST['confirm']; $ret = TimeUnit::competition_create($clone_court, $competition_name, $competition_from, $competition_to, $competition_fromt, $competition_tot, $confirm == "true", $admin_username); echo json_encode($ret);
require_once($GLOBALS['g_campsiteDir'].'/classes/Phorum_forum.php'); require_once($GLOBALS['g_campsiteDir'].'/classes/Phorum_setting.php'); require_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/camp_html.php"); camp_load_translation_strings("api"); // Check permissions if (!$g_user->hasPermission('ManagePub')) { camp_html_display_error(getGS("You do not have the right to add publications.")); exit; } $languages = Language::GetLanguages(null, null, null, array(), array(), true); $defaultLanguage = array_pop(Language::GetLanguages(null, camp_session_get('TOL_Language', 'en'), null, array(), array(), true)); $urlTypes = UrlType::GetUrlTypes(); $allTemplates = Template::GetAllTemplates(null, true, true, true); $timeUnits = TimeUnit::GetTimeUnits(camp_session_get('TOL_Language', 'en')); $shortNameUrlType = UrlType::GetByName('short names'); $aliases = array(); $crumbs = array(); $crumbs[] = array(getGS("Publications"), "/$ADMIN/pub/"); $crumbs[] = array(getGS("Add new publication"), ""); echo camp_html_breadcrumbs($crumbs); include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); ?> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;"> <TR> <TD><A HREF="/<?php echo $ADMIN; ?>/pub/"><IMG SRC="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/left_arrow.png" BORDER="0"></A></TD> <TD><A HREF="/<?php echo $ADMIN; ?>/pub/"><B><?php putGS("Publication List"); ?></B></A></TD>
/** * Creates a ReminderIntervals object from rows in the rule_reminder table, * and sets it in the supplied Rule. * @param Rule $rule */ private function fillRuleReminderIntervals($rule) { $stmt = sqlStatement(self::SQL_RULE_REMINDER_INTERVAL, array($rule->id)); $reminderInterval = new ReminderIntervals(); for ($iter = 0; $row = sqlFetchArray($stmt); $iter++) { $amount = $row['value']; $unit = TimeUnit::from($row['method_detail']); $methodParts = explode('_', $row['method']); $type = ReminderIntervalType::from($methodParts[0]); $range = ReminderIntervalRange::from($methodParts[2]); if (!is_null($type) && !is_null($range) && !is_null($unit)) { $detail = new ReminderIntervalDetail($type, $range, $amount, $unit); $reminderInterval->addDetail($detail); } } $rule->setReminderIntervals($reminderInterval); }
$TOL_Language = camp_session_get('TOL_Language', 'en'); if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']); exit; } $languages = Language::GetLanguages(null, null, null, array(), array(), true); $urlTypes = UrlType::GetUrlTypes(); $allTemplates = Template::GetAllTemplates(null, true, true, true); $timeUnits = TimeUnit::GetTimeUnits($TOL_Language); $publicationObj = new Publication($f_publication_id); $aliases = Alias::GetAliases(null, $f_publication_id); $forum = new Phorum_forum($publicationObj->getForumId()); $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), $publicationObj->getLanguageId()); if (!$pubTimeUnit->exists()) { $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), 1); } include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); echo camp_html_content_top(getGS("Configure publication"), array("Pub" => $publicationObj)); ?> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;"> <TR> <TD><A HREF="/<?php echo $ADMIN; ?>/pub/"><IMG SRC="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/left_arrow.png" BORDER="0"></A></TD> <TD><A HREF="/<?php echo $ADMIN; ?>/pub/"><B><?php putGS("Publication List"); ?></B></A></TD> <TD style="padding-left: 20px;"><A HREF="/<?php echo $ADMIN; ?>/issues/?Pub=<?php p($f_publication_id); ?>"><B><?php putGS("Go To Issues"); ?></B></A></TD> <TD ><A HREF="/<?php echo $ADMIN; ?>/issues/?Pub=<?php p($f_publication_id); ?>"><IMG SRC="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/go_to.png" BORDER="0"></A></TD>
case "new": require_once 'admin-timeline-modify.php'; break; case "modify": require_once 'admin-timeline-modify.php'; break; case "delete": require_once 'admin-timeline-delete.php'; break; case "delete_reservation": require_once 'admin-timeline-delete_reservation.php'; break; case "deleteday": require_once 'admin-timeline-deleteday.php'; break; case "clone": require_once 'admin-timeline-clone.php'; break; case "competition": require_once 'admin-timeline-competition.php'; break; default: $times = Calendar::get_times(); $timeunits = TimeUnit::get_day_timeunits_admin($selected_date); $courts = Court::get_all(); $smarty->assign('courts', $courts); $smarty->assign('times', $times); $smarty->assign('timeunits', $timeunits); $smarty->assign('selected_date', $selected_date); $smarty->display('admin-timeline.tpl'); }
FROM kispests_db.`reservation` LEFT JOIN kispests_db.user ON (kispests_db.reservation.user_id=kispests_db.user.id) WHERE kispests_db.reservation.`date` > UNIX_TIMESTAMP( "2015-01-01 00:00:00" ) AND kispests_db.user.login!="uszoda" '; $sth = $DB->prepare($sql); $sth->execute(); $reservations = array(); foreach ($sth->fetchAll() as $res) { $date = date("Y-m-d", $res['date']); $username = $res['login']; $court_id = $res['palya']; // 3-as pály az igazából 6-os pálya, 4-es az 7-es, 5-ös az 8-as if ($court_id >= 3) { $court_id += 3; } $price = $res['price']; $from = date("H:i", $res['date'] - 2 * 60 * 60); $add_date = date("Y-m-d H:i:s", $res['created']); $timeunit = TimeUnit::get_by_date_and_from($date, $from, $court_id); reservation_migrate($timeunit->id, $username, $price, $add_date); echo '"' . $username . '";"' . $date . '";"' . $from . '";"' . $price . '";"' . $court_id . '";"' . $timeunit->id . '"' . "\n"; $two_hour_timeunits = array('08:00' => '09:00', '10:00' => '11:00', '12:00' => '13:00'); if (in_array($from, array_keys($two_hour_timeunits))) { $next_hour = $two_hour_timeunits[$from]; $timeunit = TimeUnit::get_by_date_and_from($date, $next_hour, $court_id); echo '"' . $username . '";"' . $date . '";"' . $next_hour . '";"' . $price . '";"' . $court_id . '";"' . $timeunit->id . '";"2ND HOUR"' . "\n"; reservation_migrate($timeunit->id, $username, $price, $add_date); } }
public static function competition_create($courts, $name, $from, $to, $fromt, $tot, $reservations_delete = false, $admin_username) { global $DB; $ret = array(); if (!is_array($courts) || count($courts) == 0) { $ret['success'] = false; $ret['error'] = 'Nincs kiválasztva pálya!'; $ret['error_type'] = 1; } elseif ($name == "") { $ret['success'] = false; $ret['error'] = 'A rendezvény nevének megadása kötelező!'; $ret['error_type'] = 2; } elseif (strtotime($to) < strtotime($from)) { $ret['success'] = false; $ret['error'] = 'A dátum intervallum hibás!'; $ret['error_type'] = 3; } elseif (TimeUnit::convert_to_minutes($tot) <= TimeUnit::convert_to_minutes($fromt)) { $ret['success'] = false; $ret['error'] = 'Az idő intervallum hibás!'; $ret['error_type'] = 4; } else { $where = ' (timeunits.date BETWEEN :from_date AND :to_date) AND ( (timeunits.from>=:from AND timeunits.from<:to) OR (timeunits.to>:from AND timeunits.to<=:to) ) AND timeunits.court_id IN (' . implode(',', $courts) . ') '; $sql = ' SELECT COUNT(*) as c FROM timeunits WHERE ' . $where . ' AND reserved_by IS NOT NULL AND 1=1 '; $sth = $DB->prepare($sql); $sth->bindParam(':from_date', $from, PDO::PARAM_STR); $sth->bindParam(':to_date', $to, PDO::PARAM_STR); $sth->bindParam(':from', $fromt, PDO::PARAM_STR); $sth->bindParam(':to', $tot, PDO::PARAM_STR); $sth->execute(); $c = $sth->fetchColumn(); if ($c > 0 && $reservations_delete === false) { $ret['success'] = false; $ret['error'] = 'A kijelölt időszakban van lefoglalt idősáv. A foglalások törléséhez pipálja be a "foglalások törlése" jelölőnégyzetet.'; $ret['error_type'] = 5; } else { if ($reservations_delete === true) { // foglalások törlése $sql = ' SELECT reservations.* FROM reservations LEFT JOIN timeunits ON (reservations.timeunit_id=timeunits.id) WHERE ' . $where . ' AND reserved_by IS NOT NULL AND 1=1 '; $sth = $DB->prepare($sql); $sth->bindParam(':from_date', $from, PDO::PARAM_STR); $sth->bindParam(':to_date', $to, PDO::PARAM_STR); $sth->bindParam(':from', $fromt, PDO::PARAM_STR); $sth->bindParam(':to', $tot, PDO::PARAM_STR); $sth->execute(); foreach ($sth->fetchAll() as $tmp) { $res = new Reservation($tmp); $res->load_timeunit(); $res->load_user(); $res->is_freeable(true); $res->free($admin_username); } } $sql = ' UPDATE timeunits SET comment=:name, available=0 WHERE ' . $where . ' '; $sth = $DB->prepare($sql); $sth->bindParam(':name', $name, PDO::PARAM_STR); $sth->bindParam(':from_date', $from, PDO::PARAM_STR); $sth->bindParam(':to_date', $to, PDO::PARAM_STR); $sth->bindParam(':from', $fromt, PDO::PARAM_STR); $sth->bindParam(':to', $tot, PDO::PARAM_STR); $sth->execute(); $ret['success'] = true; } } return $ret; }
<?php require_once 'classes/_loader.php'; require_once 'classes/init.php'; $id = $_GET['id']; $timeunit = TimeUnit::get_by_id($id); if (!is_object($timeunit)) { $ret = array('error' => 'Invalid timeunit id'); } else { if ($timeunit->is_prereserveable()) { $login = new Login('users'); $logined_user = $login->doLogin() == 1 ? $login->obj : null; $basket->add($timeunit, $logined_user); $ret = $basket->get_basket(); } else { $ret = array('error' => 'Már foglalt időpont!'); } } echo json_encode($ret); require_once 'classes/close.php';
<?php require_once $base_path . 'classes/checkframework.php'; $did = $_GET['did']; if ($did != "") { $timeunit = TimeUnit::get_by_id($did); } else { $court = Court::get_by_id($_GET['court']); $timeunit = new TimeUnit(array('date' => $selected_date, 'from' => $_GET['from'], 'court' => $court, 'price' => $court->price, 'available' => 1)); } if (count($_POST) > 0) { $timeunit->set_data_for_change($_POST); $errors = array(); $valid = $timeunit->is_valid(); if ($valid === true) { $timeunit->save(); } else { $errors = $valid; } $smarty->assign('errors', $errors); $smarty->display('return.tpl'); } else { $smarty->assign('timeunit', $timeunit); $smarty->display('admin-timeline-modify.tpl'); }
/** * @param TimeUnit $unit * * @return bool */ public function equals(TimeUnit $unit) : bool { return $this->equalsAmount($unit->inWeeks()->getAmount()); }
if ($f_language_code == "") { camp_html_add_msg($translator->trans('You must fill in the $1 field.', array('$1' => '<B>' . $translator->trans('Code') . '</B>'))); } if ($editMode) { $languageObj = new Language($f_language_id); } if ($correct) { $columns = array('Name' => $f_language_name, 'Code' => $f_language_code, 'OrigName' => $f_native_name, 'Month1' => $f_month_1, 'Month2' => $f_month_2, 'Month3' => $f_month_3, 'Month4' => $f_month_4, 'Month5' => $f_month_5, 'Month6' => $f_month_6, 'Month7' => $f_month_7, 'Month8' => $f_month_8, 'Month9' => $f_month_9, 'Month10' => $f_month_10, 'Month11' => $f_month_11, 'Month12' => $f_month_12, 'ShortMonth1' => $f_short_month_1, 'ShortMonth2' => $f_short_month_2, 'ShortMonth3' => $f_short_month_3, 'ShortMonth4' => $f_short_month_4, 'ShortMonth5' => $f_short_month_5, 'ShortMonth6' => $f_short_month_6, 'ShortMonth7' => $f_short_month_7, 'ShortMonth8' => $f_short_month_8, 'ShortMonth9' => $f_short_month_9, 'ShortMonth10' => $f_short_month_10, 'ShortMonth11' => $f_short_month_11, 'ShortMonth12' => $f_short_month_12, 'WDay1' => $f_sunday, 'WDay2' => $f_monday, 'WDay3' => $f_tuesday, 'WDay4' => $f_wednesday, 'WDay5' => $f_thursday, 'WDay6' => $f_friday, 'WDay7' => $f_saturday, 'ShortWDay1' => $f_short_sunday, 'ShortWDay2' => $f_short_monday, 'ShortWDay3' => $f_short_tuesday, 'ShortWDay4' => $f_short_wednesday, 'ShortWDay5' => $f_short_thursday, 'ShortWDay6' => $f_short_friday, 'ShortWDay7' => $f_short_saturday); $success = true; if ($editMode) { $languageObj->update($columns); } else { $languageObj = new Language(); $result = $languageObj->create($columns); if (PEAR::isError($result)) { camp_html_add_msg($result->getMessage()); $success = false; } else { $f_language_id = $languageObj->getLanguageId(); } } if ($success) { TimeUnit::SetTimeUnit('D', $f_language_id, $D); TimeUnit::SetTimeUnit('W', $f_language_id, $W); TimeUnit::SetTimeUnit('M', $f_language_id, $M); TimeUnit::SetTimeUnit('Y', $f_language_id, $Y); camp_html_goto_page("/{$ADMIN}/languages/index.php"); } } $link = "/{$ADMIN}/languages/add_modify.php" . ($editMode ? "?f_language_id=" . $f_language_id : ""); camp_html_goto_page($link);
/** * Returns the publication subscription time unit name. * * @param int $p_languageId * @return string */ public function getTimeUnitName($p_languageId = null) { $languageId = is_null($p_languageId) ? $this->m_data['IdDefaultLanguage'] : $p_languageId; $timeUnit = new TimeUnit($this->m_data['TimeUnit'], $languageId); if (!$timeUnit->exists()) { $timeUnit = new TimeUnit($this->m_data['TimeUnit'], 1); } return $timeUnit->getName(); }
camp_html_display_error(getGS("You do not have the right to manage publications.")); exit; } $Pub = Input::Get('Pub', 'int'); $Language = Input::Get('Language', 'int', 1); if (!Input::IsValid()) { camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']); exit; } $publicationObj = new Publication($Pub); $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), $publicationObj->getLanguageId()); if (!$pubTimeUnit->exists()) { $pubTimeUnit = new TimeUnit($publicationObj->getTimeUnit(), 1); } $defaultTimes = SubscriptionDefaultTime::GetSubscriptionDefaultTimes(null, $Pub); include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); camp_html_content_top(getGS("Subscription Settings by Country"), array("Pub" => $publicationObj)); ?> <p> <TABLE class="action_buttons"> <TR> <TD><A HREF="countryadd.php?Pub=<?php p($Pub); ?>&Language=<?php p($Language); ?>" ><IMG SRC="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/add.png" BORDER="0"></A></TD> <TD><A HREF="countryadd.php?Pub=<?php p($Pub); ?>&Language=<?php p($Language); ?>" ><B><?php putGS("Set subscription settings for a country"); ?></B></A></TD> </TR>