We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 6d3e6b42 authored by Evan Prodromou's avatar Evan Prodromou

move flag creation to a method of data object

parent 2ae04bb6
......@@ -118,4 +118,23 @@ class User_flag_profile extends Memcached_DataObject
return !empty($ufp);
}
static function create($user_id, $profile_id)
{
$ufp = new User_flag_profile();
$ufp->profile_id = $profile_id;
$ufp->user_id = $user_id;
$ufp->created = common_sql_now();
if (!$ufp->insert()) {
$msg = sprintf(_("Couldn't flag profile '%d' for review."),
$profile_id);
throw new ServerException($msg);
}
$ufp->free();
return true;
}
}
......@@ -105,19 +105,9 @@ class FlagprofileAction extends ProfileFormAction
assert(!empty($user));
assert(!empty($this->profile));
$ufp = new User_flag_profile();
// throws an exception on error
$ufp->profile_id = $this->profile->id;
$ufp->user_id = $user->id;
$ufp->created = common_sql_now();
if (!$ufp->insert()) {
$msg = sprintf(_("Couldn't flag profile '%s' for review."),
$this->profile->nickname);
throw new ServerException($msg);
}
$ufp->free();
User_flag_profile::create($user->id, $this->profile->id);
if ($this->boolean('ajax')) {
$this->ajaxResults();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment