tagmanager.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Thomas Tanghus
  6. * @copyright 2013 Thomas Tanghus <thomas@tanghus.net>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Factory class creating instances of \OCP\ITags
  24. *
  25. * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
  26. * anything else that is either parsed from a vobject or that the user chooses
  27. * to add.
  28. * Tag names are not case-sensitive, but will be saved with the case they
  29. * are entered in. If a user already has a tag 'family' for a type, and
  30. * tries to add a tag named 'Family' it will be silently ignored.
  31. */
  32. namespace OC;
  33. class TagManager implements \OCP\ITagManager {
  34. /**
  35. * User
  36. *
  37. * @var string
  38. */
  39. private $user = null;
  40. /**
  41. * Constructor.
  42. *
  43. * @param string $user The user whos data the object will operate on.
  44. */
  45. public function __construct($user) {
  46. $this->user = $user;
  47. }
  48. /**
  49. * Create a new \OCP\ITags instance and load tags from db.
  50. *
  51. * @see \OCP\ITags
  52. * @param string $type The type identifier e.g. 'contact' or 'event'.
  53. * @param array $defaultTags An array of default tags to be used if none are stored.
  54. * @return \OCP\ITags
  55. */
  56. public function load($type, $defaultTags=array()) {
  57. return new Tags($this->user, $type, $defaultTags);
  58. }
  59. }