array( 'flag_friend' => array( 'approve' => array( 'runs when' => t("A user approves another's relationship request."), ), 'request' => array( 'runs when' => t("A user requested another's relationship."), ), 'deny' => array( 'runs when' => t("A user denies another's relationship request."), ), 'remove' => array( 'runs when' => t("A user cancels relationship with another user."), ), ), ), ); } /** * Implementation of hook_trigger_name(). */ function flag_friend_flag_friend($op, $friend, $user, $flag) { if (function_exists('_trigger_get_hook_aids')) { $aids = _trigger_get_hook_aids('flag_friend', $op); switch ($op) { // in this case, the users performing the operations are flipped case 'approve': case 'deny': $user->friend = $friend; $context = array( 'hook' => 'flag_friend', 'op' => $op, 'user' => $friend, 'flag_friend' => $user, 'flag' => $flag, ); break; // these are normal case 'request': case 'remove': case 'cancel': $friend->friend = $user; $context = array( 'hook' => 'flag_friend', 'op' => $op, 'user' => $user, 'flag_friend' => $friend, 'flag' => $flag, ); break; } if ($aids) { actions_do(array_keys($aids), $friend, $context); } } }