Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsDirNode.cpp
Go to the documentation of this file.
1 
14 #include "WsDirNode.h"
15 #include <Include/WsGlobalConfig.h>
16 
17 WsDirNode::WsDirNode(const path& fullPath, const path& rootPath):
18  WsNode(fullPath, rootPath),
19  m_resources(0)
20 {
21 }
22 
24  WsNode(),
25  m_resources(0)
26 {
27 }
28 
30 {
31  if (m_resources != 0)
32  delete m_resources;
33  m_resources = 0;
34 }
35 
36 set<string> WsDirNode::getGroups()
37 {
38  return m_properties.get()->getGroups();
39 }
40 
41 bool WsDirNode::isAllowed(const set<string>& gids)
42 {
44  if (props->get("global", "public_site", "false") == "true") {
45  /* Public site access granted */
46  return true;
47  }
48  //lock the parent because we are using it to avoid free
49  NodePtr parent = m_parent.lock();
50  if ((m_properties.get() == 0 || m_properties.get()->getGroups().size() == 0) && parent.get() != 0) {
51  /* Check if inherit from parent is set to true in Global configuration */
52  if (props->get("global", "inherit_rights_from_parent", "false") == "true") {
53  /* Set to true, so Get right from parent */
54  return parent.get()->isAllowed(gids);
55  /* Check if inherit from parent set to true in Node conf */
56  } else if (m_properties.get()->get("global", "inherit_rights_from_parent", "false") == "true") {
57  if (!parent.get() == 0) {
58  /* get right from parent if not null */
59  return parent.get()->isAllowed(gids);
60  } else return false;
61  } else
62  return false;
63  } else {
64  /* We need the rights from the current node */
65  return m_properties.get()->isAllowed(gids);
66  }
67 }
68 
69 vector<string> WsDirNode::getResource(ResourceType t, bool recurse)
70 {
71 }
72 
74 {
75  m_resources = resources;
76 }
77 
79 {
80  string s = m_properties.get()->get("global", "in_parent", "true");
81  if (s == "true")
82  return true;
83  return false;
84 }
85 
87 {
88  return true;
89 }
90 
92 {
93  return false;
94 }
95 
96 const uintmax_t WsDirNode::getSize()
97 {
98  if (WsGlobalProperties::instance()->get("global", "dir_size", "true") == "true")
99  if (getAll().size() == 0)
100  return m_size;
101  return getAll().size();
102 }
std::vector< std::string > getResource(ResourceType t, bool recurse=false)
get the resource of a node Not implemented yet
Definition: WsDirNode.cpp:69
boost::shared_ptr< WsAbstractNode > NodePtr
Global properties class.
bool isDirectory()
return true
Definition: WsDirNode.cpp:86
A dir node.
Represents a node on disk.
Definition: WsNode.h:27
bool isAllowed(const std::set< string > &gids)
return true if one of the groups contained in gids has access to the node false otherwise If the node...
Definition: WsDirNode.cpp:41
bool getDisplayInParent()
Definition: WsDirNode.cpp:78
const vector< NodePtr > getAll()
combine the vector of files and directories into a single one
Definition: WsNode.cpp:130
set< string > getGroups()
returns the list of the groups allowed to access this node
Definition: WsDirNode.cpp:36
NodePropertiesPtr m_properties
Definition: WsNode.h:218
WsNodeResources * m_resources
Definition: WsDirNode.h:80
void setResources(WsNodeResources *resources)
Definition: WsDirNode.cpp:73
std::string get(const std::string &section, const std::string &id, const std::string &def)
const uintmax_t getSize()
returns the file size. If the Node is a WsDirNode, 0 is returned. if the global property dir_size is ...
Definition: WsDirNode.cpp:96
bool isRegularFile()
return false
Definition: WsDirNode.cpp:91
static WsGlobalProperties * instance()
uintmax_t m_size
Resources of a WsNode.