function common_element_end($tag) {
global $xw;
- $xw->endElement();
+ # TODO: switch based on $tag
+ $xw->fullEndElement();
}
function common_element($tag, $attrs=NULL, $content=NULL) {
common_element_end('div'); # content div
common_foot_menu();
common_element_start('div', array('id' => 'footer'));
- common_element_start('p', 'laconica');
+ common_element_start('div', 'laconica');
if (common_config('site', 'broughtby')) {
$instr = _t('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
} else {
'(http://www.fsf.org/licensing/licenses/agpl-3.0.html).');
$output = common_markup_to_html($instr);
common_raw($output);
- common_element_end('p');
+ common_element_end('div');
common_element('img', array('id' => 'cc',
'src' => $config['license']['image'],
'alt' => $config['license']['title']));
'cols' => 40,
'name' => $id,
'id' => $id),
- ($content) ? $content : ' ');
+ ($content) ? $content : '');
if ($instructions) {
common_element('span', 'input_instructions', $instructions);
}
common_set_cookie(REMEMBERME,
implode(':', array($rm->user_id, $rm->code)),
time() + REMEMBERME_EXPIRY);
+ return true;
}
function common_remembered_user() {
return common_path('avatar/'.$filename);
}
+function common_avatar_display_url($avatar) {
+ $server = common_config('avatar', 'server');
+ if ($server) {
+ return 'http://'.$server.'/'.$avatar->filename;
+ } else {
+ return $avatar->url;
+ }
+}
+
function common_default_avatar($size) {
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
AVATAR_STREAM_SIZE => 'stream',
}
function common_broadcast_notice($notice, $remote=false) {
- // XXX: optionally use a queue system like http://code.google.com/p/microapps/wiki/NQDQ
+ if (common_config('queue', 'enabled')) {
+ # Do it later!
+ return common_enqueue_notice($notice);
+ } else {
+ return common_real_broadcast($notice, $remote);
+ }
+}
+
+# Stick the notice on the queue
+
+function common_enqueue_notice($notice) {
+ common_log(LOG_INFO, 'start queueing notice ID = ' . $notice->id);
+ $qi = new Queue_item();
+ $qi->notice_id = $notice->id;
+ $qi->created = DB_DataObject_Cast::dateTime();
+ $result = $qi->insert();
+ if ($result === FALSE) {
+ $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+ common_log(LOG_ERROR, 'DB error inserting queue item: ' . $last_error->message);
+ return false;
+ }
+ common_log(LOG_INFO, 'complete queueing notice ID = ' . $notice->id);
+ return $result;
+}
+
+function common_real_broadcast($notice, $remote=false) {
+ $success = true;
if (!$remote) {
# Make sure we have the OMB stuff
require_once(INSTALLDIR.'/lib/omb.php');
- omb_broadcast_remote_subscribers($notice);
+ $success = omb_broadcast_remote_subscribers($notice);
+ if (!$success) {
+ common_log(LOG_ERROR, 'Error in OMB broadcast for notice ' . $notice->id);
+ }
+ }
+ if ($success) {
+ require_once(INSTALLDIR.'/lib/jabber.php');
+ $success = jabber_broadcast_notice($notice);
+ if (!$success) {
+ common_log(LOG_ERROR, 'Error in jabber broadcast for notice ' . $notice->id);
+ }
}
- require_once(INSTALLDIR.'/lib/jabber.php');
- jabber_broadcast_notice($notice);
// XXX: broadcast notices to SMS
// XXX: broadcast notices to other IM
- return true;
+ return $success;
}
function common_broadcast_profile($profile) {
$user = common_current_user();
assert(!is_null($user));
common_element_start('form', array('id' => 'status_form',
- 'method' => 'POST',
+ 'method' => 'post',
'action' => common_local_url('newnotice')));
common_element_start('p');
- common_element('label', array('for' => 'status_update',
+ common_element('label', array('for' => 'status_textarea',
'id' => 'status_label'),
_t('What\'s up, ').$user->nickname.'?');
common_element('span', array('id' => 'counter', 'class' => 'counter'), '140');
common_element('textarea', array('id' => 'status_textarea',
+ 'cols' => 60,
+ 'rows' => 3,
'name' => 'status_textarea'),
- ' ');
+ ($content) ? $content : '');
if ($action) {
common_hidden('returnto', $action);
}