Ejemplo n.º 1
0
function frontend_he_wall_display($params)
{
    global $user, $setting, $smarty;
    $wall_object = $params['object'];
    $wall_object_id = (int) $params['object_id'];
    $where_clause = '';
    $setting_actions_visibility = 0;
    $setting_actions_actionsper = $setting['setting_actions_actionsonprofile'];
    $allow_post = 0;
    if (!$setting['setting_he_wall_guest_view'] && $user->level_info['level_wall_allowed'] == 0) {
        return '<center>' . SE_Language::get(690706102) . '</center>';
    }
    if ($wall_object == 'user') {
        $owner = new se_user(array($wall_object_id));
        $privacy_max = $owner->user_privacy_max($user);
        $allow_post = (int) ($privacy_max == 1 || $privacy_max == 2);
        $actiontype_ids = he_wall::get_actiontype_ids();
        $actiontype_ids_str = implode(',', $actiontype_ids);
        $where_clause .= "\r\n             IF ( \r\n                se_actions.action_actiontype_id IN ({$actiontype_ids_str}),\r\n                ( se_actions.action_object_owner='user' AND se_actions.action_object_owner_id='{$owner->user_info['user_id']}'),\r\n                se_actions.action_user_id='{$owner->user_info['user_id']}'\r\n             )\r\n            ";
    } elseif ($wall_object == 'userhome') {
        $owner = new se_user(array($wall_object_id));
        $privacy_max = $owner->user_privacy_max($user);
        $allow_post = (int) ($privacy_max == 1 || $privacy_max == 2);
        $setting_actions_visibility = 10;
        $setting_actions_actionsper = $setting['setting_actions_actionsperuser'];
        $where_clause .= "1";
    } elseif ($wall_object == 'group') {
        $owner = new se_group($user->user_info['user_id'], $wall_object_id);
        $privacy_max = $owner->user_rank;
        $allow_post = (int) ($privacy_max != -1);
        $setting_actions_visibility = 10;
        $setting_actions_actionsper = $setting['setting_actions_actionsonprofile'];
        $where_clause .= "se_actions.action_object_owner='group' AND se_actions.action_object_owner_id='{$wall_object_id}'";
    } elseif ($wall_object == 'pages') {
        $where_clause .= " se_actions.action_object_owner='pages' AND se_actions.action_object_owner_id='{$wall_object_id}'";
    } else {
        $where_clause .= '';
    }
    $hidden_action_ids = he_wall::get_hidden_actions($user->user_info['user_id']);
    if ($hidden_action_ids) {
        $where_clause .= $where_clause != '' ? " AND " : '';
        $where_clause .= "se_actions.action_id NOT IN (" . implode(',', $hidden_action_ids) . ")";
    }
    $wall_actions = he_wall::actions_display($setting_actions_visibility, $setting_actions_actionsper, $where_clause);
    $action_owner_ids = array();
    foreach ($wall_actions as $key => $wall_action) {
        $action_owner_ids[] = $wall_action['action_user_id'];
    }
    $action_owner_ids = array_unique($action_owner_ids);
    $action_owners = he_wall::get_users($action_owner_ids);
    $action_ids = array();
    foreach ($wall_actions as $key => $wall_action) {
        $action_ids[] = $wall_action['action_id'];
        $wall_actions[$key]['owner'] = $action_owners[$wall_action['action_user_id']];
    }
    $action_likes = he_wall::get_likes($action_ids);
    $action_comments = he_wall::get_comments($action_ids);
    //Check Privacy
    $privacy_options = he_wall::get_privacy_options($wall_object, $wall_object_id);
    $smarty->assign('wall_uid', uniqid());
    $smarty->assign('js_action_ids', json_encode($action_ids));
    $smarty->assign('wall_actions', $wall_actions);
    $smarty->assign('wall_action_count', count($wall_actions));
    $smarty->assign('action_likes', $action_likes);
    $smarty->assign('action_comments', $action_comments);
    $smarty->assign('wall_object', $wall_object);
    $smarty->assign('wall_object_id', $wall_object_id);
    $smarty->assign('allow_post', $allow_post);
    $smarty->assign('privacy_options', $privacy_options);
    return he_wall_include_footer_logic('wall.tpl');
}