本文整理汇总了PHP中get_column_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_column_sql函数的具体用法?PHP get_column_sql怎么用?PHP get_column_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_column_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dump_export_data
public function dump_export_data()
{
if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS && $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) {
// Dont' care about profile information in this case
return;
}
$smarty = $this->exporter->get_smarty('../../', 'internal');
$smarty->assign('page_heading', get_string('profilepage', 'artefact.internal'));
// Profile page
$profileviewid = $this->exporter->get('user')->get_profile_view()->get('id');
foreach ($this->exporter->get('views') as $viewid => $view) {
if ($profileviewid == $viewid) {
$smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html')));
$view = $this->exporter->get('user')->get_profile_view();
$outputfilter = new HtmlExportOutputFilter('../../');
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html/internal:profilepage.tpl');
if (!file_put_contents($this->fileroot . 'profilepage.html', $content)) {
throw new SystemException("Unable to write profile page");
}
$this->profileviewexported = true;
break;
}
}
// Generic profile information
$smarty->assign('page_heading', get_string('profileinformation', 'artefact.internal'));
$smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html')));
// Organise profile information by sections, ordered how it's ordered
// on the 'edit profile' page
$sections = array('aboutme' => array(), 'contact' => array(), 'messaging' => array(), 'general' => array());
$elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields');
$elementlistlookup = array_flip(array_keys($elementlist));
$profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN (' . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($elementlist))) . ")", array($this->exporter->get('user')->get('id')));
foreach ($profilefields as $id) {
$artefact = artefact_instance_from_id($id);
$rendered = $artefact->render_self(array('link' => true));
if ($artefact->get('artefacttype') == 'introduction') {
$outputfilter = new HtmlExportOutputFilter('../../');
$rendered['html'] = $outputfilter->filter($rendered['html']);
}
$sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array('html' => $rendered['html'], 'weight' => $elementlistlookup[$artefact->get('artefacttype')]);
}
// Sort the data and then drop the weighting information
foreach ($sections as &$section) {
uasort($section, create_function('$a, $b', 'return $a["weight"] > $b["weight"];'));
foreach ($section as &$data) {
$data = $data['html'];
}
}
$smarty->assign('sections', $sections);
$iconid = $this->exporter->get('user')->get('profileicon');
if ($iconid) {
$icon = artefact_instance_from_id($iconid);
$smarty->assign('icon', '<img src="../../static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Icon">');
}
$content = $smarty->fetch('export:html/internal:index.tpl');
if (!file_put_contents($this->fileroot . 'index.html', $content)) {
throw new SystemException("Unable to write profile information page");
}
}
示例2: 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);
}
示例3: find_matching_blocks
/**
* Given a list of tags, finds blocks by the current user that contain those tags
* (Used to determine which ones to check for the view_artefact table)
* @param array $tags
* @return array
*/
public static function find_matching_blocks(array $tags)
{
global $USER;
$taggedblockids = (array) get_column_sql('SELECT bi.id as block
FROM
{blocktype_taggedposts_tags} btt
INNER JOIN {block_instance} bi
ON btt.block_instance = bi.id
INNER JOIN {view} v
ON bi.view = v.id
WHERE
v.owner = ?
AND btt.tagtype = ?
AND btt.tag IN (' . implode(',', db_array_to_ph($tags)) . ')
', array_merge(array($USER->id, PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE), $tags));
if ($taggedblockids) {
return $taggedblockids;
} else {
return array();
}
}
示例4: dump_export_data
public function dump_export_data()
{
if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS && $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) {
// Dont' care about resume in this case
return;
}
$smarty = $this->exporter->get_smarty('../../', 'resume');
$smarty->assign('page_heading', get_string('resumeofuser', 'artefact.resume', full_name($this->exporter->get('user'))));
$smarty->assign('breadcrumbs', array(array('text' => get_string('resume', 'artefact.resume'), 'path' => 'index.html')));
if ($artefacts = get_column_sql("SELECT id\n FROM {artefact}\n WHERE owner = ?\n AND artefacttype IN\n (SELECT name FROM {artefact_installed_type} WHERE plugin = 'resume')", array($this->exporter->get('user')->get('id')))) {
foreach ($artefacts as $id) {
$artefact = artefact_instance_from_id($id);
$rendered = $artefact->render_self(array());
$smarty->assign($artefact->get('artefacttype'), $rendered['html']);
}
}
$content = $smarty->fetch('export:html/resume:index.tpl');
if (false === file_put_contents($this->fileroot . 'index.html', $content)) {
throw new SystemException("Unable to create index.html for resume");
}
}
示例5: get_annotation_feedback
/**
* Generates the data object required for displaying annotations on the page.
*
* @param object $options Object of annotation options
* - defaults can be retrieved from get_annotation_feedback_options()
* @return object $result Annotation data object
*/
public static function get_annotation_feedback($options)
{
global $USER;
// set the object's key/val pairs as variables
foreach ($options as $key => $option) {
${$key} = $option;
}
$userid = $USER->get('id');
$canedit = false;
if (!empty($artefact)) {
// This is the artefact that the annotation is linked to.
$artefactobj = artefact_instance_from_id($artefact);
$canedit = $USER->can_edit_artefact($artefactobj);
$owner = $artefactobj->get('owner');
$isowner = $userid && $userid == $owner;
$view = null;
} else {
if (!empty($view)) {
// This is the view that the annotation is linked to.
$viewobj = new View($view);
$canedit = $USER->can_moderate_view($viewobj);
$owner = $viewobj->get('owner');
$isowner = $userid && $userid == $owner;
$artefact = null;
}
}
$result = (object) array('limit' => $limit, 'offset' => $offset, 'annotation' => $annotation, 'view' => $view, 'artefact' => $artefact, 'block' => $block, 'canedit' => $canedit, 'owner' => $owner, 'isowner' => $isowner, 'export' => $export, 'sort' => $sort, 'data' => array());
$wherearray = array();
$wherearray[] = 'a.id = ' . (int) $annotation;
// if artefact and view are not set, this annotation is not linked to anything.
if (!empty($artefact)) {
$wherearray[] = 'an.artefact = ' . (int) $artefact;
} else {
if (!empty($view)) {
$wherearray[] = 'an.view = ' . (int) $view;
} else {
// Something is wrong. Don't show anything.
$wherearray[] = '1 = 2';
}
}
if (!$canedit) {
$wherearray[] = '(f.private = 0 OR af.author = ' . (int) $userid . ')';
}
$where = implode(' AND ', $wherearray);
$sql = 'SELECT COUNT(*)
FROM {artefact} a
INNER JOIN {artefact_annotation} an ON a.id = an.annotation
INNER JOIN {artefact_annotation_feedback} f ON an.annotation = f.onannotation
INNER JOIN {artefact} af ON f.artefact = af.id
INNER JOIN {usr} u ON a.author = u.id
LEFT JOIN {usr} uf ON af.author = uf.id
LEFT JOIN {usr_institution} uif ON uf.id = uif.usr
WHERE ' . $where;
$result->count = count_records_sql($sql);
if ($result->count > 0) {
// If pagination is in use, see if we want to get a page with particular comment
if ($limit) {
if ($showcomment == 'last') {
// If we have limit (pagination is used) ignore $offset and just get the last page of feedback.
$result->forceoffset = $offset = (ceil($result->count / $limit) - 1) * $limit;
} else {
if (is_numeric($showcomment)) {
// Ignore $offset and get the page that has the comment
// with id $showcomment on it.
// Fetch everything up to $showcomment to get its rank
// This will get ugly if there are 1000s of feedback.
$ids = get_column_sql('
SELECT f.artefact
FROM {artefact} a
INNER JOIN {artefact_annotation} an ON a.id = an.annotation
INNER JOIN {artefact_annotation_feedback} f ON an.annotation = f.onannotation
INNER JOIN {artefact} af ON f.artefact = af.id
INNER JOIN {usr} u ON a.author = u.id
LEFT JOIN {usr} uf ON af.author = uf.id
LEFT JOIN {usr_institution} uif ON uf.id = uif.usr
WHERE ' . $where . '
AND f.artefact <= ?
ORDER BY a.ctime', array($showcomment));
$last = end($ids);
if ($last == $showcomment) {
// Add 1 because array index starts from 0 and therefore key value is offset by 1.
$rank = key($ids) + 1;
$result->forceoffset = $offset = (ceil($rank / $limit) - 1) * $limit;
$result->showcomment = $showcomment;
}
}
}
}
$sortorder = !empty($sort) && $sort == 'latest' ? 'af.ctime DESC' : 'af.ctime ASC';
$sql = 'SELECT
af.id, af.author, af.authorname, af.ctime, af.mtime, af.description, af.group,
f.private, f.deletedby, f.requestpublic, f.lastcontentupdate,
uf.username, uf.firstname, uf.lastname, uf.preferredname, uf.email, uf.staff, uf.admin,
//.........这里部分代码省略.........
示例6: user_joined_group
/**
* When a user joins a group, subscribe them automatically to all forums
* that should be subscribable
*
* @param array $eventdata
*/
public static function user_joined_group($event, $gm)
{
if ($forumids = get_column_sql("\n SELECT ii.id\n FROM {group} g\n LEFT JOIN {interaction_instance} ii ON g.id = ii.group\n LEFT JOIN {interaction_forum_instance_config} ific ON ific.forum = ii.id\n WHERE \"group\" = ? AND ific.field = 'autosubscribe' and ific.value = '1'", array($gm['group']))) {
db_begin();
foreach ($forumids as $forumid) {
insert_record('interaction_forum_subscription_forum', (object) array('forum' => $forumid, 'user' => $gm['member']));
}
db_commit();
}
}
示例7: get_new_file_title
/**
* Return a unique artefact title for a given owner & parent.
*
* Try to add digits before the filename extension: If the desired
* title contains a ".", add "." plus digits before the final ".",
* otherwise append "." and digits.
*
* @param string $desired
* @param integer $parent
* @param integer $owner
* @param integer $group
* @param string $institution
*/
public static function get_new_file_title($desired, $parent, $owner = null, $group = null, $institution = null)
{
$bits = split('\\.', $desired);
if (count($bits) > 1 && preg_match('/[^0-9]/', end($bits))) {
$start = join('.', array_slice($bits, 0, count($bits) - 1));
$end = '.' . end($bits);
} else {
$start = $desired;
$end = '';
}
$where = $parent ? "parent = {$parent}" : 'parent IS NULL';
$where .= ' AND ' . artefact_owner_sql($owner, $group, $institution);
$taken = get_column_sql("\n SELECT title FROM {artefact}\n WHERE artefacttype IN ('" . join("','", array_diff(PluginArtefactFile::get_artefact_types(), array('profileicon'))) . "')\n AND title LIKE ? || '%' || ? AND " . $where, array($start, $end));
$taken = array_flip($taken);
$i = 0;
$newname = $start . $end;
while (isset($taken[$newname])) {
$i++;
$newname = $start . '.' . $i . $end;
}
return $newname;
}
示例8: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
safe_require('artefact', 'blog');
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
$blog = $instance->get_artefact_instance($configdata['artefactid']);
}
$elements = array();
// If the blog post in this block is owned by the owner of the View,
// then the block can be configured. Otherwise, the blog post was
// copied in from another View. We won't confuse users by asking them to
// choose a blog post to put in this block, when the one that is
// currently in it isn't choosable.
//
// Note: the owner check will have to change when we do group/site
// blogs
if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) {
$publishedposts = get_column_sql('
SELECT a.id
FROM {artefact} a
INNER JOIN {artefact_blog_blogpost} p ON p.blogpost = a.id
WHERE p.published = 1 AND a.owner= ?', array($USER->get('id')));
$elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $publishedposts);
$elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blogpost');
} else {
$elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blogpost', 'artefact.blog')) . '</div>');
}
return $elements;
}
示例9: update_locked
public static function update_locked($userid)
{
if (empty($userid)) {
return;
}
$submitted = get_column_sql('
SELECT a.id
FROM {artefact} a
JOIN {view_artefact} va ON a.id = va.artefact
JOIN {view} v ON va.view = v.id
WHERE a.owner = ?
AND v.owner = ?
AND (v.submittedgroup IS NOT NULL OR v.submittedhost IS NOT NULL)', array($userid, $userid));
if ($submitted) {
$submitted = artefact_get_descendants($submitted);
if ($attachments = get_column_sql('
SELECT attachment FROM {artefact_attachment}
WHERE artefact IN (' . join(',', $submitted) . ')', array())) {
$submitted = array_merge($submitted, $attachments);
}
}
db_begin();
if (!empty($submitted)) {
$idstr = '(' . join(',', $submitted) . ')';
set_field_select('artefact', 'locked', 1, "locked = 0 AND id IN {$idstr}", array());
}
// Unlock
$select = 'locked = 1 AND "owner" = ?';
if (isset($idstr)) {
$select .= " AND NOT id IN {$idstr}";
}
set_field_select('artefact', 'locked', 0, $select, array($userid));
db_commit();
}
示例10: xmldb_core_upgrade
function xmldb_core_upgrade($oldversion = 0)
{
global $SESSION;
raise_time_limit(120);
raise_memory_limit('256M');
$status = true;
if ($oldversion < 2009022700) {
// Get rid of all blocks with position 0 caused by 'about me' block on profile views
if (count_records('block_instance', 'order', 0) && !count_records_select('block_instance', '"order" < 0')) {
if (is_mysql()) {
$ids = get_column_sql('
SELECT i.id FROM {block_instance} i
INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
ON (z.view = i.view AND z.column = i.column)');
execute_sql('UPDATE {block_instance} SET "order" = -1 * "order" WHERE id IN (' . join(',', $ids) . ')');
} else {
execute_sql('UPDATE {block_instance} SET "order" = -1 * "order" WHERE id IN (
SELECT i.id FROM {block_instance} i
INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
ON (z.view = i.view AND z.column = i.column))');
}
execute_sql('UPDATE {block_instance} SET "order" = 1 WHERE "order" = 0');
execute_sql('UPDATE {block_instance} SET "order" = -1 * ("order" - 1) WHERE "order" < 0');
}
}
if ($oldversion < 2009031000) {
reload_html_filters();
}
if ($oldversion < 2009031300) {
$table = new XMLDBTable('institution');
$expiry = new XMLDBField('expiry');
$expiry->setAttributes(XMLDB_TYPE_DATETIME);
add_field($table, $expiry);
$expirymailsent = new XMLDBField('expirymailsent');
$expirymailsent->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $expirymailsent);
$suspended = new XMLDBField('suspended');
$suspended->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $suspended);
// Insert a cron job to check for soon expiring and expired institutions
if (!record_exists('cron', 'callfunction', 'auth_handle_institution_expiries')) {
$cron = new StdClass();
$cron->callfunction = 'auth_handle_institution_expiries';
$cron->minute = '5';
$cron->hour = '9';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
}
if ($oldversion < 2009031800) {
// Files can only attach blogpost artefacts, but we would like to be able to attach them
// to other stuff. Rename the existing attachment table artefact_blog_blogpost_file to
// artefact_file_attachment so we don't end up with many tables doing the same thing.
execute_sql("ALTER TABLE {artefact_blog_blogpost_file} RENAME TO {artefact_attachment}");
if (is_postgres()) {
// Ensure all of the indexes and constraints are renamed
execute_sql("\n ALTER TABLE {artefact_attachment} RENAME blogpost TO artefact;\n ALTER TABLE {artefact_attachment} RENAME file TO attachment;\n\n ALTER INDEX {arteblogblogfile_blofil_pk} RENAME TO {arteatta_artatt_pk};\n ALTER INDEX {arteblogblogfile_blo_ix} RENAME TO {arteatta_art_ix};\n ALTER INDEX {arteblogblogfile_fil_ix} RENAME TO {arteatta_att_ix};\n\n ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_blo_fk};\n ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY (artefact) REFERENCES {artefact}(id);\n\n ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_fil_fk};\n ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY (attachment) REFERENCES {artefact}(id);\n ");
} else {
if (is_mysql()) {
execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_blo_fk}");
execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_blo_ix}");
execute_sql("ALTER TABLE {artefact_attachment} CHANGE blogpost artefact BIGINT(10) DEFAULT NULL");
execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY {arteatta_art_ix} (artefact) REFERENCES {artefact}(id)");
execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_fil_fk}");
execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_fil_ix}");
execute_sql("ALTER TABLE {artefact_attachment} CHANGE file attachment BIGINT(10) DEFAULT NULL");
execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY {arteatta_att_ix} (attachment) REFERENCES {artefact}(id)");
}
}
// Drop the _pending table. From now on files uploaded as attachments will become artefacts
// straight away. Hopefully changes to the upload/file browser form will make it clear to
// the user that these attachments sit in his/her files area as soon as they are uploaded.
$table = new XMLDBTable('artefact_blog_blogpost_file_pending');
drop_table($table);
}
if ($oldversion < 2009040900) {
// The view access page has been putting the string 'null' in as a group role in IE.
set_field('view_access_group', 'role', null, 'role', 'null');
}
if ($oldversion < 2009040901) {
$table = new XMLDBTable('import_installed');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('version', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('release', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('active', XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 1);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
create_table($table);
$table = new XMLDBTable('import_cron');
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('callfunction', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('minute', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('hour', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('day', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('dayofweek', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('month', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('nextrun', XMLDB_TYPE_DATETIME, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'callfunction'));
$table->addKeyInfo('pluginfk', XMLDB_KEY_FOREIGN, array('plugin'), 'import_installed', array('name'));
//.........这里部分代码省略.........
示例11: regenerateurls_submit
function regenerateurls_submit(Pieform $form, $values)
{
global $SESSION, $USER;
require_once 'upgrade.php';
log_debug("Regenerating clean urls...");
db_begin();
// Checking duplicates one by one is too slow, so drop the index,
// generate the urlids in big chunks, remove duplicates in one hit,
// recreate the index.
// Users: set urlid based on username.
$table = new XMLDBTable('usr');
$index = new XMLDBIndex('urliduk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('urlid'));
drop_index($table, $index);
execute_sql('UPDATE {usr} SET urlid = NULL WHERE NOT urlid IS NULL');
$usrcount = count_records_select('usr', 'deleted = 0 AND id > 0');
$sql = 'SELECT id, username FROM {usr} WHERE id > ? AND deleted = 0 ORDER BY id';
$done = 0;
$lastid = 0;
$limit = 1000;
while ($records = get_records_sql_array($sql, array($lastid), 0, $limit)) {
$firstid = $lastid;
$values = array();
foreach ($records as $r) {
$r->urlid = generate_urlid($r->username, get_config('cleanurluserdefault'), 3, 30);
array_push($values, $r->id, $r->urlid);
$lastid = $r->id;
}
$updatesql = "UPDATE {usr} SET urlid = CASE id\n ";
$updatesql .= join("\n ", array_fill(0, count($records), 'WHEN ? THEN ?'));
$updatesql .= "\n ELSE NULL\n END WHERE id > ? AND id <= ? AND deleted = 0";
array_push($values, $firstid, $lastid);
execute_sql($updatesql, $values);
$done += count($records);
log_debug("Generating user urls: {$done}/{$usrcount}");
}
// Fix any duplicates created above
$dupurls = get_records_sql_array('
SELECT id, urlid
FROM {usr}
WHERE urlid IN (
SELECT urlid FROM {usr} WHERE id > 0 AND deleted = 0 GROUP BY urlid HAVING COUNT(id) > 1
)
ORDER BY urlid, id', array());
$last = null;
if ($dupurls) {
log_debug('Fixing ' . count($dupurls) . ' duplicate user urls');
$ids = array();
$values = array();
for ($i = 0; $i < count($dupurls); $i++) {
if ($dupurls[$i]->urlid != $last) {
// The first user with this name can keep it, but get all the taken urlids that are similar
// so we can check against them when appending digits below.
$taken = get_column_sql("SELECT urlid FROM {usr} WHERE urlid LIKE ?", array(substr($dupurls[$i]->urlid, 0, 24) . '%'));
} else {
// Subsequent users need digits appended, while keeping the max length at 30
$suffix = 1;
$try = substr($dupurls[$i]->urlid, 0, 28) . '-1';
while (in_array($try, $taken)) {
$suffix++;
$try = substr($dupurls[$i]->urlid, 0, 29 - strlen($suffix)) . '-' . $suffix;
}
$taken[] = $try;
$ids[] = $dupurls[$i]->id;
array_push($values, $dupurls[$i]->id, $try);
}
$last = $dupurls[$i]->urlid;
}
$updatesql = "UPDATE {usr} SET urlid = CASE id\n ";
$updatesql .= join("\n ", array_fill(0, count($values) / 2, 'WHEN ? THEN ?'));
$updatesql .= "\n ELSE urlid\n END\n WHERE id IN (";
$updatesql .= join(',', array_fill(0, count($ids), '?'));
$updatesql .= ')';
$values = array_merge($values, $ids);
execute_sql($updatesql, $values);
}
$table = new XMLDBTable('usr');
$index = new XMLDBIndex('urliduk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('urlid'));
add_index($table, $index);
// Groups: set urlid based on group name
execute_sql('UPDATE {group} SET urlid = NULL');
$table = new XMLDBTable('group');
$index = new XMLDBIndex('urliduk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('urlid'));
drop_index($table, $index);
// Transliteration using iconv is bad if locale is set to C, so set it based on
// the site language.
$lang = $sitelang = get_config('lang');
set_locale_for_language($lang);
$groupcount = count_records('group', 'deleted', 0);
$sql = 'SELECT id, name FROM {group} WHERE deleted = 0 AND id > ? ORDER BY id';
$done = 0;
$lastid = 0;
$limit = 1000;
while ($records = get_records_sql_array($sql, array($lastid), 0, $limit)) {
$firstid = $lastid;
$values = array();
foreach ($records as $r) {
$r->urlid = generate_urlid($r->name, get_config('cleanurlgroupdefault'), 3, 30);
//.........这里部分代码省略.........
示例12: define
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configsite/sitelicenses');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'licenses');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'license.php';
require_once 'pieforms/pieform.php';
define('TITLE', get_string('sitelicenses', 'admin'));
define('DEFAULTPAGE', 'home');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['license_delete'])) {
$del = array_shift(array_keys($_POST['license_delete']));
delete_records('artefact_license', 'name', $del);
$SESSION->add_ok_msg(get_string('licensedeleted', 'admin'));
}
}
if (!isset($licenses)) {
$licenses = get_records_assoc('artefact_license', null, null, 'displayname');
}
$extralicenses = get_column_sql("\n SELECT DISTINCT license\n FROM {artefact}\n WHERE license IS NOT NULL AND license <> ''\n AND license NOT IN (SELECT name FROM {artefact_license})\n ORDER BY license\n");
$smarty = smarty();
setpageicon($smarty, 'icon-legal');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('licenses', $licenses);
$smarty->assign('extralicenses', $extralicenses);
$smarty->assign('allowextralicenses', get_config('licenseallowcustom'));
$smarty->assign('enabled', get_config('licensemetadata'));
$smarty->display('admin/site/licenses.tpl');
示例13: group_get_new_homepage_urlid
function group_get_new_homepage_urlid($desired)
{
$maxlen = 30;
$desired = strtolower(substr($desired, 0, $maxlen));
$taken = get_column_sql('SELECT urlid FROM {group} WHERE urlid LIKE ?', array(substr($desired, 0, $maxlen - 6) . '%'));
if (!$taken) {
return $desired;
}
$i = 1;
$newname = substr($desired, 0, $maxlen - 2) . '-1';
while (in_array($newname, $taken)) {
$i++;
$newname = substr($desired, 0, $maxlen - strlen($i) - 1) . '-' . $i;
}
return $newname;
}
示例14: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
safe_require('artefact', 'blog');
$configdata = $instance->get('configdata');
require_once get_config('libroot') . 'view.php';
$view = new View($instance->get('view'));
$institution = $view->get('institution');
$group = $view->get('group');
if (!empty($configdata['artefactid'])) {
$blog = $instance->get_artefact_instance($configdata['artefactid']);
}
$elements = array();
// If the blog in this block is owned by the owner of the View, then
// the block can be configured. Otherwise, the blog was copied in from
// another View. We won't confuse users by asking them to choose a blog
// to put in this block, when the one that is currently in it isn't
// choosable.
//
// Note: the owner check will have to change when we do group/site
// blogs
if (empty($configdata['artefactid']) || ArtefactTypeBlog::can_edit_blog($blog, $institution, $group)) {
$where = array('blog');
$sql = "SELECT a.id FROM {artefact} a\n WHERE a.artefacttype = ?";
if ($institution) {
$sql .= " AND a.institution = ?";
$where[] = $institution;
} else {
if ($group) {
$sql .= " AND a.group = ?";
$where[] = $group;
} else {
$sql .= " AND a.owner = ?";
$where[] = $USER->get('id');
}
}
$blogids = get_column_sql($sql, $where);
$elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $blogids);
$elements['count'] = array('type' => 'text', 'title' => get_string('postsperpage', 'blocktype.blog/blog'), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 5, 'size' => 3);
$elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blog');
} else {
$elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('Blog', 'artefact.blog')) . '</div>');
}
return $elements;
}
示例15: db_begin
$deleteunread++;
}
}
}
db_begin();
$countdeleted = 0;
foreach ($rawids as $table => $idspertable) {
if ('artefact_multirecipient_notification' === $table) {
delete_messages_mr($idspertable, $USER->get('id'));
} else {
if ('notification_internal_activity' === $table) {
$userid = $USER->get('id');
// Ignore message ids that do not belong to the current user to stop
// hacking of the form allowing the deletion of messages owned by other users.
$rawstrids = join(',', array_map('db_quote', $idspertable));
$ids = get_column_sql("SELECT id FROM {notification_internal_activity}\n WHERE id IN ({$rawstrids}) AND usr = ?", array($userid));
if ($ids) {
$strids = join(',', $ids);
// Remove parent pointers to messages we're about to delete
execute_sql("\n UPDATE {notification_internal_activity}\n SET parent = NULL\n WHERE parent IN ({$strids})");
delete_records_select('notification_internal_activity', "id IN ({$strids})");
if ($deleteunread) {
$newunread = $USER->add_unread(-1 * $deleteunread);
}
}
}
}
$countdeleted += $ids ? count($ids) : count($idspertable);
}
db_commit();
$message = get_string('deletednotifications1', 'activity', $countdeleted);