本文整理汇总了PHP中DateUtil::makeTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::makeTimestamp方法的具体用法?PHP DateUtil::makeTimestamp怎么用?PHP DateUtil::makeTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::makeTimestamp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteDocument
public function deleteDocument($args) {
$documentId = $this->request->getPost()->get('documentId', '');
if (!$documentId) {
throw new Zikula_Exception_Fatal($this->__('no document id'));
}
// get document
$document = ModUtil::apiFunc($this->name, 'user', 'getDocument', array('documentId' => $documentId));
if (!$document) {
throw new Zikula_Exception_Fatal($this->__('Document not found.'));
}
// the documents only can be deleted by people with EDIT_ACCESS to the module or by creators during the time defined in the module configuration
if (!SecurityUtil::checkPermission('IWdocmanager::', "$document[categoryId]::", ACCESS_DELETE) && ($document['validated'] == 1 || UserUtil::getVar('uid') != $document['cr_uid'] || DateUtil::makeTimestamp($document['cr_date']) + $this->getVar('deleteTime') * 30 < time())) {
throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
}
$deleted = ModUtil::apiFunc($this->name, 'user', 'deleteDocument', array('documentId' => $documentId));
if (!$deleted) {
throw new Zikula_Exception_Fatal($this->__('Error! Delete document failed.'));
}
if ($document['fileName'] != '') {
// download the document
$documentPath = ModUtil::getVar('IWmain', 'documentRoot') . '/' . $this->getVar('documentsFolder') . '/' . $document['fileName'];
// delete file form server
if (file_exists($documentPath)) {
unlink($documentPath);
}
}
// upload the number of documents in category
ModUtil::apiFunc($this->name, 'user', 'countDocuments', array('categoryId' => $document['categoryId']));
$content = ModUtil::func($this->name, 'user', 'getDocumentsContent', array('categoryId' => $document['categoryId']));
return new Zikula_Response_Ajax(array('content' => $content,
));
}
示例2: deleteDocument
public function deleteDocument($args) {
// get document
$document = ModUtil::apiFunc($this->name, 'user', 'getDocument', array('documentId' => $args['documentId']));
if (!$document) {
return LogUtil::registerError($this->__('Document not found.'));
}
// the documents only can be deleted by people with DELETE_ACCESS to the module or by creators during the time defined in the module configuration
if (!SecurityUtil::checkPermission('IWdocmanager::', "$document[categoryId]::", ACCESS_DELETE) && ($document['validated'] == 1 || UserUtil::getVar('uid') != $document['cr_uid'] || DateUtil::makeTimestamp($document['cr_date']) + $this->getVar('deleteTime') * 30 < time())) {
return LogUtil::registerPermissionError();
}
if (!DBUtil::deleteObjectByID('IWdocmanager', $args['documentId'], 'documentId')) {
return LogUtil::registerError($this->__('Error! Update attempt failed.'));
}
return true;
}
示例3: viewStats
public function viewStats($args) {
$statsSaved = unserialize(SessionUtil::getVar('statsSaved'));
$moduleName = (isset($statsSaved['moduleName'])) ? $statsSaved['moduleName'] : '';
$fromDate = (isset($statsSaved['fromDate'])) ? $statsSaved['fromDate'] : null;
$toDate = (isset($statsSaved['toDate'])) ? $statsSaved['toDate'] : '';
$moduleName = FormUtil::getPassedValue('moduleName', isset($args['moduleName']) ? $args['moduleName'] : $moduleName, 'GETPOST');
$uname = FormUtil::getPassedValue('uname', isset($args['uname']) ? $args['uname'] : $statsSaved['uname'], 'GETPOST');
$fromDate = FormUtil::getPassedValue('fromDate', isset($args['fromDate']) ? $args['fromDate'] : $fromDate, 'GETPOST');
$toDate = FormUtil::getPassedValue('toDate', isset($args['toDate']) ? $args['toDate'] : $toDate, 'GETPOST');
$uid = FormUtil::getPassedValue('uid', isset($args['uid']) ? $args['uid'] : 0, 'GETPOST');
if ($uid > 0) {
$uname = UserUtil::getVar('uname', $uid);
}
SessionUtil::setVar('statsSaved', serialize(array('uname' => $uname,
'moduleName' => $moduleName,
'fromDate' => $fromDate,
'toDate' => $toDate,
)));
if (!SecurityUtil::checkPermission('IWstats::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
$uid = 0;
$rpp = 50;
$lastDays = 10;
$nusers = 0;
if ($uname != null && $uname != '') {
// get user id from uname
$uid = UserUtil::getIdFromName($uname);
if (!$uid) {
LogUtil::registerError(__f('User \'%s\' not found', array($uname)));
$uname = '';
}
}
$time = time();
if ($fromDate != null) {
$fromDate = mktime(0, 0, 0, substr($fromDate, 3, 2), substr($fromDate, 0, 2), substr($fromDate, 6, 4));
$fromDate = date('Y-m-d 00:00:00', $fromDate);
$fromDate = DateUtil::makeTimestamp($fromDate);
$fromDate = date('d-m-Y', $fromDate);
} else {
$fromDate = date('d-m-Y', $time - $lastDays * 24 * 60 * 60);
}
if ($toDate != null) {
$toDate = mktime(0, 0, 0, substr($toDate, 3, 2), substr($toDate, 0, 2), substr($toDate, 6, 4));
$toDate = date('Y-m-d 00:00:00', $toDate);
$toDate = DateUtil::makeTimestamp($toDate);
$toDate = date('d-m-Y', $toDate);
} else {
$toDate = date('d-m-Y', $time);
}
// get last records
$records = ModUtil::apiFunc('IWstats', 'user', 'getAllSummary', array('rpp' => -1,
'init' => -1,
'fromDate' => $fromDate,
'toDate' => $toDate,
));
// get all modules
$modules = ModUtil::apiFunc('Extensions', 'admin', 'listmodules', array('state' => 0));
foreach ($modules as $module) {
$modulesNames[$module['id']] = $module['name'];
$modulesArray[] = array('id' => $module['id'],
'name' => $module['name']);
}
$modulesNames[0] = $this->__('unknown');
$usersListArray = array();
$moduleStatsArray = array();
$userModulesArray = array();
$userArray = array();
$moduleArray = array();
$usersForModule = array();
$users = array();
$usersIpCounter = 0;
$nRecords = 0;
$userNRecords = 0;
$usersList = '';
$userName = '';
foreach ($records as $record) {
$nRecords = $nRecords + $record['nrecords'];
$usersIpCounter = $usersIpCounter + $record['nips'];
$users = explode('$$', substr($record['users'], 1, -1)); // substr to remove $ in the begining and the end of the string
foreach ($users as $user) {
$oneUser = explode('|', $user);
if (!in_array($oneUser[0], $usersListArray)) {
//.........这里部分代码省略.........
示例4: viewDocumentVersions
public function viewDocumentVersions($args) {
$documentId = FormUtil::getPassedValue('documentId', isset($args['documentId']) ? $args['documentId'] : 0, 'GET');
// get document
$documentOrigin = ModUtil::apiFunc($this->name, 'user', 'getDocument', array('documentId' => $documentId));
if (!$documentOrigin) {
LogUtil::registerError($this->__('Document not found.'));
return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs'));
}
$documentOrigin['extension'] = FileUtil::getExtension($documentOrigin['fileName']);
$documentOrigin['filesize'] = ModUtil::func($this->name, 'user', 'getReadableFileSize', array('filesize' => $documentOrigin['filesize']));
$categoryId = $documentOrigin['categoryId'];
// check if user can access to this category
$canAccess = ModUtil::func($this->name, 'user', 'canAccessCategory', array('categoryId' => $categoryId,
'accessType' => 'read',
));
if (!$canAccess) {
LogUtil::registerError($this->__('You can not access to this document.'));
return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs'));
}
// versions
$documents = ModUtil::apiFunc($this->name, 'user', 'getDocumentVersions', array('documentId' => $documentId));
if (!$documents) {
LogUtil::registerError($this->__('This document have not versions.'));
return System::redirect(ModUtil::url($this->name, 'user', 'viewDocs', array('categoryId' => $categoryId)));
}
$usersList = $documentOrigin['cr_uid'] . '$$';
$users = array();
$canEdit = false;
$canDelete = false;
$canAdd = false;
$canEditCategory = (SecurityUtil::checkPermission('IWdocmanager::', "$categoryId::", ACCESS_EDIT)) ? true : false;
$canDeleteCategory = (SecurityUtil::checkPermission('IWdocmanager::', "$categoryId::", ACCESS_DELETE)) ? true : false;
foreach ($documents as $document) {
$extensionIcon['icon'] = '';
if ($document['fileName'] != '') {
$extension = FileUtil::getExtension($document['fileName']);
$extensionIcon = ($extension != '') ? ModUtil::func('IWmain', 'user', 'getMimetype', array('extension' => $extension)) : '';
}
$documents[$document['documentId']]['extension'] = $extensionIcon['icon'];
if ($document['authorName'] == '') {
$usersList .= $document['cr_uid'] . '$$';
}
$documents[$document['documentId']]['canEdit'] = false;
$documents[$document['documentId']]['canDelete'] = false;
if ($canEditCategory || ($document['validated'] == 0 && UserUtil::getVar('uid') == $document['cr_uid'] && DateUtil::makeTimestamp($document['cr_date']) + $this->getVar('editTime') * 30 > time())) {
$documents[$document['documentId']]['canEdit'] = true;
$canEdit = true; // in order to show edit icon in legend
}
if ($canDeleteCategory || ($document['validated'] == 0 && UserUtil::getVar('uid') == $document['cr_uid'] && DateUtil::makeTimestamp($document['cr_date']) + $this->getVar('deleteTime') * 30 > time())) {
$documents[$document['documentId']]['canDelete'] = true;
$canDelete = true; // in order to show delete icon in legend
}
$documents[$document['documentId']]['filesize'] = ModUtil::func($this->name, 'user', 'getReadableFileSize', array('filesize' => $document['filesize']));
}
if ($usersList != '') {
// get all users information
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$users = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('sv' => $sv,
'info' => 'ncc',
'list' => $usersList));
}
return $this->view->assign('documentOrigin', $documentOrigin)
->assign('documents', $documents)
->assign('canAdd', $canAdd)
->assign('users', $users)
->assign('canEdit', $canEdit)
->assign('canDelete', $canDelete)
->assign('versionsVision', 1)
->fetch('IWdocmanager_user_viewDocumentVersions.tpl');
}
示例5: smarty_function_duditemmodify
//.........这里部分代码省略.........
$render->assign('listoptions', array_keys($options));
$render->assign('listoutput', array_values($options));
break;
case 4: // SELECT
$type = 'select';
if (DataUtil::is_serialized($uservalue)) {
$render->assign('value', unserialize($uservalue));
}
// multiple flag is the first field
$options = explode('@@', $item['prop_listoptions'], 2);
$selectmultiple = $options[0] ? ' multiple="multiple"' : '';
$render->assign('selectmultiple', $selectmultiple);
$options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));
$render->assign('listoptions', array_keys($options));
$render->assign('listoutput', array_values($options));
break;
case 5: // DATE
$type = 'date';
// gets the format to use
$format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));
switch (trim(strtolower($format)))
{
case 'datelong':
//! This is from the core domain (datelong)
$format = __('%A, %B %d, %Y');
break;
case 'datebrief':
//! This is from the core domain (datebrief)
$format = __('%b %d, %Y');
break;
case 'datestring':
//! This is from the core domain (datestring)
$format = __('%A, %B %d @ %H:%M:%S');
break;
case 'datestring2':
//! This is from the core domain (datestring2)
$format = __('%A, %B %d');
break;
case 'datetimebrief':
//! This is from the core domain (datetimebrief)
$format = __('%b %d, %Y - %I:%M %p');
break;
case 'datetimelong':
//! This is from the core domain (datetimelong)
$format = __('%A, %B %d, %Y - %I:%M %p');
break;
case 'timebrief':
//! This is from the core domain (timebrief)
$format = __('%I:%M %p');
break;
case 'timelong':
//! This is from the core domain (timelong)
$format = __('%T %p');
break;
}
//! This is from the core domain (datebrief)
$format = !empty($format) ? $format : __('%b %d, %Y');
// process the temporal data if any
$timestamp = null;
if (isset($item['temp_propdata'])) {
$timestamp = DateUtil::parseUIDate($item['temp_propdata']);
$uservalue = DateUtil::transformInternalDate($timestamp);
} elseif (!empty($uservalue)) {
$timestamp = DateUtil::makeTimestamp($uservalue);
}
$render->assign('value', $uservalue);
$render->assign('timestamp', $timestamp);
$render->assign('dudformat', $format);
break;
case 6: // EXTDATE (deprecated)
// TODO [deprecate completely]
$type = 'hidden';
break;
case 7: // MULTICHECKBOX
$type = 'multicheckbox';
$render->assign('value', (array)unserialize($uservalue));
$options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));
$render->assign('fields', $options);
break;
default: // TEXT
$type = 'text';
break;
}
return $render->fetch('profile_dudedit_'.$type.'.tpl');
}
示例6: summary
public function summary($args) {
// get the last record in summary table
$table = DBUtil::getTables();
$c = $table['IWstats_summary_column'];
$d = $table['IWstats_column'];
// get first record datetime
$orderby = "$d[summarised] asc";
$last = DBUtil::selectObjectArray('IWstats', '', $orderby, -1, 1);
$time = DateUtil::makeTimestamp($last[0]['datetime']);
$toDateTimeStamp = $time + $args['days'] * 24 * 60 * 60;
// calc the period
$fromDate = date('d-m-Y', $time);
$toDate = date('d-m-Y', $toDateTimeStamp);
$records = ModUtil::apiFunc('IWstats', 'user', 'getAllRecords', array('fromDate' => $fromDate,
'toDate' => $toDate,
'all' => 1,
));
$recordsArray = array();
foreach ($records as $record) {
if (key_exists(substr($record['datetime'], 0, 10), $recordsArray)) {
// add new information in array element
$recordsArray[substr($record['datetime'], 0, 10)]['nRecords']++;
if (($record['uid'] > 0))
$recordsArray[substr($record['datetime'], 0, 10)]['registered']++;
if (key_exists($record['moduleid'], $recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'])) {
$recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']]++;
} else {
// add a new user in users array field
$recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']] = 1;
}
if (key_exists($record['moduleid'], $recordsArray[substr($record['datetime'], 0, 10)]['modules'])) {
$recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']]++;
} else {
$recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']] = 1;
}
if (($record['skipped'] == 1))
$recordsArray[substr($record['datetime'], 0, 10)]['skipped']++;
if (($record['skippedModule'] == 1))
$recordsArray[substr($record['datetime'], 0, 10)]['skippedModule']++;
if (($record['isadmin'] == 1))
$recordsArray[substr($record['datetime'], 0, 10)]['isadmin']++;
if (!in_array($record['ip'], $recordsArray[substr($record['datetime'], 0, 10)]['ips'])) {
$recordsArray[substr($record['datetime'], 0, 10)]['ips'][] = $record['ip'];
}
} else {
// add a new element into the array
$recordsArray[substr($record['datetime'], 0, 10)]['nRecords'] = 1;
$recordsArray[substr($record['datetime'], 0, 10)]['registered'] = ($record['uid'] > 0) ? 1 : 0;
$recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']] = 1;
$recordsArray[substr($record['datetime'], 0, 10)]['ips'][] = $record['ip'];
$recordsArray[substr($record['datetime'], 0, 10)]['datetime'] = substr($record['datetime'], 0, 10) . ' 00:00:00';
$recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']] = 1;
$recordsArray[substr($record['datetime'], 0, 10)]['skipped'] = ($record['skipped'] == 1) ? 1 : 0;
$recordsArray[substr($record['datetime'], 0, 10)]['skippedModule'] = ($record['skippedModule'] == 1) ? 1 : 0;
$recordsArray[substr($record['datetime'], 0, 10)]['isadmin'] = ($record['isadmin'] == 1) ? 1 : 0;
}
}
ksort($recordsArray);
// print_r($recordsArray);die();
// save records in ddbb
foreach ($recordsArray as $record) {
$usersArray = array();
foreach ($record['users'] as $key => $value) {
$usersString = $key . '|';
$usersModulesArray = array();
foreach ($value['modules'] as $k => $v) {
$usersModulesArray[] = $k . '=' . $v;
}
$usersModulesString = implode('#', $usersModulesArray);
$usersArray[] = $usersString . $usersModulesString;
}
$users = '$' . implode('$$', $usersArray) . '$';
$modulesArray = array();
foreach ($record['modules'] as $key => $value) {
$modulesArray[] = $key . '|' . $value;
}
$modules = '$' . implode('$$', $modulesArray) . '$';
$item = array(
'datetime' => $record['datetime'],
'nrecords' => $record['nRecords'],
'registered' => $record['registered'],
'modules' => $modules,
'skipped' => $record['skipped'],
'skippedModule' => $record['skippedModule'],
'isadmin' => $record['isadmin'],
'users' => $users,
'nips' => count($record['ips']),
);
//.........这里部分代码省略.........
示例7: monthlyview
/**
* Show bookings monthly view
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @author Josep Ferràndiz Farré (jferran6@xtec.cat)
* @return The renderized information
*/
public function monthlyview($args) {
// Security check
if (!SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_READ)) {
throw new Zikula_Exception_Forbidden();
}
$sid = FormUtil::getPassedValue('sid', isset($args['sid']) ? $args['sid'] : null, 'GET');
$year = FormUtil::getPassedValue('year', isset($args['year']) ? $args['year'] : null, 'GET');
$month = FormUtil::getPassedValue('month', isset($args['month']) ? $args['month'] : null, 'GET');
$inc = FormUtil::getPassedValue('m', isset($args['m']) ? $args['m'] : 0, 'GET');
$aux_month = (int) DateUtil::getDatetime('', '%m');
$aux_year = (int) DateUtil::getDatetime('', '%Y');
if (empty($year) or empty($month)) {
$year = DateUtil::getDatetime('', '%Y');
$month = $aux_month;
} else {
$month = $month + $inc;
}
if ($month == 0) {
$month = 12;
$year = $year - 1;
}
if ($month == 13) {
$month = 1;
$year = $year + 1;
}
if (($month < $aux_month) && ($year == $aux_year)) {
$month = $aux_month;
} //Minim month is current month
//Memoritzem un array amb els dies de la setmana
// Create an array with the days of the week
$showWeekends = ModUtil::getVar('IWbookings', 'weekends');
if ($showWeekends) {
$days = array($this->__('Monday'),
$this->__('Tuesday'),
$this->__('Wednesday'),
$this->__('Thursday'),
$this->__('Friday'),
$this->__('Saturday'),
$this->__('Sunday'));
} else {
$days = array($this->__('Monday'),
$this->__('Tuesday'),
$this->__('Wednesday'),
$this->__('Thursday'),
$this->__('Friday'));
}
//Array with the name of the months
$monthNames = array('', $this->__('January'),
$this->__('February'),
$this->__('March'),
$this->__('April'),
$this->__('May'),
$this->__('June'),
$this->__('July'),
$this->__('August'),
$this->__('September'),
$this->__('October'),
$this->__('November'),
$this->__('December'));
// Get month days number
$numDays = count(DateUtil::getMonthDates($month, $year));
// First day of month
$startDate = DateUtil::buildDatetime($year, $month, 1, 0, 0, 0);
// last day of month
$endDate = DateUtil::buildDatetime($year, $month, $numDays, 23, 59, 59);
//determinem quin dia de la setmana �s el primer dia del mes
// Get the fisrt day of week of the month
$firstDay = date("w", DateUtil::makeTimestamp($startDate));
//per si el primer dia del mes �s diumenge el posem a 7, ja que en aquest cas PHP retorna el valor 0
($firstDay == 0) ? $firstDay = 7 : "";
//Situem els espais de reserva en un camp multiselect des d'on es podran filtra les dades dels espais
//Cridem la funci� API que retornar� la informaci� de tots els espais de reserva definits
$espais[] = array('id' => -1, 'name' => $this->__('All rooms and equipments'));
$registres = ModUtil::apiFunc('IWbookings', 'user', 'getall');
foreach ($registres as $registre) {
if ($registre['active'] == 1) {
$espais[] = array('id' => $registre['sid'],
'name' => $registre['space_name']);
$space_info[$registre['sid']]['name'] = $registre['space_name'];
$space_info[$registre['sid']]['color'] = $registre['color'];
}
}
$taula = array();
//.........这里部分代码省略.........
示例8: getWeek
/**
* Calcula la data inicial de la setmana a la qual pertany una determinada data
* @author Josep Ferr�ndiz Farr� (jferran6@xtec.cat)
* @args The date (a MySQL timestamp or a string)
* @return the start date of the week
*/
public function getWeek($args) {
$TheDate = FormUtil::getPassedValue('date', isset($args['date']) ? $args['date'] : null, 'GET');
$format = FormUtil::getPassedValue('format', isset($args['format']) ? $args['format'] : null, 'GET');
$week = array();
if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) {
return $week;
}
$avui = DateUtil::makeTimestamp($TheDate);
$dow = date("w", $avui);
($dow == 0) ? $dow = 7 : ""; // If sunday
$fields = explode('-', $TheDate);
if ($format == 'ymd') {
$week['start'] = DateUtil::getDatetime_NextDay((1 - $dow), '%Y-%m-%d', $fields[0], $fields[1], $fields[2]);
$week['end'] = DateUtil::getDatetime_NextDay((7 - $dow), "%Y-%m-%d %H:%M:%S", $fields[0], $fields[1], $fields[2], 23, 59, 59);
} else {
$week['start'] = DateUtil::getDatetime_NextDay((1 - $dow), '%d-%m-%y', $fields[0], $fields[1], $fields[2]);
$week['end'] = DateUtil::getDatetime_NextDay((7 - $dow), "%d-%m-%y", $fields[0], $fields[1], $fields[2]);
}
return $week;
}