/** * Load action. * * @param string $action The name of the action * * @return void */ function ossn_action($action) { global $Ossn; if (isset($Ossn->action) && array_key_exists($action, $Ossn->action)) { if (is_file($Ossn->action[$action])) { $params['action'] = $action; ossn_trigger_callback('action', 'load', $params); include_once $Ossn->action[$action]; if (ossn_is_xhr()) { header('Content-Type: application/json'); $vars = array(); if (isset($_SESSION['ossn_messages']['success']) && !empty($_SESSION['ossn_messages']['success'])) { $vars['success'] = $_SESSION['ossn_messages']['success']; } //danger = error bootstrap if (isset($_SESSION['ossn_messages']['danger']) && !empty($_SESSION['ossn_messages']['danger'])) { $vars['error'] = $_SESSION['ossn_messages']['danger']; } if (isset($Ossn->redirect) && !empty($Ossn->redirect)) { $vars['redirect'] = $Ossn->redirect; } if (isset($Ossn->ajaxData) && !empty($Ossn->ajaxData)) { $vars['data'] = $Ossn->ajaxData; } unset($_SESSION['ossn_messages']); if (!empty($vars)) { echo json_encode($vars); } } } } else { ossn_error_page(); } }
/** * Like item * * @params $subject_id: Id of item which users liked * $guid: Guid of user * $type: Post or Entity * * @return bool */ public function Like($subject_id, $guid, $type = 'post') { if (empty($subject_id) || empty($guid) || empty($type)) { return false; } if ($type == 'annotation') { $annotation = new OssnAnnotation(); $annotation->annotation_id = $subject_id; $annotation = $annotation->getAnnotationById(); if (empty($annotation->id)) { return false; } } if ($type == 'post') { $post = new OssnObject(); $post->object_guid = $subject_id; $post = $post->getObjectById(); if (empty($post->time_created)) { return false; } } if (!$this->isLiked($subject_id, $guid, $type)) { $this->statement("INSERT INTO ossn_likes (`subject_id`, `guid`, `type`)\n\t\t\t\t\t VALUES('{$subject_id}', '{$guid}', '{$type}');"); if ($this->execute()) { $params['subject_guid'] = $subject_id; $params['owner_guid'] = $guid; $params['type'] = "like:{$type}"; ossn_trigger_callback('like', 'created', $params); return true; } } return false; }
function ossn_search_page($pages) { $page = $pages[0]; if (empty($page)) { $page = 'search'; } ossn_trigger_callback('page', 'load:search'); switch ($page) { case 'search': $query = input('q'); $type = input('type'); $title = ossn_print("search:result", array($query)); if (empty($type)) { $params['type'] = 'users'; } else { $params['type'] = $type; } $type = $params['type']; if (ossn_is_hook('search', "type:{$type}")) { $contents['contents'] = ossn_call_hook('search', "type:{$type}", array('q' => input('q'))); } $contents = array('content' => ossn_plugin_view('search/pages/search', $contents)); $content = ossn_set_page_layout('search', $contents); echo ossn_view_page($title, $content); break; default: ossn_error_page(); break; } }
/** * Add notification to database * * @param integer $subject_id Id of item which user comment * @param integer $poster_guid Guid of item poster * @param integer $item_guid: Guid of item * @param integer $notification_owner: Guid of notification owner * * @return boolean; */ public function add($type, $poster_guid, $subject_guid, $item_guid = NULL, $notification_owner = '') { if (!empty($type) && !empty($subject_guid) && !empty($poster_guid)) { $vars = array('type' => $type, 'poster_guid' => $poster_guid, 'owner_guid' => null, 'item_guid' => $item_guid, 'subject_guid' => $subject_guid, 'notification_owner' => $notification_owner); $this->notification = ossn_call_hook('notification:add', $type, $vars, false); if (!$this->notification) { return false; } //check if owner_guid is empty or owner_guid is same as poster_guid then return false, if (empty($this->notification['owner_guid']) || $this->notification['owner_guid'] == $this->notification['poster_guid']) { return false; } //check if notification owner is set then use it. if (!empty($this->notification['notification_owner'])) { $this->notification['owner_guid'] = $this->notification['notification_owner']; } $callback = array('type' => $this->notification['type'], 'poster_guid' => $this->notification['poster_guid'], 'owner_guid' => $this->notification['owner_guid'], 'subject_guid' => $this->notification['subject_guid'], 'item_guid' => $this->notification['item_guid']); if ($poster_guid == $guid_two) { $paricipates = $this->get_comments_participates($subject_guid); if ($type !== 'like:post' && $paricipates) { foreach ($paricipates as $partcipate) { $params['into'] = 'ossn_notifications'; $params['names'] = array('type', 'poster_guid', 'owner_guid', 'subject_guid', 'item_guid', 'time_created'); $params['values'] = array($this->notification['type'], $this->notification['poster_guid'], $partcipate, $this->notification['subject_guid'], $this->notification['item_guid'], time()); if ($partcipate !== $poster_guid) { ossn_trigger_callback('notification', 'add:participates', $callback); $this->insert($params); } } } return false; } $params['into'] = 'ossn_notifications'; $params['names'] = array('type', 'poster_guid', 'owner_guid', 'subject_guid', 'item_guid', 'time_created'); $params['values'] = array($this->notification['type'], $this->notification['poster_guid'], $this->notification['owner_guid'], $this->notification['subject_guid'], $this->notification['item_guid'], time()); if ($this->insert($params)) { //notify participates $paricipates = $this->get_comments_participates($subject_guid); if ($type !== 'like:post' && $paricipates) { foreach ($paricipates as $partcipate) { $params['into'] = 'ossn_notifications'; $params['names'] = array('type', 'poster_guid', 'owner_guid', 'subject_guid', 'item_guid', 'time_created'); $params['values'] = array($this->notification['type'], $this->notification['poster_guid'], $partcipate, $this->notification['subject_guid'], $this->notification['item_guid'], time()); if ($partcipate !== $poster_guid) { if ($this->insert($params)) { unset($callback['owner_guid']); $callback['owner_guid'] = $partcipate; ossn_trigger_callback('notification', 'add:participates', $callback); } } } } ossn_trigger_callback('notification', 'add', $callback); return true; } } return false; }
function ossn_action($action) { global $Ossn; if (isset($Ossn->action) && array_key_exists($action, $Ossn->action)) { if (is_file($Ossn->action[$action])) { ossn_trigger_callback('action', "load:{$action}"); include_once $Ossn->action[$action]; } } else { ossn_error_page(); exit; } }
/** * Load action. * * @param string $action The name of the action * * @return void */ function ossn_action($action) { global $Ossn; if (isset($Ossn->action) && array_key_exists($action, $Ossn->action)) { if (is_file($Ossn->action[$action])) { $params['action'] = $action; ossn_trigger_callback('action', 'load', $params); include_once $Ossn->action[$action]; } } else { ossn_error_page(); } }
/** * Group page handler * This page also contain subpages like group/<guid>/members * * Pages: * group/<guid> * group/<guid>/<subpage> * Subpage need to be register seperatly. * * @return mixdata; * @access private */ function ossn_group_page($pages) { if (empty($pages[0])) { ossn_error_page(); } if (!empty($pages[0]) && !empty($pages[0])) { if (isset($pages[1])) { $params['subpage'] = $pages[1]; } else { $params['subpage'] = ''; } if (!ossn_is_group_subapge($params['subpage']) && !empty($params['subpage'])) { return false; } $group = ossn_get_group_by_guid($pages[0]); if (empty($group->guid)) { ossn_error_page(); } ossn_set_page_owner_guid($group->guid); ossn_trigger_callback('page', 'load:group'); $params['group'] = $group; $title = $group->title; $view = ossn_plugin_view('groups/pages/profile', $params); $contents['content'] = ossn_group_layout($view); $content = ossn_set_page_layout('contents', $contents); echo ossn_view_page($title, $content); } }
/** * Delete user from syste, * * @return boolean */ public function deleteUser() { self::initAttributes(); if (!empty($this->guid) && !empty($this->username)) { $params['from'] = 'ossn_users'; $params['wheres'] = array("guid='{$this->guid}'"); if ($this->delete($params)) { //delete user files $datadir = ossn_get_userdata("user/{$this->guid}/"); if (is_dir($datadir)) { OssnFile::DeleteDir($datadir); //From of v2.0 DeleteDir delete directory also #138 //rmdir($datadir); } //delete user entites also $this->deleteByOwnerGuid($this->guid, 'user'); //delete annotations $this->OssnAnnotation->owner_guid = $this->guid; $this->OssnAnnotation->deleteAnnotationByOwner($this->guid); //trigger callback so other components can be notified when user deleted. //should delete relationships ossn_delete_user_relations($this); $vars['entity'] = $this; ossn_trigger_callback('user', 'delete', $vars); return true; } } return false; }
redirect('home'); } $username = input('username'); $password = input('password'); if (empty($username) || empty($password)) { ossn_trigger_message(ossn_print('login:error')); redirect(); } $user = ossn_user_by_username($username); //check if username is email if (strpos($username, '@') !== false) { $user = ossn_user_by_email($username); $username = $user->username; } if ($user && !$user->isUserVALIDATED()) { $user->resendValidationEmail(); ossn_trigger_message(ossn_print('ossn:user:validation:resend'), 'error'); redirect(REF); } $vars = array('user' => $user); ossn_trigger_callback('user', 'before:login', $vars); $login = new OssnUser(); $login->username = $username; $login->password = $password; if ($login->Login()) { //One uneeded redirection when login #516 ossn_trigger_callback('login', 'success', $vars); redirect('home'); } else { redirect('login?error=1'); }
/** * Delete group * * @params $guid Group guid * * @return bool; */ public function deleteGroup($guid) { if (empty($guid)) { return false; } $vars['entity'] = ossn_get_group_by_guid($guid); if ($this->deleteObject($guid)) { //delete group relations ossn_delete_group_relations($vars['entity']); //trigger callback so other components can be notified when group is deleted. ossn_trigger_callback('group', 'delete', $vars); return true; } return false; }
/** * Load all active components * * @return false|null startup files; */ public function loadComs() { $coms = $this->getActive(); $lang = ossn_site_settings('language'); $vars['activated'] = $coms; ossn_trigger_callback('components', 'before:load', $vars); if (!$coms) { return false; } foreach ($coms as $com) { $dir = ossn_route()->com; $name = $this->getCom($com->com_id); if (!empty($name->name)) { ossn_register_plugins_by_path("{$dir}{$com->com_id}/plugins/"); if (is_file("{$dir}{$com->com_id}/locale/ossn.{$lang}.php")) { include "{$dir}{$com->com_id}/locale/ossn.{$lang}.php"; } include_once "{$dir}{$com->com_id}/ossn_com.php"; } } ossn_trigger_callback('components', 'after:load', $vars); }
/** * Delete Comment * * @params $comment: Comment id * * @return bool */ public function deleteComment($comment) { if ($this->deleteAnnotation($comment)) { $params['comment'] = $comment; ossn_trigger_callback('comment', 'delete', $params); return true; } 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 */ ossn_trigger_callback('entity', 'load:comment:share:like', $params); ?> <div class="comments-likes ossn-photos-comments" style="width:525px;"> <div class="menu-likes-comments-share"> <div class="like_share comments-like-comment-links"> <?php echo ossn_view_menu('entityextra'); ?> </div> </div> <?php if (ossn_is_hook('post', 'likes:entity')) { $entity['entity_guid'] = $params['entity']->guid; echo ossn_call_hook('post', 'likes:entity', $entity); } ?> <?php if (ossn_is_hook('post', 'comments:entity')) { $entity['entity_guid'] = $params['entity']->guid; echo ossn_call_hook('post', 'comments:entity', $entity);
/** * Delete entity. * * @param integer $guid Entity guid in database * * @return boolean */ public function deleteEntity($guid) { if (isset($this->guid) && !empty($this->guid) && empty($guid)) { $guid = $this->guid; } $params['from'] = 'ossn_entities'; $params['wheres'] = array("guid = '{$guid}'"); if ($this->delete($params)) { $metadata['from'] = 'ossn_entities_metadata'; $metadata['wheres'] = array("guid = '{$guid}'"); $this->delete($metadata); $vars['entity'] = $guid; ossn_trigger_callback('delete', 'entity', $vars); return true; } return false; }
/** * Delete profile photo * * @params = $this->photoid Id of photo * * @return bool; */ public function deleteAlbumPhoto() { if (isset($this->photoid)) { $this->file_id = $this->photoid; $this->entity = new OssnEntities(); $file = $this->fetchFile(); $source = ossn_get_userdata("object/{$file->owner_guid}/{$file->value}"); //delete croped photos unlink($source); foreach (ossn_photos_sizes() as $size => $dimensions) { $filename = str_replace('album/photos/', '', $file->value); $filename = ossn_get_userdata("object/{$file->owner_guid}/album/photos/{$size}_{$filename}"); unlink($filename); } //delete photo from database if ($this->deleteEntity($file->guid)) { $params['photo'] = get_object_vars($file); ossn_trigger_callback('delete', 'album:photo', $params); return true; } } return false; }
/** * Delete entity. * * @params = $guid = Entity guid in database * * @return (bool); */ public function deleteEntity($guid) { $this->statement("DELETE FROM kullaniciveriler WHERE(guid='{$guid}');"); if ($this->execute()) { $this->statement("DELETE FROM kullanicivericerik WHERE(guid='{$guid}');"); $this->execute(); $params['entity'] = $guid; ossn_trigger_callback('delete', 'entity', $params); return true; } return false; }
/** * Delete Annotation * * @params $annotation = annotation_id * * @return bool; */ public function deleteAnnotation($annotation) { self::initAttributes(); if ($this->deleteByOwnerGuid($annotation, 'annotation')) { $this->statement("DELETE FROM yorumlar WHERE(id='{$annotation}')"); if ($this->execute()) { $data = ossn_get_userdata("annotation/{$annotation}/"); if (is_dir($data)) { OssnFile::DeleteDir($data); rmdir($data); } $params['annotation'] = $annotation; ossn_trigger_callback('annotation', 'delete', $params); return true; } } return false; }
* @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.informatikon.com/ */ session_start(); global $Ossn; if (!isset($Ossn)) { $Ossn = new stdClass(); } include_once dirname(dirname(__FILE__)) . '/libraries/ossn.lib.route.php'; if (!is_file(ossn_route()->configs . 'ossn.config.site.php') && !is_file(ossn_route()->configs . 'ossn.config.db.php')) { header("Location: installation"); exit; } include_once ossn_route()->configs . 'libraries.php'; include_once ossn_route()->configs . 'classes.php'; include_once ossn_route()->configs . 'ossn.config.site.php'; include_once ossn_route()->configs . 'ossn.config.db.php'; foreach ($Ossn->classes as $class) { if (!(include_once ossn_route()->classes . "Ossn{$class}.php")) { throw new exception('Cannot include all classes'); } } foreach ($Ossn->libraries as $lib) { if (!(include_once ossn_route()->libs . "ossn.lib.{$lib}.php")) { throw new exception('Cannot include all libraries'); } } ossn_trigger_callback('ossn', 'init'); //need to update user last_action // @note why its here? update_last_activity();
<?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
/** * Profile page handler * * @return false|null data; */ function profile_page_handler($page) { $user = ossn_user_by_username($page[0]); if (empty($user->guid)) { ossn_error_page(); } ossn_set_page_owner_guid($user->guid); ossn_trigger_callback('page', 'load:profile'); $params['user'] = $user; $params['page'] = $page; if (isset($page[1])) { $params['subpage'] = $page[1]; } else { $params['subpage'] = ''; } if (!ossn_is_profile_subapge($params['subpage']) && !empty($params['subpage'])) { return false; } $title = $user->fullname; $contents['content'] = ossn_plugin_view('profile/pages/profile', $params); $content = ossn_set_page_layout('contents', $contents); echo ossn_view_page($title, $content); }
/** * Delete All Posts * * @return void; */ public function deleteAllPosts() { $posts = $this->GetPosts(); if (!$posts) { return false; } foreach ($posts as $post) { $this->deleteObject($post->guid); ossn_trigger_callback('post', 'delete', $post->guid); } }
/** * Wall template view * Depends on wall post type * * @param string $callback Name of callback * @param string $type Callback type * @param array $params Arrays or Objects * * @return mixed data * @access private */ function ossn_wall_templates($hook, $type, $return, $params) { ossn_trigger_callback('wall', 'load:item', $params); $params = ossn_call_hook('wall', 'templates:item', $params, $params); return ossn_plugin_view("wall/templates/wall/{$type}/item", $params); }