本文整理汇总了PHP中db_format_tsfield函数的典型用法代码示例。如果您正苦于以下问题:PHP db_format_tsfield函数的具体用法?PHP db_format_tsfield怎么用?PHP db_format_tsfield使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_format_tsfield函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_blog_posts_in_block
/**
* Get the blog entries that will be displayed by this block.
* (This list will change depending when new blog entries are created, published, etc
*
* @param BlockInstance $instance
* @return array of objects
*/
public static function get_blog_posts_in_block(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
$limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
$mostrecent = array();
if (!empty($configdata['artefactids'])) {
$before = 'TRUE';
if ($instance->get_view()->is_submitted()) {
if ($submittedtime = $instance->get_view()->get('submittedtime')) {
// Don't display posts added after the submitted date.
$before = "a.ctime < '{$submittedtime}'";
}
}
$blogids = $configdata['artefactids'];
$artefactids = implode(', ', array_map('db_quote', $blogids));
$mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
WHERE a.artefacttype = \'blogpost\'
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
AND ' . $before . '
ORDER BY a.ctime DESC, a.id DESC
LIMIT ' . $limit, array($instance->get('view')));
if (!$mostrecent) {
$mostrecent = array();
}
}
return $mostrecent;
}
示例2: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$result = '';
if (!empty($configdata['artefactids'])) {
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
WHERE a.artefacttype = \'blogpost\'
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT owner from {view} WHERE id = ?)
ORDER BY a.ctime DESC
LIMIT 10', array($instance->get('view'))))) {
$mostrecent = array();
}
// format the dates
foreach ($mostrecent as &$data) {
$data->displaydate = format_date($data->ctime);
}
$smarty = smarty_core();
$smarty->assign('mostrecent', $mostrecent);
$smarty->assign('view', $instance->get('view'));
$result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
}
return $result;
}
示例3: assign_smarty_vars
public function assign_smarty_vars()
{
$user = $this->get('exporter')->get('user');
$userid = $user->get('id');
$updated = get_record_sql('select ' . db_format_tsfield('max(mtime)', 'mtime') . ' from {artefact} a join {artefact_installed_type} t on a.artefacttype = t.name where t.plugin = \'internal\'');
$this->smarty->assign('artefacttype', 'internal');
$this->smarty->assign('artefactplugin', 'internal');
$this->smarty->assign('title', display_name($user, $user));
$this->smarty->assign('updated', PluginExportLeap::format_rfc3339_date($updated->mtime));
// If this ID is changed, you'll have to change it in author.tpl too
$this->smarty->assign('id', 'portfolio:artefactinternal');
$this->smarty->assign('leaptype', $this->get_leap_type());
$persondata = array();
$spacialdata = array();
usort($this->artefacts, array($this, 'artefact_sort'));
foreach ($this->artefacts as $a) {
if (!($data = $this->data_mapping($a))) {
if ($a->get('artefacttype') == 'introduction') {
$this->smarty->assign('contenttype', 'html');
$this->smarty->assign('content', clean_html($a->get('title')));
}
continue;
}
$value = $a->render_self(array());
$value = $value['html'];
// TODO fix this when we non-js stuff
$data = array_merge(array('value' => $value, 'artefacttype' => $a->get('artefacttype'), 'artefactplugin' => 'internal'), $data);
if (array_key_exists('spacial', $data)) {
$spacialdata[] = (object) $data;
} else {
$label = get_string($a->get('artefacttype'), 'artefact.internal');
if ($a->get('artefacttype') == 'socialprofile') {
$label = $a->get('description');
}
$data = array_merge($data, array('label' => $label));
$persondata[] = (object) $data;
}
}
if ($extras = $this->exporter->get('extrapersondata')) {
$persondata = array_merge($persondata, $extras);
}
$this->smarty->assign('persondata', $persondata);
$this->smarty->assign('spacialdata', $spacialdata);
// Grab profile icons and link to them, making sure the default is first
if ($icons = get_column_sql("SELECT id\n FROM {artefact}\n WHERE artefacttype = 'profileicon'\n AND \"owner\" = ?\n ORDER BY id = (\n SELECT profileicon FROM {usr} WHERE id = ?\n ) DESC, id", array($userid, $userid))) {
foreach ($icons as $icon) {
$icon = artefact_instance_from_id($icon);
$this->add_artefact_link($icon, 'related');
}
$this->smarty->assign('links', $this->links);
}
if (!($categories = $this->get_categories())) {
$categories = array();
}
$this->smarty->assign('categories', $categories);
}
示例4: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$result = '';
$limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
if (!empty($configdata['artefactids'])) {
$before = 'TRUE';
if ($instance->get_view()->is_submitted()) {
if ($submittedtime = $instance->get_view()->get('submittedtime')) {
// Don't display posts added after the submitted date.
$before = "a.ctime < '{$submittedtime}'";
}
}
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
WHERE a.artefacttype = \'blogpost\'
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
AND ' . $before . '
ORDER BY a.ctime DESC, a.id DESC
LIMIT ' . $limit, array($instance->get('view'))))) {
$mostrecent = array();
}
// format the dates
foreach ($mostrecent as &$data) {
$data->displaydate = format_date($data->ctime);
}
$smarty = smarty_core();
$smarty->assign('mostrecent', $mostrecent);
$smarty->assign('view', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('editing', $editing);
if ($editing) {
// Get id and title of configued blogs
$recentpostconfigdata = $instance->get('configdata');
$wherestm = ' WHERE id IN (' . join(',', array_fill(0, count($recentpostconfigdata['artefactids']), '?')) . ')';
if (!($selectedblogs = get_records_sql_array('SELECT id, title FROM {artefact}' . $wherestm, $recentpostconfigdata['artefactids']))) {
$selectedblogs = array();
}
$smarty->assign('blogs', $selectedblogs);
}
$result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
}
return $result;
}
示例5: auth_handle_institution_expiries
/**
* Sends notification e-mails to site and institutional admins when:
*
* - An institution is expiring within the institution expiry warning
* period, set in site options.
*
* The actual prevention of users logging in is handled by the authentication
* code. This cron job sends e-mails to notify users that these events will
* happen soon.
*/
function auth_handle_institution_expiries()
{
// The 'expiry' flag on the usr table
$sitename = get_config('sitename');
$wwwroot = get_config('wwwroot');
$expire = get_config('institutionautosuspend');
$warn = get_config('institutionexpirynotification');
$daystoexpire = ceil($warn / 86400) . ' ';
$daystoexpire .= $daystoexpire == 1 ? get_string('day') : get_string('days');
// Get site administrators
$siteadmins = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.admin, u.staff FROM {usr} u WHERE u.admin = 1', array());
// Expiry warning messages
if ($institutions = get_records_sql_array('SELECT i.name, i.displayname FROM {institution} i ' . 'WHERE ' . db_format_tsfield('i.expiry', false) . ' < ? AND suspended != 1 AND expirymailsent != 1', array(time() + $warn))) {
foreach ($institutions as $institution) {
$institution_displayname = $institution->displayname;
// Email site administrators
foreach ($siteadmins as $user) {
$user_displayname = display_name($user);
_email_or_notify($user, get_string('institutionexpirywarning'), get_string('institutionexpirywarningtext_site', 'mahara', $user_displayname, $institution_displayname, $daystoexpire, $sitename, $sitename), get_string('institutionexpirywarninghtml_site', 'mahara', $user_displayname, $institution_displayname, $daystoexpire, $sitename, $sitename));
}
// Email institutional administrators
$institutionaladmins = get_records_sql_array('SELECT u.id, u.username, u.expiry, u.staff, u.admin AS siteadmin, ui.admin AS institutionadmin, u.firstname, u.lastname, u.email ' . 'FROM {usr_institution} ui JOIN {usr} u ON (ui.usr = u.id) WHERE ui.admin = 1', array());
foreach ($institutionaladmins as $user) {
$user_displayname = display_name($user);
_email_or_notify($user, get_string('institutionexpirywarning'), get_string('institutionexpirywarningtext_institution', 'mahara', $user_displayname, $institution_displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename), get_string('institutionexpirywarninghtml_institution', 'mahara', $user_displayname, $institution_displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename));
}
set_field('institution', 'expirymailsent', 1, 'name', $institution->name);
}
}
// If we can automatically suspend expired institutions
$autosuspend = get_config('institutionautosuspend');
if ($autosuspend) {
// Actual expired institutions
if ($institutions = get_records_sql_array('SELECT name FROM {institution} ' . 'WHERE ' . db_format_tsfield('expiry', false) . ' < ?', array(time()))) {
// Institutions have expired!
foreach ($institutions as $institution) {
set_field('institution', 'suspended', 1, 'name', $institution->name);
}
}
}
}
示例6: login
/**
* Take a username and password and try to authenticate the
* user
*
* @param string $username
* @param string $password
* @return bool
*/
public function login($username, $password)
{
$sql = 'SELECT
*,
' . db_format_tsfield('expiry') . ',
' . db_format_tsfield('lastlogin') . ',
' . db_format_tsfield('lastlastlogin') . ',
' . db_format_tsfield('lastaccess') . ',
' . db_format_tsfield('suspendedctime') . ',
' . db_format_tsfield('ctime') . '
FROM
{usr}
WHERE
LOWER(username) = ?';
if (function_exists('mb_strtolower')) {
$user = get_record_sql($sql, array(mb_strtolower($username, 'UTF-8')));
} else {
$user = get_record_sql($sql, array(strtolower($username)));
}
if ($user == false) {
throw new AuthUnknownUserException("\"{$username}\" is not known");
}
if (isset($user->logintries) && $user->logintries >= MAXLOGINTRIES) {
global $SESSION;
$SESSION->add_error_msg(get_string('toomanytries', 'auth'));
return false;
}
if (is_site_closed($user->admin)) {
return false;
}
// Authentication instances that have parents do so because they cannot
// use Mahara's normal login mechanism - for example, XMLRPC. If the
// user is using one of these authentication instances, we look and try
// to use the parent.
//
// There's no code here that prevents the authinstance being tried if
// it has no parent, mainly because that's an extra database lookup for
// the general case, and the authentication will probably just fail
// anyway. (XMLRPC, for example, leaves implementation of
// authenticate_user_account to the parent Auth class, which says 'not
// authorised' by default).
$instanceid = $user->authinstance;
if ($parentid = get_field('auth_instance_config', 'value', 'field', 'parent', 'instance', $instanceid)) {
$instanceid = $parentid;
}
// Check for a suspended institution
// If a user in more than one institution and one of them is suspended
// make sure their authinstance is not set to the suspended institution
// otherwise they will not be able to login.
$authinstance = get_record_sql('
SELECT i.suspended, i.displayname
FROM {institution} i JOIN {auth_instance} a ON a.institution = i.name
WHERE a.id = ?', array($instanceid));
if ($authinstance->suspended) {
$sitename = get_config('sitename');
throw new AccessTotallyDeniedException(get_string('accesstotallydenied_institutionsuspended', 'mahara', $authinstance->displayname, $sitename));
return false;
}
$auth = AuthFactory::create($instanceid);
// catch the AuthInstanceException that allows authentication plugins to
// fail but pass onto the next possible plugin
try {
if ($auth->authenticate_user_account($user, $password)) {
$this->authenticate($user, $auth->instanceid);
return true;
}
} catch (AuthInstanceException $e) {
return false;
}
// Display a message to users who are only allowed to login via their
// external application.
if ($auth->authloginmsg != '') {
global $SESSION;
$SESSION->add_error_msg(clean_html($auth->authloginmsg), false, 'loginbox');
}
if (empty($user->logintries)) {
$user->logintries = 0;
}
if ($user->logintries < MAXLOGINTRIES) {
$record = get_record('usr', 'id', $user->id, null, null, null, null, 'id, logintries');
$record->logintries = $user->logintries + 1;
update_record('usr', $record, false);
}
return false;
}
示例7: load_user_institutions
function load_user_institutions($userid)
{
if (!is_numeric($userid) || $userid < 0) {
throw new InvalidArgumentException("couldn't load institutions, no user id specified");
}
if ($institutions = get_records_sql_assoc('
SELECT u.institution,' . db_format_tsfield('ctime') . ',' . db_format_tsfield('u.expiry', 'membership_expiry') . ',u.studentid,u.staff,u.admin,i.theme,i.registerallowed
FROM {usr_institution} u INNER JOIN {institution} i ON u.institution = i.name
WHERE u.usr = ?', array($userid))) {
return $institutions;
}
return array();
}
示例8: login
public function login($email)
{
// This will do one of 3 things
// 1 - If a user has an account, log them in
// 2 - If a user doesn't have an account, and there is an auth method (which also has weautocreate), create acc and login
// 3 - If a user doesn't have an account, and there is more than one auth method, show a registration page
$sql = "SELECT\n a.id, i.name AS institutionname\n FROM\n {auth_instance} a\n JOIN\n {institution} i ON a.institution = i.name\n WHERE\n a.authname = 'browserid' AND\n i.suspended = 0";
$authinstances = get_records_sql_array($sql, array());
if (!$authinstances) {
throw new ConfigException(get_string('browseridnotenabled', 'auth.browserid'));
}
$autocreate = array();
// Remember the authinstances that are happy to create users
foreach ($authinstances as $authinstance) {
$auth = AuthFactory::create($authinstance->id);
$institutionjoin = '';
$institutionwhere = '';
$sqlvalues = array($email);
if ($authinstance->institutionname != 'mahara') {
// Make sure that user is in the right institution
$institutionjoin = 'JOIN {usr_institution} ui ON ui.usr = u.id';
$institutionwhere = 'AND ui.institution = ?';
$sqlvalues[] = $authinstance->institutionname;
}
$sql = "SELECT\n u.*,\n " . db_format_tsfield('u.expiry', 'expiry') . ",\n " . db_format_tsfield('u.lastlogin', 'lastlogin') . ",\n " . db_format_tsfield('u.lastlastlogin', 'lastlastlogin') . ",\n " . db_format_tsfield('u.lastaccess', 'lastaccess') . ",\n " . db_format_tsfield('u.suspendedctime', 'suspendedctime') . ",\n " . db_format_tsfield('u.ctime', 'ctime') . "\n FROM\n {usr} u\n JOIN\n {artefact_internal_profile_email} a ON a.owner = u.id\n {$institutionjoin}\n WHERE\n a.verified = 1 AND\n a.email = ?\n {$institutionwhere}";
$user = get_record_sql($sql, $sqlvalues);
if (!$user) {
if ($auth->weautocreateusers) {
if ($authinstance->institutionname == 'mahara') {
array_unshift($autocreate, $auth);
// Try "No Instititution" first when creating users below
} else {
$autocreate[] = $auth;
}
}
continue;
// skip to the next auth_instance
}
if (is_site_closed($user->admin)) {
return false;
}
ensure_user_account_is_active($user);
$this->authenticate($user, $auth->instanceid);
return true;
}
foreach ($autocreate as $auth) {
if (!($user = $auth->create_new_user($email))) {
continue;
}
$this->authenticate($user, $auth->instanceid);
return;
}
// Autocreation failed; try registration.
list($form, $registerconfirm) = auth_generate_registration_form('register', 'browserid', '/register.php');
if (!$form) {
throw new AuthUnknownUserException(get_string('emailnotfound', 'auth.browserid', $email));
}
if (record_exists('usr', 'email', $email) || record_exists('artefact_internal_profile_email', 'email', $email)) {
throw new AuthUnknownUserException(get_string('emailalreadytaken', 'auth.internal', $email));
}
$form['elements']['email'] = array('type' => 'hidden', 'value' => $email);
$form['elements']['authtype'] = array('type' => 'hidden', 'value' => 'browserid');
list($formhtml, $js) = auth_generate_registration_form_js($form, $registerconfirm);
$registerdescription = get_string('registerwelcome');
if ($registerterms = get_config('registerterms')) {
$registerdescription .= ' ' . get_string('registeragreeterms');
}
$registerdescription .= ' ' . get_string('registerprivacy');
$smarty = smarty();
$smarty->assign('register_form', $formhtml);
$smarty->assign('registerdescription', $registerdescription);
if ($registerterms) {
$smarty->assign('termsandconditions', get_site_page_content('termsandconditions'));
}
$smarty->assign('PAGEHEADING', get_string('register', 'auth.browserid'));
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->display('register.tpl');
die;
}
示例9: get_views
/**
* get the views that a user can see belonging
* to the given users
*
* @param array $users users to fetch views owned by
* @param int $userlooking (optional, defaults to logged in user)
* @param int $limit grab this many views. (setting this null means get all)
*
* @return array Associative array keyed by userid, of arrays of view ids
*/
function get_views($users, $userlooking = null, $limit = 5, $type = null)
{
$userlooking = optional_userid($userlooking);
if (is_int($users)) {
$users = array($users);
}
$list = array();
if (count($users) == 0) {
return $list;
}
$users = array_flip($users);
$dbnow = db_format_timestamp(time());
if ($friends = get_records_sql_array('SELECT
CASE WHEN usr1=? THEN usr2 ELSE usr1 END AS id
FROM
{usr_friend} f
WHERE
( usr1=? AND usr2 IN (' . join(',', array_map('db_quote', array_keys($users))) . ') )
OR
( usr2=? AND usr1 IN (' . join(',', array_map('db_quote', array_keys($users))) . ') )
', array($userlooking, $userlooking, $userlooking))) {
foreach ($friends as $user_id) {
$users[$user_id->id] = 'friend';
}
}
if (is_null($type)) {
$typesql = "AND v.type != 'profile'";
} else {
$typesql = 'AND v.type = ' . db_quote($type);
}
$data = array();
$done = false;
// public, logged in, or friends' views
if ($results = get_records_sql_assoc('SELECT
v.*,
' . db_format_tsfield('atime') . ',
' . db_format_tsfield('mtime') . ',
' . db_format_tsfield('v.ctime', 'ctime') . '
FROM
{view} v
INNER JOIN {view_access} a ON
v.id=a.view
AND (
accesstype IN (\'public\',\'loggedin\')
' . (count(preg_grep('/^friend$/', $users)) > 0 ? 'OR (
accesstype = \'friends\'
AND v.owner IN (' . join(',', array_map('db_quote', array_keys(preg_grep('/^friend$/', $users)))) . ')
)' : '') . '
)
WHERE
v.owner IN (' . join(',', array_map('db_quote', array_keys($users))) . ')
AND ( v.startdate IS NULL OR v.startdate < ? )
AND ( v.stopdate IS NULL OR v.stopdate > ? )
' . $typesql, array($dbnow, $dbnow))) {
foreach ($results as $row) {
$list[$row->owner][$row->id] = $row->id;
}
$data = $results;
// bail if we've filled all users to the limit
$done = _get_views_trim_list($list, $users, $limit, $data);
}
// check individual user access
if (!$done && ($results = get_records_sql_assoc('SELECT
v.*,
' . db_format_tsfield('atime') . ',
' . db_format_tsfield('mtime') . ',
' . db_format_tsfield('v.ctime', 'ctime') . '
FROM
{view} v
INNER JOIN {view_access} a ON v.id=a.view AND a.usr=?
WHERE
v.owner IN (' . join(',', array_map('db_quote', array_keys($users))) . ')
AND ( v.startdate IS NULL OR v.startdate < ? )
AND ( v.stopdate IS NULL OR v.stopdate > ? )
' . $typesql, array($userlooking, $dbnow, $dbnow)))) {
foreach ($results as &$row) {
$list[$row->owner][$row->id] = $row->id;
}
$data = array_merge($data, $results);
// bail if we've filled all users to the limit
$done = $done && _get_views_trim_list($list, $users, $limit, $data);
}
// check group access
if (!$done && ($results = get_records_sql_assoc('SELECT
v.*,
' . db_format_tsfield('v.atime', 'atime') . ',
' . db_format_tsfield('v.mtime', 'mtime') . ',
' . db_format_tsfield('v.ctime', 'ctime') . '
FROM
{view} v
//.........这里部分代码省略.........
示例10: get_activities
/**
* This function returns a list of the current cpds activities.
*
* @param limit how many activities to display per page
* @param offset current page to display
* @return array (grandtotalhours: number, count: integer, data: array)
*
*/
public static function get_activities($cpd, $offset = 0, $limit = 10)
{
($results = get_records_sql_array("\n SELECT a.id, at.artefact AS activity, at.location, at.hours, " . db_format_tsfield('startdate') . ", " . db_format_tsfield('enddate') . ",\n a.title, a.description, a.parent\n FROM {artefact} a\n JOIN {artefact_cpds_activity} at ON at.artefact = a.id\n WHERE a.artefacttype = 'activity' AND a.parent = ?\n ORDER BY at.startdate DESC", array($cpd), $offset, $limit)) || ($results = array());
// format the date and calculate grand total of hours spent
$grandtotalhours = 0;
if (!empty($results)) {
foreach ($results as $result) {
$grandtotalhours = $grandtotalhours + $result->hours;
if (!empty($result->startdate)) {
$result->startdate = strftime(get_string('strftimedate'), $result->startdate);
if (!empty($result->enddate)) {
$result->enddate = strftime(get_string('strftimedate'), $result->enddate);
}
}
}
}
$result = array('grandtotalhours' => $grandtotalhours, 'count' => count_records('artefact', 'artefacttype', 'activity', 'parent', $cpd), 'data' => $results, 'offset' => $offset, 'limit' => $limit, 'id' => $cpd);
return $result;
}
示例11: define
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'internal');
define('SECTION_PAGE', 'validate');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'pieforms/pieform.php';
safe_require('artefact', 'internal');
define('TITLE', get_string('emailactivation', 'artefact.internal'));
$email = param_variable('email');
$key = param_variable('key');
$decline = param_boolean('decline');
$row = get_record('artefact_internal_profile_email', 'email', $email, 'key', $key, null, null, 'owner,artefact,email,verified,' . db_format_tsfield('expiry'));
if ($row) {
if ($decline) {
delete_records_select('artefact_internal_profile_email', 'verified=0 AND key=? AND email=?', array($key, $email));
$SESSION->add_ok_msg(get_string('emailactivationdeclined', 'artefact.internal'));
redirect(get_config('wwwroot'));
}
if ($row->expiry > time()) {
if ($row->artefact) {
$artefact = new ArtefactTypeEmail($row->artefact);
} else {
$artefact = new ArtefactTypeEmail();
}
$artefact->set('owner', $row->owner);
$artefact->set('title', $row->email);
$artefact->commit();
示例12: safe_require
safe_require('interaction', 'forum');
require_once 'group.php';
require_once get_config('docroot') . 'interaction/lib.php';
require_once 'pieforms/pieform.php';
require_once 'antispam.php';
require_once 'embeddedimage.php';
$userid = $USER->get('id');
$topicid = param_integer('id', 0);
$returnto = param_alpha('returnto', 'topic');
if ($topicid == 0) {
// new topic
unset($topicid);
$forumid = param_integer('forum');
} else {
// edit topic
$topic = get_record_sql('SELECT p.subject, p.id AS postid, p.body, p.poster, p.topic AS id, ' . db_format_tsfield('p.ctime', 'ctime') . ', t.sticky, t.closed, f.id AS forum
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t ON (p.topic = t.id AND t.deleted != 1)
INNER JOIN {interaction_instance} f ON (f.id = t.forum AND f.deleted != 1)
WHERE p.parent IS NULL
AND p.topic = ?', array($topicid));
$forumid = $topic->forum;
if (!$topic) {
throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid));
}
}
$forum = get_record_sql('SELECT f.group AS groupid, f.title, g.name AS groupname, g.grouptype
FROM {interaction_instance} f
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = 0)
WHERE f.id = ?
AND f.deleted != 1', array($forumid));
示例13: import_process_queue
/**
* cron job to process the queue and wake up and finish imports
*/
function import_process_queue()
{
if (!($ready = get_records_select_array('import_queue', 'ready = ? OR expirytime < ?', array(1, db_format_timestamp(time())), '', '*,' . db_format_tsfield('expirytime', 'ex')))) {
return true;
}
$now = time();
$processed = array();
foreach ($ready as $item) {
if ($item->ex < $now) {
log_debug('deleting expired import record', $item);
$processed[] = $item->id;
continue;
}
$tr = null;
if (!empty($item->host)) {
$tr = new MnetImporterTransport($item);
} else {
$tr = new LocalImporterTransport($item);
}
$importer = PluginImport::create_importer($item->id, $tr, $item);
try {
$importer->prepare();
$importer->process();
$importer->cleanup();
$processed[] = $item->id;
} catch (Exception $e) {
log_debug('an error occurred on import: ' . $e->getMessage());
$importer->get('importertransport')->cleanup();
}
}
if (empty($processed)) {
return true;
}
delete_records_select('import_queue', 'id IN ( ' . implode(',', db_array_to_ph($processed)) . ')', $processed);
}
示例14: set_composites
public function set_composites()
{
$this->composites = get_records_sql_array('SELECT ' . db_format_tsfield('a.mtime', 'mtime') . ', b.* FROM {artefact} a JOIN {' . $this->artefact->get_other_table_name() . '} b
ON a.id = b.artefact
WHERE b.artefact = ?', array($this->artefact->get('id')));
}
示例15: mobile_api_json_reply
mobile_api_json_reply(array('fail' => get_string('mobileuploadusernamenotset', 'auth')));
}
$USER = new User();
try {
$USER->find_by_mobileuploadtoken($token, $username);
} catch (AuthUnknownUserException $e) {
mobile_api_json_reply(array('fail' => get_string('mobileuploadtokennotfound', 'auth')));
}
// Add in bits of sync data - let's start with notifications
$lastsync = param_integer('lastsync', 0);
$notification_types_sql = '';
$notification_types = explode(",", trim(param_variable('notifications', '')));
if (count($notification_types) > 0) {
$notification_types_sql = ' a.name IN (' . join(',', array_map('db_quote', $notification_types)) . ')';
}
$activity_arr = get_records_sql_array("\n SELECT n.id, n.subject, n.message\n FROM {notification_internal_activity} n\n INNER JOIN {activity_type} a ON n.type=a.id\n WHERE {$notification_types_sql}\n AND n.read=0\n AND " . db_format_tsfield('ctime', '') . " >= ?\n AND n.usr= ? ", array($lastsync, $USER->id));
if (count($activity_arr) > 0) {
$json['activity'] = $activity_arr;
}
// OK - let's add tags
$tags_arr = array();
$tagsort = param_alpha('ts', null) != 'freq' ? 'alpha' : 'freq';
foreach (get_my_tags(null, false, $tagsort) as $tag) {
$tags_arr[] = array("id" => $tag->tag, "tag" => $tag->tag);
}
if (count($tags_arr) > 0) {
$json['tags'] = $tags_arr;
}
// OK - let's add journals (and journal posts)
$blogs_arr = array();
$blogs = (object) array('offset' => param_integer('offset', 0), 'limit' => param_integer('limit', 10));