本文整理汇总了PHP中db_format_timestamp函数的典型用法代码示例。如果您正苦于以下问题:PHP db_format_timestamp函数的具体用法?PHP db_format_timestamp怎么用?PHP db_format_timestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_format_timestamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requestfriendship_submit
function requestfriendship_submit(Pieform $form, $values)
{
global $USER, $SESSION, $id, $goto;
$loggedinid = $USER->get('id');
$user = get_record('usr', 'id', $id);
// friend db record
$f = new StdClass();
$f->ctime = db_format_timestamp(time());
// notification info
$n = new StdClass();
$n->url = profile_url($USER, false);
$n->users = array($user->id);
$n->fromuser = $loggedinid;
$lang = get_user_language($user->id);
$displayname = display_name($USER, $user);
$n->strings = new stdClass();
$n->strings->urltext = (object) array('key' => 'Requests');
$f->owner = $id;
$f->requester = $loggedinid;
$f->message = $values['message'];
insert_record('usr_friend_request', $f);
$n->subject = get_string_from_language($lang, 'requestedfriendlistsubject', 'group');
if (isset($values['message']) && !empty($values['message'])) {
$n->message = get_string_from_language($lang, 'requestedfriendlistmessageexplanation', 'group', $displayname) . $values['message'];
} else {
$n->message = get_string_from_language($lang, 'requestedfriendlistinboxmessage', 'group', $displayname);
}
require_once 'activity.php';
activity_occurred('maharamessage', $n);
handle_event('addfriendrequest', array('requester' => $loggedinid, 'owner' => $id));
$SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id)));
redirect($goto);
}
示例2: notify_user
public static function notify_user($user, $data)
{
$toinsert = new StdClass();
$toinsert->type = $data->type;
$toinsert->usr = $user->id;
if (!empty($user->markasread)) {
$toinsert->read = 1;
} else {
$toinsert->read = 0;
}
$toinsert->message = $data->message;
$toinsert->subject = $data->subject;
$toinsert->parent = $data->parent;
$toinsert->ctime = db_format_timestamp(time());
if (!empty($data->url)) {
$toinsert->url = $data->url;
}
if (!empty($data->urltext)) {
$toinsert->urltext = $data->urltext;
}
if (!empty($data->fromuser)) {
$toinsert->from = $data->fromuser;
}
return insert_record('notification_internal_activity', $toinsert, 'id', true);
}
示例3: forgotpass_submit
function forgotpass_submit(Pieform $form, $values)
{
global $SESSION;
try {
if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(email) = ?', array(strtolower($values['emailusername']))))) {
if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(username) = ?', array(strtolower($values['emailusername']))))) {
die_info(get_string('forgotpassnosuchemailaddressorusername'));
}
}
$pwrequest = new StdClass();
$pwrequest->usr = $user->id;
$pwrequest->expiry = db_format_timestamp(time() + 86400);
$pwrequest->key = get_random_key();
$sitename = get_config('sitename');
$fullname = display_name($user);
email_user($user, null, get_string('forgotusernamepasswordemailsubject', 'mahara', $sitename), get_string('forgotusernamepasswordemailmessagetext', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename), get_string('forgotusernamepasswordemailmessagehtml', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename));
insert_record('usr_password_request', $pwrequest);
} catch (SQLException $e) {
die_info(get_string('forgotpassemailsendunsuccessful'));
} catch (EmailDisabledException $e) {
die_info(get_string('forgotpassemaildisabled'));
} catch (EmailException $e) {
die_info(get_string('forgotpassemailsendunsuccessful'));
}
// Add a marker in the session to say that the user has registered
$_SESSION['pwchangerequested'] = true;
redirect('/forgotpass.php');
}
示例4: editgroup_submit
function editgroup_submit(Pieform $form, $values)
{
global $USER, $SESSION, $group_data;
db_begin();
$now = db_format_timestamp(time());
list($grouptype, $jointype) = explode('.', $values['grouptype']);
$values['public'] = isset($values['public']) ? $values['public'] : 0;
$values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0;
update_record('group', (object) array('id' => $values['id'], 'name' => $values['name'], 'description' => $values['description'], 'grouptype' => $grouptype, 'category' => empty($values['category']) ? null : intval($values['category']), 'jointype' => $jointype, 'mtime' => $now, 'usersautoadded' => intval($values['usersautoadded']), 'public' => intval($values['public']), 'viewnotify' => intval($values['viewnotify'])), 'id');
// When jointype changes from invite/request to anything else,
// remove all open invitations/requests, ---
// Except for when jointype changes from request to open. Then
// we can just add group membership for everyone with an open
// request.
if ($group_data->jointype == 'invite' && $jointype != 'invite') {
delete_records('group_member_invite', 'group', $group_data->id);
} else {
if ($group_data->jointype == 'request') {
if ($jointype == 'open') {
$userids = get_column_sql('
SELECT u.id
FROM {usr} u JOIN {group_member_request} r ON u.id = r.member
WHERE r.group = ? AND u.deleted = 0', array($group_data->id));
if ($userids) {
foreach ($userids as $uid) {
group_add_user($group_data->id, $uid);
}
}
} else {
if ($jointype != 'request') {
delete_records('group_member_request', 'group', $group_data->id);
}
}
}
}
// When group type changes from course to standard, make sure that tutors
// are demoted to members.
if ($group_data->grouptype == 'course' && $grouptype != 'course') {
set_field('group_member', 'role', 'member', 'group', $values['id'], 'role', 'tutor');
}
// When a group changes from public -> private or vice versa, set the
// appropriate access permissions on the group homepage view.
if ($group_data->public != $values['public']) {
$homepageid = get_field('view', 'id', 'type', 'grouphomepage', 'group', $group_data->id);
if ($group_data->public && !$values['public']) {
delete_records('view_access', 'view', $homepageid, 'accesstype', 'public');
insert_record('view_access', (object) array('view' => $homepageid, 'accesstype' => 'loggedin'));
} else {
if (!$group_data->public && $values['public']) {
delete_records('view_access', 'view', $homepageid, 'accesstype', 'loggedin');
insert_record('view_access', (object) array('view' => $homepageid, 'accesstype' => 'public'));
}
}
}
$SESSION->add_ok_msg(get_string('groupsaved', 'group'));
db_commit();
redirect('/group/view.php?id=' . $values['id']);
}
示例5: notify_user
public static function notify_user($user, $data)
{
$toinsert = new StdClass();
$toinsert->type = $data->type;
$toinsert->usr = $user->id;
$toinsert->message = $data->message;
$toinsert->ctime = db_format_timestamp(time());
if (!empty($data->url)) {
$toinsert->url = $data->url;
}
insert_record('notification_emaildigest_queue', $toinsert);
}
示例6: activity_occurred
/**
* This is the function to call whenever anything happens
* that is going to end up on a user's activity page.
*
* @param string $activitytype type of activity
* @param mixed $data data
*/
function activity_occurred($activitytype, $data, $plugintype = null, $pluginname = null)
{
$at = activity_locate_typerecord($activitytype, $plugintype, $pluginname);
if (!empty($at->delay)) {
$delayed = new StdClass();
$delayed->type = $at->id;
$delayed->data = serialize($data);
$delayed->ctime = db_format_timestamp(time());
insert_record('activity_queue', $delayed);
} else {
handle_activity($at, $data);
}
}
示例7: editgroup_submit
function editgroup_submit(Pieform $form, $values)
{
global $USER;
global $SESSION;
db_begin();
$now = db_format_timestamp(time());
list($grouptype, $jointype) = explode('.', $values['grouptype']);
$values['public'] = isset($values['public']) ? $values['public'] : 0;
$values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0;
update_record('group', (object) array('id' => $values['id'], 'name' => $values['name'], 'description' => $values['description'], 'grouptype' => $grouptype, 'jointype' => $jointype, 'mtime' => $now, 'usersautoadded' => intval($values['usersautoadded']), 'public' => intval($values['public'])), 'id');
$SESSION->add_ok_msg(get_string('groupsaved', 'group'));
db_commit();
redirect('/group/view.php?id=' . $values['id']);
}
示例8: invitetogroup_submit
function invitetogroup_submit(Pieform $form, $values)
{
global $SESSION, $USER, $group, $user;
$data = new StdClass();
$data->group = $group->id;
$data->member = $user->id;
$data->ctime = db_format_timestamp(time());
$data->role = $values['role'];
insert_record('group_member_invite', $data);
$lang = get_user_language($user->id);
require_once 'activity.php';
activity_occurred('maharamessage', array('users' => array($user->id), 'subject' => get_string_from_language($lang, 'invitetogroupsubject', 'group'), 'message' => get_string_from_language($lang, 'invitetogroupmessage', 'group', display_name($USER, $user), $group->name), 'url' => get_config('wwwroot') . 'group/view.php?id=' . $group->id));
$SESSION->add_ok_msg(get_string('userinvited', 'group'));
redirect('/user/view.php?id=' . $user->id);
}
示例9: notify_user
public static function notify_user($user, $data)
{
$toinsert = new StdClass();
$toinsert->type = $data->type;
$toinsert->usr = $user->id;
// Some messages are all html (or the message is not required).
// When they're 'cleaned' for display, they are left empty.
// Make sure something is in the field as it's NOT NULL in the database.
$toinsert->message = empty($data->message) ? ' ' : $data->message;
$toinsert->ctime = db_format_timestamp(time());
if (!empty($data->url)) {
$toinsert->url = $data->url;
}
insert_record('notification_emaildigest_queue', $toinsert);
}
示例10: editsitepage_submit
function editsitepage_submit(Pieform $form, $values)
{
global $USER;
$data = new StdClass();
$data->name = $values['pagename'];
$data->content = $values['pagetext'];
$data->mtime = db_format_timestamp(time());
$data->mauthor = $USER->get('id');
try {
update_record('site_content', $data, 'name');
} catch (SQLException $e) {
$form->reply(PIEFORM_ERR, get_string('savefailed', 'admin'));
}
$form->reply(PIEFORM_OK, get_string('pagesaved', 'admin'));
}
示例11: submitview_submit
function submitview_submit(Pieform $form, $values)
{
global $SESSION, $USER, $viewid, $groupid, $group;
db_begin();
update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
$roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
foreach ($roles as $role) {
$accessrecord = (object) array('view' => $viewid, 'group' => $groupid, 'role' => $role, 'visible' => 0, 'allowcomments' => 1, 'approvecomments' => 0);
ensure_record_exists('view_access', $accessrecord, $accessrecord);
}
ArtefactType::update_locked($USER->get('id'));
activity_occurred('groupmessage', array('subject' => get_string('viewsubmitted', 'view'), 'message' => get_string('viewsubmitted', 'view'), 'submittedview' => $viewid, 'viewowner' => $USER->get('id'), 'group' => $groupid, 'roles' => $roles, 'strings' => (object) array('urltext' => (object) array('key' => 'view'))));
db_commit();
$SESSION->add_ok_msg(get_string('viewsubmitted', 'view'));
redirect('/' . returnto());
}
示例12: import_submit
function import_submit(Pieform $form, $values)
{
global $SESSION;
$date = time();
$nicedate = date('Y/m/d h:i:s', $date);
$uploaddir = get_config('dataroot') . 'import/test-' . $date . '/';
$filename = $uploaddir . $values['file']['name'];
check_dir_exists($uploaddir);
move_uploaded_file($values['file']['tmp_name'], $filename);
if ($values['file']['type'] == 'application/zip') {
// Unzip here
$command = sprintf('%s %s %s %s', escapeshellcmd(get_config('pathtounzip')), escapeshellarg($filename), get_config('unzipdirarg'), escapeshellarg($uploaddir));
$output = array();
exec($command, $output, $returnvar);
if ($returnvar != 0) {
$SESSION->add_error_msg('Unable to unzip the file');
redirect('/import/');
}
$filename = $uploaddir . 'leap2a.xml';
if (!is_file($filename)) {
$SESSION->add_error_msg('No leap2a.xml file detected - please check your export file again');
redirect('/import/');
}
}
// Create dummy user
$user = (object) array('username' => 'import_' . $date, 'password' => 'import1', 'firstname' => 'Imported', 'lastname' => 'User (' . $nicedate . ')', 'email' => 'imported@example.org');
$userid = create_user($user);
// And we're good to go
echo '<pre>';
$filename = substr($filename, strlen(get_config('dataroot')));
require_once dirname(dirname(__FILE__)) . '/import/lib.php';
safe_require('import', 'leap');
db_begin();
$importer = PluginImport::create_importer(null, (object) array('token' => '', 'usr' => $userid, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('filename' => $filename), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_STDOUT, 'profile' => true));
$importer->process();
// Now done, delete the temporary e-mail address if there's a new one
// A bit sucky, presumes only one email in the import
$email = artefact_instance_from_id(get_field('artefact', 'id', 'title', 'imported@example.org', 'artefacttype', 'email', 'owner', $userid));
$email->delete();
execute_sql('UPDATE {artefact_internal_profile_email} SET principal = 1 WHERE "owner" = ?', array($userid));
db_commit();
echo "\n\n";
echo 'Done. You can <a href="' . get_config('wwwroot') . '/admin/users/changeuser.php?id=' . $userid . '">change to this user</a> to inspect the result, ';
echo 'or <a href="' . get_config('wwwroot') . 'import/">try importing again</a>';
echo '</pre>';
exit;
}
示例13: import_from_requests
/**
* Import from entry requests for Mahara files/folders
*
* @param PluginImportLeap $importer
* @return updated DB
* @throw ImportException
*/
public static function import_from_requests(PluginImportLeap $importer)
{
$importid = $importer->get('importertransport')->get('importid');
// Create a folder for import files/folders
$folder = new ArtefactTypeFolder(0, (object) array('owner' => $importer->get('usr'), 'title' => get_string('importfolder', 'import', db_format_timestamp(time()))));
$folder->commit();
$importfolderid = $folder->get('id');
if ($entry_requests = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ? AND entryparent IS NULL', array($importid, 'file'))) {
foreach ($entry_requests as $entry_request) {
self::create_file_from_request($importer, $entry_request, $importfolderid);
}
}
if ($entry_requests = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ? AND entryparent IS NULL', array($importid, 'folder'))) {
foreach ($entry_requests as $entry_request) {
self::import_folder_and_children_from_request($importer, $entry_request, $importfolderid);
}
}
}
示例14: requestjoingroup_submit
function requestjoingroup_submit(Pieform $form, $values)
{
global $SESSION, $USER, $group, $goto;
insert_record('group_member_request', (object) array('group' => $group->id, 'member' => $USER->get('id'), 'ctime' => db_format_timestamp(time()), 'reason' => isset($values['reason']) ? $values['reason'] : null));
// Send request to all group admins
require_once 'activity.php';
$groupadmins = get_column('group_member', 'member', 'group', $group->id, 'role', 'admin');
foreach ($groupadmins as $groupadmin) {
$adminlang = get_user_language($groupadmin);
if (isset($values['reason']) && $values['reason'] != '') {
$message = get_string_from_language($adminlang, 'grouprequestmessagereason', 'group', display_name($USER, get_record('usr', 'id', $groupadmin)), $group->name, $values['reason']);
} else {
$message = get_string_from_language($adminlang, 'grouprequestmessage', 'group', display_name($USER, get_record('usr', 'id', $groupadmin)), $group->name);
}
activity_occurred('maharamessage', array('users' => array($groupadmin), 'subject' => get_string_from_language($adminlang, 'grouprequestsubject', 'group'), 'message' => $message, 'url' => 'group/members.php?id=' . $group->id . '&membershiptype=request', 'strings' => (object) array('urltext' => (object) array('key' => 'pendingmembers', 'section' => 'group'))));
}
$SESSION->add_ok_msg(get_string('grouprequestsent', 'group'));
redirect($goto);
}
示例15: denyrequest_submit
function denyrequest_submit(Pieform $form, $values)
{
global $USER, $SESSION, $id;
$loggedinid = $USER->get('id');
$user = get_record('usr', 'id', $id);
// friend db record
$f = new StdClass();
$f->ctime = db_format_timestamp(time());
// notification info
$n = new StdClass();
$n->url = profile_url($USER, false);
$n->users = array($user->id);
$n->fromuser = $USER->get('id');
$lang = get_user_language($user->id);
$displayname = display_name($USER, $user);
$n->urltext = $displayname;
delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $id);
$n->subject = get_string_from_language($lang, 'friendrequestrejectedsubject', 'group');
if (isset($values['reason']) && !empty($values['reason'])) {
$n->message = get_string_from_language($lang, 'friendrequestrejectedmessagereason', 'group', $displayname) . $values['reason'];
} else {
$n->message = get_string_from_language($lang, 'friendrequestrejectedmessage', 'group', $displayname);
}
require_once 'activity.php';
activity_occurred('maharamessage', $n);
handle_event('removefriendrequest', array('owner' => $loggedinid, 'requester' => $id));
$SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
break;
}
$goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
redirect($goto);
}