/** * Get all site settings; * * @return object; */ public function getAllSettings() { $params['from'] = 'ossn_site_settings'; $this->settings = $this->select($params, true); foreach ($this->settings as $setting) { $result[$setting->name] = $setting->value; } return arrayObject($result, get_class($this)); }
/** * Get spilted array or object; * * @note = (object may changed to arrays) * * @return bool; */ public function getItem() { $item = $this->getItems(); if (empty($item)) { $item = array(); } $offset = (int) input('offset'); if (empty($offset)) { $offset = 1; } if (array_key_exists($offset, $item)) { if (!empty($this->item_class)) { return arrayObject($item[$offset], $this->item_class); } return $item[$offset]; } return false; }
/** * Get user with its entities. * * @return object; */ public function getUser() { self::initAttributes(); if (!empty($this->email)) { $params['from'] = 'kullanicilar'; $params['wheres'] = array("email='{$this->email}'"); $user = $this->OssnDatabase->select($params); } if (empty($user) && !empty($this->username)) { $params['from'] = 'kullanicilar'; $params['wheres'] = array("username='******'"); $user = $this->OssnDatabase->select($params); } if (empty($user) && !empty($this->guid)) { $params['from'] = 'kullanicilar'; $params['wheres'] = array("guid='{$this->guid}'"); $user = $this->OssnDatabase->select($params); } if (!$user) { return false; } $user->fullname = "{$user->first_name} {$user->last_name}"; $this->owner_guid = $user->guid; $this->type = 'user'; $entities = $this->get_entities(); if (empty($entities)) { return arrayObject($user, get_class($this)); } foreach ($entities as $entity) { $fields[$entity->subtype] = $entity->value; } $data = array_merge(get_object_vars($user), $fields); return arrayObject($data, get_class($this)); }
<?php require __DIR__ . "/bootstrap.php"; $nav = array(); $jsons = glob(ROOT . "/category/*/category.json"); foreach ($jsons as $file) { $category = json_decode(file_get_contents($file)); if (isset($category->nav->position)) { if (preg_match('/category\\/(.+)\\//', $file, $m)) { $nav[$category->nav->position] = arrayObject(array('icon' => $category->nav->icon, 'title' => $category->title, 'link' => $m[1])); } } } ksort($nav); tpl('common/header'); ?> <header class="lp" style="background-image: url(<? sitelink("category/bg-hero.png") ?>)"> <?php tpl('common/logo'); ?> <?php tpl('common/menu-toggle-button'); ?> <?php tpl('common/nav'); ?> <div class="container"> <div class="row">
/** * Get album by id * * @params = $album_id Id of album * * @return object->album object->photos; */ public function GetAlbum($album_id) { if (!empty($album_id)) { $this->object_guid = $album_id; $this->album = $this->getObjectbyId(); if (!empty($this->album)) { $this->photos = new OssnPhotos(); $this->album = array('album' => $this->album, 'photos' => $this->photos->GetPhotos($album_id)); return arrayObject($this->album, get_class($this)); } } }
<?php /** * Open Source Social Network * * @packageOpen Source Social Network * @author Open Social Website Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ ossn_trigger_callback('comment', 'load', $params['comment']); $OssnLikes = new OssnLikes(); $comment = arrayObject($params['comment'], 'OssnWall'); $user = ossn_user_by_guid($comment->owner_guid); if ($comment->type == 'comments:post' || $comment->type == 'comments:entity') { $type = 'annotation'; } $likes_total = $OssnLikes->CountLikes($comment->id, $type); $datalikes = ''; if ($likes_total > 0) { $datalikes = $likes_total; $likes_total = '<span class="dot-likes">.</span><div class="ossn-like-icon"></div>' . $likes_total; } ?> <div class="comments-item" id="comments-item-<?php echo $comment->id; ?> "> <div class="ossn-comment-menu" onclick="Ossn.CommentMenu(this);"> <?php
/** * Get system directory paths * * @return object */ function ossn_route() { $root = str_replace("\\", "/", dirname(dirname(__FILE__))); $defaults = array('www' => "{$root}/", 'libs' => "{$root}/libraries/", 'classes' => "{$root}/classes/", 'actions' => "{$root}/actions/", 'locale' => "{$root}/locale/", 'sys' => "{$root}/system/", 'configs' => "{$root}/configurations/", 'themes' => "{$root}/themes/", 'pages' => "{$root}/pages/", 'com' => "{$root}/components/", 'admin' => "{$root}/admin/", 'forms' => "{$root}/forms/", 'upgrade' => "{$root}/upgrade/", 'cache' => "{$root}/cache/", 'js' => "{$root}/javascripts/", 'system' => "{$root}/system/", 'components' => "{$root}/components"); return arrayObject($defaults); }
/** * Get annotation by subject_guid; * * @requires : $object->(subject_guid, types(optional)) * * @return annotations; */ public function getAnnotationBySubject() { self::initAttributes(); if (!empty($this->type)) { $type = "AND type='{$this->type}'"; } $params['from'] = 'yorumlar'; $params['wheres'] = array("subject_guid='{$this->subject_guid}' {$type}"); $params['order_by'] = $this->order_by; $annotations = $this->OssnDatabase->select($params, true); unset($this->order_by); if ($annotations) { foreach ($annotations as $annotation) { $this->owner_guid = $annotation->id; $this->type = 'annotation'; $this->entities = $this->get_entities(); if ($this->entities) { foreach ($this->entities as $entity) { $entities[$entity->subtype] = $entity->value; } $data[] = array_merge(get_object_vars($annotation), $entities); //should not merge with other objects unset($entities); } } return arrayObject($data, get_class($this)); } return false; }
/** * Get object by object guid; * * @requires : (object)->(object_guid) * * @return (object); */ public function getObjectById() { self::initAttributes(); if (empty($this->object_guid)) { return false; } $params['from'] = 'ossn_object'; $params['wheres'] = array("guid='{$this->object_guid}'"); $params['order_by'] = $this->order_by; $object = $this->OssnDatabase->select($params); $this->owner_guid = $object->guid; $this->subtype = ''; $this->type = 'object'; $this->entities = $this->get_entities(); if ($this->entities) { foreach ($this->entities as $entity) { $fields[$entity->subtype] = $entity->value; } $data = array_merge(get_object_vars($object), $fields); if (!empty($fields)) { return arrayObject($data, get_class($this)); } } if (empty($fields)) { return arrayObject($object, get_class($this)); } return false; }
/** * Search entities * * @param array $params A valid options in format: * 'search_type' => true(default) to performs matching on a per-character basis * false for performs matching on exact value. * 'subtype' => Valid entity subtype * 'type' => Valid entity type * 'value' => Value which you want to search * 'owner_guid' => A valid owner guid, which results integer value * 'limit' => Result limit default, Default is 20 values * 'order_by' => To show result in sepcific order. There is no default order. * * reutrn array|false; * */ public function searchEntities(array $params = array()) { self::initAttributes(); //set default values $default = array('search_type' => true, 'subtype' => false, 'type' => false, 'value' => false, 'owner_guid' => false, 'limit' => false, 'order_by' => false, 'offset' => 1, 'page_limit' => ossn_call_hook('pagination', 'per_page', false, 10), 'count' => false); $options = array_merge($default, $params); $wheres = array(); //prepare limit $limit = $options['limit']; //validate offset values if ($options['limit'] !== false && $options['limit'] !== 0 && $options['page_limit'] !== 0) { $offset_vals = ceil($options['limit'] / $options['page_limit']); $offset_vals = abs($offset_vals); $offset_vals = range(1, $offset_vals); if (!in_array($options['offset'], $offset_vals)) { return false; } } //get only required result, don't bust your server memory $getlimit = $this->generateLimit($options['limit'], $options['page_limit'], $options['offset']); if ($getlimit) { $options['limit'] = $getlimit; } //search entities if (!empty($options['subtype'])) { $wheres[] = "e.subtype='{$options['subtype']}'"; } if (!empty($options['type'])) { $wheres[] = "e.type='{$options['type']}'"; } if (!empty($options['owner_guid'])) { $wheres[] = "e.owner_guid ='{$options['owner_guid']}'"; } if (!empty($options['value']) && $options['search_type'] === true) { $wheres[] = "emd.value LIKE '%{$options['value']}%'"; } elseif (!empty($options['value']) && $options['search_type'] === false) { $wheres[] = "emd.value = '{$options['value']}'"; } $params = array(); $params['from'] = 'ossn_entities as e'; $params['params'] = array('e.guid', 'e.time_created', 'e.time_updated', 'e.permission', 'e.active', 'e.owner_guid', 'emd.value', 'e.type', 'e.subtype'); $params['joins'] = "JOIN ossn_entities_metadata as emd ON e.guid=emd.guid"; $params['wheres'] = array($this->constructWheres($wheres)); $params['order_by'] = $options['order_by']; $params['limit'] = $options['limit']; if (!$options['order_by']) { $params['order_by'] = "e.guid ASC"; } $this->get = $this->select($params, true); //prepare count data; if ($options['count'] === true) { unset($params['params']); unset($params['limit']); $count = array(); $count['params'] = array("count(*) as total"); $count = array_merge($params, $count); return $this->select($count)->total; } if ($this->get) { foreach ($this->get as $entity) { //prepare entities for display $entities[] = arrayObject($entity, $this->types[$this->type]); } return $entities; } return false; }
<?php /** * Open Source Social Network * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ $friends = ossn_chat()->getOnlineFriends('', 10); $have = ''; if ($friends) { foreach ($friends as $friend) { $friend = arrayObject($friend, 'OssnUser'); $friend->fullname = $friend->first_name . ' ' . $friend->last_name; $vars['entity'] = $friend; $vars['icon'] = $friend->iconURL()->smaller; $have = 1; echo ossn_plugin_view('chat/friends-item', $vars); } } if ($have !== 1) { echo '<div class="ossn-chat-none">' . ossn_print('ossn:chat:no:friend:online') . '</div>'; }
/** * Get entities. * * @params = $this->type => entity type; * $this->subtype => entity subtype; * $this->owner_guid => guid of entity owner * $this->order_by = to sort the data in a recordset * * @return (object); */ public function get_entities() { self::initAttributes(); if (!empty($this->subtype)) { $this->subtype = "AND subtype='{$this->subtype}'"; } else { $this->subtype = ''; } $this->get = array('from' => 'kullaniciveriler', 'wheres' => array("owner_guid ='{$this->owner_guid}' AND type='{$this->type}' {$this->subtype}"), 'order_by' => $this->order_by); $this->get = $this->select($this->get, true); if ($this->get) { foreach ($this->get as $entites) { $metadata = $this->select(array('from' => 'kullanicivericerik', 'wheres' => array("guid='{$entites->guid}'"))); unset($metadata->id); $data = array_merge(get_object_vars($entites), get_object_vars($metadata)); $entity[] = arrayObject($data, $this->types[$this->type]); } return $entity; } return false; }
/** * Search annotation by its type, owner etc * * @param array $params A valid options in format: * @param string $params['search_type'] true(default) to performs matching on a per-character basis , false to performs matching on exact value. * @param string $params['type'] Valid annotation type * @param integer $params['subject_guid'] A valid subject guid, which results integer value * @param integer $params['owner_guid'] A valid owner guid, which results integer value * @param integer $params['limit'] Result limit default, Default is 20 values * @param string $params['order_by'] To show result in sepcific order. There is no default order. * * reutrn array|false; */ public function searchAnnotation(array $params = array()) { self::initAttributes(); if (empty($params)) { return false; } //prepare default attributes $default = array('search_type' => true, 'type' => false, 'owner_guid' => false, 'annotation_id' => false, 'subject_guid' => false, 'limit' => false, 'order_by' => false, 'offset' => input('offset', '', 1), 'page_limit' => ossn_call_hook('pagination', 'page_limit', false, 10), 'count' => false); $options = array_merge($default, $params); $wheres = array(); //validate offset values if ($options['limit'] !== false && $options['limit'] !== 0 && $options['page_limit'] !== 0) { $offset_vals = ceil($options['limit'] / $options['page_limit']); $offset_vals = abs($offset_vals); $offset_vals = range(1, $offset_vals); if (!in_array($options['offset'], $offset_vals)) { return false; } } //get only required result, don't bust your server memory $getlimit = $this->generateLimit($options['limit'], $options['page_limit'], $options['offset']); if ($getlimit) { $options['limit'] = $getlimit; } if (!empty($options['annotation_id'])) { $wheres[] = "a.id='{$options['annotation_id']}'"; } if (!empty($params['type'])) { $wheres[] = "a.type='{$options['type']}'"; $wheres[] = "e.subtype='{$options['type']}'"; } if (!empty($params['owner_guid'])) { $wheres[] = "a.owner_guid ='{$options['owner_guid']}'"; } if (!empty($params['subject_guid'])) { $wheres[] = "a.subject_guid ='{$options['subject_guid']}'"; } $wheres[] = "e.owner_guid=a.id"; $wheres[] = "e.type='annotation'"; $wheres[] = "emd.guid=e.guid"; //prepare search $params = array(); $params['from'] = 'ossn_annotations as a, ossn_entities as e , ossn_entities_metadata as emd'; $params['params'] = array('a.id', 'a.time_created', 'a.owner_guid', 'a.subject_guid', 'a.type', 'emd.value'); $params['wheres'] = array($this->constructWheres($wheres)); $params['order_by'] = $options['order_by']; $params['limit'] = $options['limit']; if (!$options['order_by']) { $params['order_by'] = "a.id ASC"; } $this->get = $this->select($params, true); //prepare count data; if ($options['count'] === true) { unset($params['params']); unset($params['limit']); $count = array(); $count['params'] = array("count(*) as total"); $count = array_merge($params, $count); return $this->select($count)->total; } if ($this->get) { foreach ($this->get as $annotation) { $merge = array($annotation->type => $annotation->value); //unset value unset($annotation->value); //get object vars and then merge into arrays $values = get_object_vars($annotation); $merge = array_merge($values, $merge); $this->owner_guid = $annotation->id; $this->type = 'annotation'; $this->order_by = ''; $entities = $this->get_entities(); if (!empty($entities)) { foreach ($entities as $entity) { $entities_data[$entity->subtype] = $entity->value; } $merge = array_merge($merge, $entities_data); unset($entities_data); } //construct object again $annotations[] = arrayObject($merge, get_class($this)); } return $annotations; } return false; }
/** * Get online users by gender * * @param string $gender Gender type * @param boolean $count true or false * @param integer $intervals Seconds * * @return object|false * @access public */ public function onlineByGender($gender = 'male', $count = false, $intervals = 100) { if (empty($gender) || !in_array($gender, $this->genderTypes())) { return false; } $time = time(); $params = array(); $wheres['wheres'] = array(); $params['joins'] = array(); $params['params'] = array('u.*, emd.value as gender'); $params['from'] = 'ossn_users as u'; $wheres['wheres'][] = "e.type='user'"; $wheres['wheres'][] = "e.subtype='gender'"; $wheres['wheres'][] = "emd.value='{$gender}'"; $wheres['wheres'][] = "last_activity > {$time} - {$intervals}"; $params['joins'][] = "JOIN ossn_entities as e ON e.owner_guid=u.guid"; $params['joins'][] = "JOIN ossn_entities_metadata as emd ON emd.guid=e.guid"; $params['wheres'] = array($this->constructWheres($wheres['wheres'])); if ($count) { $params['params'] = array("count(*) as total"); $count = $this->select($params); return $count->total; } $users = $this->select($params, true); if ($users) { foreach ($users as $user) { $result[] = arrayObject($user, get_class($this)); } return $result; } return false; }
/** * Get database settings * * @return object */ function ossn_database_settings() { global $Ossn; $defaults = array('host' => $Ossn->host, 'user' => $Ossn->user, 'password' => $Ossn->password, 'database' => $Ossn->database); return arrayObject($defaults); }
/** * Get recently chat list * * @params $to User 2 guid * * @return object */ public function recentChat($to) { $params['from'] = 'ossn_messages'; $params['wheres'] = array("message_to='{$to}' OR message_from='{$to}'"); $params['order_by'] = "id DESC"; $chats = $this->select($params, true); if (!$chats) { return false; } foreach ($chats as $rec) { $recents[$rec->message_from] = $rec->message_to; } foreach ($recents as $k => $v) { if ($k !== $to) { $message_get = $this->get($to, $k); if ($message_get) { $latest = get_object_vars($message_get); $latest = array_reverse($latest); $latest = arrayObject($latest[0]); $c = get_object_vars($latest); if (!empty($c)) { $users[] = $latest; } } } } if (isset($users)) { return $users; } return false; }
/** * Fetch the data from memory that is stored during execution; * * @params = $data = (ture if you want to fetch all data , or flase if only one row) * * @return bool; */ public function fetch($data = false) { if (isset($this->exe)) { if ($data !== true) { if ($fetch = $this->exe) { return arrayObject($fetch->fetch_assoc()); } } if ($data === true) { if ($fetch = $this->exe) { while ($all = $fetch->fetch_assoc()) { $alldata[] = arrayObject($all); } } if (isset($alldata) && !empty($alldata)) { return arrayObject($alldata); } } } return false; }
/** * Get component * * @note This id is not a package id * * @return integer|false; */ public function getbyName($name) { $params = array(); $params['from'] = 'ossn_components'; $params['where'] = array("com_id='{$name}'"); if ($data = $this->select($params)) { return arrayObject($data, get_class($this)); } return false; }
/** * Delete wall post if profile photo is deleted * * @return void; */ function ossn_profile_delete_photo_wallpost($callback, $type, $params) { $params['photo'] = arrayObject($params['photo']); if (isset($params['photo']->guid) && !empty($params['photo']->guid)) { $profile = new OssnProfile(); $profile->deletePhotoWallPost($params['photo']->guid); } }
/** * getFiles * Get owner files * * @param integer $object->owner_guid Guid of owner , the file belongs to * @param string $object->type Owner type * @param string $object->subtype File type * * @return object */ public function getFiles() { if (!empty($this->type) && !empty($this->owner_guid) && !empty($this->subtype)) { $this->filetype = "file:{$this->subtype}"; $this->subtype = preg_replace('/file:file:/i', 'file:', $this->filetype); $this->order_by = 'guid DESC'; return arrayObject($this->get_entities(), get_class($this)); } }
/** * Get ad entity * * @params $guid ad guid * * @return object; * @access public */ function get_ad_entity($guid) { if ($guid < 1 || empty($guid)) { return false; } $resume = new OssnObject(); $resume->object_guid = $guid; $resume = $resume->getObjectById(); if (isset($resume->guid)) { return arrayObject($resume, 'OssnAds'); } return false; }
/** * Get Component Settings * * @params $component Component id * * @return array; */ public function getComSettings($component) { $this->entity = new OssnEntities(); $this->entity->type = 'component'; $this->entity->owner_guid = self::getComponentGuid($component); $settings = $this->entity->get_entities(); if (is_array($settings) && !empty($settings)) { foreach ($settings as $setting) { $comsettings[$setting->subtype] = $setting->value; } return arrayObject($comsettings, 'OssnComponents'); } return false; }
/** * Get object by object guid; * * Requires : $object->object_guid * * @return object; */ public function getObjectById() { self::initAttributes(); if (empty($this->object_guid)) { return false; } $params['from'] = 'ossn_object as o'; $params['wheres'] = array("o.guid='{$this->object_guid}'"); //there is no need to order as its will fetch only one record //$params['order_by'] = $this->order_by; unset($this->order_by); $object = $this->select($params); $this->owner_guid = $object->guid; $this->subtype = ''; $this->type = 'object'; $this->entities = $this->get_entities(); if ($this->entities && $object) { foreach ($this->entities as $entity) { $fields[$entity->subtype] = $entity->value; } $object_array = get_object_vars($object); if (is_array($object_array)) { $data = array_merge($object_array, $fields); } if (!empty($fields)) { return arrayObject($data, get_class($this)); } } if (empty($fields)) { return arrayObject($object, get_class($this)); } return false; }
/** * Get user groups (owned groups and groups user member of) * * @param object $user User entity * @return array */ public function getMyGroups($user) { self::initAttributes(); if (empty($user->guid) || !$user instanceof OssnUser) { return false; } $params = array(); $params['from'] = "ossn_relationships"; $params['wheres'] = array("relation_from='{$user->guid}'", "AND type='group:join'"); # zfix #177 old code throws PHP warnings if user is not member of any group if ($myGroups = $this->OssnDatabase->select($params, true)) { $myGroups = $this->OssnDatabase->select($params, true); $myGroups = get_object_vars($myGroups); foreach ($myGroups as $group) { $group = $this->getGroup($group->relation_to); if ($this->isMember($group->guid, $user->guid)) { $groupsEntities[] = arrayObject($group, get_class($this)); } } if (!empty($groupsEntities)) { return $groupsEntities; } } return false; }
/** * Get album by id * * @param integer $album_id Id of album * * @return void|object; */ public function GetAlbum($album_id) { if (!empty($album_id)) { $this->object_guid = $album_id; $this->album = $this->getObjectbyId(); if (!empty($this->album)) { $this->photos = new OssnPhotos(); //Photos limit issue, only 10 displays #523 $this->photos->page_limit = false; $this->album = array('album' => $this->album, 'photos' => $this->photos->GetPhotos($album_id)); return arrayObject($this->album, get_class($this)); } } }