本文整理汇总了PHP中BackendModel::getUTCDate方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendModel::getUTCDate方法的具体用法?PHP BackendModel::getUTCDate怎么用?PHP BackendModel::getUTCDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackendModel
的用法示例。
在下文中一共展示了BackendModel::getUTCDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired'));
$this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired'));
$this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired'));
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = $this->frm->getField('category_id')->getValue();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['language'] = BL::getWorkingLanguage();
$item['question'] = $this->frm->getField('title')->getValue();
$item['answer'] = $this->frm->getField('answer')->getValue(true);
$item['created_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1;
// save the data
$item['id'] = BackendFaqModel::insert($item);
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// add search index
BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']);
}
}
}
示例2: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// action to execute
$id = SpoonFilter::getGetValue('id', null, 0);
// no id's provided
if (empty($id) || !BackendMailmotorModel::existsMailing($id)) {
$this->redirect(BackendModel::createURLForAction('index') . '&error=mailing-does-not-exist');
} else {
// get the mailing and reset some fields
$mailing = BackendMailmotorModel::getMailing($id);
$mailing['status'] = 'concept';
$mailing['send_on'] = null;
$mailing['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$mailing['edited_on'] = $mailing['created_on'];
$mailing['data'] = serialize($mailing['data']);
unset($mailing['recipients'], $mailing['id'], $mailing['cm_id'], $mailing['send_on_raw']);
// set groups
$groups = $mailing['groups'];
unset($mailing['groups']);
// create a new mailing based on the old one
$newId = BackendMailmotorModel::insertMailing($mailing);
// update groups for this mailing
BackendMailmotorModel::updateGroupsForMailing($newId, $groups);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_copy_mailing', array('item' => $mailing));
}
// redirect
$this->redirect(BackendModel::createURLForAction('index') . '&report=mailing-copied&var=' . $mailing['name']);
}
示例3: buildQuery
/**
* Builds the query for this datagrid
*
* @return array An array with two arguments containing the query and its parameters.
*/
private function buildQuery()
{
$parameters = array($this->id);
// start query, as you can see this query is build in the wrong place, because of the filter it is a special case
// wherin we allow the query to be in the actionfile itself
$query = 'SELECT i.id, UNIX_TIMESTAMP(i.sent_on) AS sent_on
FROM forms_data AS i
WHERE i.form_id = ?';
// add start date
if ($this->filter['start_date'] !== '') {
// explode date parts
$chunks = explode('/', $this->filter['start_date']);
// add condition
$query .= ' AND i.sent_on >= ?';
$parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
}
// add end date
if ($this->filter['end_date'] !== '') {
// explode date parts
$chunks = explode('/', $this->filter['end_date']);
// add condition
$query .= ' AND i.sent_on <= ?';
$parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
}
// new query
return array($query, $parameters);
}
示例4: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
// build item
$item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['template'] = count($this->templates) > 1 ? $this->frm->getField('template')->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['hidden'] = $this->frm->getField('hidden')->getValue() ? 'N' : 'Y';
$item['status'] = 'active';
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
// insert the item
$item['revision_id'] = BackendContentBlocksModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例5: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
$sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
$sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
$messageDate = $sendOnDate;
// validate mailing ID
if ($mailingId == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
}
if ($sendOnDate == '' || $sendOnTime == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
}
// record is empty
if (!BackendMailmotorModel::existsMailing($mailingId)) {
$this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor'));
}
// reverse the date and make it a proper
$explodedDate = explode('/', $sendOnDate);
$sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
// calc full send timestamp
$sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
// build data
$item['id'] = $mailingId;
$item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
$item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// update mailing
BackendMailmotorModel::updateMailing($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
// output
$this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
}
示例6: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get parameters
$id = SpoonFilter::getPostValue('id', null, '', 'int');
$name = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($name == '') {
$this->output(self::BAD_REQUEST, null, 'no name provided');
}
// get existing id
$existingId = BackendMailmotorModel::getCampaignId($name);
// existing campaign
if ($existingId !== 0 && $id !== $existingId) {
$this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
}
// build array
$item = array();
$item['id'] = $id;
$item['name'] = $name;
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// get page
$rows = BackendMailmotorModel::updateCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item));
// output
if ($rows !== 0) {
$this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule()));
} else {
$this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule()));
}
}
示例7: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// shorten fields
$txtName = $this->frm->getField('name');
$rbtDefaultForLanguage = $this->frm->getField('default');
// validate fields
if ($txtName->isFilled(BL::err('NameIsRequired'))) {
// check if the group exists by name
if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) {
$txtName->addError(BL::err('GroupAlreadyExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['name'] = $txtName->getValue();
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue();
$item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N';
// insert the item
$item['id'] = BackendMailmotorCMHelper::insertGroup($item);
// check if all default groups were set
BackendMailmotorModel::checkDefaultGroups();
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
}
}
}
示例8: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// user is god?
$isGod = BackendAuthentication::getUser()->isGod();
// get possible languages
if ($isGod) {
$possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
} else {
$possibleLanguages = BL::getWorkingLanguages();
}
// get parameters
$language = SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
$module = SpoonFilter::getPostValue('module', BackendModel::getModules(false), null, 'string');
$name = SpoonFilter::getPostValue('name', null, null, 'string');
$type = SpoonFilter::getPostValue('type', BackendModel::getDB()->getEnumValues('locale', 'type'), null, 'string');
$application = SpoonFilter::getPostValue('application', array('backend', 'frontend'), null, 'string');
$value = SpoonFilter::getPostValue('value', null, null, 'string');
// validate values
if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'frontend' && $module != 'core') {
$error = BL::err('InvalidValue');
}
// in case this is a 'act' type, there are special rules concerning possible values
if ($type == 'act' && !isset($error)) {
if (!SpoonFilter::isValidAgainstRegexp('|^([a-z0-9\\-\\_])+$|', $value)) {
$error = BL::err('InvalidActionValue', $this->getModule());
}
}
// no error?
if (!isset($error)) {
// build item
$item['language'] = $language;
$item['module'] = $module;
$item['name'] = $name;
$item['type'] = $type;
$item['application'] = $application;
$item['value'] = $value;
$item['edited_on'] = BackendModel::getUTCDate();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
// does the translation exist?
if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
// add the id to the item
$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
// update in db
BackendLocaleModel::update($item);
} else {
// insert in db
BackendLocaleModel::insert($item);
}
// output OK
$this->output(self::OK);
} else {
$this->output(self::ERROR, null, $error);
}
}
示例9: createXML
/**
* Create the XML based on the locale items.
*
* @return void
*/
private function createXML()
{
// create XML
$xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
// xml headers
$headers[] = 'Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"';
$headers[] = 'Content-Type: application/octet-stream;charset=utf-8';
$headers[] = 'Content-Length: ' . strlen($xmlOutput);
// set headers
SpoonHTTP::setHeaders($headers);
// output XML
echo $xmlOutput;
// stop script
exit;
}
示例10: execute
/**
* Execute the action.
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// action to execute
$action = SpoonFilter::getGetValue('action', array('addToGroup', 'delete'), '');
$ids = isset($_GET['id']) ? (array) $_GET['id'] : array();
$newGroupId = SpoonFilter::getGetValue('newGroup', array_keys(BackendProfilesModel::getGroups()), '');
// at least one id
if (!empty($ids)) {
// delete the given profiles
if ($action === 'delete') {
BackendProfilesModel::delete($ids);
$report = 'deleted';
} elseif ($action === 'addToGroup') {
// for which we need a group of course
if ($newGroupId != '') {
// set new status
foreach ($ids as $id) {
// profile must exist
if (BackendProfilesModel::exists($id)) {
// make sure the user is not already part of this group without an expiration date
foreach (BackendProfilesModel::getProfileGroups($id) as $existingGroup) {
// if he is, skip to the next user
if ($existingGroup['group_id'] === $newGroupId) {
continue 2;
}
}
// OK, it's safe to add the user to this group
BackendProfilesModel::insertProfileGroup(array('profile_id' => $id, 'group_id' => $newGroupId, 'starts_on' => BackendModel::getUTCDate()));
}
}
// report
$report = 'added-to-group';
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=no-group-selected');
}
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=unknown-action');
}
// report
$report = (count($ids) > 1 ? 'profiles-' : 'profile-') . $report;
// redirect
$this->redirect(BackendModel::createURLForAction('index', null, null, array('offset' => SpoonFilter::getGetValue('offset', null, ''), 'order' => SpoonFilter::getGetValue('order', null, ''), 'sort' => SpoonFilter::getGetValue('sort', null, ''), 'email' => SpoonFilter::getGetValue('email', null, ''), 'status' => SpoonFilter::getGetValue('status', null, ''), 'group' => SpoonFilter::getGetValue('group', null, ''))) . '&report=' . $report);
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=no-profiles-selected');
}
}
示例11: parseKeywords
/**
* Parse the keywords datagrid
*/
private function parseKeywords()
{
$results = BackendAnalyticsModel::getRecentKeywords();
if (!empty($results)) {
$dataGrid = new BackendDataGridArray($results);
$dataGrid->setPaging(false);
$dataGrid->setColumnsHidden('id', 'date');
// parse the datagrid
$this->tpl->assign('dgAnalyticsKeywords', $dataGrid->getContent());
}
// get date
$date = isset($results[0]['date']) ? substr($results[0]['date'], 0, 10) : date('Y-m-d');
$timestamp = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
// assign date label
$this->tpl->assign('analyticsTrafficSourcesDate', $date != date('Y-m-d') ? BackendModel::getUTCDate('d-m', $timestamp) : BL::lbl('Today'));
}
示例12: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// no errors?
if ($this->frm->isCorrect()) {
// the total amount of subscribers
$subscribersTotal = 0;
// loop all groups
foreach ($this->externalGroups as $group) {
// insert them in our database
$groupID = BackendModel::getDB(true)->insert('mailmotor_groups', array('name' => $group['name'], 'custom_fields' => $group['custom_fields'], 'created_on' => BackendModel::getUTCDate()));
// insert the CM ID
BackendMailmotorCMHelper::insertCampaignMonitorID('list', $group['id'], $groupID);
// continue looping if this group has no subscribers
if (empty($group['subscribers'])) {
continue;
}
// add this groups subscribers amount to the total
$subscribersTotal += $group['subscribers_amount'];
// loop the subscribers for this group, and import them
foreach ($group['subscribers'] as $subscriber) {
// build new subscriber record
$item = array();
$item['email'] = $subscriber['email'];
$item['source'] = 'import';
$item['created_on'] = $subscriber['date'];
// add an additional custom field 'name', if it was set in the subscriber record
if (!empty($subscriber['name'])) {
$subscriber['custom_fields']['Name'] = $subscriber['name'];
}
// save the subscriber in our database, and subscribe it to this group
BackendMailmotorModel::saveAddress($item, $groupID, !empty($subscriber['custom_fields']) ? $subscriber['custom_fields'] : null);
}
}
// at this point, groups are set
BackendModel::setModuleSetting($this->getModule(), 'cm_groups_set', true);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_import_groups');
// redirect to the index
$this->redirect(BackendModel::createURLForAction('index', $this->getModule()) . '&report=groups-imported&var[]=' . count($this->externalGroups) . '&var[]=' . $subscribersTotal);
}
}
}
示例13: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('email')->isFilled(BL::err('EmailIsRequired'));
// get addresses
$addresses = (array) explode(',', $this->frm->getField('email')->getValue());
// loop addresses
foreach ($addresses as $email) {
// validate email
if (!SpoonFilter::isEmail(trim($email))) {
// add error if needed
$this->frm->getField('email')->addError(BL::err('ContainsInvalidEmail'));
// stop looking
break;
}
}
$this->frm->getField('groups')->isFilled(BL::err('ChooseAtLeastOneGroup'));
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = $this->frm->getValues();
$item['source'] = BL::lbl('Manual');
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// loop the groups
foreach ($item['groups'] as $group) {
foreach ($addresses as $email) {
BackendMailmotorCMHelper::subscribe(trim($email), $group);
}
}
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_address', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('addresses') . (!empty($this->groupId) ? '&group_id=' . $this->groupId : '') . '&report=added');
}
}
}
示例14: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// get fields
$ddmGroup = $this->frm->getField('group');
$txtExpirationDate = $this->frm->getField('expiration_date');
$txtExpirationTime = $this->frm->getField('expiration_time');
// fields filled?
$ddmGroup->isFilled(BL::getError('FieldIsRequired'));
if ($txtExpirationDate->isFilled()) {
$txtExpirationDate->isValid(BL::getError('DateIsInvalid'));
}
if ($txtExpirationTime->isFilled()) {
$txtExpirationTime->isValid(BL::getError('TimeIsInvalid'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$values['profile_id'] = $this->id;
$values['group_id'] = $ddmGroup->getSelected();
$values['starts_on'] = BackendModel::getUTCDate();
// only format date if not empty
if ($txtExpirationDate->isFilled() && $txtExpirationTime->isFilled()) {
// format date
$values['expires_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($txtExpirationDate, $txtExpirationTime));
}
// insert values
$id = BackendProfilesModel::insertProfileGroup($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_profile_add_to_group', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $values['profile_id'] . '&report=membership-added&highlight=row-' . $id . '#tabGroups');
}
}
}
示例15: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// shorten fields
$txtName = $this->frm->getField('name');
// validate fields
$txtName->isFilled(BL::err('NameIsRequired'));
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['name'] = $txtName->getValue();
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// insert the item
$item['id'] = BackendMailmotorModel::insertCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_campaign', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('campaigns') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
}
}
}