本文整理汇总了PHP中get_records_sql_array函数的典型用法代码示例。如果您正苦于以下问题:PHP get_records_sql_array函数的具体用法?PHP get_records_sql_array怎么用?PHP get_records_sql_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_records_sql_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
$userid = $instance->get_view()->get('owner');
if (!$userid) {
// 'My Friends' doesn't make sense for group/site views
return '';
}
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?
ORDER BY ' . db_random() . '
LIMIT ?', array($userid, $userid, MAXFRIENDDISPLAY));
// get the friends into a 4x4 array
if ($records) {
$friends = array();
for ($i = 0; $i < 4; $i++) {
if (isset($records[4 * $i])) {
$friends[$i] = array();
for ($j = 4 * $i; $j < ($i + 1) * 4; $j++) {
if (isset($records[$j])) {
if ($records[$j]->usr1 == $userid) {
$friends[$i][] = $records[$j]->usr2;
} else {
$friends[$i][] = $records[$j]->usr1;
}
}
}
}
}
} else {
$friends = false;
}
$smarty->assign('friends', $friends);
// If the user has no friends, try and display something useful, such
// as a 'request friendship' button
$loggedinid = $USER->get('id');
$is_friend = is_friend($userid, $loggedinid);
if ($is_friend) {
$relationship = 'existingfriend';
} else {
if (record_exists('usr_friend_request', 'requester', $loggedinid, 'owner', $userid)) {
$relationship = 'requestedfriendship';
} else {
$relationship = 'none';
$friendscontrol = get_account_preference($userid, 'friendscontrol');
if ($friendscontrol == 'auto') {
$newfriendform = pieform(array('name' => 'myfriends_addfriend', 'successcallback' => 'addfriend_submit', 'autofocus' => false, 'renderer' => 'div', 'elements' => array('add' => array('type' => 'submit', 'value' => get_string('addtomyfriends', 'group')), 'id' => array('type' => 'hidden', 'value' => $userid))));
$smarty->assign('newfriendform', $newfriendform);
}
$smarty->assign('friendscontrol', $friendscontrol);
}
}
$smarty->assign('relationship', $relationship);
$smarty->assign_by_ref('USER', $USER);
$smarty->assign('USERID', $userid);
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:60,代码来源:lib.php
示例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;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:27,代码来源:lib.php
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$smarty = smarty_core();
$filter = param_alpha('filter', 'all');
$offset = param_integer('offset', 0);
$limit = 1000;
//get list online friend
$result_friend_online_id = get_onlinefriends($limit, $offset);
$str_eselma_online = implode(',', $result_friend_online_id['data']);
if ($str_eselma_online) {
$query_result_friend_online = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_online})\n ";
$result_friend_online = get_records_sql_array($query_result_friend_online);
}
//get list offline friend
$result_friend_offline_id = get_offlinefriends($limit, $offset);
$str_eselma_offline = implode(',', $result_friend_offline_id['data']);
if ($str_eselma_offline) {
$query_result_friend_offline = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_offline})\n ";
$result_friend_offline = get_records_sql_array($query_result_friend_offline);
}
$smarty->assign('eselma_get_online', $result_friend_online);
$smarty->assign('eselma_get_offline', $result_friend_offline);
$smarty->assign('lastminutes', floor(get_config('accessidletimeout') / 60));
$smarty->assign('eselma_count_online', $result_friend_online_id['count']);
$smarty->assign('eselma_count_offline', $result_friend_offline_id['count']);
return $smarty->fetch('blocktype:eselmaonoff:content.tpl');
}
开发者ID:vohung96,项目名称:mahara,代码行数:28,代码来源:lib.php
示例4: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
safe_require('artefact', 'survey');
//require_once(dirname(dirname(dirname(__FILE__))) . '/dwoo/function.survey_name.php');
$configdata = $instance->get('configdata');
// this will make sure to unserialize it for us
$survey = isset($configdata['survey']) ? $configdata['survey'] : '';
$userid = isset($configdata['userid']) ? $configdata['userid'] : '';
//$showresponses = (isset($configdata['showresponses']) ? $configdata['showresponses'] : false);
//$showresults = (isset($configdata['showresults']) ? $configdata['showresults'] : true);
$showchart = isset($configdata['showchart']) ? $configdata['showchart'] : true;
$palette = isset($configdata['palette']) ? $configdata['palette'] : 'default';
$legend = isset($configdata['legend']) ? $configdata['legend'] : 'key';
$fonttype = isset($configdata['fonttype']) ? $configdata['fonttype'] : 'sans';
$fontsize = isset($configdata['fontsize']) ? $configdata['fontsize'] : 10;
$height = isset($configdata['height']) ? $configdata['height'] : 250;
$width = isset($configdata['width']) ? $configdata['width'] : 400;
$artefactids = get_records_sql_array("SELECT\ta.id\n\t\t\tFROM {artefact} a\n\t\t\tWHERE a.artefacttype = 'survey' AND a.title = ? AND a.owner = ?\n\t\t\tORDER BY a.ctime DESC, a.mtime DESC", array($survey, $userid));
$data = array();
$first = true;
foreach ($artefactids as $artefactid) {
if ($first) {
$alpha = 30;
} else {
$alpha = 10;
}
$data[] = array('id' => $artefactid->id, 'palette' => $palette, 'legend' => $legend, 'fonttype' => $fonttype, 'fontsize' => $fontsize, 'height' => $height, 'width' => $width, 'alpha' => $alpha);
$first = false;
}
$smarty = smarty_core();
//$smarty->addPlugin('survey_name', 'Dwoo_Plugin_survey_name');
$smarty->assign('CHART', $showchart ? true : false);
$smarty->assign('data', $data);
return $smarty->fetch('blocktype:surveyhistory:surveyhistory.tpl');
}
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:35,代码来源:lib.php
示例5: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$type = isset($configdata['displaytype']) ? $configdata['displaytype'] : 'texticon';
$showicon = $type == 'icononly' || $type == 'texticon' ? true : false;
$showtext = $type == 'textonly' || $type == 'texticon' ? true : false;
$owner = $instance->get('view_obj')->get('owner');
// Whether to include email button
if (isset($configdata['displayemail']) && $configdata['displayemail']) {
$email = get_field('artefact_internal_profile_email', 'email', 'principal', 1, 'owner', $owner);
} else {
$email = false;
}
if (!isset($configdata['artefactids']) || empty($configdata['artefactids'])) {
// When we first come into this block, it will have
// no social profiles configured yet.
$configdata['artefactids'] = array(0);
}
// Include selected social profiles
$sql = 'SELECT title, description, note FROM {artefact}
WHERE id IN (' . join(',', $configdata['artefactids']) . ')
AND owner = ? AND artefacttype = ?
ORDER BY description ASC';
if (!($data = get_records_sql_array($sql, array($owner, 'socialprofile')))) {
$data = array();
}
safe_require('artefact', 'internal');
$data = ArtefactTypeSocialprofile::get_profile_icons($data);
$smarty = smarty_core();
$smarty->assign('showicon', $showicon);
$smarty->assign('showtext', $showtext);
$smarty->assign('profiles', $data);
$smarty->assign('email', $email);
return $smarty->fetch('blocktype:socialprofile:content.tpl');
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:35,代码来源:lib.php
示例6: xmldb_blocktype_externalvideo_upgrade
function xmldb_blocktype_externalvideo_upgrade($oldversion = 0)
{
if ($oldversion < 2014030500) {
$urlpattern = '#\\b(https?://)prezi\\.com/bin/preziloader\\.swf\\?prezi_id=([a-z0-9]+)\\b#';
$matches = array();
$sql = "SELECT id, configdata FROM {block_instance} WHERE blocktype='externalvideo'";
$records = get_records_sql_array($sql, array());
if ($records) {
foreach ($records as $r) {
$configdata = unserialize($r->configdata);
if (isset($configdata['html'])) {
preg_match($urlpattern, $configdata['html'], $matches);
} else {
if (isset($configdata['videoid'])) {
preg_match($urlpattern, $configdata['videoid'], $matches);
}
}
if (count($matches) >= 3) {
$newurl = $matches[1] . 'prezi.com/embed/' . $matches[2];
$width = !empty($configdata['width']) ? $configdata['width'] : 0;
$height = !empty($configdata['height']) ? $configdata['height'] : 0;
$configdata['html'] = $configdata['videoid'] = PluginBlocktypeExternalvideo::iframe_code($newurl, $width, $height);
set_field('block_instance', 'configdata', serialize($configdata), 'id', $r->id);
}
}
}
ensure_record_exists('iframe_source_icon', (object) array('name' => 'Prezi', 'domain' => 'prezi.com'), (object) array('name' => 'Prezi', 'domain' => 'prezi.com'));
ensure_record_exists('iframe_source', (object) array('prefix' => 'prezi.com/embed/', 'name' => 'Prezi'), (object) array('prefix' => 'prezi.com/embed/', 'name' => 'Prezi'));
update_safe_iframe_regex();
}
return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:32,代码来源:upgrade.php
示例7: mahara_group_get_groups
function mahara_group_get_groups($client)
{
$function = 'mahara_group_get_groups';
$dbgroups = get_records_sql_array('SELECT * FROM {group} WHERE institution = ? AND shortname = ? AND deleted = 0', array('mahara', 'mytestgroup1'));
$params = array();
$groups = $client->call($function, $params);
$this->assertEquals(count($groups), count($groups));
}
开发者ID:rboyatt,项目名称:mahara,代码行数:8,代码来源:WebServiceGroupTest.php
示例8: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER, $THEME;
$configdata = $instance->get('configdata');
$desiredtypes = array();
foreach ($configdata as $k => $v) {
if (!empty($v) && $k != 'maxitems') {
$type = preg_replace('/[^a-z]+/', '', $k);
$desiredtypes[$type] = $type;
}
}
if ($USER->get('admin') && !empty($desiredtypes['adminmessages'])) {
unset($desiredtypes['adminmessages']);
$desiredtypes += get_column('activity_type', 'name', 'admin', 1);
}
$maxitems = isset($configdata['maxitems']) ? $configdata['maxitems'] : 5;
// check if multirecipientnotification plugin is active or if we proceed here
if (record_exists('module_installed', 'name', 'multirecipientnotification', 'active', '1') && safe_require_plugin('module', 'multirecipientnotification')) {
global $USER;
$userid = $USER->get('id');
$activitylist = activityblocklistin(join(',', $desiredtypes), $maxitems);
$records = $activitylist->records;
$showmore = $activitylist->count > $maxitems;
// use a different template
$smartytemplate = 'blocktype:inbox:inboxmr.tpl';
} else {
$records = array();
if ($desiredtypes) {
$sql = "\n SELECT n.id, n.subject, n.message, n.url, n.urltext, n.read, t.name AS type\n FROM {notification_internal_activity} n JOIN {activity_type} t ON n.type = t.id\n WHERE n.usr = ?\n AND t.name IN (" . join(',', array_map('db_quote', $desiredtypes)) . ")\n ORDER BY n.ctime DESC\n LIMIT ?;";
$records = get_records_sql_array($sql, array($USER->get('id'), $maxitems + 1));
}
// Hack to decide whether to show the More... link
if ($showmore = count($records) > $maxitems) {
unset($records[$maxitems]);
}
if ($records) {
foreach ($records as &$r) {
$r->message = format_notification_whitespace($r->message, $r->type);
}
}
$smartytemplate = 'blocktype:inbox:inbox.tpl';
}
if ($records) {
require_once 'activity.php';
foreach ($records as &$r) {
$section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
$r->strtype = get_string('type' . $r->type, $section);
}
}
$smarty = smarty_core();
if ($showmore) {
$smarty->assign('morelink', self::get_link($instance) . '?type=' . implode(',', $desiredtypes));
}
$smarty->assign('blockid', 'blockinstance_' . $instance->get('id'));
$smarty->assign('items', $records);
return $smarty->fetch($smartytemplate);
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:57,代码来源:lib.php
示例9: view_access_records
/**
* Get all view access records relevant at the data of the indexing
*/
public static function view_access_records($viewid)
{
$records = get_records_sql_array('
SELECT va.view AS view_id, va.accesstype, va.group, va.role, va.usr, va.institution
FROM {view_access} va
WHERE va.view = ?
AND (startdate IS NULL OR startdate < current_timestamp)
AND (stopdate IS NULL OR stopdate > current_timestamp)', array($viewid));
return $records;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:13,代码来源:ElasticsearchType_view.php
示例10: search_functions
function search_functions($request, $limit, $offset)
{
$data = array('count' => 0, 'data' => false);
$sql = "SELECT * FROM {external_functions} WHERE name LIKE ?";
$values = array('%' . $request . '%');
if ($results = get_records_sql_array($sql, $values, $offset, $limit)) {
$data['count'] = sizeof(get_records_sql_array($sql, $values));
$data['data'] = (array) $results;
}
return $data;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:11,代码来源:functions.json.php
示例11: collection_access_records
/**
* Get all view access records relevant at the data of the indexing
*/
public static function collection_access_records($id)
{
$records = get_records_sql_array('
SELECT vac.view AS view_id, vac.accesstype, vac.group, vac.role, vac.usr, vac.institution
FROM {view_access} vac
INNER JOIN {collection_view} vcol ON vac.view = vcol.view
WHERE vcol.collection = ?
AND (vac.startdate IS NULL OR vac.startdate < current_timestamp)
AND (vac.stopdate IS NULL OR vac.stopdate > current_timestamp)', array($id));
return $records;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:14,代码来源:ElasticsearchType_collection.php
示例12: xmldb_interaction_forum_upgrade
function xmldb_interaction_forum_upgrade($oldversion = 0)
{
if ($oldversion < 2009062300) {
foreach (array('topic', 'forum') as $type) {
log_debug("Subscription upgrade for {$type}s");
// Add missing primary key to the subscription tables
// Step 1: remove duplicates
if ($dupes = get_records_sql_array('
SELECT "user", ' . $type . ', COUNT(*)
FROM {interaction_forum_subscription_' . $type . '}
GROUP BY "user", ' . $type . '
HAVING COUNT(*) > 1', array())) {
// We found duplicate subscriptions to a topic/forum
foreach ($dupes as $dupe) {
log_debug("interaction.forum: Removing duplicate {$type} subscription for {$dupe->user}");
delete_records('interaction_forum_subscription_' . $type, 'user', $dupe->user, $type, $dupe->{$type});
insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type}));
}
}
// Step 2: add the actual key
$table = new XMLDBTable('interaction_forum_subscription_' . $type);
$key = new XMLDBKey('primary');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type));
add_key($table, $key);
// Add a 'key' column, used for unsubscriptions
$field = new XMLDBField('key');
$field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null);
add_field($table, $field);
$key = new XMLDBKey('keyuk');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('key'));
add_key($table, $key);
// Populate the key column
if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) {
foreach ($records as $where) {
$new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand()));
update_record('interaction_forum_subscription_' . $type, $new, $where);
}
}
// Now make the key column not null
$field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL);
change_field_notnull($table, $field);
}
}
if ($oldversion < 2009081700) {
if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
}
}
if ($oldversion < 2009081800) {
$subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum');
ensure_record_exists('interaction_event_subscription', $subscription, $subscription);
}
return true;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:54,代码来源:upgrade.php
示例13: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
$smarty = smarty_core();
// Get viewable views
$views = array();
if ($allviews = get_records_select_array('view', "\"owner\" = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
foreach ($allviews as $view) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
$view->artefacts = array();
}
}
}
if ($views) {
$viewidlist = implode(', ', array_map(create_function('$a', 'return (int)$a->id;'), $views));
$artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN (' . $viewidlist . ')
GROUP BY 1, 2, 3, 4, 5
ORDER BY a.title, va.artefact', '');
if ($artefacts) {
foreach ($artefacts as $artefactrec) {
safe_require('artefact', $artefactrec->plugin);
// Perhaps I shouldn't have to construct the entire
// artefact object to render the name properly.
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
if (!$artefactobj->in_view_list()) {
continue;
}
$artname = $artefactobj->display_title(30);
if (strlen($artname)) {
$views[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
}
}
}
$tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
if ($tags) {
foreach ($tags as &$tag) {
$views[$tag->view]->tags[] = $tag->tag;
}
}
}
$smarty->assign('VIEWS', $views);
return $smarty->fetch('blocktype:myviews:myviews.tpl');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:53,代码来源:lib.php
示例14: delete_all_notifications_submit
function delete_all_notifications_submit()
{
global $USER, $SESSION;
$userid = $USER->get('id');
$type = param_variable('type', 'all');
$typesql = '';
if ($type != 'all') {
// Treat as comma-separated list of activity type names
$types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) {
$typesql = '(' . $typesql . ' OR at.admin = 1)';
}
$typesql = ' AND ' . $typesql;
}
}
$from = "\n FROM {notification_internal_activity} a\n JOIN {activity_type} at ON a.type = at.id\n WHERE a.usr = ? {$typesql}";
$values = array($userid);
db_begin();
$count = 0;
$records = get_records_sql_array('SELECT a.id ' . $from, $values);
if ($records) {
$count = sizeof($records);
$ids = array();
foreach ($records as $row) {
$ids[] = $row->id;
}
// Remove parent pointers to messages we're about to delete
execute_sql('
UPDATE {notification_internal_activity}
SET parent = NULL
WHERE parent IN (
' . join(',', array_map('db_quote', $ids)) . '
)');
// delete
execute_sql('
DELETE FROM {notification_internal_activity}
WHERE id IN (
' . join(',', array_map('db_quote', $ids)) . '
)');
// The update_unread_delete db trigger on notification_internal_activity
// will update the unread column on the usr table.
}
db_commit();
$SESSION->add_ok_msg(get_string('deletednotifications1', 'activity', $count));
safe_require('module', 'multirecipientnotification');
if (PluginModuleMultirecipientnotification::is_active()) {
redirect(get_config('wwwroot') . 'module/multirecipientnotification/inbox.php?type=' . $type);
} else {
redirect(get_config('wwwroot') . 'account/activity/index.php?type=' . $type);
}
}
开发者ID:patkira,项目名称:mahara,代码行数:53,代码来源:index.php
示例15: xmldb_blocktype_textbox_upgrade
function xmldb_blocktype_textbox_upgrade($oldversion = 0)
{
if ($oldversion < 2011082200) {
// Convert all textbox html content to artefacts
$tbcount = count_records('block_instance', 'blocktype', 'textbox');
$sql = '
SELECT b.id, b.title, b.configdata, b.view,
v.owner, v.group, v.institution, v.ctime, v.mtime, v.atime
FROM {block_instance} b JOIN {view} v ON b.view = v.id
WHERE b.id > ? AND b.blocktype = ?
ORDER BY b.id';
$done = 0;
$lastid = 0;
if (is_mysql()) {
$mp = mysql_get_variable('max_allowed_packet');
$limit = $mp && is_numeric($mp) && $mp > 1048576 ? $mp / 8192 : 100;
} else {
$limit = 5000;
}
while ($records = get_records_sql_array($sql, array($lastid, 'textbox'), 0, $limit)) {
// Create the new artefacts
$values = array();
foreach ($records as $r) {
$configdata = unserialize($r->configdata);
array_push($values, 'html', $r->ctime, $r->mtime, $r->atime, $r->title, isset($configdata['text']) ? $configdata['text'] : '', $r->owner, $r->group, $r->institution, $r->owner > 0 ? $r->owner : null, $r->owner > 0 ? null : '?', $r->id);
// Dumping the block id in the note column makes it easier to update block_instance later
}
$insertsql = "\n INSERT INTO {artefact}\n (artefacttype, ctime, mtime, atime, title, description, owner, \"group\", institution, author, authorname, note)\n VALUES ";
$insertsql .= join(',', array_fill(0, count($records), '(?,?,?,?,?,?,?,?,?,?,?,?)'));
execute_sql($insertsql, $values);
// Update block_instance configdata to point at the new artefacts
if (is_postgres()) {
execute_sql("\n UPDATE {block_instance}\n SET configdata = 'a:1:{s:10:\"artefactid\";i:' || a.id::text || ';}'\n FROM (\n SELECT id, note FROM {artefact} WHERE artefacttype = 'html' AND note IS NOT NULL\n ) a\n WHERE blocktype = 'textbox' AND {block_instance}.id::text = a.note");
// Update view_artefact table
execute_sql("\n INSERT INTO {view_artefact} (view, block, artefact)\n SELECT b.view, b.id, a.id\n FROM {block_instance} b, {artefact} a\n WHERE b.blocktype = 'textbox' AND a.artefacttype = 'html' AND a.note IS NOT NULL AND CAST(b.id AS TEXT) = a.note", array());
} else {
if (is_mysql()) {
execute_sql("\n UPDATE {block_instance}, {artefact}\n SET {block_instance}.configdata = CONCAT('a:1:{s:10:\"artefactid\";i:', {artefact}.id, ';}')\n WHERE\n {artefact}.artefacttype = 'html'\n AND {artefact}.note IS NOT NULL\n AND {block_instance}.blocktype = 'textbox'\n AND {block_instance}.id = {artefact}.note");
// Update view_artefact table
execute_sql("\n INSERT INTO {view_artefact} (view, block, artefact)\n SELECT b.view, b.id, a.id\n FROM {block_instance} b, {artefact} a\n WHERE b.blocktype = 'textbox' AND a.artefacttype = 'html' AND a.note IS NOT NULL AND b.id = a.note", array());
}
}
// Remove the dodgy block id in the note column
execute_sql("UPDATE {artefact} SET note = NULL WHERE artefacttype = 'html' AND note IS NOT NULL");
$done += count($records);
log_debug("Upgrading textbox blocks: {$done}/{$tbcount}");
$last = end($records);
$lastid = $last->id;
}
}
return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:52,代码来源:upgrade.php
示例16: setup_links
public static function setup_links(&$links, $viewids, $artefactids)
{
$viewlist = join(',', array_map('intval', $viewids));
$artefactlist = join(',', array_map('intval', $artefactids));
// Get the annotations that are on these views.
$records = get_records_select_array('artefact_annotation', "view IN ({$viewlist})", array(), '', 'annotation,view');
if ($records) {
foreach ($records as &$r) {
// view is reflected_on_by annotation (at the current moment).
if (!isset($links->viewartefact[$r->view][$r->annotation])) {
$links->viewartefact[$r->view][$r->annotation] = array();
}
$links->viewartefact[$r->view][$r->annotation][] = 'reflected_on_by';
// annotation reflects_on view (at the current moment).
if (!isset($links->artefactview[$r->annotation][$r->view])) {
$links->artefactview[$r->annotation][$r->view] = array();
}
$links->artefactview[$r->annotation][$r->view][] = 'reflects_on';
// Get the embedded images in the annotation.
$sql = "SELECT fileid\n FROM {artefact_file_embedded}\n WHERE resourceid = ?";
if ($files = get_records_sql_array($sql, array($r->annotation))) {
foreach ($files as $file) {
$links->attachments[$r->annotation][$file->fileid] = 1;
}
}
// Get the feedback on the annotation.
$sql = "SELECT f.artefact as feedback\n FROM {artefact_annotation_feedback} f\n WHERE f.onannotation = ?\n AND f.deletedby IS NULL\n ORDER BY f.artefact DESC";
if ($annotationfeedback = get_records_sql_array($sql, array($r->annotation))) {
foreach ($annotationfeedback as $f) {
// feedback reflects_on annotation.
if (!isset($links->artefactartefact[$f->feedback][$r->annotation])) {
$links->artefactartefact[$f->feedback][$r->annotation] = array();
}
$links->artefactartefact[$f->feedback][$r->annotation][] = 'reflects_on';
// annotation is reflected_on_by feedback.
if (!isset($links->artefactartefact[$r->annotation][$f->feedback])) {
$links->artefactartefact[$r->annotation][$f->feedback] = array();
}
$links->artefactartefact[$r->annotation][$f->feedback][] = 'reflected_on_by';
// Get the embedded images in the annotation feedback.
$sql = "SELECT *\n FROM {artefact_file_embedded}\n WHERE resourceid = ?";
if ($files = get_records_sql_array($sql, array($f->feedback))) {
foreach ($files as $file) {
$links->attachments[$f->feedback][$file->fileid] = 1;
}
}
}
}
}
}
}
开发者ID:rboyatt,项目名称:mahara,代码行数:51,代码来源:lib.php
示例17: 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;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:48,代码来源:lib.php
示例18: get_accessible_surveys
function get_accessible_surveys()
{
// Get names of all the survey responses (from other users) that are accessible to our user...
global $USER;
$results = get_records_sql_array("SELECT\ta.title\n\t\tFROM {artefact} a\n\t\tLEFT JOIN {artefact_access_usr} aau ON (aau.artefact = a.id)\n\t\tWHERE aau.usr = ?", array($USER->get('id')));
// Prepare our accessible surveys array so we can use it as options in drop-down select box...
$survey_types = array('empty' => get_string('selectsurvey', 'artefact.survey'));
if ($results) {
// There can be (and often will be) duplicates of survey names:
// two/more users can complete the same survey, but the responses will appear as different artefacts.
//
// We use/simulate mathematical concept of Set, which can contain only one instance of the same thing (survey in our case).
//
// We achieve that by checking if the current survey name is already contained in our accessible surveys array.
// If not, we add the name of taht survey to our accessible surveys array
$accessible_surveys = array();
foreach ($results as $result) {
if (!in_array($result->title, $accessible_surveys)) {
$accessible_surveys[] = $result->title;
}
}
foreach ($accessible_surveys as $filename) {
$LANGUAGE = ArtefactTypeSurvey::get_default_lang($filename);
$xmlDoc = new DOMDocument('1.0', 'UTF-8');
$ch = curl_init(get_config('wwwroot') . 'artefact/survey/surveys/' . $filename);
# Return http response in string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$loaded = $xmlDoc->loadXML(curl_exec($ch));
if ($loaded) {
$surveyname = $xmlDoc->getElementsByTagName('survey')->item(0)->getAttribute('name');
if (isset($surveyname) && $surveyname == substr($filename, 0, -4)) {
$title = $xmlDoc->getElementsByTagName('title')->item(0)->getAttribute($LANGUAGE);
$survey_types = array_merge($survey_types, array($filename => $title));
} else {
$message = get_string('surveynameerror', 'artefact.survey', $filename);
$_SESSION['messages'][] = array('type' => 'error', 'msg' => $message);
}
} else {
$message = get_string('surveyerror', 'artefact.survey', $filename);
$_SESSION['messages'][] = array('type' => 'error', 'msg' => $message);
}
}
}
return $survey_types;
}
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:45,代码来源:index.php
示例19: search_user
/**
* Given a query string and limits, return an array of matching users using the
* search plugin defined in config.php
*
* @param string The query string
* @param integer How many results to return
* @param integer What result to start at (0 == first result)
* @return array A data structure containing results looking like ...
* $results = array(
* count => integer, // total number of results
* limit => integer, // how many results are returned
* offset => integer, // starting from which result
* results => array( // the result records
* array(
* id => integer,
* username => string,
* institution => string,
* firstname => string,
* lastname => string,
*
|
请发表评论