ossn.lib.objects.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Open Source Social Network
4  *
5  * @package (Informatikon.com).ossn
6  * @author OSSN Core Team <[email protected]>
7  * @copyright 2014 iNFORMATIKON TECHNOLOGIES
8  * @license General Public Licence http://www.opensource-socialnetwork.org/licence
9  * @link http://www.opensource-socialnetwork.org/licence
10  */
11 
12 /**
13  * Ossn get object
14  *
15  * @param int $guid Guid of object
16  *
17  * @return object
18  */
19 function ossn_get_object($guid){
20  if(!empty($guid)){
21  $object = new OssnObject;
22  $object->object_guid = $guid;
23  $object = $object->getObjectById();
24  if($object){
25  return $object;
26  }
27  }
28  return false;
29 }
30 /**
31  * Get entities of object
32  *
33  * @param object $object Must be valid object
34  * @param array $params Options
35  *
36  * @return object
37  */
38 function ossn_get_object_entities($object, $params = array()){
39  if(isset($object->guid)){
40  $vars['owner_guid'] = $object->guid;
41  $vars['type'] = 'object';
42  $vars = array_merge($vars, $params);
43 
44  return ossn_get_entities($vars);
45  }
46  return false;
47 }
48 /**
49  * Get objects
50  *
51  * @param array $params Options
52  * @param int $params['owner_guid'] object owner guid
53  * @param string $params['type'] object type
54  * @param string $params['subtype'] object subtype
55  * @param string $params['limit'] limit of fetch data
56  * @param string $params['order_by'] order fetch data
57  *
58  * @return object
59  */
60 function ossn_get_objects(array $params){
61  if(isset($params['owner_guid']) && !empty($params['owner_guid'])){
62 
63  $object = new OssnObject;
64  $object->owner_guid = $params['owner_guid'];
65 
66  if(isset($params['type']) && !empty($params['type'])){
67  $object->type = $params['type'];
68  }
69  if(isset($params['subtype']) && !empty($params['subtype'])){
70  $object->subtype = $params['subtype'];
71  }
72  if(isset($params['limit']) && !empty($params['limit'])){
73  $object->limit = $params['limit'];
74  }
75  if(isset($params['order_by']) && !empty($params['order_by'])){
76  $object->order_by = $params['order_by'];
77  }
78 
79  $objects = $object->getObjectByOwner();
80  if($objects){
81  return $objects;
82  }
83  }
84  return false;
85 }
86 /**
87  * Get objects by type
88  *
89  * @param array $params Options
90  * @param string $params['type'] object type
91  * @param string $params['subtype'] object subtype
92  * @param string $params['limit'] limit of fetch data
93  * @param string $params['order_by'] order fetch data
94  *
95  * @return object
96  */
97 function ossn_get_objects_by_type(array $params){
98  if(isset($params['type']) && !empty($params['type'])){
99 
100  $object = new OssnObject;
101  $object->type = $params['type'];
102 
103  if(isset($params['subtype']) && !empty($params['subtype'])){
104  $object->subtype = $params['subtype'];
105  }
106  if(isset($params['limit']) && !empty($params['limit'])){
107  $object->limit = $params['limit'];
108  }
109  if(isset($params['order_by']) && !empty($params['order_by'])){
110  $object->order_by = $params['order_by'];
111  }
112 
113  $objects = $object->getObjectsByTypes();
114  if($objects){
115  return $objects;
116  }
117  }
118  return false;
119 }