ossn.lib.entities.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 Entity
14  *
15  * @param int $guid Guid of entity
16  *
17  * @return bool
18  */
19 function ossn_get_entity($guid){
20  if(!empty($guid)){
21  $entity = new OssnEntities;
22  $entity->entity_guid = $guid;
23  $entity = $entity->get_entity();
24  if($entity){
25  return $entity;
26  }
27  }
28  return false;
29 }
30 /**
31  * Ossn Get Entities
32  *
33  * @param array $params search data
34  * @param string $params['type'] Entity type
35  * @param string $params['subtype'] Entity subtype
36  * @param string $params['order_by'] Order by (ASC , DESC)
37  * @param string $params['limit'] Limit for data that need to be fetched
38  * @param string $params['owner_guid'] Owner guid
39  *
40  * @return bool
41  */
42 function ossn_get_entities(array $params){
43  $entities = new OssnEntities;
44  $entities = $entities->searchEntities($params);
45  if($entities){
46  return $entities;
47  }
48  return false;
49 }
50 /**
51  * Ossn Add Entity
52  *
53  * @param array $params search data
54  * @param string $params['type'] Entity type
55  * @param string $params['subtype'] Entity subtype
56  * @param string $params['value'] Entity Value
57  * @param string $params['owner_guid'] Owner guid
58  * @param string $params['permission'] Permission (access of entity)
59  * @param string $params['active'] 1 or 0 Does your entity is active?
60  *
61  * @return bool
62  */
63 function ossn_add_entity(array $params){
64  $entity = new OssnEntities;
65  $entity->type = $params['type'];
66  $entity->owner_guid = $params['owner_guid'];
67  $entity->value = $params['value'];
68 
69  if(isset($params['subtype'])){
70  $entity->subtype = $params['subtype'];
71  }
72  if(isset($params['permission'])){
73  $entity->entity_permission = $params['value'];
74  }
75  if(isset($params['active'])){
76  $entity->active = $params['active'];
77  }
78  if($entity->add()){
79  return true;
80  }
81  return false;
82 }
83 /**
84  * Ossn update entity
85  *
86  * @param int $guid Entity guid
87  * @param string $value Entity new value
88  *
89  * @return bool
90  */
91 function ossn_update_entity($guid, $value){
92  $update = new OssnEntities;
93  $update->guid = $guid;
94  $update->value = $value;
95 
96  return $update->updateEntity();
97 }