本文整理汇总了PHP中ilDateTime::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ilDateTime::get方法的具体用法?PHP ilDateTime::get怎么用?PHP ilDateTime::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilDateTime
的用法示例。
在下文中一共展示了ilDateTime::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse table content
*/
public function parse()
{
$this->initTable();
// @TODO add filter
$users = $this->getParentObject()->object->getTrackedUsers($this->filter['lastname']);
$attempts = $this->getParentObject()->object->getAttemptsForUsers();
$versions = $this->getParentObject()->object->getModuleVersionForUsers();
include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
$privacy = ilPrivacySettings::_getInstance();
$allowExportPrivacy = $privacy->enabledExportSCORM();
$data = array();
foreach ($users as $user) {
$tmp = array();
$tmp['user'] = $user['user_id'];
if ($allowExportPrivacy == true) {
$tmp['name'] = $user['lastname'] . ', ' . $user['firstname'];
} else {
$tmp['name'] = $user['user_id'];
}
$dt = new ilDateTime($user['last_access'], IL_CAL_DATETIME);
$tmp['last_access'] = $dt->get(IL_CAL_UNIX);
$tmp['attempts'] = (int) $attempts[$user['user_id']];
$tmp['version'] = (int) $versions[$user['user_id']];
$data[] = $tmp;
}
$this->setData($data);
}
示例2: calculate
/**
* Calculates schedules.
*/
public function calculate()
{
$events = $this->getEvents();
// we need category type for booking handling
$ids = array();
foreach ($events as $event) {
$ids[] = $event->getEntryId();
}
$counter = 0;
foreach ($events as $event) {
$this->schedule[$counter]['event'] = $event;
$this->schedule[$counter]['dstart'] = $event->getStart()->get(IL_CAL_UNIX);
$this->schedule[$counter]['dend'] = $event->getEnd()->get(IL_CAL_UNIX);
$this->schedule[$counter]['fullday'] = $event->isFullday();
if (!$event->isFullday()) {
switch ($this->type) {
case self::TYPE_DAY:
case self::TYPE_WEEK:
// store date info (used for calculation of overlapping events)
$start_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone);
$this->schedule[$counter]['start_info'] = $start_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
$end_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone);
$this->schedule[$counter]['end_info'] = $end_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
break;
default:
break;
}
}
$counter++;
if ($this->areEventsLimited() && $counter >= $this->getEventsLimit()) {
break;
}
}
}
示例3: run
public function run()
{
global $ilSetting, $ilDB;
$status = ilCronJobResult::STATUS_NO_ACTION;
$days_before = $ilSetting->get('ch_reminder_days');
$now = new ilDateTime(time(), IL_CAL_UNIX);
$limit = clone $now;
$limit->increment(IL_CAL_DAY, $days_before);
$counter = 0;
$query = 'SELECT * FROM booking_user ' . 'JOIN cal_entries ON entry_id = cal_id ' . 'WHERE notification_sent = ' . $ilDB->quote(0, 'integer') . ' ' . 'AND starta > ' . $ilDB->quote($now->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' . 'AND starta <= ' . $ilDB->quote($limit->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp');
$res = $ilDB->query($query);
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
$mail = new ilCalendarMailNotification();
$mail->setAppointmentId($row->entry_id);
$mail->setRecipients(array($row->user_id));
$mail->setType(ilCalendarMailNotification::TYPE_BOOKING_REMINDER);
$mail->send();
// update notification
$query = 'UPDATE booking_user ' . 'SET notification_sent = ' . $ilDB->quote(1, 'integer') . ' ' . 'WHERE user_id = ' . $ilDB->quote($row->user_id, 'integer') . ' ' . 'AND entry_id = ' . $ilDB->quote($row->entry_id, 'integer');
$ilDB->manipulate($query);
$counter++;
}
if ($counter) {
$status = ilCronJobResult::STATUS_OK;
}
$result = new ilCronJobResult();
$result->setStatus($status);
return $result;
}
示例4: handleEvent
/**
* Handle an event in a listener.
*
* @param string $a_component component, e.g. "Modules/Forum" or "Services/User"
* @param string $a_event event e.g. "createUser", "updateUser", "deleteUser", ...
* @param array $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...)
*/
static function handleEvent($a_component, $a_event, $a_parameter)
{
global $ilLog;
$ilLog->write(__METHOD__ . ': Listening to event from: ' . $a_component);
switch ($a_component) {
case 'Services/User':
switch ($a_event) {
case 'afterCreation':
$user = $a_parameter['user_obj'];
$this->handleMembership($user);
break;
}
break;
case 'Modules/Course':
switch ($a_event) {
case 'addSubscriber':
case 'addParticipant':
if (ilObjUser::_lookupAuthMode($a_parameter['usr_id']) == 'ecs') {
if (!($user = ilObjectFactory::getInstanceByObjId($a_parameter['usr_id']))) {
$GLOBALS['ilLog']->write(__METHOD__ . ': No valid user found for usr_id ' . $a_parameter['usr_id']);
return true;
}
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$server_id = ilECSImport::lookupServerId($a_parameter['usr_id']);
$GLOBALS['ilLog']->write(__METHOD__ . ': Found server id: ' . $server_id);
include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
$settings = ilECSSetting::getInstanceByServerId($server_id);
$end = new ilDateTime(time(), IL_CAL_UNIX);
$end->increment(IL_CAL_MONTH, $settings->getDuration());
if ($user->getTimeLimitUntil() < $end->get(IL_CAL_UNIX)) {
$user->setTimeLimitUntil($end->get(IL_CAL_UNIX));
$user->update();
}
self::_sendNotification($settings, $user);
unset($user);
}
break;
}
break;
}
}
示例5: buildJson
protected function buildJson(ilECSSetting $a_server)
{
$json = $this->getJsonCore('application/ecs-file');
$json->version = $this->content_obj->getVersion();
require_once "./Services/History/classes/class.ilHistory.php";
$entries = ilHistory::_getEntriesForObject($this->content_obj->getId(), $this->content_obj->getType());
if (count($entries)) {
$entry = array_shift($entries);
$entry = new ilDateTime($entry["date"], IL_CAL_DATETIME);
$json->version_date = $entry->get(IL_CAL_UNIX);
} else {
$json->version_date = time();
}
return $json;
}
示例6: getLuceneSearchString
public function getLuceneSearchString($a_value)
{
// see ilADTDateTimeSearchBridgeRange::importFromPost();
if ($a_value["tgl"]) {
$start = mktime($a_value["lower"]["time"]["h"], $a_value["lower"]["time"]["m"], 1, $a_value["lower"]["date"]["m"], $a_value["lower"]["date"]["d"], $a_value["lower"]["date"]["y"]);
$end = mktime($a_value["upper"]["time"]["h"], $a_value["upper"]["time"]["m"], 1, $a_value["upper"]["date"]["m"], $a_value["upper"]["date"]["d"], $a_value["upper"]["date"]["y"]);
if ($start && $end && $start > $end) {
$tmp = $start;
$start = $end;
$end = $tmp;
}
$start = new ilDateTime($start, IL_CAL_UNIX);
$end = new ilDateTime($end, IL_CAL_UNIX);
return "{" . $start->get(IL_CAL_DATETIME) . " TO " . $end->get(IL_CAL_DATETIME) . "}";
}
}
示例7: getAppointmentIdsByGroup
/**
* Get appointment ids by consultation hour group
* @param type $a_user_id
* @param type $a_ch_group_id
* @param ilDateTime $start
*/
public static function getAppointmentIdsByGroup($a_user_id, $a_ch_group_id, ilDateTime $start = null)
{
global $ilDB;
// @todo check start time
include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
$type = ilCalendarCategory::TYPE_CH;
$start_limit = '';
if ($start instanceof ilDateTime) {
$start_limit = 'AND ce.starta >= ' . $ilDB->quote($start->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
}
$query = 'SELECT ce.cal_id FROM cal_entries ce ' . 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' . 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' . 'JOIN booking_entry be ON ce.context_id = be.booking_id ' . 'WHERE cc.obj_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' . 'AND cc.type = ' . $ilDB->quote($type, 'integer') . ' ' . 'AND be.booking_group = ' . $ilDB->quote($a_ch_group_id, 'integer') . ' ' . $start_limit . ' ' . 'ORDER BY ce.starta ';
$res = $ilDB->query($query);
$app_ids = array();
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
$app_ids[] = $row->cal_id;
}
return $app_ids;
}
示例8: parse
/**
* Parse table content
*/
public function parse()
{
$this->initTable();
// @TODO add filter
$users = $this->getParentObject()->object->getTrackedUsers($this->filter['lastname']);
$attempts = $this->getParentObject()->object->getAttemptsForUsers();
$versions = $this->getParentObject()->object->getModuleVersionForUsers();
$data = array();
foreach ($users as $user) {
$tmp = array();
$tmp['user'] = $user['user_id'];
$tmp['firstname'] = $user['firstname'];
$tmp['lastname'] = $user['lastname'];
$dt = new ilDateTime($user['last_access'], IL_CAL_DATETIME);
$tmp['last_access'] = $dt->get(IL_CAL_UNIX);
$tmp['attempts'] = (int) $attempts[$user['user_id']];
$tmp['version'] = (int) $versions[$user['user_id']];
$data[] = $tmp;
}
$this->setData($data);
}
示例9: foreach
function _getProgress($a_user_id, $a_obj_id)
{
require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
$events = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
include_once './Services/Calendar/classes/class.ilDateTime.php';
foreach ($events as $row) {
$tmp_date = new ilDateTime($row['last_access'], IL_CAL_UNIX);
$row['last_access'] = $tmp_date->get(IL_CAL_TIMESTAMP);
if ($progress) {
$progress['spent_seconds'] += $row['spent_seconds'];
$progress['access_time'] = max($progress['access_time'], $row['last_access']);
} else {
$progress['obj_id'] = $row['obj_id'];
$progress['user_id'] = $row['usr_id'];
$progress['spent_seconds'] = $row['spent_seconds'];
$progress['access_time'] = $row['last_access'];
$progress['visits'] = $row['read_count'];
}
}
return $progress ? $progress : array();
}
示例10: checkInput
/**
* Check input, strip slashes etc. set alert, if input is not ok.
*
* @return boolean Input ok, true/false
*/
function checkInput()
{
global $lng, $ilUser;
$ok = true;
$_POST[$this->getPostVar()]["date"]["y"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["y"]);
$_POST[$this->getPostVar()]["date"]["m"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["m"]);
$_POST[$this->getPostVar()]["date"]["d"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["d"]);
$_POST[$this->getPostVar()]["time"]["h"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["h"]);
$_POST[$this->getPostVar()]["time"]["m"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["m"]);
$_POST[$this->getPostVar()]["time"]["s"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["s"]);
// verify date
$dt['year'] = (int) $_POST[$this->getPostVar()]['date']['y'];
$dt['mon'] = (int) $_POST[$this->getPostVar()]['date']['m'];
$dt['mday'] = (int) $_POST[$this->getPostVar()]['date']['d'];
$dt['hours'] = (int) $_POST[$this->getPostVar()]['time']['h'];
$dt['minutes'] = (int) $_POST[$this->getPostVar()]['time']['m'];
$dt['seconds'] = (int) $_POST[$this->getPostVar()]['time']['s'];
if ($dt['year'] == 0 && $dt['mon'] == 0 && $dt['mday'] == 0 && $this->getRequired()) {
$this->date = null;
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
} else {
if ($dt['year'] == 0 && $dt['mon'] == 0 && $dt['mday'] == 0) {
$this->date = null;
$_POST[$this->getPostVar()]['date'] = "";
// #10413
} else {
if (!checkdate((int) $dt['mon'], (int) $dt['mday'], (int) $dt['year'])) {
$this->date = null;
$this->setAlert($lng->txt("exc_date_not_valid"));
return false;
}
$date = new ilDateTime($dt, IL_CAL_FKT_GETDATE, $ilUser->getTimeZone());
$_POST[$this->getPostVar()]['date'] = $date->get(IL_CAL_FKT_DATE, 'Y-m-d', $ilUser->getTimeZone());
$this->setDate($date);
}
}
return true;
}
示例11: createVmsSessionCode
public function createVmsSessionCode($a_vuser_id, $a_group_id, ilDateTime $expires)
{
$GLOBALS['ilLog']->write('Creating new vms session code');
try {
$this->initClient();
$req = new stdClass();
$req->sessioncode = new stdClass();
$req->sessioncode->userid = (int) $a_vuser_id;
$req->sessioncode->groupid = (int) $a_group_id;
$req->sessioncode->codelength = self::CODELENGTH;
$req->sessioncode->expirationdate = $expires->get(IL_CAL_FKT_DATE, 'YmdHi', self::CONVERT_TIMZONE);
$req->sessioncode->timezone = self::WS_TIMEZONE;
$reps = $this->getClient()->createVmsSessionCode($req);
ilViteroSessionStore::getInstance()->addSession($a_vuser_id, $reps->code, $expires, self::SESSION_TYPE_VMS);
return $reps->code;
} catch (SoapFault $e) {
$code = $this->parseErrorCode($e);
$GLOBALS['ilLog']->write(__METHOD__ . ': Creating vms session code failed with message: ' . $code);
$GLOBALS['ilLog']->write(__METHOD__ . ': Last request: ' . $this->getClient()->__getLastRequest());
$GLOBALS['ilLog']->write(__METHOD__ . ': Last request: ' . $this->getClient()->__getLastResponse());
throw new ilViteroConnectorException($e->getMessage(), $code);
}
}
示例12: save
/**
* save one entry
*
* @access public
*
*/
public function save()
{
global $ilDB;
$next_id = $ilDB->nextId('cal_entries');
$now = new ilDateTime(time(), IL_CAL_UNIX);
$utc_timestamp = $now->get(IL_CAL_TIMESTAMP, '', ilTimeZone::UTC);
$query = "INSERT INTO cal_entries (cal_id,title,last_update,subtitle,description,location,fullday,starta,enda, " . "informations,auto_generated,context_id,translation_type, completion, is_milestone, notification) " . "VALUES( " . $ilDB->quote($next_id, 'integer') . ", " . $this->db->quote($this->getTitle(), 'text') . ", " . $ilDB->quote($utc_timestamp, 'timestamp') . ", " . $this->db->quote($this->getSubtitle(), 'text') . ", " . $this->db->quote($this->getDescription(), 'text') . ", " . $this->db->quote($this->getLocation(), 'text') . ", " . $ilDB->quote($this->isFullday() ? 1 : 0, 'integer') . ", " . $this->db->quote($this->getStart()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " . $this->db->quote($this->getEnd()->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ", " . $this->db->quote($this->getFurtherInformations(), 'text') . ", " . $this->db->quote($this->isAutoGenerated(), 'integer') . ", " . $this->db->quote($this->getContextId(), 'integer') . ", " . $this->db->quote($this->getTranslationType(), 'integer') . ", " . $this->db->quote($this->getCompletion(), 'integer') . ", " . $this->db->quote($this->isMilestone() ? 1 : 0, 'integer') . ", " . $this->db->quote($this->isNotificationEnabled() ? 1 : 0, 'integer') . ' ' . ")";
$res = $ilDB->manipulate($query);
$this->entry_id = $next_id;
return true;
}
示例13: confirmDeleteExportFileObject
/**
* confirmation screen for export file deletion
*/
function confirmDeleteExportFileObject()
{
global $ilTabs;
$this->handleWriteAccess();
$ilTabs->activateTab("export");
if (!isset($_POST["file"])) {
ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
$this->ctrl->redirect($this, "export");
}
ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
$export_dir = $this->object->getExportDirectory();
$export_files = $this->object->getExportFiles($export_dir);
$data = array();
if (count($_POST["file"]) > 0) {
foreach ($_POST["file"] as $exp_file) {
$file_arr = explode("__", $exp_file);
$date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
array_push($data, array('file' => $exp_file, 'size' => filesize($export_dir . "/" . $exp_file), 'date' => $date->get(IL_CAL_DATETIME)));
}
}
include_once "./Modules/Survey/classes/tables/class.ilSurveyExportTableGUI.php";
$table_gui = new ilSurveyExportTableGUI($this, 'export', true);
$table_gui->setData($data);
$this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
}
示例14: save
/**
* save Record
*
* @param string $a_mode values: create | edit
*/
public function save()
{
global $tpl, $ilUser, $lng, $ilCtrl;
$this->initForm();
if ($this->form->checkInput()) {
$record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
$date_obj = new ilDateTime(time(), IL_CAL_UNIX);
$record_obj->setTableId($this->table_id);
$record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setLastEditBy($ilUser->getId());
$create_mode = false;
if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
$all_fields = $this->table->getRecordFields();
} else {
$all_fields = $this->table->getEditableFields();
}
$fail = "";
//Check if we can create this record.
foreach ($all_fields as $field) {
try {
$value = $this->form->getInput("field_" . $field->getId());
$field->checkValidity($value, $this->record_id);
} catch (ilDataCollectionInputException $e) {
$fail .= $field->getTitle() . ": " . $e . "<br>";
}
}
if ($fail) {
ilUtil::sendFailure($fail, true);
$this->sendFailure();
return;
}
if (!isset($this->record_id)) {
if (!$this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
$record_obj->setOwner($ilUser->getId());
$record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setTableId($this->table_id);
$record_obj->doCreate();
$this->record_id = $record_obj->getId();
$create_mode = true;
} else {
if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
}
//edit values, they are valid we already checked them above
foreach ($all_fields as $field) {
$value = $this->form->getInput("field_" . $field->getId());
//deletion flag on MOB inputs.
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB && $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()) {
$value = -1;
}
$record_obj->setRecordFieldValue($field->getId(), $value);
}
// Do we need to set a new owner for this record?
if (!$create_mode) {
$owner_id = ilObjUser::_lookupId($_POST['field_owner']);
if (!$owner_id) {
ilUtil::sendFailure($lng->txt('user_not_known'));
$this->sendFailure();
return;
}
$record_obj->setOwner($owner_id);
}
if ($create_mode) {
ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
}
$record_obj->doUpdate();
ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
$ilCtrl->setParameter($this, "table_id", $this->table_id);
$ilCtrl->setParameter($this, "record_id", $this->record_id);
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
} else {
global $tpl;
$this->form->setValuesByPost();
$tpl->setContent($this->form->getHTML());
}
}
示例15: findDeletedObjects
/**
* Search database for all tree entries having no valid parent (=> no valid path to root node)
* and stores result in $this->unbound_objects
* Result also contains childs that are marked as deleted! Deleted childs has
* a negative number in ["deleted"] otherwise NULL.
*
* @access public
* @return boolean false if analyze mode disabled or nothing found
* @see this::getUnboundObjects()
* @see this::restoreUnboundObjects()
*/
function findDeletedObjects()
{
// check mode: analyze
if ($this->mode["scan"] !== true) {
return false;
}
// init
$this->deleted_objects = array();
$this->writeScanLogLine("\nfindDeletedObjects:");
// Delete objects, start with the oldest objects first
$query = "SELECT object_data.*,tree.tree,tree.child,tree.parent,deleted " . "FROM object_data " . "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id " . "LEFT JOIN tree ON tree.child=object_reference.ref_id " . " WHERE tree != 1 " . " ORDER BY deleted";
$r = $this->db->query($query);
include_once './Services/Calendar/classes/class.ilDateTime.php';
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
$tmp_date = new ilDateTime($row->deleted, IL_CAL_DATETIME);
$this->deleted_objects[] = array("child" => $row->child, "parent" => $row->parent, "tree" => $row->tree, "type" => $row->type, "title" => $row->title, "desc" => $row->description, "owner" => $row->owner, "deleted" => $row->deleted, "deleted_timestamp" => $tmp_date->get(IL_CAL_UNIX), "create_date" => $row->create_date, "last_update" => $row->last_update);
}
if (count($this->deleted_objects) > 0) {
$this->writeScanLogArray(array(array_keys($this->deleted_objects[0])));
$this->writeScanLogArray($this->deleted_objects);
return true;
}
$this->writeScanLogLine("none");
return false;
}