$ERRORS[] = 'Invalid user specified.'; } elseif ($User->getUserName() == $other_user->getUserName()) { $ERRORS[] = 'You cannot give an item to yourself.'; } if ($item != null && $other_user != null) { if ($item->getUniqueItem() == 'Y') { if ($other_user->hasItem($item->getItemTypeId()) == true) { $ERRORS[] = 'That user already has this unique item!'; } elseif ($quantity > 1) { // This case should never come up... $ERRORS[] = 'This is a unique item; you cannot give the user two!'; } } } // end item and user exist if (sizeof($ERRORS) > 0) { draw_errors($ERRORS); } else { $word = $item->getItemName(); $item->giveItem($other_user, $quantity); if ($quantity > 1) { $word = English_Inflector::pluralize($word); } $_SESSION['item_notice'] = "You have given <strong>{$quantity} {$word}</strong> to {$other_user->getUserName()}."; redirect('items'); } // end DO IT break; // end give_process } // end switch
/** * Turns a quantity for the item into appropriately-pluralized text. * * 20 apples in total, using 1 => the apple * 20 apples in total, using 2 => 20 apples * 20 apples in total, using 20 => all 20 apples * 2 apple in total, using 1 => your apple * * @param mixed $quantity * @return string **/ public function makeActionText($quantity) { $word = ''; if ($quantity == $this->getQuantity()) { // Figure it out here so you have the methods available. if ($quantity > 1) { $word = "all <strong>{$quantity} {$this->getInflectedItemName()}</strong>"; } else { $word = "your <strong>{$this->getItemName()}</strong>"; } } else { if ($quantity > 1) { $plural = English_Inflector::pluralize($this->getItemName()); $word = "<strong>{$quantity} {$plural}</strong>"; } else { $word = "the <strong>{$this->getItemName()}</strong>"; } } // end not all return $word; }