ossn.lib.annotations.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 annotation
14  *
15  * @param int $guid Guid of annotation
16  *
17  * @return object
18  */
19 function ossn_get_annotation($id){
20  if(!empty($id)){
21  $annotation = new OssnAnnotation;
22  $annotation->annotation_id = $id;
23  $annotation = $annotation->getAnnotationById();
24  if($annotation){
25  return $annotation;
26  }
27  }
28  return false;
29 }
30 /**
31  * Get entities of annotation
32  *
33  * @param object $annotation Must be valid annotation object
34  * @param array $params Options
35  *
36  * @return object
37  */
38 function ossn_get_annotation_entities($annotation, $params = array()){
39  if(isset($annotation->id)){
40  $vars['owner_guid'] = $annotation->id;
41  $vars['type'] = 'annotation';
42  $vars = array_merge($vars, $params);
43 
44  return ossn_get_entities($vars);
45  }
46  return false;
47 }
48 /**
49  * Get Annotations
50  *
51  * @param array $params Options
52  * @param int $params['owner_guid'] annotation owner guid
53  * @param string $params['type'] annotation type
54  * @param string $params['subtype'] annotation 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_annotations(array $params){
61  if(isset($params['owner_guid']) && !empty($params['owner_guid'])){
62 
63  $annotation = new OssnAnnotation;
64  $annotation->owner_guid = $params['owner_guid'];
65 
66  if(isset($params['type']) && !empty($params['type'])){
67  $annotation->type = $params['type'];
68  }
69  if(isset($params['subtype']) && !empty($params['subtype'])){
70  $annotation->subtype = $params['subtype'];
71  }
72  if(isset($params['limit']) && !empty($params['limit'])){
73  $annotation->limit = $params['limit'];
74  }
75  if(isset($params['order_by']) && !empty($params['order_by'])){
76  $annotation->order_by = $params['order_by'];
77  }
78 
79  $annotations = $annotation->getAnnotationsByOwner();
80  if($annotations){
81  return $annotations;
82  }
83  }
84  return false;
85 }
86 /**
87  * Get annotations by types
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_annotations_by_type(array $params){
98  if(isset($params['type']) && !empty($params['type'])){
99 
100  $annotation = new OssnAnnotation;
101  $annotation->type = $params['type'];
102 
103  if(isset($params['limit']) && !empty($params['limit'])){
104  $annotation->limit = $params['limit'];
105  }
106  if(isset($params['order_by']) && !empty($params['order_by'])){
107  $annotation->order_by = $params['order_by'];
108  }
109 
110  $annotations = $annotation->getAnnotationsByType();
111  if($annotations){
112  return $annotations;
113  }
114  }
115  return false;
116 }