Skip to content

Instantly share code, notes, and snippets.

View michaeltwofish's full-sized avatar

Michael C. Harris michaeltwofish

  • South Australia, Australia
View GitHub Profile
<?php
/**
* A generic form mailer, designed to be built upon by other plugins and themes
*/
class FormMailer extends Plugin
{
const X_MAILER = 'Habari Form Mailer';
public function __get($name) {
aligned
fun-with-photos
georgia
gray
habarism
hmallow2
lace
menyu
phoenixblue
redarry
public function action_admin_header($theme)
{
if ( $theme->page == 'themes' ) {
$js = <<<JS
$(document).ready(function() {
$('#twitter input:checkbox').bind('change', function() {
var disable_twitter_username = $('#twitter input:checked').length == 0;
$('#twitter_username input').attr('disabled', disable_twitter_username);
});
public function get_years_array()
{
$years = DB::get_column(
"SELECT DISTINCT habari__postinfo.value from habari__posts
INNER join habari__posttype on habari__posts.content_type = habari__posttype.id and habari__posttype.name = ?
left join habari__postinfo on habari__posts.id = habari__postinfo.`post_id` and `habari__postinfo`.name = ?
ORDER BY habari__postinfo.value DESC",
array('imprint', 'year')
);
$years = DB::get_column(
"SELECT habari__postinfo.value, count(habari__posts.id) FROM habari__posts
INNER JOIN habari__posttype ON habari__posts.content_type = habari__posttype.id AND habari__posttype.name = ?
INNER JOIN habari__postinfo ON habari__posts.id = habari__postinfo.`post_id` AND `habari__postinfo`.name = ?
INNER JOIN habari__poststatus ON habari__posts.status = habari__poststatus.id AND habari__poststatus.name = ?
GROUP BY habari__postinfo.value
ORDER BY habari__postinfo.value DESC",
array('imprint', 'year', 'published')
);
postgres=# \l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+-----------+-----------+-------+-----------------------
habari | habari | SQL_ASCII | C | C | =Tc/habari
: habari=CTc/habari
postgres | postgres | SQL_ASCII | C | C |
template0 | postgres | SQL_ASCII | C | C | =c/postgres
: postgres=CTc/postgres
template1 | postgres | SQL_ASCII | C | C | =c/postgres
Version Cluster Port Status Owner Data directory Log file
8.4 main 5433 online postgres /var/lib/postgresql/8.4/main /var/log/postgresql/postgresql-8.4-main.log
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN
tcp6 0 0 ::1:5432 :::* LISTEN
tcp6 0 0 ::1:5433 :::* LISTEN
tcp6 0 0 ::1:37957 ::1:5432 CLOSE_WAIT
tcp6 1 0 ::1:55184 ::1:5432 CLOSE_WAIT
unix 2 [ ACC ] STREAM LISTENING 1132560 /var/run/postgresql/.s.PGSQL.5433
unix 2 [ ACC ] STREAM LISTENING 1146714 /var/run/postgresql/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 1146473 /var/run/postgresql/.s.PGSQL.5433
unix 3 [ ] STREAM CONNECTED 539543
postgres 3632 0.0 0.9 65876 3080 pts/23 S+ 04:12 0:00 /usr/lib/postgresql/8.4/bin/psql
postgres 3633 0.0 1.1 99728 3912 ? Ss 04:12 0:00 postgres: postgres postgres [local] idle
postgres 3677 0.0 2.6 52256 8672 pts/21 T 04:25 0:00 vim /etc/postgresql/8.4/main/postgresql.conf
postgres 3684 0.0 1.7 91928 5868 pts/21 S 04:27 0:00 /usr/lib/postgresql/8.4/bin/postgres -D /usr/lib/postgresql/data
postgres 3686 0.0 0.4 91928 1596 ? Ss 04:27 0:00 postgres: writer process
postgres 3687 0.0 0.4 91928 1380 ? Ss 04:27 0:00 postgres: wal writer process
postgres 3688 0.0 0.4 92064 1572 ? Ss 04:27 0:00 postgres: autovacuum launcher process
postgres 3689 0.0 0.4 63468 1320 ? Ss 04:27 0:00 postgres: stats collector process
public function test_get_posts_by_tag()
{
// Create some tagged posts
$user = User::get_by_name( 'posts_test' );
$time = time() - 160;
$tagged_posts = array();
$tag_sets = array(
array('one'),