Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsUser.h
Go to the documentation of this file.
1 
13 #ifndef USER_H__
14 #define USER_H__
15 
16 #include <iostream>
17 #include <set>
18 
21 #include <Logger/WsLogger.h>
22 #ifdef HAS_DAEMON
24 #endif //HAS_DAEMON
25 
26 
27 
33 class WsUser {
34 public :
35  enum NodeType { File, Directory };
36 
44  WsUser(const std::string& strUid, const std::string& pass = "", const std::string& ip = "");
45 
49  ~WsUser();
50 
57  int load();
58 
62  const std::string getHomePage();
63 
69 
73  const std::string getRootPath();
74 
79  const std::string& getSurname() const;
80 
85  const std::string& getFirstName() const;
86 
91  const std::string& getEmail() const;
92 
93  const std::string& getUid() const;
94 
99  int getLock(const std::string& path);
100 
105  int putLock(const std::string& path);
106 
114  int isLocked(const std::string& path, std::string& uid);
115 
122  int getPermissions(const std::string& p);
123 
129  const WsNodeProperties* getProperties(const std::string& p);
130 
141  std::string getProperty(const std::string& path, const std::string& section, const string& attr, const std::string& def);
148  std::vector<WsResultItem> getSearchResults(const std::string& terms);
149 
150  /*
151  * @brief returns all the possible groups
152  */
153  std::set<std::string> getAllGroups();
154 
161  int saveProperties(WsNodeProperties* props, const std::string& path);
162 
171  int saveProperty(const std::string& path, const std::string& section, const std::string& attr, const std::string& val);
172 
180  int createNode(const string& path, NodeType type);
181 
188  int deleteNode(const string& path);
189 
197  int renameNode(const string& path, const string& newPath);
198 
199 
208  int writeFile(const std::string path, const std::string& text);
209 
213  bool isAdministrator();
214 
218  bool isEditor();
219 
224  std::vector<std::string> getTemplatesList(const std::string& path);
225 
226 private:
227 
228  std::string cleanPath(const std::string& path);
229 
234 
239  std::string m_uid;
240  std::string m_pass;
241  std::string m_ip;
243 };
244 #endif
245 
int isLocked(const std::string &path, std::string &uid)
check is the path is already locked
Definition: WsUser.cpp:135
boost::shared_ptr< WsAbstractNode > NodePtr
std::string m_ip
Definition: WsUser.h:241
std::string cleanPath(const std::string &path)
Definition: WsUser.cpp:194
~WsUser()
Destructor.
Definition: WsUser.cpp:14
int getPermissions(const std::string &p)
return the permissions on specific node
Definition: WsUser.cpp:81
int saveProperty(const std::string &path, const std::string &section, const std::string &attr, const std::string &val)
sets one property of the node and save it on disk.
Definition: WsUser.cpp:99
std::string getProperty(const std::string &path, const std::string &section, const string &attr, const std::string &def)
returns one property of a node If the property does not exist, a empty string is returned.
Definition: WsUser.cpp:91
Global properties class.
int saveProperties(WsNodeProperties *props, const std::string &path)
save the properties of the node on disk. The user must have access and edit rights for the node...
Definition: WsUser.cpp:156
Properties of a WsNode.
WsAbstractFsClient * m_client
this will be an instance of WsFsTreeClient if not using daemon or WsFsDaemonClient if using daemon ...
Definition: WsUser.h:233
int putLock(const std::string &path)
releases the lock for the path.
Definition: WsUser.cpp:130
std::vector< WsResultItem > getSearchResults(const std::string &terms)
search for all matching results of terms using WsSearch class
Definition: WsUser.cpp:146
std::vector< std::string > getTemplatesList(const std::string &path)
return all the templates contained in a directory and parents If two templates have the same name...
Definition: WsUser.cpp:189
std::string m_pass
Definition: WsUser.h:240
int writeFile(const std::string path, const std::string &text)
writes the text to the file
Definition: WsUser.cpp:161
WsUser(const std::string &strUid, const std::string &pass="", const std::string &ip="")
Constructor.
Definition: WsUser.cpp:7
Interacts directly with the menuTree and the fsTree.
const std::string getHomePage()
return the home page
Definition: WsUser.cpp:140
Interface that provides differents methods for accessing the FsTree as well as other features...
Definition: WsUser.h:33
std::set< std::string > getAllGroups()
Definition: WsUser.cpp:151
Interacts with the menuTree and FsTree via the daemon.
int load()
Load infos of the user.
Definition: WsUser.cpp:22
const std::string & getEmail() const
return the email of the person
Definition: WsUser.cpp:71
bool isEditor()
Definition: WsUser.cpp:179
const std::string & getFirstName() const
return the name of the person
Definition: WsUser.cpp:66
int m_isDaemon
Use daemon or no.
Definition: WsUser.h:238
std::string m_uid
Definition: WsUser.h:239
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
Definition: WsUser.cpp:55
const std::string & getSurname() const
return the surname of the person
Definition: WsUser.cpp:61
int createNode(const string &path, NodeType type)
create a directory or File. If the node is a WsDirNode than it will be only accessible to the Admin a...
Definition: WsUser.cpp:105
Abstract Interface between the WsUser class and the operation on the tree.
const WsNodeProperties * getProperties(const std::string &p)
returns the properties of a node
Definition: WsUser.cpp:86
bool isAdministrator()
Definition: WsUser.cpp:184
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
Definition: WsUser.cpp:50
int renameNode(const string &path, const string &newPath)
renames a node In case of a WsDirNode, all the contents of the directory and the directory will be mo...
Definition: WsUser.cpp:120
NodeType
Definition: WsUser.h:35
const std::string & getUid() const
Definition: WsUser.cpp:76
int getLock(const std::string &path)
tries to acquire the lock for the path. @ return ErrorCode::Locked if the lock cannot be aquired beca...
Definition: WsUser.cpp:125
int deleteNode(const string &path)
delete a node. The user must be an Admin on editor to remove the node In case of a WsDirNode...
Definition: WsUser.cpp:115
WsGlobalProperties * m_conf
Definition: WsUser.h:242