$schema = Schema::get();
// For storing user-submitted flags on profiles
- $schema->ensureDataObject('User_flag_profile');
+
+ $schema->ensureTable('user_flag_profile',
+ array(new ColumnDef('profile_id', 'integer', null,
+ false, 'PRI'),
+ new ColumnDef('user_id', 'integer', null,
+ false, 'PRI'),
+ new ColumnDef('created', 'datetime', null,
+ false, 'MUL'),
+ new ColumnDef('cleared', 'datetime', null,
+ true, 'MUL')));
return true;
}
return true;
}
- function onRouterInitialized(&$m) {
+ function onRouterInitialized($m) {
$m->connect('main/flag/profile', array('action' => 'flagprofile'));
$m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
return true;
{
$user = common_current_user();
- if (!empty($user)) {
+ if (!empty($user) && ($user->id != $profile->id)) {
$action->elementStart('li', 'entity_flag');
if (!empty($user)) {
- $form = new FlagProfileForm($item->action, $item->profile);
+ list($action, $args) = $item->action->returnToArgs();
+
+ $args['action'] = $action;
+ $form = new FlagProfileForm($item->action, $item->profile, $args);
+
+ $item->action->elementStart('li', 'entity_flag');
$form->show();
+ $item->action->elementEnd('li');
}
return true;
function onEndShowStatusNetStyles($action)
{
- $action->elementStart('style', array('type' => 'text/css'));
- $action->raw('.entity_flag input, .entity_flag p {'.
- ' background:url('.common_path('plugins/UserFlag/flag.gif').') 5px 5px no-repeat;'.
- ' }');
- $action->elementEnd('style');
-
+ $action->cssLink(common_path('plugins/UserFlag/userflag.css'),
+ null, 'screen, projection, tv');
return true;
}
function onEndShowScripts($action)
{
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw('/*<![CDATA[*/ SN.U.FormXHR($(".form_entity_flag")); /*]]>*/');
- $action->elementEnd('script');
+ $action->inlineScript('if ($(".form_entity_flag").length > 0) { SN.U.FormXHR($(".form_entity_flag")); }');
return true;
}
}