/**
 * Initialize components
 *
 * @return false|null
 * @access private;
 */
function ossn_components_init()
{
    $panels = ossn_registered_com_panel();
    if (!$panels) {
        return false;
    }
    foreach ($panels as $configure) {
        ossn_register_menu_item('topbar_admin', array('name' => OssnTranslit::urlize($configure), 'text' => $configure, 'parent' => 'configure', 'href' => ossn_site_url("administrator/component/{$configure}")));
    }
}
Exemplo n.º 2
0
/**
 * Add a entity like menu item
 *
 * @return void
 */
function ossn_entity_like_link($callback, $type, $params)
{
    $guid = $params['entity']->guid;
    ossn_unregister_menu('like', 'entityextra');
    if (!empty($guid)) {
        $likes = new OssnLikes();
        if (!$likes->isLiked($guid, ossn_loggedin_user()->guid, 'entity')) {
            ossn_register_menu_item('entityextra', array('name' => 'like', 'href' => "javascript:;", 'id' => 'ossn-like-' . $guid, 'onclick' => "Ossn.EntityLike({$guid});", 'text' => ossn_print('ossn:like')));
        } else {
            ossn_register_menu_item('entityextra', array('name' => 'like', 'href' => "javascript:;", 'id' => 'ossn-like-' . $guid, 'onclick' => "Ossn.EntityUnlike({$guid});", 'text' => ossn_print('ossn:unlike')));
        }
    }
}
Exemplo n.º 3
0
/**
 * Initialize library
 *
 * @return bool
 */
function ossn_users()
{
    ossn_register_page('uservalidate', 'ossn_uservalidate_pagehandler');
    /**
     * Logout outuser if user didn't exists
     */
    if (ossn_isLoggedin()) {
        $user = ossn_user_by_guid(ossn_loggedin_user()->guid);
        if (!$user) {
            ossn_logout();
            redirect();
        }
        //register menu item for logout, in topbar dropdown menu
        ossn_register_menu_item('topbar_dropdown', array('name' => 'logout', 'text' => ossn_print('logout'), 'href' => ossn_site_url('action/user/logout'), 'action' => true));
    }
}
Exemplo n.º 4
0
/**
 * Initialize Profile Component
 *
 * @return void;
 * @access private;
 */
function ossn_profile()
{
    //pages
    ossn_register_page('u', 'profile_page_handler');
    ossn_register_page('avatar', 'avatar_page_handler');
    ossn_register_page('cover', 'cover_page_handler');
    //css and js
    ossn_extend_view('css/ossn.default', 'css/profile');
    ossn_extend_view('js/opensource.socialnetwork', 'js/OssnProfile');
    //actions
    if (ossn_isLoggedin()) {
        ossn_register_action('profile/photo/upload', __OSSN_PROFILE__ . 'actions/photo/upload.php');
        ossn_register_action('profile/cover/upload', __OSSN_PROFILE__ . 'actions/cover/upload.php');
        ossn_register_action('profile/cover/reposition', __OSSN_PROFILE__ . 'actions/cover/reposition.php');
        ossn_register_action('profile/edit', __OSSN_PROFILE__ . 'actions/edit.php');
        ossn_register_menu_item('topbar_dropdown', array('name' => 'account_settings', 'text' => ossn_print('account:settings'), 'href' => ossn_loggedin_user()->profileURL('/edit')));
    }
    //callback
    ossn_register_callback('page', 'load:search', 'ossn_search_users_link');
    ossn_register_callback('page', 'load:profile', 'ossn_profile_load_event');
    ossn_register_callback('delete', 'profile:photo', 'ossn_profile_delete_photo_wallpost');
    ossn_register_callback('delete', 'profile:cover:photo', 'ossn_profile_delete_photo_wallpost');
    //hooks
    ossn_add_hook('newsfeed', "sidebar:left", 'profile_photo_newsefeed', 1);
    ossn_add_hook('profile', 'subpage', 'profile_user_friends');
    ossn_add_hook('search', 'type:users', 'profile_search_handler');
    ossn_add_hook('profile', 'subpage', 'profile_edit_page');
    ossn_add_hook('profile', 'modules', 'profile_modules');
    ossn_add_hook('wall:template', 'profile:photo', 'ossn_wall_profile_photo');
    ossn_add_hook('wall:template', 'cover:photo', 'ossn_wall_profile_cover_photo');
    //notifications
    ossn_add_hook('notification:view', 'like:entity:file:profile:photo', 'ossn_notification_like_profile_photo');
    ossn_add_hook('notification:view', 'comments:entity:file:profile:photo', 'ossn_notification_like_profile_photo');
    //subpages of profile
    ossn_profile_subpage('friends');
    ossn_profile_subpage('edit');
}
Exemplo n.º 5
0
/**
 * Delete comment menu
 *
 * @return voud;
 * @access private
 */
