-
Notifications
You must be signed in to change notification settings - Fork 2.1k
OC_VCategories => OC\Tags. Public interface and getter in server container #4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
823b4cc
More trimming
tanghus e760343
Merge branch 'appframework-master' into vcategories_public
tanghus b0762ad
OC_VCategories=>OC\Tags. Public interface + getter in server container
tanghus 690e98d
Merge branch 'appframework-master' into vcategories_public
DeepDiver1975 76f8be3
fixing namespaces and rename hasCategory to hasTag
DeepDiver1975 314ca84
Updated method names and added a few more tests.
tanghus de81210
Add another test.
tanghus 0b4de84
Added more error checking in add()
tanghus 93258e1
Forgot to return false if add() didn't add anything.
tanghus 910a033
Use fetchOne() instead of numRows() when doing a COUNT(*).
tanghus d27416e
Moar tests.
tanghus 200e969
Merge pull request #4928 from owncloud/interfaces
tanghus 5ca181e
More trimming
tanghus 45f73fe
OC_VCategories=>OC\Tags. Public interface + getter in server container
tanghus b63acdb
fixing namespaces and rename hasCategory to hasTag
DeepDiver1975 1bbeb12
Updated method names and added a few more tests.
tanghus 8fab9ee
Add another test.
tanghus 8a02afd
Added more error checking in add()
tanghus be402fa
Forgot to return false if add() didn't add anything.
tanghus 60bff6c
Use fetchOne() instead of numRows() when doing a COUNT(*).
tanghus f022ea7
Moar tests.
tanghus 7cad510
Fix conflict
tanghus aaed871
Add factory class for the server container.
tanghus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
| /** | ||
| * ownCloud | ||
| * | ||
| * @author Thomas Tanghus | ||
| * @copyright 2013 Thomas Tanghus <thomas@tanghus.net> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
| * License as published by the Free Software Foundation; either | ||
| * version 3 of the License, or any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public | ||
| * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| /** | ||
| * Factory class creating instances of \OCP\ITags | ||
| * | ||
| * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or | ||
| * anything else that is either parsed from a vobject or that the user chooses | ||
| * to add. | ||
| * Tag names are not case-sensitive, but will be saved with the case they | ||
| * are entered in. If a user already has a tag 'family' for a type, and | ||
| * tries to add a tag named 'Family' it will be silently ignored. | ||
| */ | ||
|
|
||
| namespace OCP; | ||
|
|
||
| interface ITagManager { | ||
|
|
||
| /** | ||
| * Create a new \OCP\ITags instance and load tags from db. | ||
| * | ||
| * @see \OCP\ITags | ||
| * @param string $type The type identifier e.g. 'contact' or 'event'. | ||
| * @param array $defaultTags An array of default tags to be used if none are stored. | ||
| * @return \OCP\ITags | ||
| */ | ||
| public function load($type, $defaultTags=array()); | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| <?php | ||
| /** | ||
| * ownCloud | ||
| * | ||
| * @author Thomas Tanghus | ||
| * @copyright 2013 Thomas Tanghus <thomas@tanghus.net> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
| * License as published by the Free Software Foundation; either | ||
| * version 3 of the License, or any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public | ||
| * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCP; | ||
|
|
||
| // FIXME: Where should I put this? Or should it be implemented as a Listener? | ||
| \OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Tags', 'post_deleteUser'); | ||
|
|
||
| /** | ||
| * Class for easily tagging objects by their id | ||
| * | ||
| * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or | ||
| * anything else that is either parsed from a vobject or that the user chooses | ||
| * to add. | ||
| * Tag names are not case-sensitive, but will be saved with the case they | ||
| * are entered in. If a user already has a tag 'family' for a type, and | ||
| * tries to add a tag named 'Family' it will be silently ignored. | ||
| */ | ||
|
|
||
| interface ITags { | ||
|
|
||
| /** | ||
| * Check if any tags are saved for this type and user. | ||
| * | ||
| * @return boolean. | ||
| */ | ||
| public function isEmpty(); | ||
|
|
||
| /** | ||
| * Get the tags for a specific user. | ||
| * | ||
| * This returns an array with id/name maps: | ||
| * [ | ||
| * ['id' => 0, 'name' = 'First tag'], | ||
| * ['id' => 1, 'name' = 'Second tag'], | ||
| * ] | ||
| * | ||
| * @returns array | ||
| */ | ||
| public function getTags(); | ||
|
|
||
| /** | ||
| * Get the a list if items tagged with $tag. | ||
| * | ||
| * Throws an exception if the tag could not be found. | ||
| * | ||
| * @param string|integer $tag Tag id or name. | ||
| * @return array An array of object ids or false on error. | ||
| */ | ||
| public function getIdsForTag($tag); | ||
|
|
||
| /** | ||
| * Checks whether a tag is already saved. | ||
| * | ||
| * @param string $name The name to check for. | ||
| * @return bool | ||
| */ | ||
| public function hasTag($name); | ||
|
|
||
| /** | ||
| * Add a new tag. | ||
| * | ||
| * @param string $name A string with a name of the tag | ||
| * @return int the id of the added tag or false if it already exists. | ||
| */ | ||
| public function add($name); | ||
|
|
||
| /** | ||
| * Rename tag. | ||
| * | ||
| * @param string $from The name of the existing tag | ||
| * @param string $to The new name of the tag. | ||
| * @return bool | ||
| */ | ||
| public function rename($from, $to); | ||
|
|
||
| /** | ||
| * Add a list of new tags. | ||
| * | ||
| * @param string[] $names A string with a name or an array of strings containing | ||
| * the name(s) of the to add. | ||
| * @param bool $sync When true, save the tags | ||
| * @param int|null $id int Optional object id to add to this|these tag(s) | ||
| * @return bool Returns false on error. | ||
| */ | ||
| public function addMultiple($names, $sync=false, $id = null); | ||
|
|
||
| /** | ||
| * Delete tag/object relations from the db | ||
| * | ||
| * @param array $ids The ids of the objects | ||
| * @return boolean Returns false on error. | ||
| */ | ||
| public function purgeObjects(array $ids); | ||
|
|
||
| /** | ||
| * Get favorites for an object type | ||
| * | ||
| * @return array An array of object ids. | ||
| */ | ||
| public function getFavorites(); | ||
|
|
||
| /** | ||
| * Add an object to favorites | ||
| * | ||
| * @param int $objid The id of the object | ||
| * @return boolean | ||
| */ | ||
| public function addToFavorites($objid); | ||
|
|
||
| /** | ||
| * Remove an object from favorites | ||
| * | ||
| * @param int $objid The id of the object | ||
| * @return boolean | ||
| */ | ||
| public function removeFromFavorites($objid); | ||
|
|
||
| /** | ||
| * Creates a tag/object relation. | ||
| * | ||
| * @param int $objid The id of the object | ||
| * @param int|string $tag The id or name of the tag | ||
| * @return boolean Returns false on database error. | ||
| */ | ||
| public function tagAs($objid, $tag); | ||
|
|
||
| /** | ||
| * Delete single tag/object relation from the db | ||
| * | ||
| * @param int $objid The id of the object | ||
| * @param int|string $tag The id or name of the tag | ||
| * @return boolean | ||
| */ | ||
| public function unTag($objid, $tag); | ||
|
|
||
| /** | ||
| * Delete tags from the | ||
| * | ||
| * @param string[] $names An array of tags to delete | ||
| * @return bool Returns false on error | ||
| */ | ||
| public function delete($names); | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <?php | ||
| /** | ||
| * ownCloud | ||
| * | ||
| * @author Thomas Tanghus | ||
| * @copyright 2013 Thomas Tanghus <thomas@tanghus.net> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
| * License as published by the Free Software Foundation; either | ||
| * version 3 of the License, or any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU AFFERO GENERAL PUBLIC LICENSE for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public | ||
| * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| /** | ||
| * Factory class creating instances of \OCP\ITags | ||
| * | ||
| * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or | ||
| * anything else that is either parsed from a vobject or that the user chooses | ||
| * to add. | ||
| * Tag names are not case-sensitive, but will be saved with the case they | ||
| * are entered in. If a user already has a tag 'family' for a type, and | ||
| * tries to add a tag named 'Family' it will be silently ignored. | ||
| */ | ||
|
|
||
| namespace OC; | ||
|
|
||
| class TagManager implements \OCP\ITagManager { | ||
|
|
||
| /** | ||
| * User | ||
| * | ||
| * @var string | ||
| */ | ||
| private $user = null; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param string $user The user whos data the object will operate on. | ||
| */ | ||
| public function __construct($user) { | ||
|
|
||
| $this->user = $user; | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Create a new \OCP\ITags instance and load tags from db. | ||
| * | ||
| * @see \OCP\ITags | ||
| * @param string $type The type identifier e.g. 'contact' or 'event'. | ||
| * @param array $defaultTags An array of default tags to be used if none are stored. | ||
| * @return \OCP\ITags | ||
| */ | ||
| public function load($type, $defaultTags=array()) { | ||
| return new Tags($this->user, $type, $defaultTags); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@icewind1991 What is the correct way to do this with the new hooks system?