Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
petersphilo authored Mar 6, 2023
1 parent ecefa0e commit 0c3485e
Show file tree
Hide file tree
Showing 13 changed files with 814 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* Peter Zieseniss
* Copyright (C) 2022
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

namespace humhub\modules\social_utils;

use Yii;
use yii\web\AssetBundle;

class Assets extends AssetBundle
{
public function init()
{
$this->sourcePath = dirname(__FILE__).'/assets';
/*
$this->js = [
['chart.min.js', 'type' => 'module'],
['chart.esm.js', 'type' => 'module'],
['chart.mjs', 'type' => 'module'],
['helpers.esm.js', 'type' => 'module'],
['helpers.mjs', 'type' => 'module']
];
*/
$this->js = [
'Social_Utils.js'
];
/* */
$this->publishOptions = [
'forceCopy' => true
];

parent::init();
}
}
60 changes: 60 additions & 0 deletions Events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* Peter Zieseniss
* Copyright (C) 2022
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

namespace humhub\modules\social_utils;

use Yii;
use yii\helpers\Url;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\admin\widgets\AdminMenu;
use humhub\modules\admin\permissions\ManageModules;
use yii\db;
use yii\db\Connection;
use yii\db\Query;
use yii\db\Command;


class Events extends \yii\base\BaseObject{

public static function onAdminMenuInit($event){

if (!Yii::$app->user->can(ManageModules::class)) {
return;
}

/** @var AdminMenu $menu */
$menu = $event->sender;
$menu->addEntry(new MenuLink([
'label' => Yii::t('SocialUtilsModule.base', 'Social Utils'),
'url' => Url::to(['/social_utils/main/index']),
//'group' => 'manage',
'icon' => 'ge',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'social_utils' && Yii::$app->controller->id == 'admin'),
'sortOrder' => 700,
]));

}

public static function onDailyCronRun(){

$TodaysDate=date("Y-m-d");
}

}




20 changes: 20 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Peter Zieseniss
* Copyright (C) 2022
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

namespace humhub\modules\social_utils;

class Module extends \humhub\components\Module {
}
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Social Utils
This one-trick module allows you to invite, un-invite, or remove groups of users to any of your spaces.. That's it..

### Please Note

Make sure you back up your database before using this!!!!
This module is pre-pre-pre alpha!!


<br><br>

## Donationware -- Consider a Donation!!

Your doantion would really, really, really, really help!
https://www.paypal.com/donate/?hosted_button_id=AEA7Q4V5RMY4S

<br><br>

## ScreenShots

This is pretty much how it looks:

![ScreenShot 1](/assets/screen-1.jpg?raw=true "ScreenShot 1")

<br><br>

## Other ways to install

### Installation (Using Git Clone)

- Clone the social_utils module into your modules directory
```
cd protected/modules
git clone https://github.com/petersphilo/humhub-social_utils.git social_utils
```

- Go to Admin > Modules. You should now see the `Social Utils` module in your list of installed modules

- Click "Enable". This will install the module for you

Eventually, i hope to have this module in the 'store'

### Installation (Manually, using Release zip - for those not comfortable with the command line)

