if (!empty($targetEl)) {
$this->target = new ActivityObject($targetEl);
- } elseif (ActivityUtils::compareTypes($this->verb, array(ActivityVerb::FAVORITE))) {
+ } elseif (ActivityUtils::compareVerbs($this->verb, array(ActivityVerb::FAVORITE))) {
// StatusNet didn't send a 'target' for their Favorite atom entries
$this->target = clone($this->objects[0]);
}
function isMyVerb($verb) {
$verb = $verb ?: ActivityVerb::POST; // post is the default verb
- return ActivityUtils::compareTypes($verb, $this->verbs());
+ return ActivityUtils::compareVerbs($verb, $this->verbs());
}
function isMyType($type) {
} elseif ($target instanceof Profile && $target->isLocal()) {
$original = null;
// FIXME: Shouldn't favorites show up with a 'target' activityobject?
- if (!ActivityUtils::compareTypes($activity->verb, array(ActivityVerb::POST)) && isset($activity->objects[0])) {
+ if (!ActivityUtils::compareVerbs($activity->verb, array(ActivityVerb::POST)) && isset($activity->objects[0])) {
// If this is not a post, it's a verb targeted at something (such as a Favorite attached to a note)
if (!empty($activity->objects[0]->id)) {
$activity->context->replyToID = $activity->objects[0]->id;
$actor = $oactor->localProfile();
// FIXME: will this work in all cases? I made it work for Favorite...
- if (ActivityUtils::compareTypes($activity->verb, array(ActivityVerb::POST))) {
+ if (ActivityUtils::compareVerbs($activity->verb, array(ActivityVerb::POST))) {
$object = $activity->objects[0];
} else {
$object = $activity;
return null;
}
- static function compareTypes($type, $objects) // this does verbs too!
+ static function compareTypes($type, $objects)
{
$type = self::resolveUri($type);
foreach ((array)$objects as $object) {
return false;
}
+ static function compareVerbs($type, $objects)
+ {
+ return self::compareTypes($type, $objects);
+ }
+
static function resolveUri($uri, $make_relative=false)
{
if (empty($uri)) {
$expected_verb = $exists ? ActivityVerb::UNFAVORITE : ActivityVerb::FAVORITE;
switch (true) {
- case $exists && ActivityUtils::compareTypes($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
- case !$exists && ActivityUtils::compareTypes($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
+ case $exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
+ case !$exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
common_redirect(common_local_url('activityverb',
array('id' => $target->getID(),
'verb' => ActivityUtils::resolveUri($expected_verb, true))));
protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
{
switch (true) {
- case ActivityUtils::compareTypes($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
+ case ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
Fave::addNew($scoped, $target);
break;
- case ActivityUtils::compareTypes($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
+ case ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
Fave::removeEntry($scoped, $target);
break;
default:
$target = self::getTargetFromStored($stored);
// The following logic was copied from StatusNet's Activity plugin
- if (ActivityUtils::compareTypes($target->verb, array(ActivityVerb::POST))) {
+ if (ActivityUtils::compareVerbs($target->verb, array(ActivityVerb::POST))) {
// "I like the thing you posted"
$act->objects = $target->asActivity()->objects;
} else {