Skip to content

Commit

Permalink
Merge pull request #175 from mambax7/master
Browse files Browse the repository at this point in the history
fixes, updates
  • Loading branch information
mambax7 committed May 7, 2020
2 parents 5538a28 + d94e62c commit 3260fe2
Show file tree
Hide file tree
Showing 55 changed files with 520 additions and 159 deletions.
11 changes: 11 additions & 0 deletions blocks/friends_block.php
Expand Up @@ -20,6 +20,7 @@
*/

use XoopsModules\Suico;
use XoopsModules\Suico\Helper;

if (!defined('XOOPS_ROOT_PATH')) {
exit();
Expand All @@ -33,6 +34,16 @@
function b_suico_friends_show($options)
{
global $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsUser;

/** @var Helper $helper */
if (!class_exists(Helper::class)) {
return false;
}

$helper = Helper::getInstance();

$helper->loadLanguage('main');

$myts = MyTextSanitizer::getInstance();
$block = [];
if ($xoopsUser) {
Expand Down
14 changes: 12 additions & 2 deletions blocks/photos_block.php
Expand Up @@ -20,6 +20,7 @@
*/

use XoopsModules\Suico;
use XoopsModules\Suico\Helper;

if (!defined('XOOPS_ROOT_PATH')) {
exit();
Expand All @@ -32,8 +33,17 @@
*/
function b_suico_lastpictures_show($options)
{
global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
$myts = MyTextSanitizer::getInstance();
global $xoopsDB;

/** @var Helper $helper */
if (!class_exists(Helper::class)) {
return false;
}

$helper = Helper::getInstance();
$helper->loadLanguage('main');

$myts = \MyTextSanitizer::getInstance();
$block = [];
/**
* Criteria for Pictures Block
Expand Down
6 changes: 4 additions & 2 deletions class/FriendsController.php
Expand Up @@ -45,11 +45,13 @@ public function checkPrivilege()
if (1 === $this->configsFactory->getCount($criteria)) {
$configs = $this->configsFactory->getObjects($criteria);
$config = $configs[0]->getVar('friends');
/*
if (!$this->checkPrivilegeLevel($config)) {
//mb temporary fix for self-loop
// \redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, \_MD_SUICO_NOPRIVILEGE);
redirect_header('/', 10, \_MD_SUICO_NOPRIVILEGE);
// \redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Friends'));
redirect_header('/', 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Friends'));
}
*/
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion class/GroupController.php
Expand Up @@ -45,9 +45,11 @@ public function checkPrivilege()
if (1 === $this->configsFactory->getCount($criteria)) {
$configs = $this->configsFactory->getObjects($criteria);
$config = $configs[0]->getVar('groups');
/*
if (!$this->checkPrivilegeLevel($config)) {
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, \_MD_SUICO_NOPRIVILEGE);
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Groups'));
}
*/
}
return true;
}
Expand Down
6 changes: 0 additions & 6 deletions class/GroupsHandler.php
Expand Up @@ -35,12 +35,6 @@
use XoopsPersistableObjectHandler;
use XoopsThemeForm;

/**
* Protection against inclusion outside the site
*/
if (!\defined('XOOPS_ROOT_PATH')) {
die('XOOPS root path not defined');
}

/**
* suico_groupshandler class.
Expand Down
7 changes: 1 addition & 6 deletions class/Image.php
Expand Up @@ -25,12 +25,7 @@
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org>
*/
/**
* Protection against inclusion outside the site
*/
if (!\defined('XOOPS_ROOT_PATH')) {
die('XOOPS root path not defined');
}

/**
* Includes of form objects and uploader
*/
Expand Down
15 changes: 2 additions & 13 deletions class/ImageHandler.php
Expand Up @@ -34,12 +34,7 @@
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org>
*/
/**
* Protection against inclusion outside the site
*/
if (!\defined('XOOPS_ROOT_PATH')) {
die('XOOPS root path not defined');
}

/**
* Includes of form objects and uploader
*/
Expand Down Expand Up @@ -567,21 +562,15 @@ public function getLastPictures($limit)
public function getLastPicturesForBlock($limit)
{
global $xoopsUser, $xoopsDB;
$memberHandler = xoops_getHandler('member');
$user = $xoopsUser;
$user2 = $GLOBALS['xoopsUser'];
if (is_object($xoopsUser)) {
$uid = $xoopsUser->getVar('uid');
}

$controller = new PhotosController($xoopsDB, $xoopsUser);

$isAdmin = Helper::getInstance()->isUserAdmin();
$isUser = $controller->isUser;
$isAnonymous = $controller->isAnonym;

$ret = [];

if (1 == $isAnonymous) {
$sql = 'SELECT uname, t.uid_owner, t.filename, t.title, t.caption, t.date_created, t.date_updated FROM ' . $this->db->prefix('suico_images') . ' AS t';
$sql .= ' INNER JOIN ' . $this->db->prefix('users') . ' u ON t.uid_owner=u.uid';
Expand All @@ -597,7 +586,7 @@ public function getLastPicturesForBlock($limit)
$sql .= ' INNER JOIN ' . $this->db->prefix('suico_configs') . ' c on t.uid_owner=c.config_uid';
$sql .= ' WHERE (private=0 AND c.pictures < 3 )'; //all pictures visible to members
$sql .= ' OR ( private=0 AND c.pictures = 3 AND c.config_uid IN ( '. $sql0 .')) '; //pictures visible to friends
$sql .= ' OR ( c.config_uid = '. $uid .' AND c.pictures = 4) '; //my private pictures
$sql .= ' OR ( c.config_uid = '. $uid .' ) '; //my private pictures
$sql .= ' ORDER BY image_id DESC';
}

Expand Down
4 changes: 3 additions & 1 deletion class/NotesController.php
Expand Up @@ -70,9 +70,11 @@ public function checkPrivilege(
if (1 === $this->configsFactory->getCount($criteria)) {
$configs = $this->configsFactory->getObjects($criteria);
$config = $configs[0]->getVar('notes');
/*
if (!$this->checkPrivilegeLevel($config)) {
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, \_MD_SUICO_NOPRIVILEGE);
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Notes'));
}
*/
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion class/PhotosController.php
Expand Up @@ -46,10 +46,12 @@ public function checkPrivilege()
if (1 == $this->configsFactory->getCount($criteria)) {
$configs = $this->configsFactory->getObjects($criteria);
$config = $configs[0]->getVar('pictures');
/*
if (!$this->checkPrivilegeLevel($config)) {
// \redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, \_MD_SUICO_NOPRIVILEGE);
\redirect_header('index.php', 10, \_MD_SUICO_NOPRIVILEGE);
\redirect_header('index.php', 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Photos'));
}
*/
}
return true;
}
Expand Down
6 changes: 0 additions & 6 deletions class/Video.php
Expand Up @@ -26,12 +26,6 @@
use XoopsDatabaseFactory;
use XoopsObject;

/**
* Protection against inclusion outside the site
*/
if (!\defined('XOOPS_ROOT_PATH')) {
die('XOOPS root path not defined');
}
/**
* Includes of form objects and uploader
*/
Expand Down
4 changes: 3 additions & 1 deletion class/VideoController.php
Expand Up @@ -124,9 +124,11 @@ public function checkPrivilege()
if (1 === $this->configsFactory->getCount($criteria)) {
$configs = $this->configsFactory->getObjects($criteria);
$config = $configs[0]->getVar('videos');
/*
if (!$this->checkPrivilegeLevel($config)) {
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, \_MD_SUICO_NOPRIVILEGE);
\redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Videos'));
}
*/
}
return true;
}
Expand Down
7 changes: 0 additions & 7 deletions class/VideoHandler.php
Expand Up @@ -33,13 +33,6 @@
use XoopsPersistableObjectHandler;
use XoopsThemeForm;

/**
* Protection against inclusion outside the site
*/
if (!\defined('XOOPS_ROOT_PATH')) {
die('XOOPS root path not defined');
}

/**
* suico_videohandler class.
* This class provides simple mechanism for Video object
Expand Down
80 changes: 40 additions & 40 deletions index.php
Expand Up @@ -42,9 +42,9 @@
if (is_object($GLOBALS['xoopsUser']) && $uid == $GLOBALS['xoopsUser']->getVar('uid')) {
//disable cache
$GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
// include $GLOBALS['xoops']->path('header.php');
// include $GLOBALS['xoops']->path('header.php');
/* @var XoopsConfigHandler $configHandler */
$configHandler = xoops_getHandler('config');
$configHandler = xoops_getHandler('config');
$GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
$GLOBALS['xoopsTpl']->assign('user_ownpage', true);
if (1 == $GLOBALS['xoopsConfigUser']['self_delete']) {
Expand Down Expand Up @@ -83,7 +83,7 @@
/* @var XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
$groups_accessible = $grouppermHandler->getItemIds('profile_access', $groups_xoopsUser, $helper->getModule()->getVar('mid'));
$rejected = false;
$rejected = false;
if ($thisUser->isAdmin()) {
$rejected = !in_array(XOOPS_GROUP_ADMIN, $groups_accessible);
} elseif ($groups_thisUser_nonbasic) {
Expand All @@ -107,14 +107,14 @@
$GLOBALS['xoopsTpl']->assign('userlevel', $thisUser->isActive());
}
// Dynamic User Profiles
$thisUsergroups = $thisUser->getGroups();
$thisUsergroups = $thisUser->getGroups();
$visibilityHandler = $helper->getHandler('Visibility');
//search for visible Fields or null for none
$field_ids_visible = $visibilityHandler->getVisibleFields($thisUsergroups, $groups);
$profileHandler = $helper->getHandler('Profile');
$fields = $profileHandler->loadFields();
$categoryHandler = $helper->getHandler('Category');
$categoryCriteria = new CriteriaCompo();
$profileHandler = $helper->getHandler('Profile');
$fields = $profileHandler->loadFields();
$categoryHandler = $helper->getHandler('Category');
$categoryCriteria = new CriteriaCompo();
$categoryCriteria->setSort('cat_weight');
$cats = $categoryHandler->getObjects($categoryCriteria, true, false);
unset($categoryCriteria);
Expand All @@ -126,7 +126,7 @@
$categories[$i] = $cats[$i];
}
$profileHandler = $helper->getHandler('Profile');
$profile = $profileHandler->get($thisUser->getVar('uid'));
$profile = $profileHandler->get($thisUser->getVar('uid'));
// Add dynamic fields
foreach (array_keys($fields) as $i) {
//If field is not visible, skip
Expand All @@ -146,9 +146,9 @@
}
$GLOBALS['xoopsTpl']->assign('categories', $categories);
// Dynamic user profiles end
$featuredvideocode = '';
$featuredvideocode = '';
$featuredvideotitle = '';
$featuredvideodesc = '';
$featuredvideodesc = '';
//require_once __DIR__ . '/class/suico_controller.php';
//if (!@ require_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php') {
// require_once XOOPS_ROOT_PATH . '/language/english/user.php';
Expand All @@ -161,14 +161,14 @@
/**
* Criteria for featuredvideo
*/
$criteriaUidVideo = new Criteria('uid_owner', $controller->uidOwner);
$criteriaUidVideo = new Criteria('uid_owner', $controller->uidOwner);
$criteria_featuredvideo = new Criteria('featured_video', '1');
$criteria_video = new CriteriaCompo($criteria_featuredvideo);
$criteria_video = new CriteriaCompo($criteria_featuredvideo);
$criteria_video->add($criteriaUidVideo);
if ((isset($nbSections['countVideos']) && $nbSections['countVideos'] > 0) && ($videos = $controller->videosFactory->getObjects($criteria_video))) {
$featuredvideocode = $videos[0]->getVar('youtube_code');
$featuredvideotitle = $videos[0]->getVar('video_title');
$featuredvideodesc = $videos[0]->getVar('video_desc');
$featuredvideocode = $videos[0]->getVar('youtube_code');
$featuredvideotitle = $videos[0]->getVar('video_title');
$featuredvideodesc = $videos[0]->getVar('video_desc');
}
/**
* Groups
Expand All @@ -180,10 +180,14 @@
*/
$controller->visitorsFactory->purgeVisits();
if (0 === $controller->isAnonym) {
/**
* Fetching last visitors
*/
// Fetching last visitors
if ($controller->uidOwner !== $xoopsUser->getVar('uid')) {
$criteriaDeleteOldVisits = new CriteriaCompo(new Criteria('uid_owner', $controller->uidOwner));
$criteriaDeleteOldVisits->add(new Criteria('uid_visitor', $xoopsUser->getVar('uid')));
$visitorsFactory->deleteAll($criteriaDeleteOldVisits, true);



$visitor_now = $controller->visitorsFactory->create();
$visitor_now->setVar('uid_owner', $controller->uidOwner);
$visitor_now->setVar('uid_visitor', $xoopsUser->getVar('uid'));
Expand All @@ -195,37 +199,33 @@
$visitorsObjectArray = $controller->visitorsFactory->getObjects(
$criteria_visitors
);
/**
* Lets populate an array with the data from visitors
*/
// Lets populate an array with the data from visitors
$i = 0;
$visitorsArray = [];
if (is_array($visitorsObjectArray) && count($visitorsObjectArray) > 0) {
foreach ($visitorsObjectArray as $visitor) {
$myvisitor= [];
$myvisitor = [];
if (null !== $visitor) {
$myvisitor['uid_visitor'] = $visitor->getVar('uid_visitor', 's');
$myvisitor['uname_visitor'] = $visitor->getVar('uname_visitor', 's');
$myvisitor['date_visited'] = formatTimestamp($visitor->getVar('date_visited'),'S');
$memberHandler = xoops_getHandler('member');
$visitor= $memberHandler->getUser($visitor->getVar('uid_visitor'));
$myvisitor['avatar_visitor'] = $visitor->getVar('user_avatar', 's');
$visitorsArray[] = $myvisitor;
$myvisitor['uid_visitor'] = $visitor->getVar('uid_visitor', 's');
$myvisitor['uname_visitor'] = $visitor->getVar('uname_visitor', 's');
$myvisitor['date_visited'] = formatTimestamp($visitor->getVar('date_visited'), 'S');
$memberHandler = xoops_getHandler('member');
$visitor = $memberHandler->getUser($visitor->getVar('uid_visitor'));
$myvisitor['avatar_visitor'] = $visitor->getVar('user_avatar', 's');
$visitorsArray[] = $myvisitor;
unset($myvisitor);
++$i;
}
}
}
$xoopsTpl->assign('visitors', $visitorsArray);
$xoopsTpl->assign('lang_visitors', _MD_SUICO_VISITORS);
/* $criteria_deletevisitors = new criteria('uid_owner',$uid);
$criteria_deletevisitors->setStart(5);
print_r($criteria_deletevisitors);
$visitorsFactory->deleteAll($criteria_deletevisitors, true);
*/
// $criteria_deletevisitors = new criteria('uid_owner', $uid);
// $criteria_deletevisitors->setStart(5);
// print_r($criteria_deletevisitors);
// $visitorsFactory->deleteAll($criteria_deletevisitors, true);
}
$avatar = $controller->owner->getVar('user_avatar');
$avatar = $controller->owner->getVar('user_avatar');
$memberHandler = xoops_getHandler('member');
$thisUser = $memberHandler->getUser($controller->uidOwner);
$myts = MyTextSanitizer::getInstance();
Expand All @@ -250,11 +250,11 @@
if (isset($nbSections['countVideos']) && $nbSections['countVideos'] > 0) {
$xoopsTpl->assign('featuredvideocode', $featuredvideocode);
$xoopsTpl->assign('featuredvideodesc', $featuredvideodesc);
$xoopsTpl->assign('featuredvideotitle', $featuredvideotitle);
$xoopsTpl->assign('featuredvideotitle', $featuredvideotitle);
$xoopsTpl->assign(
'width',
$helper->getConfig('width_maintube')
); // Falta configurar o tamnho do main nas configs e alterar no template
); // We still need to configure the main size in the configs and change the template
$xoopsTpl->assign(
'height',
$helper->getConfig('height_maintube')
Expand All @@ -271,7 +271,7 @@
$newFriendrequest = $friendController->friendrequestFactory->getObjects($criteria_uidfriendrequest);
if ($newFriendrequest) {
$countFriendrequest = count($newFriendrequest);
$memberHandler = xoops_getHandler('member');
$memberHandler = xoops_getHandler('member');
$friendrequester = $memberHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
$friendrequester_uid = $friendrequester->getVar('uid');
$friendrequester_uname = $friendrequester->getVar('uname');
Expand Down

0 comments on commit 3260fe2

Please sign in to comment.