/** * {%inheritDoc} */ public static function process(User $user, $params = []) { if (!isset($params['code']) || empty($params['code'])) { return false; } if ($activity = Activity::findActivityType('LikeWorkOfArt')->first()) { $code = $params['code']; if ($data = self::isAssessionNumber($code)) { // Skip activity process if user has already like this work of art $likeCount = ActivityMetadata::hasMetadataValue($user, $activity, 'object_id', $data['object_id'])->count(); if ($likeCount == 0) { // User haven't like this artwork yet if ($ret = parent::process($user, ['activity' => $activity])) { // TODO: Find a better way to pass this data $activity->objectData = $data; // Save user metada activity ActivityMetadata::addUserActivity($user, $activity, $data, ['object_title']); FriendsLog::artwork(['user' => $user, 'artwork_id' => $params['code']]); } return $ret; } else { Session::put('activityError', Lang::get('dma.friends::lang.activities.alreadyLikeWorkArtError', ['code' => $params['code']])); } } else { // Verify if user try to enter an Object number // Regex expression to match object number format $re = "/((([a-zA-Z0-9_\\-]+\\.){1,})([a-zA-Z0-9_\\-]+))/"; $isObjectNumber = preg_match_all($re, str_replace(' ', '', $code)) > 0; if ($isObjectNumber) { Session::put('activityError', Lang::get('dma.friends::lang.activities.likeWorkArtCodeError', ['code' => $params['code']])); } } } return false; }
/** * @see \DMA\Friends\Classes\ActivityTypeBase * * Process and determine if an award can be isued * based on a provided activity code * * @param User $user * A user model for which the activity should act upon * * @param array $params * An array of parameters for validating activities * * @return boolean * returns true if the process was successful */ public static function process(User $user, $params = []) { if (!isset($params['code']) || empty($params['code'])) { return false; } if ($activity = Activity::findCode($params['code'])->first()) { return parent::process($user, ['activity' => $activity]); } Session::put('activityError', Lang::get('dma.friends::lang.activities.codeError', ['code' => $params['code']])); return false; }
/** * {@inheritDoc} */ public static function process(User $user, $params = []) { $activities = Activity::where('activity_type', '=', 'Registration')->get(); if (!$activities) { return; } foreach ($activities as $activity) { parent::process($user, ['activity' => $activity]); } return true; }
/** * @see \DMA\Friends\Classes\ActivityTypeBase * * Process and determine if an award can be isued * based on a provided activity code * * @param User $user * A user model for which the activity should act upon * * @param array $params * An array of parameters for validating activities * * @return boolean * returns true if the process was successful */ public static function process(User $user, $params = []) { static $is_running = false; if (!$is_running) { $is_running = true; $activities = Activity::findActivityType('Points')->get(); foreach ($activities as $activity) { if ($user->activities->contains($activity->id)) { continue; } if ($user->points >= $activity->points) { parent::process($user, ['activity' => $activity]); } } $is_running = false; } return true; }