-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
201 changed files
with
8,474 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# ryssbowh/craft-restrict-deletions Changelog | ||
|
||
## 0.1.0 - unreleased | ||
|
||
### Added | ||
- First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Copyright © Web Puzzlers | ||
|
||
Permission is hereby granted to any person obtaining a copy of this software (the “Software”) to use, copy, modify, merge, publish and/or distribute copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
Don’t plagiarize. The above copyright notice and this license shall be included in all copies or substantial portions of the Software. | ||
|
||
Don’t use the same license on more than one project. Each licensed copy of the Software shall be actively installed in no more than one production environment at a time. | ||
|
||
Don’t mess with the licensing features. Software features related to licensing shall not be altered or circumvented in any way, including (but not limited to) license validation, payment prompts, feature restrictions, and update eligibility. | ||
|
||
Pay up. Payment shall be made immediately upon receipt of any notice, prompt, reminder, or other message indicating that a payment is owed. | ||
|
||
Follow the law. All use of the Software shall not violate any applicable law or regulation, nor infringe the rights of any other person or entity. | ||
|
||
Failure to comply with the foregoing conditions will automatically and immediately result in termination of the permission granted hereby. This license does not include any right to receive updates to the Software or technical support. Licensees bear all risk related to the quality and performance of the Software and any modifications made or obtained to it, including liability for actual and consequential harm, such as loss or corruption of data, and any necessary service, repair, or correction. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, INCLUDING SPECIAL, INCIDENTAL AND CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "ryssbowh/craft-activity", | ||
"description": "Record user activity in control panel", | ||
"type": "craft-plugin", | ||
"keywords": [ | ||
"cms", | ||
"craftcms", | ||
"user", | ||
"activity", | ||
"track" | ||
], | ||
"license": "proprietary", | ||
"authors": [ | ||
{ | ||
"name": "The Web Puzzlers", | ||
"homepage": "https://github.com/ryssbowh" | ||
} | ||
], | ||
"require": { | ||
"craftcms/cms": "^3.7" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Ryssbowh\\Activity\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"name": "Activity", | ||
"handle": "activity", | ||
"developer": "The Web Puzzlers", | ||
"developerUrl": "https://github.com/ryssbowh", | ||
"documentationUrl": "https://github.com/ryssbowh/craft-activity", | ||
"class": "Ryssbowh\\Activity\\Activity" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
namespace Ryssbowh\Activity; | ||
|
||
use Ryssbowh\Activity\base\Recorder; | ||
use Ryssbowh\Activity\models\Settings; | ||
use Ryssbowh\Activity\services\FieldHandlers; | ||
use Ryssbowh\Activity\services\Logs; | ||
use Ryssbowh\Activity\services\Recorders; | ||
use Ryssbowh\Activity\services\Types; | ||
use Ryssbowh\Activity\twig\ActivityExtension; | ||
use craft\base\Model; | ||
use craft\base\Plugin; | ||
use craft\services\Elements; | ||
use craft\services\Gc; | ||
use craft\services\UserPermissions; | ||
use craft\web\UrlManager; | ||
use yii\base\Event; | ||
|
||
class Activity extends Plugin | ||
{ | ||
/** | ||
* @var Themes | ||
*/ | ||
public static $plugin; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $hasCpSettings = true; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public $hasCpSection = true; | ||
|
||
/** | ||
* inheritDoc | ||
*/ | ||
public function init(): void | ||
{ | ||
parent::init(); | ||
|
||
self::$plugin = $this; | ||
|
||
$this->registerServices(); | ||
$this->registerPermissions(); | ||
$this->registerCpRoutes(); | ||
$this->registerGarbageCollection(); | ||
|
||
if (!($this->settings->ignoreApplyingYaml and !\Craft::$app->projectConfig->isApplyingYamlChanges) and | ||
!($this->settings->ignoreConsoleRequests and \Craft::$app->request->isConsoleRequest) and | ||
!($this->settings->ignoreCpRequests and \Craft::$app->request->isCpRequest) and | ||
!($this->settings->ignoreSiteRequests and \Craft::$app->request->isSiteRequest)) { | ||
$this->recorders->register(); | ||
$this->registerElementEvents(); | ||
} | ||
if (\Craft::$app->request->isCpRequest) { | ||
\Craft::$app->view->registerTwigExtension(new ActivityExtension); | ||
} | ||
} | ||
|
||
/** | ||
* Get a recorder by its name | ||
* | ||
* @param string $name | ||
* @return Recorder | ||
*/ | ||
public static function getRecorder(string $name): ?Recorder | ||
{ | ||
return static::$plugin->recorders->$name; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function createSettingsModel(): ?Model | ||
{ | ||
return new Settings(); | ||
} | ||
|
||
/** | ||
* Register garbace collection | ||
*/ | ||
protected function registerGarbageCollection() | ||
{ | ||
Event::on(Gc::class, Gc::EVENT_RUN, function () { | ||
Activity::$plugin->logs->runGc(); | ||
}); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function settingsHtml(): string | ||
{ | ||
$types = []; | ||
foreach ($this->types->getTypes() as $handle => $class) { | ||
$class = new $class; | ||
$types[$handle] = $class->name; | ||
} | ||
ksort($types); | ||
return \Craft::$app->view->renderTemplate( | ||
'activity/settings', | ||
[ | ||
'settings' => $this->getSettings(), | ||
'types' => $types | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Register elements events | ||
*/ | ||
protected function registerElementEvents() | ||
{ | ||
if ($this->settings->ignoreResaveElements) { | ||
// Event::on(Elements::class, Elements::EVENT_BEFORE_RESAVE_ELEMENT, function (Event $event) { | ||
// \Craft::debug('disabling all recorders 1'); | ||
// Activity::$plugin->recorders->stopRecording(); | ||
// }); | ||
// Event::on(Elements::class, Elements::EVENT_AFTER_RESAVE_ELEMENT, function (Event $event) { | ||
// Activity::$plugin->recorders->startRecording(); | ||
// }); | ||
// Event::on(Elements::class, Elements::EVENT_BEFORE_RESAVE_ELEMENTS, function (Event $event) { | ||
// \Craft::debug('disabling all recorders 2'); | ||
// Activity::$plugin->recorders->stopRecording(); | ||
// }); | ||
// Event::on(Elements::class, Elements::EVENT_AFTER_RESAVE_ELEMENTS, function (Event $event) { | ||
// Activity::$plugin->recorders->startRecording(); | ||
// }); | ||
} | ||
if ($this->settings->ignoreUpdateSlugs) { | ||
Event::on(Elements::class, Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI, function (Event $event) { | ||
Activity::$plugin->recorders->stopRecording(); | ||
}); | ||
Event::on(Elements::class, Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI, function (Event $event) { | ||
Activity::$plugin->recorders->startRecording(); | ||
}); | ||
} | ||
if ($this->settings->ignorePropagate) { | ||
Event::on(Elements::class, Elements::EVENT_BEFORE_PROPAGATE_ELEMENTS, function (Event $event) { | ||
Activity::$plugin->recorders->stopRecording(); | ||
}); | ||
Event::on(Elements::class, Elements::EVENT_AFTER_PROPAGATE_ELEMENTS, function (Event $event) { | ||
Activity::$plugin->recorders->startRecording(); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Register cp routes | ||
*/ | ||
protected function registerCpRoutes() | ||
{ | ||
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function(Event $event) { | ||
$event->rules = array_merge($event->rules, [ | ||
'activity' => 'activity/activity' | ||
]); | ||
}); | ||
} | ||
|
||
/** | ||
* Register permissions | ||
*/ | ||
protected function registerPermissions() | ||
{ | ||
Event::on(UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, function (Event $event) { | ||
$event->permissions[\Craft::t('activity', 'Activity')] = [ | ||
'viewActivityLogs' => [ | ||
'label' => \Craft::t('activity', 'View activity records') | ||
], | ||
'deleteActivityLogs' => [ | ||
'label' => \Craft::t('activity', 'Delete activity records') | ||
] | ||
]; | ||
}); | ||
} | ||
|
||
/** | ||
* Register all services | ||
*/ | ||
protected function registerServices() | ||
{ | ||
$this->setComponents([ | ||
'recorders' => Recorders::class, | ||
'logs' => Logs::class, | ||
'types' => Types::class, | ||
'fieldHandlers' => FieldHandlers::class, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Ryssbowh\Activity\assets; | ||
|
||
use craft\web\AssetBundle; | ||
use craft\web\assets\cp\CpAsset; | ||
|
||
class ActivityAssets extends AssetBundle | ||
{ | ||
public $sourcePath = __DIR__; | ||
|
||
public $js = [ | ||
'js/activity.js' | ||
]; | ||
|
||
public $css = [ | ||
'css/activity.css' | ||
]; | ||
|
||
public $depends = [ | ||
CpAsset::class, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.icon.arrow { | ||
width: 8px; | ||
height: 8px; | ||
margin-left: 5px; | ||
} | ||
|
||
.icon.arrow:after { | ||
transition: all 0.3s; | ||
display: inline-block; | ||
content: ""; | ||
font-size: 0; | ||
width: 5px; | ||
height: 5px; | ||
border: solid var(--ui-control-color); | ||
border-width: 0 2px 2px 0; | ||
-webkit-transform: rotate(45deg); | ||
-o-transform: rotate(45deg); | ||
transform: rotate(45deg); | ||
position: relative; | ||
} | ||
|
||
.icon.arrow.down:after { | ||
-webkit-transform: rotate(-135deg); | ||
-o-transform: rotate(-135deg); | ||
transform: rotate(-135deg); | ||
margin-top: 2px; | ||
} | ||
|
||
#activity-table ul { | ||
list-style: initial; | ||
margin-left: 15px; | ||
} | ||
|
||
#activity-table .status { | ||
margin-right: 3px; | ||
} | ||
|
||
#reset-filters { | ||
margin-top: 7px; | ||
} |
Oops, something went wrong.