Skip to content

Instantly share code, notes, and snippets.

@ydenissov
ydenissov / ExportCalendar.php
Last active October 30, 2022 18:30
Export records in ics
<?php
// For non blocking write logs by job
CalendarLogJob::dispatch($data_log);
// Get data and send calendar in ics
$date = Carbon::now()->timezone($hotel_data->timezone)->format("Y-m-d H:i:s");
$date_end = Carbon::now()->addYear(1)->timezone($hotel_data->timezone)->format("Y-m-d H:i:s");
// None Eloquent select
$data = DB::select("SELECT * FROM records WHERE room_id = $room_id AND status != 'canceled'
@ydenissov
ydenissov / CheckUserActive.php
Created October 30, 2022 18:25
Middleware for check user Active
<?php
/* Add in Http\Kernel.php after protected $routeMiddleware -> 'isActive' => \App\Http\Middleware\CheckUserActive::class, */
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Auth;
@ydenissov
ydenissov / change.php
Last active March 19, 2018 18:09
Change icon in tree Evolution CMS
<?php
$e = &$modx->Event;
switch($e->name){
case 'OnManagerNodePrerender':
if($ph['id'] == '2'){
//Change icons for doc with id 2
$ph['icon'] = "<i class="fa fa-address-card-o"></i>";
$ph['icon_folder_open'] = "<i class="fa fa-address-card-o"></i>";
$ph['icon_folder_close'] = "<i class="fa fa-address-card-o"></i>";
@ydenissov
ydenissov / thumbs.php
Last active November 22, 2017 08:39
Phpthumb wrapper for DocLister n Evolution CMS
<?php
[[DocLister?
&prepare=`thumb`
&thumbOptions=`w=100,h100,zc=1`
&tpl=`@CODE: <a href="[+tv.image+]"><img src="[+thumb+]"></a>`
]]
// thumb snippet
$data['thumb'] = $modx->runSnippet('phpthumb', Array(
'input' => $data['tv.image'],
@ydenissov
ydenissov / removeWidgets.php
Last active November 21, 2017 05:48
Plugin for remove widgets from dashboard EvolutionCMS
<?php
$e = &$modx->Event;
switch($e->name){
case 'OnManagerWelcomeHome':
//if($_SESSION['mgrRole']!=='2') return;
//$widgets['welcome']['hide']='1';
$widgets['onlineinfo']['hide']='1';
$widgets['recentinfo']['hide']='1';
$widgets['news']['hide']='1';
@ydenissov
ydenissov / get_photos.php
Last active April 8, 2018 17:17
Last photos preview from instagram for Evolution CMS
<?php
// Get last 20 photos from instagram, running from cron, write preview urls (150*150) in {{prefix}}_insta_photos table (id, url)
function rudr_instagram_api_curl_connect( $api_url ){
$connection_c = curl_init(); // initializing
curl_setopt( $connection_c, CURLOPT_URL, $api_url ); // API URL to connect
curl_setopt( $connection_c, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
curl_setopt( $connection_c, CURLOPT_TIMEOUT, 20 );
$json_return = curl_exec( $connection_c ); // connect and get json data
curl_close( $connection_c ); // close connection
return json_decode( $json_return ); // decode and return
@ydenissov
ydenissov / hits.php
Created October 20, 2017 03:24 — forked from Dmi3yy/hits.php
hits
//<?Hits % OnLogPageHit, OnBeforeDocFormSave, OnDocFormRender
if(!defined('MODX_BASE_PATH')){die('What are you doing? Get out of here!');}
/*
Hits 1.0.3 by Yurik Dertlyan | yurik@unix.am
update by Dmi3yy@gmail.com
Plugin for Evolution CMS to register and output page hits
Installation:
- SQL 'ALTER TABLE modx_site_content ADD COLUMN `hits` INT(10) UNSIGNED NOT NULL';
- Create plugin with name "Hits" and description "1.0.3"
@ydenissov
ydenissov / people.config.inc.php
Created October 19, 2017 17:18
MultiTV select with dropdown from documents Evolution CMS
<?php
$settings['display'] = 'horizontal';
$settings['fields'] = array(
'key' => array(
'caption' => 'User',
'type' => 'dropdown',
'elements' => '@SELECT pagetitle, id FROM [+PREFIX+]site_content WHERE parent = 10 AND `published` = 1 ORDER BY menuindex ASC'
),
'value' => array(
'caption' => 'Desc',
@ydenissov
ydenissov / template.html
Last active October 19, 2017 17:18
Evolutions CMS DLMenu example
[!DLMenu?
&parents=`0`
&maxDepth=`1`
&outerTpl=`@CODE:<ul id="nav" class="cont">[+wrap+]</ul>`
&rowTpl=`@CODE:<li><a href="[+url+]" title="[+title+]">[+title+]</a></li>`
&rowHereTpl=`@CODE:<li class="active"><a href="[+url+]" title="[+title+]">[+title+]</a></li>`
!]
@ydenissov
ydenissov / hits.php
Last active October 19, 2017 17:12
Evolution CMS hits
<?php
// Remember create column hits with type int
// Create plugin with any name and check in events OnWebPageInit
$e = &$modx->Event;
if($e->name == 'OnWebPageInit') {
if(!isset($_SESSION['usertype'])) {
$_SESSION['usertype'] = '';
}
if($_SESSION['usertype'] != 'manager') {