- Download the zip file from [/releases/latest](https://github.com/petersphilo/humhub-social_utils/releases/latest)

- Upload it to the `protected/modules` directory of your HumHub installation and expand it (then delete the zip file)

- Go to Admin > Modules. You should now see the `Social Utils` module in your list of installed modules

- Click "Enable". This will install the module for you

Eventually, i hope to have this module in the 'store'
194 changes: 194 additions & 0 deletions assets/Social_Utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
$(function(){
var MyDailyChartSelector=$('#MyDailyChart'),
MyHourlyBreakdownChartSelector=$('#MyHourlyBreakdownChart'),


GroupSpaceDataLoading="<div class='mycentertext margbothalf myita myturquoiseDark MyDataLoading GroupSpaceDataLoading'>Please wait for data to load..</div>",
MyHourlyBreakdownChart,

MyTestText='',
MyBR='<br>',
GDSelector='',

MyCurrentGetURL,
MyNewGetURL,
MyFetchURL;

MyCurrentGetURL=window.location.search;
/*
if(MyCurrentGetURL.length){MyNewGetURL=MyCurrentGetURL+'&'; }
else{MyNewGetURL='./?'; }
*/

var SpacesSelectPost=$.post(
MyCurrentGetURL,
{ListAllSpaces:'Yes'},
function(SSData){
$('.TheSpacesSelect').html(SSData);
},
"text"
);
SpacesSelectPost.done(function(){
$('.SpacesDataReady').removeClass('MyDataLoading').hide();
});


var GroupSelectPost=$.post(
MyCurrentGetURL,
{ListAllGroups:'Yes'},
function(GSData){
$('.TheGroupSelect').html(GSData);
},
"text"
);

CheckGroupSpaceSelect=function(){
var TheSpacesSelect=$('.TheSpacesSelect'),
TheSpacesSelectVal=TheSpacesSelect.val(),
TheGroupSelect=$('.TheGroupSelect'),
TheGroupSelectVal=TheGroupSelect.val();
TheSpacesSelect.removeClass('SelectError');
TheGroupSelect.removeClass('SelectError');
if(TheSpacesSelectVal==0){
TheSpacesSelect.addClass('SelectError');
}
if(TheGroupSelectVal==0){
TheGroupSelect.addClass('SelectError');
}
if(TheSpacesSelectVal!=0&&TheGroupSelectVal!=0){
$('.TheGroupSpaceMembersReport').fadeIn();
$('.GroupSpaceDataLoading').show();
console.log('TheSpacesSelectVal: '+TheSpacesSelectVal+'; TheGroupSelectVal: '+TheGroupSelectVal);
$.post(
MyCurrentGetURL,
{GetGroupSpaceMembers:'Yes',TheSpacesSelectVal:TheSpacesSelectVal,TheGroupSelectVal:TheGroupSelectVal},
function(GSMData){
$('.GroupPopulation').text(GSMData['GroupPopulation']);
$('.NotYetMembers').text(GSMData['NotYetMembers']);
$('.GroupSpaceMembers').text(GSMData['GroupSpaceMembers']);
$('.GroupSpaceInvites').text(GSMData['GroupSpaceInvites']);
$('.GroupSpaceTotal').text(GSMData['GroupSpaceTotal']);
$('.GroupSpaceDataLoading').hide();
},
"json"
);
return true;
}
else{
return false;
}
};

GroupSpaceInviteOrMember=function(IoM){
var TheSpacesSelect=$('.TheSpacesSelect'),
TheSpacesSelectVal=TheSpacesSelect.val(),
TheGroupSelect=$('.TheGroupSelect'),
TheGroupSelectVal=TheGroupSelect.val();
TheSpacesSelect.removeClass('SelectError');
TheGroupSelect.removeClass('SelectError');
if(TheSpacesSelectVal==0){
TheSpacesSelect.addClass('SelectError');
}
if(TheGroupSelectVal==0){
TheGroupSelect.addClass('SelectError');
}
if(TheSpacesSelectVal!=0&&TheGroupSelectVal!=0){
$('.GroupSpaceDataLoading').show();
console.log('TheSpacesSelectVal: '+TheSpacesSelectVal+'; TheGroupSelectVal: '+TheGroupSelectVal);
$.post(
MyCurrentGetURL,
{InviteOrAddMembers:'Yes',TheSpacesSelectVal:TheSpacesSelectVal,TheGroupSelectVal:TheGroupSelectVal,IoM:IoM},
function(IoAData){
var UsersAffected=IoAData['UsersAffected'],
ActionTaken=IoAData['ActionTaken'];
$('.GroupSpaceDataLoading').hide();
$('.SocUtilResult').text(UsersAffected+' users '+ActionTaken);
CheckGroupSpaceSelect();
},
"json"
);
return true;
}
else{
return false;
}
};

KickThemAll=function(IoM){
var TheSpacesSelect=$('.TheSpacesSelect'),
TheSpacesSelectVal=TheSpacesSelect.val(),
TheGroupSelect=$('.TheGroupSelect'),
TheGroupSelectVal=TheGroupSelect.val();
TheSpacesSelect.removeClass('SelectError');
TheGroupSelect.removeClass('SelectError');
if(TheSpacesSelectVal==0){
TheSpacesSelect.addClass('SelectError');
}
if(TheGroupSelectVal==0){
TheGroupSelect.addClass('SelectError');
}
if(TheSpacesSelectVal!=0&&TheGroupSelectVal!=0){
$('.GroupSpaceDataLoading').show();
console.log('TheSpacesSelectVal: '+TheSpacesSelectVal+'; TheGroupSelectVal: '+TheGroupSelectVal);
var KickConf=0;
if(confirm('Are you sure you want to remove them?')){
/**/
KickConf=1;
$.post(
MyCurrentGetURL,
{KickThemAll:'Yes',TheSpacesSelectVal:TheSpacesSelectVal,TheGroupSelectVal:TheGroupSelectVal,KickConf:KickConf},
function(KickData){
var UsersAffected=KickData['UsersAffected'];
$('.GroupSpaceDataLoading').hide();
$('.SocUtilResult').text(UsersAffected+' users Removed');
CheckGroupSpaceSelect();
},
"json"
);

}
else{
$('.GroupSpaceDataLoading').hide();
return false;
}
return true;
}
else{
return false;
}
};

$('.InviteThemAll').click(function(){
if(GroupSpaceInviteOrMember(1)){
//$(this).addClass('MyDataLoading');
//CheckGroupSpaceSelect();
}

});

$('.MakeThemMembers').click(function(){
if(GroupSpaceInviteOrMember(3)){
//$(this).addClass('MyDataLoading');
//CheckGroupSpaceSelect();
}

});

$('.KickThemAll').click(function(){
if(KickThemAll()){
//$(this).addClass('MyDataLoading');
//CheckGroupSpaceSelect();
}

});

$('.TheSpacesSelect, .TheGroupSelect').on('change',function(){
var TheVal=$(this).val();
if(TheVal!=0){
$(this).removeClass('SelectError');
CheckGroupSpaceSelect();
}
else{$(this).addClass('SelectError'); }
});

});
Binary file added assets/module_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screen-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0c3485e

Please sign in to comment.