本文整理汇总了PHP中CoreUtils类的典型用法代码示例。如果您正苦于以下问题:PHP CoreUtils类的具体用法?PHP CoreUtils怎么用?PHP CoreUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoreUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUserPermissionsForRecord
protected function checkUserPermissionsForRecord()
{
if ($this->currentUser['adminRole'] < $this->adminRoles['adminRoleSuperadmin'] && $this->currentUser['id'] != $this->record['id']) {
CoreServices2::getDB()->transactionCommit();
CoreUtils::redirect($this->getListPageAddress());
}
}
示例2: prepareData
public function prepareData()
{
parent::prepareData();
if (CoreServices2::getRequest()->getFromGet('_sm')) {
$this->successMessage = 1;
return;
}
$this->dao = new UserDAO();
$this->initRecord();
$this->initForm();
$this->createFormFields();
if (empty($this->record['id'])) {
// @TODO: własciwie w tym wypadku powinno sie przejść z powrotem do pierwszego
// formularza i rozpocząć całą procedurę od nowa
$this->errorMessageContainer = new CoreFormValidationMessageContainer();
$this->errorMessageContainer->addMessage('errorInvalidCode');
return;
}
if ($this->form->isSubmitted()) {
$this->addFormValidators();
$this->form->setFieldValuesFromRequest();
$this->handleRequest();
} else {
$this->setFormFieldValuesFromRecord();
}
if (!empty($this->redirectAddress)) {
CoreUtils::redirect($this->redirectAddress);
}
}
开发者ID:piotrPiechura,项目名称:3dPathProject,代码行数:29,代码来源:UserWebsitePasswordRecovery2Controller.class.php
示例3: process
/**
* Processes a preference item's new value
*
* @param string $key
*
* @return mixed
*/
static function process($key)
{
$value = isset($_POST['value']) ? CoreUtils::trim($_POST['value']) : null;
switch ($key) {
case "cg_itemsperpage":
$thing = 'Color Guide items per page';
if (!is_numeric($value)) {
throw new \Exception("{$thing} must be a number");
}
$value = intval($value, 10);
if ($value < 7 || $value > 20) {
throw new \Exception("{$thing} must be between 7 and 20");
}
break;
case "p_vectorapp":
if (!empty($value) && !isset(CoreUtils::$VECTOR_APPS[$value])) {
throw new \Exception("The specified app is invalid");
}
break;
case "p_hidediscord":
case "p_disable_ga":
case "cg_hidesynon":
case "cg_hideclrinfo":
$value = $value ? 1 : 0;
break;
case "discord_token":
Response::fail("You cannot change the {$key} setting");
}
return $value;
}
示例4: initRecord
protected function initRecord()
{
parent::initRecord();
if (empty($this->record['id']) || $this->record['subpageModule'] != 'Subpage' || $this->record['subpageMode'] != 'Website') {
CoreUtils::redirect($this->getListPageAddress());
}
}
示例5: getTimeRemaining
/**
* Ta funkcja zwraca na razie liczbę dni, godzin, minut, sekund
* pozostających do momentu podanego w parametrze. Podanie ilości
* miesięcy i lat to trochę gorsza sprawa (szczególnie z miesiącami
* jest problem koncepcyjny).
* @param string
* @return array
*/
public function getTimeRemaining($time)
{
$timeSeconds = strtotime($time) - strtotime(CoreUtils::getDateTime());
if ($timeSeconds <= 0) {
return null;
}
return array('timeSeconds' => $timeSeconds, 's' => $timeSeconds % 60, 'm' => floor($timeSeconds / 60) % 60, 'h' => floor($timeSeconds / (60 * 60)) % 24, 'D' => floor($timeSeconds / (60 * 60 * 24)));
}
示例6: eventFinish
public function eventFinish($category, $eventName)
{
$eventId = $this->getIdByName($eventName);
if (empty($this->info[$category]['events'][$eventId]['eventName'])) {
$this->info[$category]['events'][$eventId]['eventName'] = $eventName;
}
$this->info[$category]['events'][$eventId]['finishTime'] = CoreUtils::getTimeMicroseconds() - $this->startTime;
}
示例7: initParams
protected function initParams(&$params)
{
CoreUtils::checkConstraint(is_null($params) || is_array($params));
if (!empty($params)) {
$this->params = $params;
} else {
$this->params = array();
}
}
示例8: validate
public function validate($messageManager)
{
$field = $this->form->getField($this->fieldName);
$fieldValue = $field->getValue();
if (!is_null($fieldValue)) {
if (date('Y-m-d', strtotime($fieldValue)) < CoreUtils::getDate()) {
$messageManager->addMessage('dateInThePast', array($this->fieldName => $field->getCaption()));
}
}
}
示例9: logAction
protected function logAction($action)
{
$logRecord = $this->logDAO->getRecordTemplate();
$logRecord['adminId'] = CoreServices2::getAccess()->getCurrentUserId();
$logRecord['recordType'] = $this->recordType;
$logRecord['recordId'] = CoreServices2::getAccess()->getCurrentUserId();
$logRecord['logTime'] = CoreUtils::getDateTime();
$logRecord['logIP'] = CoreServices2::getRequest()->getRealIP();
$logRecord['logOperation'] = $action;
$this->logDAO->save($logRecord);
}
示例10: checkHTTPS
/**
* Teoretycznie jest to odporne na thickboxy.
*/
protected function checkHTTPS()
{
$httpsOn = CoreServices2::getUrl()->isHTTPSOn();
$httpsRequired = CoreConfig::get('Environment', 'httpsForWebsite');
if ($httpsRequired && !$httpsOn) {
CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('https'));
}
if (!$httpsRequired && $httpsOn) {
CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('http'));
}
}
示例11: redirectToPage
protected function redirectToPage($url, $layoutType)
{
switch ($layoutType) {
case 'standard':
CoreUtils::redirect(CoreServices2::getUrl()->createAddress('_m', 'Helper', '_o', 'WebsiteThickboxParentRedirect', 'url', $url));
case 'thickbox':
CoreUtils::redirect($url);
default:
throw new CoreException('Invalid layout type ' . $layoutType);
}
}
开发者ID:piotrPiechura,项目名称:3dPathProject,代码行数:11,代码来源:WebsiteAbstractControllerThickboxLayout.class.php
示例12: handleRequest
protected function handleRequest()
{
$this->errorMessageContainer = $this->form->getValidationResults();
if (!$this->errorMessageContainer->isAnyErrorMessage()) {
$this->setRecordValuesFromForm();
$this->record['userEraseRequestTime'] = CoreUtils::getDateTime();
$this->record['userState'] = 'forDeletion';
$this->dao->save($this->record);
CoreServices2::getAccess()->logout();
$this->redirectToStep2();
}
}
示例13: add
public static function add($pointName = '')
{
if (self::$index == 0) {
self::$timePoints = array();
}
self::$timePoints[self::$index] = array();
$currentTime = CoreUtils::getTimeMicroseconds();
self::$timePoints[self::$index]['diff'] = self::$index != 0 ? $currentTime - self::$timePoints[self::$index - 1]['time'] : 0;
self::$timePoints[self::$index]['time'] = $currentTime;
self::$timePoints[self::$index]['name'] = $pointName;
self::$index++;
}
示例14: getChildrenCount
public function getChildrenCount(&$record)
{
CoreUtils::checkConstraint(!empty($record['id']));
$db = CoreServices2::getDB();
$sql = '
SELECT COUNT(*) AS num
FROM subpage
WHERE
subpageParentId = ' . $db->prepareInputValue($record['id']);
$row = $db->getRow($sql);
return $row['num'];
}
示例15: prepareData
public function prepareData()
{
if (!$this->isCLI()) {
CoreUtils::redirect(CoreServices::get('url')->createAddress());
}
$this->garbageCollector = new TmpRecordGarbageCollector();
try {
$this->garbageCollector->clean();
} catch (Exception $e) {
$this->reportError($e->getMessage());
}
}