function ossn_comment_menu($name, $type, $params)
{
    $OssnComment = new OssnComments();
    if (is_object($params)) {
        $params = get_object_vars($params);
    }
    $comment = $OssnComment->getComment($params['id']);
    if ($comment->type == 'comments:post') {
        if (com_is_active('OssnWall')) {
            $ossnwall = new OssnWall();
            $post = $ossnwall->GetPost($comment->subject_guid);
            //check if type is group
            if ($post->type == 'group') {
                $group = ossn_get_group_by_guid($post->owner_guid);
            }
            //group admins must be able to delete ANY comment in their own group #170
            //just show menu if group owner is loggedin
            if (ossn_loggedin_user()->guid == $post->owner_guid || ossn_loggedin_user()->guid == $group->owner_guid) {
                ossn_unregister_menu('delete', 'comments');
                ossn_register_menu_item('comments', array('name' => 'delete', 'href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment', 'text' => ossn_print('comment:delete')));
            }
        }
    }
    $user = ossn_loggedin_user();
    if (ossn_isLoggedin()) {
        if ($comment->type == 'comments:entity') {
            $entity = ossn_get_entity($comment->subject_guid);
        }
        if ($user->guid == $params['owner_guid'] || ossn_isAdminLoggedin() || $comment->type == 'comments:entity' && ($entity->type = 'user' && $user->guid == $entity->owner_guid)) {
            ossn_unregister_menu('delete', 'comments');
            ossn_register_menu_item('comments', array('name' => 'delete', 'href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment', 'text' => ossn_print('comment:delete')));
        }
    }
}
Exemplo n.º 6
0
/**
 * View post menu
 *
 * @param string $hook Name of hook
 * @param string $type Hook type
 * @param string $return mixed data
 * @param array $params Arrays or Objects
 *
 * @return mixed data
 * @access private
 */
function ossn_wall_post_menu($hook, $type, $return, $params)
{
    if ($params['post']->poster_guid == ossn_loggedin_user()->guid || $params['post']->owner_guid == ossn_loggedin_user()->guid || ossn_isAdminLoggedin()) {
        $deleteurl = ossn_site_url("action/wall/post/delete?post={$params['post']->guid}", true);
        ossn_unregister_menu('delete', 'wallpost');
        ossn_register_menu_item("wallpost", array('name' => 'delete', 'class' => 'ossn-wall-post-delete', 'text' => ossn_print('delete'), 'href' => $deleteurl, 'data-guid' => $params['post']->guid));
    } else {
        ossn_unregister_menu("delete", 'wallpost');
    }
    return ossn_view_menu('wallpost', 'wall/menus/post-controls');
}
Exemplo n.º 7
0
/**
 * Register sidebar menu
 *
 * @param string $name The name of the menu
 *               $text Link text
 *               $link Full url
 *               $section Menu section
 *               $for sidebar name
 * @param string $text
 * @param string $link
 * @param string $section
 *
 * @return void
 */
function ossn_register_admin_sidemenu($name, $text, $link, $section, $for = 'admin/sidemenu')
{
    ossn_register_menu_item($for, array('name' => $name, 'text' => $text, 'href' => $link, 'parent' => strtolower($section)));
}
Exemplo n.º 8
0
/**
 * Register a menu;
 * @params string $name Name of menu;
 * @params string $text Text for menu;
 * @params string $link Link for menu;
 *
 * @return void
 */
function ossn_register_menu_link($name, $text, $link, $menutype = 'site')
{
    ossn_register_menu_item($menutype, array('name' => $name, 'text' => $text, 'href' => $link));
}